Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changes log
- 2.6.1 (??-??-2026)
- Bugs fixed
- Reuse an instance of Random class in RandomUtils. Issue #1487.
- Complete test classes. Issue #1490.
-
- 2.6.0 (29-06-2025)

- 2.6 Release Candidate 2 (21-06-2025)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ protected void configureServer(final Server server) {

protected abstract Application createApplication();

protected List<ConnectorTestCase> listTestCases() {
protected List<ConnectorsPair> listTestCases() {
return List.of(
// let's focus on Jetty server extension
// new ConnectorTestCase(HttpServer.INTERNAL_HTTP, HttpClient.INTERNAL),
// new ConnectorTestCase(HttpServer.INTERNAL_HTTP, HttpClient.JETTY),
new ConnectorTestCase(HttpServer.JETTY_HTTP, HttpClient.INTERNAL),
new ConnectorTestCase(HttpServer.JETTY_HTTP, HttpClient.JETTY)
new ConnectorsPair(HttpServer.JETTY_HTTP, HttpClient.INTERNAL),
new ConnectorsPair(HttpServer.JETTY_HTTP, HttpClient.JETTY)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import static java.lang.String.format;

public class ConnectorTestCase {
public class ConnectorsPair {
final BaseConnectorsTestCase.HttpServer httpServer;
final BaseConnectorsTestCase.HttpClient httpClient;

public ConnectorTestCase(BaseConnectorsTestCase.HttpServer httpServer, BaseConnectorsTestCase.HttpClient httpClient) {
public ConnectorsPair(BaseConnectorsTestCase.HttpServer httpServer, BaseConnectorsTestCase.HttpClient httpClient) {
this.httpServer = httpServer;
this.httpClient = httpClient;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ public static void globalSetUp() throws IOException {
}

@Override
protected List<ConnectorTestCase> listTestCases() {
protected List<ConnectorsPair> listTestCases() {
return List.of(
// let's focus on Jetty server extension
// new ConnectorTestCase(HttpServer.INTERNAL_HTTPS, HttpClient.JETTY),
// new ConnectorTestCase(HttpServer.INTERNAL_HTTPS, HttpClient.INTERNAL),
new ConnectorTestCase(HttpServer.JETTY_HTTPS, HttpClient.INTERNAL),
new ConnectorTestCase(HttpServer.JETTY_HTTPS, HttpClient.JETTY)
new ConnectorsPair(HttpServer.JETTY_HTTPS, HttpClient.INTERNAL),
new ConnectorsPair(HttpServer.JETTY_HTTPS, HttpClient.JETTY)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.springframework.context.support.ClassPathXmlApplicationContext;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Unit test case for the Spring extension.
Expand All @@ -33,7 +35,9 @@ public void testSpring() throws Exception {
// Start the Restlet component
Component component = (Component) ctx.getBean("component");
component.start();
assertTrue(component.isStarted());
component.stop();
assertFalse(component.isStarted());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@
/**
* Optimized public-domain implementation of a Java alphanumeric sort.
* <p>
*
*
* This implementation uses a single comparison pass over the characters in a
* CharSequence, and returns as soon as a differing character is found, unless
* CharSequence and returns as soon as a differing character is found, unless
* the difference occurs in a series of numeric characters, in which case that
* series is followed to its end. Numeric series of equal length are compared
* numerically, that is, according to the most significant (leftmost) differing
* digit. Series of unequal length are compared by their length.
* <p>
*
*
* This implementation appears to be 2-5 times faster than alphanumeric
* comparators based based on substring analysis, with a lighter memory
* comparators based on substring analysis, with a lighter memory
* footprint.
* <p>
*
*
* This alphanumeric comparator has approximately 20%-50% the performance of the
* lexical String.compareTo() operation. Character sequences without numeric
* data are compared more quickly.
* <p>
*
*
* Dedicated to the public domain by the original author:
* http://creativecommons.org/licenses/publicdomain/
*
* <a href="https://creativecommons.org/licenses/publicdomain/">Public Domain List</a>
*
* @author Rob Heittman, <a href="http://www.solertium.com">Solertium
* Corporation</a>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.Comparator;

/**
* Allows to sort the list of references set by the resource.
* Allows sorting the list of references set by the resource.
*
* @author Jerome Louvel
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,40 @@

package org.restlet;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;
import org.restlet.data.Protocol;

import java.time.Duration;

/**
* Test the ability of a connector to be restarted.
*
*
* @author Jerome Louvel
*/
public class RestartTestCase {

@Test
public void testRestart() throws Exception {
@Test
void testRestart() throws Exception {
final Duration waitTime = Duration.ofMillis(10);

final Server connector = new Server(Protocol.HTTP, 0, (Restlet) null);

System.out.print("Starting connector... ");
connector.start();
System.out.println("done");
assertTrue(connector.isStarted());
Thread.sleep(waitTime.toMillis());

System.out.print("Stopping connector... ");
connector.stop();
System.out.println("done");
assertFalse(connector.isStarted());
Thread.sleep(waitTime.toMillis());

System.out.print("Restarting connector... ");
connector.start();
System.out.println("done");
assertTrue(connector.isStarted());
Thread.sleep(waitTime.toMillis());
connector.stop();
assertFalse(connector.isStarted());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.restlet.representation.EmptyRepresentation;
import org.restlet.representation.StringRepresentation;
import org.restlet.resource.ClientResource;
Expand All @@ -29,6 +31,7 @@
*
* @author Remi Dewitte
*/
@Disabled("flaky on github")
public class ZipClientTestCase {

private File zipFile;
Expand All @@ -44,8 +47,8 @@ protected void tearDownEach() throws Exception {
zipFile.delete();
}

// @Test TODO seems flaky on github
public void testFileClient() throws IOException {
@Test
void testFileClient() throws IOException {
String text = "Test content\r\nLine 2\r\nLine2";
String text2 = "Test content\nLine 2";
LocalReference fr = LocalReference.createFileReference(zipFile);
Expand All @@ -58,42 +61,42 @@ public void testFileClient() throws IOException {
// Write test.txt as first entry
ClientResource testFileEntryClientResource = new ClientResource(testFileEntryReference);
testFileEntryClientResource.put(new StringRepresentation(text));
assertEquals(testFileEntryClientResource.getStatus(), Status.SUCCESS_CREATED);
assertEquals(Status.SUCCESS_CREATED, testFileEntryClientResource.getStatus());

// Get the text and compare to the original
testFileEntryClientResource.get();
assertEquals(testFileEntryClientResource.getStatus(), Status.SUCCESS_OK);
assertEquals(testFileEntryClientResource.getResponseEntity().getText(), text);
assertEquals(Status.SUCCESS_OK, testFileEntryClientResource.getStatus());
assertEquals(text, testFileEntryClientResource.getResponseEntity().getText());
testFileEntryClientResource.release();

// Write test2.txt as second entry
ClientResource test2FileEntryClientResource = new ClientResource(test2FileEntryReference);
test2FileEntryClientResource.put(new StringRepresentation(text2));
assertEquals(test2FileEntryClientResource.getStatus(), Status.SUCCESS_OK);
assertEquals(Status.SUCCESS_OK, test2FileEntryClientResource.getStatus());

// Check that the first entry has not been overwritten
testFileEntryClientResource.get();
assertEquals(testFileEntryClientResource.getStatus(), Status.SUCCESS_OK);
assertEquals(testFileEntryClientResource.getResponseEntity().getText(), text);
assertEquals(Status.SUCCESS_OK, testFileEntryClientResource.getStatus());
assertEquals(text, testFileEntryClientResource.getResponseEntity().getText());
testFileEntryClientResource.release();

// Put a directory
ClientResource dirEntryClientResource = new ClientResource(dirEntryReference);
dirEntryClientResource.put(new EmptyRepresentation());
assertEquals(dirEntryClientResource.getStatus(), Status.SUCCESS_OK);
assertEquals(Status.SUCCESS_OK, dirEntryClientResource.getStatus());

dirEntryClientResource.get();
assertEquals(dirEntryClientResource.getStatus(), Status.SUCCESS_OK);
assertEquals(Status.SUCCESS_OK, dirEntryClientResource.getStatus());

// Add a file inside the directory
ClientResource testFileInDirEntryCLientResource = new ClientResource(test3FileInDirEntryReference);
testFileInDirEntryCLientResource.put(new StringRepresentation(text));
assertEquals(testFileInDirEntryCLientResource.getStatus(), Status.SUCCESS_OK);
assertEquals(Status.SUCCESS_OK, testFileInDirEntryCLientResource.getStatus());

// Check that the second entry is still there
test2FileEntryClientResource.get();
assertEquals(test2FileEntryClientResource.getStatus(), Status.SUCCESS_OK, "Could not get " + test2FileEntryReference);
assertEquals(test2FileEntryClientResource.getResponseEntity().getText(), text2);
assertEquals(Status.SUCCESS_OK, test2FileEntryClientResource.getStatus(), "Could not get " + test2FileEntryReference);
assertEquals(text2, test2FileEntryClientResource.getResponseEntity().getText());

// Check that content negotiation does not work
ClientResource rTest2 = new ClientResource(zr + "!test2");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
package org.restlet.engine.util;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.restlet.data.Reference;
import org.restlet.resource.Directory;

Expand All @@ -18,6 +20,7 @@
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Test case for the alphanum algorithm used by {@link Directory}.
Expand Down Expand Up @@ -49,13 +52,16 @@ public void testBug() {
assertEquals(expected, result);
}

@Test
public void test02() {
@ParameterizedTest
@CsvSource({
"Intel 5000X,Intel 5500",
"3,66",
"200,66",
"18,2"
})
void testFirstIsLessThan(final String first, final String second) {
AlphaNumericComparator anc = new AlphaNumericComparator();
System.out.println(anc.compare("Intel 5000X", "Intel 5500"));
System.out.println(anc.compare("66", "3"));
System.out.println(anc.compare("200", "66"));
System.out.println(anc.compare("18", "2"));
assertTrue(anc.compare(first, second) < 0);
}

}