This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git
The following commit(s) were added to refs/heads/master by this push:
new 8eeda087df Switch to Sling Commons Log, add additional upload test if
multipart config is not enabled
8eeda087df is described below
commit 8eeda087df3fae67e36c23a36257cbe7e9432d90
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Fri May 22 15:42:56 2026 +0200
Switch to Sling Commons Log, add additional upload test if multipart config
is not enabled
---
.../felix/http/itest/BaseIntegrationTest.java | 14 +++++++++-----
.../itest/servletapi3/HttpServiceRuntimeTest.java | 2 ++
.../felix/http/itest/servletapi3/UploadTest.java | 22 ++++++++++++++--------
.../felix/http/itest/servletapi5/ResourceTest.java | 3 +--
.../felix/http/itest/servletapi5/UploadTest.java | 20 ++++++++++++++++----
5 files changed, 42 insertions(+), 19 deletions(-)
diff --git
a/http/itest/src/test/java/org/apache/felix/http/itest/BaseIntegrationTest.java
b/http/itest/src/test/java/org/apache/felix/http/itest/BaseIntegrationTest.java
index 312fb62e6f..1a242e5298 100644
---
a/http/itest/src/test/java/org/apache/felix/http/itest/BaseIntegrationTest.java
+++
b/http/itest/src/test/java/org/apache/felix/http/itest/BaseIntegrationTest.java
@@ -35,6 +35,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.Collection;
import java.util.Dictionary;
@@ -119,8 +121,8 @@ public abstract class BaseIntegrationTest {
}
int port = Integer.getInteger("org.osgi.service.http.port", 8080);
try {
- return new URL(String.format("http://localhost:%d/%s", port,
path));
- } catch (MalformedURLException e) {
+ return new URI(String.format("http://localhost:%d/%s", port,
path)).toURL();
+ } catch (URISyntaxException | MalformedURLException e) {
throw new RuntimeException(e);
}
}
@@ -156,10 +158,11 @@ public abstract class BaseIntegrationTest {
// scavenge sessions every 10 seconds (10 minutes is default
in 9.4.x)
systemProperty("org.eclipse.jetty.servlet.SessionScavengingInterval").value("10"),
- // update pax logging for SLF4J 2
-
mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version("2.3.0"),
mavenBundle("org.slf4j", "slf4j-api", "2.0.17"),
+ mavenBundle("org.osgi", "org.osgi.util.function", "1.2.0"),
+ mavenBundle("org.osgi", "org.osgi.util.converter", "1.0.9"),
+ mavenBundle("org.apache.sling",
"org.apache.sling.commons.log", "6.0.4").classifier("all"),
mavenBundle("org.apache.sling",
"org.apache.sling.commons.johnzon",
"1.2.16").startLevel(START_LEVEL_SYSTEM_BUNDLES),
- mavenBundle("commons-io", "commons-io",
"2.19.0").startLevel(START_LEVEL_SYSTEM_BUNDLES),
+ mavenBundle("commons-io", "commons-io",
"2.22.0").startLevel(START_LEVEL_SYSTEM_BUNDLES),
mavenBundle("commons-fileupload", "commons-fileupload",
"1.6.0").startLevel(START_LEVEL_SYSTEM_BUNDLES),
mavenBundle("org.apache.felix",
"org.apache.felix.configadmin").version("1.9.22").startLevel(START_LEVEL_SYSTEM_BUNDLES),
@@ -221,6 +224,7 @@ public abstract class BaseIntegrationTest {
return tracker.getServiceReferences();
}
+ @SuppressWarnings("unchecked")
private <T> ServiceTracker<T, T> getTracker(Class<T> clazz) {
synchronized ( this.trackers ) {
ServiceTracker<T, T> tracker = (ServiceTracker<T, T>)
trackers.get(clazz.getName());
diff --git
a/http/itest/src/test/java/org/apache/felix/http/itest/servletapi3/HttpServiceRuntimeTest.java
b/http/itest/src/test/java/org/apache/felix/http/itest/servletapi3/HttpServiceRuntimeTest.java
index 45bd407528..986c4a6f84 100644
---
a/http/itest/src/test/java/org/apache/felix/http/itest/servletapi3/HttpServiceRuntimeTest.java
+++
b/http/itest/src/test/java/org/apache/felix/http/itest/servletapi3/HttpServiceRuntimeTest.java
@@ -260,6 +260,7 @@ public class HttpServiceRuntimeTest extends
Servlet3BaseIntegrationTest {
assertTrue(serviceDTO.properties.containsKey(HTTP_SERVICE_ENDPOINT));
assertTrue(serviceDTO.properties.get(HTTP_SERVICE_ID) instanceof
Collection);
+ @SuppressWarnings("unchecked")
final Collection<Long> ids =
(Collection<Long>)serviceDTO.properties.get(HTTP_SERVICE_ID);
assertTrue(ids.size() == 1);
assertTrue(ids.iterator().next() instanceof Long);
@@ -1212,6 +1213,7 @@ public class HttpServiceRuntimeTest extends
Servlet3BaseIntegrationTest {
ServiceReference<?> httpServiceRuntimeRef =
m_context.getServiceReference(HttpServiceRuntime.class.getName());
Long expectedId = (Long)
httpServiceRef.getProperty(Constants.SERVICE_ID);
+ @SuppressWarnings("unchecked")
Collection<Long> col =
(Collection<Long>)httpServiceRuntimeRef.getProperty(HTTP_SERVICE_ID);
Long actualId = (Long) col.iterator().next();
diff --git
a/http/itest/src/test/java/org/apache/felix/http/itest/servletapi3/UploadTest.java
b/http/itest/src/test/java/org/apache/felix/http/itest/servletapi3/UploadTest.java
index 9b87f06d07..5897cb30d3 100644
---
a/http/itest/src/test/java/org/apache/felix/http/itest/servletapi3/UploadTest.java
+++
b/http/itest/src/test/java/org/apache/felix/http/itest/servletapi3/UploadTest.java
@@ -78,12 +78,12 @@ public class UploadTest extends Servlet3BaseIntegrationTest
{
receivedLatch = new CountDownLatch(count);
}
- public void setupServlet(final Map<String, Long> contents) throws
Exception {
+ public void setupServlet(final Map<String, Long> contents, boolean
multipartEnabled) throws Exception {
setupLatches(1);
Dictionary<String, Object> servletProps = new Hashtable<String,
Object>();
servletProps.put(HTTP_WHITEBOARD_SERVLET_PATTERN, PATH);
- servletProps.put(HTTP_WHITEBOARD_SERVLET_MULTIPART_ENABLED,
Boolean.TRUE);
+ servletProps.put(HTTP_WHITEBOARD_SERVLET_MULTIPART_ENABLED,
multipartEnabled);
servletProps.put(HTTP_WHITEBOARD_SERVLET_MULTIPART_MAXFILESIZE, 1024L);
TestServlet servletWithErrorCode = new TestServlet(initLatch,
destroyLatch) {
@@ -153,10 +153,8 @@ public class UploadTest extends
Servlet3BaseIntegrationTest {
@Test
public void testUpload() throws Exception {
- setupLatches(2);
-
final Map<String, Long> contents = new HashMap<>();
- setupServlet(contents);
+ setupServlet(contents, true);
postContent('a', 500, 201);
assertTrue(receivedLatch.await(5, TimeUnit.SECONDS));
@@ -166,13 +164,21 @@ public class UploadTest extends
Servlet3BaseIntegrationTest {
@Test
public void testMaxFileSize() throws Exception {
- setupLatches(2);
-
final Map<String, Long> contents = new HashMap<>();
- setupServlet(contents);
+ setupServlet(contents, true);
postContent('b', 2048, 500);
assertTrue(receivedLatch.await(5, TimeUnit.SECONDS));
assertTrue(contents.isEmpty());
}
+
+ @Test
+ public void testNoMultipartEnabled() throws Exception {
+ final Map<String, Long> contents = new HashMap<>();
+ setupServlet(contents, false);
+
+ postContent('c', 100, 500);
+ assertTrue(receivedLatch.await(5, TimeUnit.SECONDS));
+ assertTrue(contents.isEmpty());
+ }
}
diff --git
a/http/itest/src/test/java/org/apache/felix/http/itest/servletapi5/ResourceTest.java
b/http/itest/src/test/java/org/apache/felix/http/itest/servletapi5/ResourceTest.java
index 7357716b28..a9541aac62 100644
---
a/http/itest/src/test/java/org/apache/felix/http/itest/servletapi5/ResourceTest.java
+++
b/http/itest/src/test/java/org/apache/felix/http/itest/servletapi5/ResourceTest.java
@@ -29,7 +29,6 @@ import java.net.URL;
import java.nio.file.Files;
import java.util.Dictionary;
import java.util.Hashtable;
-import java.util.concurrent.CountDownLatch;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -83,7 +82,7 @@ public class ResourceTest extends Servlet5BaseIntegrationTest
{
resourcesProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX,
"/resource");
resourcesProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "("
+ HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=test)");
final ServiceRegistration<Object> reg =
this.m_context.registerService(Object.class, new Object(), resourcesProps);
-
+
counter = this.waitForRuntime(counter);
final TestServlet servlet = new TestServlet();
diff --git
a/http/itest/src/test/java/org/apache/felix/http/itest/servletapi5/UploadTest.java
b/http/itest/src/test/java/org/apache/felix/http/itest/servletapi5/UploadTest.java
index 554b381497..05a7982550 100644
---
a/http/itest/src/test/java/org/apache/felix/http/itest/servletapi5/UploadTest.java
+++
b/http/itest/src/test/java/org/apache/felix/http/itest/servletapi5/UploadTest.java
@@ -64,11 +64,11 @@ public class UploadTest extends Servlet5BaseIntegrationTest
{
private CountDownLatch receivedLatch;
- public void setupServlet(final Map<String, Long> contents) throws
Exception {
+ public void setupServlet(final Map<String, Long> contents, boolean
multipartEnabled) throws Exception {
long counter = this.getRuntimeCounter();
Dictionary<String, Object> servletProps = new Hashtable<String,
Object>();
servletProps.put(HTTP_WHITEBOARD_SERVLET_PATTERN, PATH);
- servletProps.put(HTTP_WHITEBOARD_SERVLET_MULTIPART_ENABLED,
Boolean.TRUE);
+ servletProps.put(HTTP_WHITEBOARD_SERVLET_MULTIPART_ENABLED,
multipartEnabled);
servletProps.put(HTTP_WHITEBOARD_SERVLET_MULTIPART_MAXFILESIZE, 1024L);
TestServlet servletWithErrorCode = new TestServlet() {
@@ -131,7 +131,7 @@ public class UploadTest extends Servlet5BaseIntegrationTest
{
this.receivedLatch = new CountDownLatch(1);
final Map<String, Long> contents = new HashMap<>();
- setupServlet(contents);
+ setupServlet(contents, true);
postContent('a', 500, 201);
assertTrue(receivedLatch.await(5, TimeUnit.SECONDS));
@@ -144,10 +144,22 @@ public class UploadTest extends
Servlet5BaseIntegrationTest {
this.receivedLatch = new CountDownLatch(1);
final Map<String, Long> contents = new HashMap<>();
- setupServlet(contents);
+ setupServlet(contents, true);
postContent('b', 2048, 500);
assertTrue(receivedLatch.await(5, TimeUnit.SECONDS));
assertTrue(contents.isEmpty());
}
+
+ @Test
+ public void testNoMultipartEnabled() throws Exception {
+ this.receivedLatch = new CountDownLatch(1);
+
+ final Map<String, Long> contents = new HashMap<>();
+ setupServlet(contents, false);
+
+ postContent('c', 100, 500);
+ assertTrue(receivedLatch.await(5, TimeUnit.SECONDS));
+ assertTrue(contents.isEmpty());
+ }
}