You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2015/01/29 11:57:49 UTC
svn commit: r1655590 - in /felix/trunk/http/jetty: pom.xml
src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
src/test/java/org/apache/felix/http/jetty/internal/JettyServiceTest.java
Author: cziegeler
Date: Thu Jan 29 10:57:49 2015
New Revision: 1655590
URL: http://svn.apache.org/r1655590
Log:
Update tests to mock filter
Modified:
felix/trunk/http/jetty/pom.xml
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
felix/trunk/http/jetty/src/test/java/org/apache/felix/http/jetty/internal/JettyServiceTest.java
Modified: felix/trunk/http/jetty/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/pom.xml?rev=1655590&r1=1655589&r2=1655590&view=diff
==============================================================================
--- felix/trunk/http/jetty/pom.xml (original)
+++ felix/trunk/http/jetty/pom.xml Thu Jan 29 10:57:49 2015
@@ -83,6 +83,7 @@
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
+ <version>6.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -143,12 +144,12 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.http.api</artifactId>
- <version>2.3.2</version>
+ <version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.http.base</artifactId>
- <version>2.4.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
Modified: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java?rev=1655590&r1=1655589&r2=1655590&view=diff
==============================================================================
--- felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java (original)
+++ felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java Thu Jan 29 10:57:49 2015
@@ -29,7 +29,6 @@ import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -132,7 +131,7 @@ public final class JettyService extends
// FELIX-4422: start Jetty synchronously...
startJetty();
- Properties props = new Properties();
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put(Constants.SERVICE_PID, PID);
this.configServiceReg = this.context.registerService(ManagedService.class.getName(), new JettyManagedService(this), props);
@@ -741,7 +740,7 @@ public final class JettyService extends
if (bundle.getState() == Bundle.ACTIVE || (bundle.getState() == Bundle.STARTING && "Lazy".equals(bundle.getHeaders().get(HEADER_ACTIVATION_POLICY))))
{
- String contextPath = (String) bundle.getHeaders().get(HEADER_WEB_CONTEXT_PATH);
+ String contextPath = bundle.getHeaders().get(HEADER_WEB_CONTEXT_PATH);
if (contextPath != null)
{
return startWebAppBundle(bundle, contextPath);
@@ -752,7 +751,7 @@ public final class JettyService extends
public void removedBundle(Bundle bundle, BundleEvent event, Object object)
{
- String contextPath = (String) bundle.getHeaders().get(HEADER_WEB_CONTEXT_PATH);
+ String contextPath = bundle.getHeaders().get(HEADER_WEB_CONTEXT_PATH);
if (contextPath == null)
{
return;
Modified: felix/trunk/http/jetty/src/test/java/org/apache/felix/http/jetty/internal/JettyServiceTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/test/java/org/apache/felix/http/jetty/internal/JettyServiceTest.java?rev=1655590&r1=1655589&r2=1655590&view=diff
==============================================================================
--- felix/trunk/http/jetty/src/test/java/org/apache/felix/http/jetty/internal/JettyServiceTest.java (original)
+++ felix/trunk/http/jetty/src/test/java/org/apache/felix/http/jetty/internal/JettyServiceTest.java Thu Jan 29 10:57:49 2015
@@ -16,6 +16,10 @@
*/
package org.apache.felix.http.jetty.internal;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
@@ -36,6 +40,8 @@ import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
+import junit.framework.TestCase;
+
import org.apache.felix.http.base.internal.DispatcherServlet;
import org.apache.felix.http.base.internal.EventDispatcher;
import org.apache.felix.http.base.internal.HttpServiceController;
@@ -46,9 +52,6 @@ import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Version;
-import junit.framework.TestCase;
-import static org.mockito.Mockito.*;
-
public class JettyServiceTest extends TestCase
{
@@ -66,6 +69,7 @@ public class JettyServiceTest extends Te
private Bundle mockBundle;
+ @Override
public void setUp() throws Exception
{
//Setup Mocks
@@ -75,6 +79,9 @@ public class JettyServiceTest extends Te
//Setup Behaviors
when(mockBundleContext.getBundle()).thenReturn(mockBundle);
+ final org.osgi.framework.Filter f = mock(org.osgi.framework.Filter.class);
+ when(f.toString()).thenReturn("(prop=*)");
+ when(mockBundleContext.createFilter(anyString())).thenReturn(f);
when(mockBundle.getSymbolicName()).thenReturn("main");
when(mockBundle.getVersion()).thenReturn(new Version("1.0.0"));
when(mockBundle.getHeaders()).thenReturn(new Hashtable<String, String>());
@@ -92,13 +99,13 @@ public class JettyServiceTest extends Te
}
/**
- *
+ *
* Tests to ensure the osgi-bundlecontext is available for init methods.
- *
+ *
* @throws MalformedURLException
* @throws InterruptedException
*/
- public void testInitBundleContextDeployIT() throws MalformedURLException, InterruptedException
+ public void testInitBundleContextDeployIT() throws Exception
{
//Setup mocks
Deployment mockDeployment = mock(Deployment.class);
@@ -107,6 +114,9 @@ public class JettyServiceTest extends Te
//Setup behaviors
when(mockDeployment.getBundle()).thenReturn(mockBundle);
+ final org.osgi.framework.Filter f = mock(org.osgi.framework.Filter.class);
+ when(f.toString()).thenReturn("(prop=*)");
+ when(mockBundleContext.createFilter(anyString())).thenReturn(f);
when(mockBundle.getBundleContext()).thenReturn(mockBundleContext);
when(mockBundle.getSymbolicName()).thenReturn("test");
when(mockBundle.getVersion()).thenReturn(new Version("0.0.1"));