diff --git a/changes.md b/changes.md index b21c80536e..ce7813b029 100644 --- a/changes.md +++ b/changes.md @@ -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) diff --git a/org.restlet.java/org.restlet.ext.jetty/src/test/java/org/restlet/ext/jetty/FormDataSetTestCase.java b/org.restlet.java/org.restlet.ext.jetty/src/test/java/org/restlet/ext/jetty/FormDataSetTestCase.java deleted file mode 100644 index 2a3e21efa1..0000000000 --- a/org.restlet.java/org.restlet.ext.jetty/src/test/java/org/restlet/ext/jetty/FormDataSetTestCase.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright 2005-2024 Qlik - *
- * The contents of this file is subject to the terms of the Apache 2.0 open - * source license available at http://www.opensource.org/licenses/apache-2.0 - *
- * Restlet is a registered trademark of QlikTech International AB.
- */
-
-package org.restlet.ext.jetty;
-
-import org.junit.jupiter.api.Test;
-
-import java.io.IOException;
-
-/**
- * Unit tests for the Form class.
- *
- * @author Jerome Louvel
- */
-public class FormDataSetTestCase {
-
- /**
- * Tests the cookies parsing.
- */
- @Test
- public void testParsing() throws IOException {
-/*
-TODO restore test of Form class
- FormDataSet form = new FormDataSet();
- form.add("name", "John D. Mitchell");
- form.add("email", "john@bob.net");
- form.add("email2", "joe@bob.net");
- String query = form.encode();
-
- Series
- *
+ *
* 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.
*
- *
+ *
* 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.
*
- *
+ *
* This alphanumeric comparator has approximately 20%-50% the performance of the
* lexical String.compareTo() operation. Character sequences without numeric
* data are compared more quickly.
*
- *
+ *
* Dedicated to the public domain by the original author:
- * http://creativecommons.org/licenses/publicdomain/
- *
+ * Public Domain List
+ *
* @author Rob Heittman, Solertium
* Corporation
*/
diff --git a/org.restlet.java/org.restlet/src/main/java/org/restlet/engine/util/AlphabeticalComparator.java b/org.restlet.java/org.restlet/src/main/java/org/restlet/engine/util/AlphabeticalComparator.java
index f88f95785c..760e574637 100644
--- a/org.restlet.java/org.restlet/src/main/java/org/restlet/engine/util/AlphabeticalComparator.java
+++ b/org.restlet.java/org.restlet/src/main/java/org/restlet/engine/util/AlphabeticalComparator.java
@@ -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
*/
diff --git a/org.restlet.java/org.restlet/src/test/java/org/restlet/RestartTestCase.java b/org.restlet.java/org.restlet/src/test/java/org/restlet/RestartTestCase.java
index 27e73d0cfe..a2e47b8964 100644
--- a/org.restlet.java/org.restlet/src/test/java/org/restlet/RestartTestCase.java
+++ b/org.restlet.java/org.restlet/src/test/java/org/restlet/RestartTestCase.java
@@ -9,6 +9,9 @@
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;
@@ -16,32 +19,30 @@
/**
* 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());
}
}
diff --git a/org.restlet.java/org.restlet/src/test/java/org/restlet/data/ZipClientTestCase.java b/org.restlet.java/org.restlet/src/test/java/org/restlet/data/ZipClientTestCase.java
index 52022aaece..6c88dd4db9 100644
--- a/org.restlet.java/org.restlet/src/test/java/org/restlet/data/ZipClientTestCase.java
+++ b/org.restlet.java/org.restlet/src/test/java/org/restlet/data/ZipClientTestCase.java
@@ -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;
@@ -29,6 +31,7 @@
*
* @author Remi Dewitte
*/
+@Disabled("flaky on github")
public class ZipClientTestCase {
private File zipFile;
@@ -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);
@@ -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");
diff --git a/org.restlet.java/org.restlet/src/test/java/org/restlet/engine/util/AlphaNumericComparatorTestCase.java b/org.restlet.java/org.restlet/src/test/java/org/restlet/engine/util/AlphaNumericComparatorTestCase.java
index e62f890faf..17706c04e2 100644
--- a/org.restlet.java/org.restlet/src/test/java/org/restlet/engine/util/AlphaNumericComparatorTestCase.java
+++ b/org.restlet.java/org.restlet/src/test/java/org/restlet/engine/util/AlphaNumericComparatorTestCase.java
@@ -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;
@@ -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}.
@@ -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);
}
}