You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ace.apache.org by ma...@apache.org on 2009/10/05 00:19:51 UTC

svn commit: r821628 - in /incubator/ace/trunk/test/src/org/apache/ace/test/http/listener: Activator.java ServletConfiguratorIntegrationTest.java

Author: marrs
Date: Sun Oct  4 22:19:51 2009
New Revision: 821628

URL: http://svn.apache.org/viewvc?rev=821628&view=rev
Log:
More fixes to the HTTP listener integration test.

Modified:
    incubator/ace/trunk/test/src/org/apache/ace/test/http/listener/Activator.java
    incubator/ace/trunk/test/src/org/apache/ace/test/http/listener/ServletConfiguratorIntegrationTest.java

Modified: incubator/ace/trunk/test/src/org/apache/ace/test/http/listener/Activator.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/test/src/org/apache/ace/test/http/listener/Activator.java?rev=821628&r1=821627&r2=821628&view=diff
==============================================================================
--- incubator/ace/trunk/test/src/org/apache/ace/test/http/listener/Activator.java (original)
+++ incubator/ace/trunk/test/src/org/apache/ace/test/http/listener/Activator.java Sun Oct  4 22:19:51 2009
@@ -21,6 +21,7 @@
 import org.apache.ace.test.osgi.dm.TestActivatorBase;
 import org.apache.felix.dependencymanager.DependencyManager;
 import org.osgi.framework.BundleContext;
+import org.osgi.service.http.HttpService;
 import org.osgi.service.log.LogService;
 
 /**
@@ -31,10 +32,14 @@
     @Override
     protected void initServices(BundleContext context, DependencyManager manager) {
         manager.add(createService()
-            .setImplementation(new ServletConfiguratorIntegrationTest(manager))
+            .setImplementation(ServletConfiguratorIntegrationTest.class)
+            .add(createServiceDependency()
+                .setService(HttpService.class)
+                .setRequired(true))
             .add(createServiceDependency()
                 .setService(LogService.class)
-                .setRequired(false)));
+                .setRequired(false))
+                );
     }
 
     @SuppressWarnings("unchecked")

Modified: incubator/ace/trunk/test/src/org/apache/ace/test/http/listener/ServletConfiguratorIntegrationTest.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/test/src/org/apache/ace/test/http/listener/ServletConfiguratorIntegrationTest.java?rev=821628&r1=821627&r2=821628&view=diff
==============================================================================
--- incubator/ace/trunk/test/src/org/apache/ace/test/http/listener/ServletConfiguratorIntegrationTest.java (original)
+++ incubator/ace/trunk/test/src/org/apache/ace/test/http/listener/ServletConfiguratorIntegrationTest.java Sun Oct  4 22:19:51 2009
@@ -36,8 +36,7 @@
 import org.apache.felix.dependencymanager.Service;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
 import org.osgi.service.http.HttpService;
 import org.testng.annotations.Factory;
 import org.testng.annotations.Test;
@@ -49,9 +48,8 @@
 
     private static Object instance;
 
-    private BundleContext m_context;
-
-    private DependencyManager m_dependencyManager;
+    private volatile BundleContext m_context;
+    private volatile DependencyManager m_dependencyManager;
 
     // the echo servlet
     private HttpServlet m_echoServlet;
@@ -76,17 +74,6 @@
         return new Object[] { instance };
     }
 
-    /**
-     * store the dependencymanager to publish our own test services
-     */
-    public ServletConfiguratorIntegrationTest(DependencyManager dependencyManager) {
-        if (instance == null) {
-            instance = this;
-        }
-        m_dependencyManager = dependencyManager;
-        // start will be called when the dependency manager is ready
-    }
-
     public void start() {
         m_echoServlet = new EchoServlet();
         Dictionary<String, String> dictionary = new Hashtable<String, String>();
@@ -101,9 +88,15 @@
                                     .setInterface(HttpService.class.getName(), null);
     }
 
-    private void setUp() throws InvalidSyntaxException, BundleException {
+    private void setUp() {
         if (m_httpBundle == null) {
-            m_httpBundle = m_context.getServiceReference(HttpService.class.getName()).getBundle();
+            ServiceReference ref = m_context.getServiceReference(HttpService.class.getName());
+            if (ref != null) {
+                m_httpBundle = ref.getBundle();
+            }
+            else {
+                throw new IllegalStateException("Could not find HttpService.");
+            }
         }
     }