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/16 20:26:23 UTC
svn commit: r1532845 -
/ace/trunk/org.apache.ace.agent.itest/src/org/apache/ace/agent/itest/AgentExtensionTest.java
Author: jawi
Date: Wed Oct 16 18:26:23 2013
New Revision: 1532845
URL: http://svn.apache.org/r1532845
Log:
ACE-419:
- make sure to clear the system properties after the test
is finished to ensure that succeeding tests are not
influenced by it.
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=1532845&r1=1532844&r2=1532845&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 16 18:26:23 2013
@@ -40,58 +40,65 @@ import org.osgi.framework.ServiceRegistr
public class AgentExtensionTest extends BaseAgentTest {
public void testLifecycle() throws Exception {
- AgentControl agentControl = getService(AgentControl.class);
- assertNotNull(agentControl);
+ try {
+ 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();
+ direg1.unregister();
+ coreg1.unregister();
+ }
+ finally {
+ System.clearProperty(AgentConstants.CONFIG_IDENTIFICATION_DISABLED);
+ System.clearProperty(AgentConstants.CONFIG_DISCOVERY_DISABLED);
+ System.clearProperty(AgentConstants.CONFIG_CONNECTION_DISABLED);
+ }
}
private ServiceRegistration registerIdentification(final String id, final int rank) {
return m_bundleContext.registerService(IdentificationHandler.class.getName(), new IdentificationHandler() {
- @Override
- public String getAgentId() {
- return id;
- }
-
- @Override
- public String toString() {
- return id;
- }
- }, new Properties() {
- {
- put(Constants.SERVICE_RANKING, rank);
- }
- });
+ @Override
+ public String getAgentId() {
+ return id;
+ }
+
+ @Override
+ public String toString() {
+ return id;
+ }
+ }, new Properties() {
+ {
+ put(Constants.SERVICE_RANKING, rank);
+ }
+ });
}