Skip to content

Commit 2216d37

Browse files
committed
Issue #1490: complete test classes
1 parent 21d990e commit 2216d37

11 files changed

Lines changed: 50 additions & 81 deletions

File tree

changes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Changes log
44
- 2.7 Milestone 3 (??-??-2025)
55
- Bugs fixed
66
- Reuse an instance of Random class in RandomUtils. Issue #1487.
7+
- Complete test classes. Issue #1490.
8+
79
- 2.7 Milestone 2 (29-06-2025)
810
- Misc
911
- Removed deprecated Servlet extension and related classes in Spring extension

org.restlet.ext.spring/src/test/java/org/restlet/ext/spring/SpringTestCase.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import org.springframework.context.support.ClassPathXmlApplicationContext;
1919

2020
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
import static org.junit.jupiter.api.Assertions.assertFalse;
22+
import static org.junit.jupiter.api.Assertions.assertTrue;
2123

2224
/**
2325
* Unit test case for the Spring extension.
@@ -33,7 +35,9 @@ public void testSpring() throws Exception {
3335
// Start the Restlet component
3436
Component component = (Component) ctx.getBean("component");
3537
component.start();
38+
assertTrue(component.isStarted());
3639
component.stop();
40+
assertFalse(component.isStarted());
3741
}
3842

3943
@Test

org.restlet/src/main/java/org/restlet/engine/util/AlphaNumericComparator.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,28 @@
1212
/**
1313
* Optimized public-domain implementation of a Java alphanumeric sort.
1414
* <p>
15-
*
15+
*
1616
* This implementation uses a single comparison pass over the characters in a
17-
* CharSequence, and returns as soon as a differing character is found, unless
17+
* CharSequence and returns as soon as a differing character is found, unless
1818
* the difference occurs in a series of numeric characters, in which case that
1919
* series is followed to its end. Numeric series of equal length are compared
2020
* numerically, that is, according to the most significant (leftmost) differing
2121
* digit. Series of unequal length are compared by their length.
2222
* <p>
23-
*
23+
*
2424
* This implementation appears to be 2-5 times faster than alphanumeric
25-
* comparators based based on substring analysis, with a lighter memory
25+
* comparators based on substring analysis, with a lighter memory
2626
* footprint.
2727
* <p>
28-
*
28+
*
2929
* This alphanumeric comparator has approximately 20%-50% the performance of the
3030
* lexical String.compareTo() operation. Character sequences without numeric
3131
* data are compared more quickly.
3232
* <p>
33-
*
33+
*
3434
* Dedicated to the public domain by the original author:
35-
* http://creativecommons.org/licenses/publicdomain/
36-
*
35+
* <a href="https://creativecommons.org/licenses/publicdomain/">Public Domain List</a>
36+
*
3737
* @author Rob Heittman, <a href="http://www.solertium.com">Solertium
3838
* Corporation</a>
3939
*/
@@ -51,7 +51,7 @@ public int compare(final String uri0, final String uri1) {
5151
final int rlength = uri1.length();
5252
final int min = Math.min(rlength, llength);
5353

54-
boolean rAtEnd, rHasNoMoreDigits;
54+
boolean rAtEnd, rHasNoMoreDigits;
5555

5656
while (ptr < min) {
5757
a = uri0.charAt(ptr);
@@ -112,7 +112,7 @@ public int compare(final String uri0, final String uri1) {
112112

113113
/**
114114
* Indicates if the character is a digit.
115-
*
115+
*
116116
* @param x The character to test.
117117
* @return True if the character is a digit.
118118
*/

org.restlet/src/main/java/org/restlet/engine/util/AlphabeticalComparator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import java.util.Comparator;
1616

1717
/**
18-
* Allows to sort the list of references set by the resource.
18+
* Allows sorting the list of references set by the resource.
1919
*
2020
* @author Jerome Louvel
2121
*/

org.restlet/src/test/java/org/restlet/RestartTestCase.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,40 @@
99

1010
package org.restlet;
1111

12+
import static org.junit.jupiter.api.Assertions.assertFalse;
13+
import static org.junit.jupiter.api.Assertions.assertTrue;
14+
1215
import org.junit.jupiter.api.Test;
1316
import org.restlet.data.Protocol;
1417

1518
import java.time.Duration;
1619

1720
/**
1821
* Test the ability of a connector to be restarted.
19-
*
22+
*
2023
* @author Jerome Louvel
2124
*/
2225
public class RestartTestCase {
2326

24-
@Test
25-
public void testRestart() throws Exception {
27+
@Test
28+
void testRestart() throws Exception {
2629
final Duration waitTime = Duration.ofMillis(10);
2730

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

30-
System.out.print("Starting connector... ");
3133
connector.start();
32-
System.out.println("done");
34+
assertTrue(connector.isStarted());
3335
Thread.sleep(waitTime.toMillis());
3436

35-
System.out.print("Stopping connector... ");
3637
connector.stop();
37-
System.out.println("done");
38+
assertFalse(connector.isStarted());
3839
Thread.sleep(waitTime.toMillis());
3940

40-
System.out.print("Restarting connector... ");
4141
connector.start();
42-
System.out.println("done");
42+
assertTrue(connector.isStarted());
4343
Thread.sleep(waitTime.toMillis());
4444
connector.stop();
45+
assertFalse(connector.isStarted());
4546
}
4647

4748
}

org.restlet/src/test/java/org/restlet/data/ZipClientTestCase.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import org.junit.jupiter.api.AfterEach;
1313
import org.junit.jupiter.api.BeforeEach;
14+
import org.junit.jupiter.api.Disabled;
15+
import org.junit.jupiter.api.Test;
1416
import org.restlet.representation.EmptyRepresentation;
1517
import org.restlet.representation.StringRepresentation;
1618
import org.restlet.resource.ClientResource;
@@ -29,6 +31,7 @@
2931
*
3032
* @author Remi Dewitte
3133
*/
34+
@Disabled("flaky on github")
3235
public class ZipClientTestCase {
3336

3437
private File zipFile;
@@ -44,8 +47,8 @@ protected void tearDownEach() throws Exception {
4447
zipFile.delete();
4548
}
4649

47-
// @Test TODO seems flaky on github
48-
public void testFileClient() throws IOException {
50+
@Test
51+
void testFileClient() throws IOException {
4952
String text = "Test content\r\nLine 2\r\nLine2";
5053
String text2 = "Test content\nLine 2";
5154
LocalReference fr = LocalReference.createFileReference(zipFile);

org.restlet/src/test/java/org/restlet/engine/connector/BaseConnectorsTestCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ protected void configureServer(final Server server) {
6363

6464
protected abstract Application createApplication();
6565

66-
protected List<ConnectorTestCase> listTestCases() {
66+
protected List<ConnectorsPair> listTestCases() {
6767
return List.of(
68-
new ConnectorTestCase(HttpServer.JETTY_HTTP, HttpClient.JETTY));
68+
new ConnectorsPair(HttpServer.JETTY_HTTP, HttpClient.JETTY));
6969
}
7070

7171
@TestFactory

org.restlet/src/test/java/org/restlet/engine/connector/ConnectorTestCase.java renamed to org.restlet/src/test/java/org/restlet/engine/connector/ConnectorsPair.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
import static java.lang.String.format;
44

5-
public class ConnectorTestCase {
5+
public class ConnectorsPair {
66
final BaseConnectorsTestCase.HttpServer httpServer;
77
final BaseConnectorsTestCase.HttpClient httpClient;
88

9-
public ConnectorTestCase(BaseConnectorsTestCase.HttpServer httpServer, BaseConnectorsTestCase.HttpClient httpClient) {
9+
public ConnectorsPair(BaseConnectorsTestCase.HttpServer httpServer, BaseConnectorsTestCase.HttpClient httpClient) {
1010
this.httpServer = httpServer;
1111
this.httpClient = httpClient;
1212
}

org.restlet/src/test/java/org/restlet/engine/connector/FormDataSetTestCase.java

Lines changed: 0 additions & 47 deletions
This file was deleted.

org.restlet/src/test/java/org/restlet/engine/connector/SslBaseConnectorsTestCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ public static void globalSetUp() throws IOException {
6767
}
6868

6969
@Override
70-
protected List<ConnectorTestCase> listTestCases() {
71-
return List.of(new ConnectorTestCase(HttpServer.JETTY_HTTPS,
70+
protected List<ConnectorsPair> listTestCases() {
71+
return List.of(new ConnectorsPair(HttpServer.JETTY_HTTPS,
7272
HttpClient.JETTY));
7373
}
7474

0 commit comments

Comments
 (0)