felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1755327 - /felix/trunk/http/itest/src/test/java/org/apache/felix/http/itest/HttpServiceRuntimeTest.java
Date Fri, 05 Aug 2016 14:09:58 GMT
Author: cziegeler
Date: Fri Aug  5 14:09:57 2016
New Revision: 1755327

URL: http://svn.apache.org/viewvc?rev=1755327&view=rev
Log:
FELIX-5319 : HttpServiceRuntime provides incorrect info for service that is both Servlet and
Resource

Modified:
    felix/trunk/http/itest/src/test/java/org/apache/felix/http/itest/HttpServiceRuntimeTest.java

Modified: felix/trunk/http/itest/src/test/java/org/apache/felix/http/itest/HttpServiceRuntimeTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/itest/src/test/java/org/apache/felix/http/itest/HttpServiceRuntimeTest.java?rev=1755327&r1=1755326&r2=1755327&view=diff
==============================================================================
--- felix/trunk/http/itest/src/test/java/org/apache/felix/http/itest/HttpServiceRuntimeTest.java
(original)
+++ felix/trunk/http/itest/src/test/java/org/apache/felix/http/itest/HttpServiceRuntimeTest.java
Fri Aug  5 14:09:57 2016
@@ -1367,6 +1367,53 @@ public class HttpServiceRuntimeTest exte
         assertTrue(endpoint[0].endsWith(":8080/"));
     }
 
+    /**
+     * Test for FELIX-5319
+     * @throws Exception
+     */
+    @Test
+    public void testCombinedServletAndResourceRegistration() throws Exception
+    {
+        // register single component as Servlet and Resource
+        final String servletPath = "/hello/sayHello";
+        final String servletName = "Hello World";
+        final String rsrcPattern = "/hello/static/*";
+        final String rsrcPrefix = "/static";
+
+        CountDownLatch initLatch = new CountDownLatch(1);
+        List<Object> propertyEntries = Arrays.<Object>asList(
+                HTTP_WHITEBOARD_SERVLET_PATTERN, servletPath,
+                HTTP_WHITEBOARD_SERVLET_NAME, servletName,
+                HTTP_WHITEBOARD_RESOURCE_PATTERN, rsrcPattern,
+                HTTP_WHITEBOARD_RESOURCE_PREFIX, rsrcPrefix);
+
+        Dictionary<String, ?> properties = createDictionary(propertyEntries.toArray());
+
+        registrations.add(m_context.registerService(Servlet.class.getName(), new TestServlet(initLatch,
null), properties));
+        awaitServiceRegistration(initLatch);
+
+        HttpServiceRuntime serviceRuntime = (HttpServiceRuntime) getService(HttpServiceRuntime.class.getName());
+        assertNotNull("HttpServiceRuntime unavailable", serviceRuntime);
+
+        RuntimeDTO runtimeDTO = serviceRuntime.getRuntimeDTO();
+
+        assertEquals(0, runtimeDTO.failedServletDTOs.length);
+        assertEquals(0, runtimeDTO.failedResourceDTOs.length);
+
+        // check servlet registration
+        ServletContextDTO contextDTO = assertDefaultContext(runtimeDTO);
+        assertEquals(1, contextDTO.servletDTOs.length);
+        assertEquals(servletName, contextDTO.servletDTOs[0].name);
+        assertEquals(1, contextDTO.servletDTOs[0].patterns.length);
+        assertEquals(servletPath, contextDTO.servletDTOs[0].patterns[0]);
+
+        // check resource registration
+        assertEquals(1, contextDTO.resourceDTOs.length);
+        assertEquals(1, contextDTO.resourceDTOs[0].patterns.length);
+        assertEquals(rsrcPattern, contextDTO.resourceDTOs[0].patterns[0]);
+        assertEquals(rsrcPrefix, contextDTO.resourceDTOs[0].prefix);
+    }
+
     private ServletContextDTO assertDefaultContext(RuntimeDTO runtimeDTO)
     {
         assertTrue(1 < runtimeDTO.servletContextDTOs.length);



Mime
View raw message