You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ace.apache.org by ja...@apache.org on 2013/10/23 09:18:28 UTC

svn commit: r1534935 - /ace/trunk/org.apache.ace.agent.itest/src/org/apache/ace/agent/itest/AgentExtensionTest.java

Author: jawi
Date: Wed Oct 23 07:18:28 2013
New Revision: 1534935

URL: http://svn.apache.org/r1534935
Log:
Once again a fix to make this itest behave properly with the other itests without breaking them.


Modified:
    ace/trunk/org.apache.ace.agent.itest/src/org/apache/ace/agent/itest/AgentExtensionTest.java

Modified: ace/trunk/org.apache.ace.agent.itest/src/org/apache/ace/agent/itest/AgentExtensionTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent.itest/src/org/apache/ace/agent/itest/AgentExtensionTest.java?rev=1534935&r1=1534934&r2=1534935&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent.itest/src/org/apache/ace/agent/itest/AgentExtensionTest.java (original)
+++ ace/trunk/org.apache.ace.agent.itest/src/org/apache/ace/agent/itest/AgentExtensionTest.java Wed Oct 23 07:18:28 2013
@@ -40,47 +40,45 @@ import org.osgi.framework.ServiceRegistr
 public class AgentExtensionTest extends BaseAgentTest {
 
     public void testLifecycle() throws Exception {
-        try {
-            AgentControl agentControl = getService(AgentControl.class);
-            assertNotNull(agentControl);
+        AgentControl agentControl = getService(AgentControl.class);
+        assertNotNull(agentControl);
 
-            getAgentBundle().stop();
-            System.setProperty(AgentConstants.CONFIG_IDENTIFICATION_DISABLED, "true");
-            System.setProperty(AgentConstants.CONFIG_DISCOVERY_DISABLED, "true");
-            System.setProperty(AgentConstants.CONFIG_CONNECTION_DISABLED, "true");
-            getAgentBundle().start();
+        getAgentBundle().stop();
+        System.setProperty(AgentConstants.CONFIG_IDENTIFICATION_DISABLED, "true");
+        System.setProperty(AgentConstants.CONFIG_DISCOVERY_DISABLED, "true");
+        System.setProperty(AgentConstants.CONFIG_CONNECTION_DISABLED, "true");
+        getAgentBundle().start();
 
-            assertNull(locateService(AgentControl.class));
+        assertNull(locateService(AgentControl.class));
 
-            ServiceRegistration idreg1 = registerIdentification("TEST1", 1);
-            assertNull(locateService(AgentControl.class));
-            ServiceRegistration direg1 = registerDiscovery(new URL("http://test1"), 1);
-            assertNull(locateService(AgentControl.class));
-            ServiceRegistration coreg1 = registerConnectionHandler();
-            assertNotNull(locateService(AgentControl.class));
+        ServiceRegistration idreg1 = registerIdentification("TEST1", 1);
+        assertNull(locateService(AgentControl.class));
+        ServiceRegistration direg1 = registerDiscovery(new URL("http://test1"), 1);
+        assertNull(locateService(AgentControl.class));
+        ServiceRegistration coreg1 = registerConnectionHandler();
+        assertNotNull(locateService(AgentControl.class));
 
-            assertEquals("TEST1", locateService(AgentControl.class).getAgentId());
+        assertEquals("TEST1", locateService(AgentControl.class).getAgentId());
 
-            ServiceRegistration idreg2 = registerIdentification("TEST2", 2);
+        ServiceRegistration idreg2 = registerIdentification("TEST2", 2);
 
-            assertEquals("TEST2", locateService(AgentControl.class).getAgentId());
+        assertEquals("TEST2", locateService(AgentControl.class).getAgentId());
 
-            idreg2.unregister();
+        idreg2.unregister();
 
-            assertEquals("TEST1", locateService(AgentControl.class).getAgentId());
+        assertEquals("TEST1", locateService(AgentControl.class).getAgentId());
 
-            idreg1.unregister();
+        idreg1.unregister();
 
-            assertNull(locateService(AgentControl.class));
+        assertNull(locateService(AgentControl.class));
 
-            direg1.unregister();
-            coreg1.unregister();
-        }
-        finally {
-            System.clearProperty(AgentConstants.CONFIG_IDENTIFICATION_DISABLED);
-            System.clearProperty(AgentConstants.CONFIG_DISCOVERY_DISABLED);
-            System.clearProperty(AgentConstants.CONFIG_CONNECTION_DISABLED);
-        }
+        direg1.unregister();
+        coreg1.unregister();
+    }
+
+    @Override
+    protected void doTearDown() throws Exception {
+        resetAgentBundleState();
     }
 
     private ServiceRegistration registerIdentification(final String id, final int rank) {