Search in sources :

Example 1 with RemoteConfigurationManager

use of com.axway.ats.agent.webapp.client.configuration.RemoteConfigurationManager in project ats-framework by Axway.

the class AgentConfigurationClient method applyConfigurationAndReloadAgentComponents.

/**
     * Apply the new settings
     *
     * @param agentSettings a list with Agent settings to change
     * @throws AgentException
     */
private void applyConfigurationAndReloadAgentComponents(Properties agentSettings) throws AgentException {
    // include the Agent configuration
    AgentConfigurator agentConfigurator = new AgentConfigurator(agentSettings);
    List<Configurator> configurators = new ArrayList<Configurator>();
    configurators.add(agentConfigurator);
    if (atsAgent.equals(LOCAL_JVM)) {
        // executed in the JVM of the test executor
        // the already loaded Agent components are first unloaded
        MainComponentLoader.getInstance().destroy();
        // the initialization procedure implicitly applies the new configurations 
        // and then loads up again the Agent components
        MainComponentLoader.getInstance().initialize(configurators);
    } else {
        // send the new configuration to the remote Agent instance
        new RemoteConfigurationManager().pushConfiguration(atsAgent, agentConfigurator);
    }
}
Also used : Configurator(com.axway.ats.agent.core.configuration.Configurator) RemoteLoggingConfigurator(com.axway.ats.agent.core.configuration.RemoteLoggingConfigurator) GenericAgentConfigurator(com.axway.ats.agent.core.configuration.GenericAgentConfigurator) AgentConfigurator(com.axway.ats.agent.core.configuration.AgentConfigurator) ArrayList(java.util.ArrayList) GenericAgentConfigurator(com.axway.ats.agent.core.configuration.GenericAgentConfigurator) AgentConfigurator(com.axway.ats.agent.core.configuration.AgentConfigurator) RemoteConfigurationManager(com.axway.ats.agent.webapp.client.configuration.RemoteConfigurationManager)

Example 2 with RemoteConfigurationManager

use of com.axway.ats.agent.webapp.client.configuration.RemoteConfigurationManager in project ats-framework by Axway.

the class TestcaseStateListener method onConfigureAtsAgents.

/**
     * This event is send right before running a regular action or starting
     * an action queue.
     *
     * It is also expected to be send between onTestStart and onTestEnd events.
     */
@Override
public void onConfigureAtsAgents(List<String> atsAgents) throws Exception {
    if (configuredAgents == null) {
        // No TestCase is started so we won't configure the remote agents
        return;
    }
    for (String atsAgent : atsAgents) {
        // configure only not configured agents
        if (!configuredAgents.contains(atsAgent)) {
            // We will try to prevent that adding a 'unique' prefix
            synchronized (("ATS_STRING_LOCK-" + atsAgent).intern()) {
                if (!configuredAgents.contains(atsAgent)) {
                    // Pass the logging configuration to the remote agent
                    RemoteLoggingConfigurator remoteLoggingConfigurator = new RemoteLoggingConfigurator(atsAgent);
                    new RemoteConfigurationManager().pushConfiguration(atsAgent, remoteLoggingConfigurator);
                    try {
                        AgentService agentServicePort = AgentServicePool.getInstance().getClient(atsAgent);
                        agentServicePort.onTestStart(getCurrentTestCaseState());
                    } catch (AgentException_Exception ae) {
                        throw new AgentException(ae.getMessage());
                    }
                    configuredAgents.add(atsAgent);
                }
            }
        }
    }
}
Also used : RemoteLoggingConfigurator(com.axway.ats.agent.core.configuration.RemoteLoggingConfigurator) AgentService(com.axway.ats.agent.webapp.client.AgentService) AgentException(com.axway.ats.agent.core.exceptions.AgentException) AgentException_Exception(com.axway.ats.agent.webapp.client.AgentException_Exception) RemoteConfigurationManager(com.axway.ats.agent.webapp.client.configuration.RemoteConfigurationManager)

Example 3 with RemoteConfigurationManager

use of com.axway.ats.agent.webapp.client.configuration.RemoteConfigurationManager in project ats-framework by Axway.

the class Test_RemoteConfigurationManager method pushConfigurationPositive.

@Test
public void pushConfigurationPositive() throws AgentException, AgentException_Exception {
    expect(AgentServicePool.getInstance()).andReturn(mockAgentServicePool);
    expect(mockAgentServicePool.getClient("10.0.0.2")).andReturn(mockAgentService);
    mockAgentService.pushConfiguration(isA(byte[].class));
    replayAll();
    new RemoteConfigurationManager().pushConfiguration("10.0.0.2", new RemoteLoggingConfigurator("127.0.0.1"));
    // verify results
    verifyAll();
//        assertTrue( RemoteConfigurationManager.getInstance().isConfigured( "10.0.0.2",
//                                                                           new RemoteLoggingConfigurator() ) );
}
Also used : RemoteLoggingConfigurator(com.axway.ats.agent.core.configuration.RemoteLoggingConfigurator) RemoteConfigurationManager(com.axway.ats.agent.webapp.client.configuration.RemoteConfigurationManager) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 4 with RemoteConfigurationManager

use of com.axway.ats.agent.webapp.client.configuration.RemoteConfigurationManager in project ats-framework by Axway.

the class Test_RemoteConfigurationManager method pushConfigurationNegativeException.

@Test(expected = AgentException.class)
public void pushConfigurationNegativeException() throws AgentException, AgentException_Exception {
    expect(AgentServicePool.getInstance()).andReturn(mockAgentServicePool);
    expect(mockAgentServicePool.getClient("10.0.0.3")).andReturn(mockAgentService);
    mockAgentService.pushConfiguration(isA(byte[].class));
    expectLastCall().andThrow(new AgentException_Exception("test", new com.axway.ats.agent.webapp.client.AgentException()));
    replayAll();
    new RemoteConfigurationManager().pushConfiguration("10.0.0.3", new RemoteLoggingConfigurator("127.0.0.1"));
    // verify results
    verifyAll();
}
Also used : RemoteLoggingConfigurator(com.axway.ats.agent.core.configuration.RemoteLoggingConfigurator) AgentException(com.axway.ats.agent.core.exceptions.AgentException) AgentException_Exception(com.axway.ats.agent.webapp.client.AgentException_Exception) RemoteConfigurationManager(com.axway.ats.agent.webapp.client.configuration.RemoteConfigurationManager) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 with RemoteConfigurationManager

use of com.axway.ats.agent.webapp.client.configuration.RemoteConfigurationManager in project ats-framework by Axway.

the class Test_RemoteConfigurationManager method pushConfigurationNegativeRuntimeException.

@Test(expected = AgentException.class)
public void pushConfigurationNegativeRuntimeException() throws AgentException, AgentException_Exception {
    expect(AgentServicePool.getInstance()).andReturn(mockAgentServicePool);
    expect(mockAgentServicePool.getClient("10.0.0.3")).andReturn(mockAgentService);
    mockAgentService.pushConfiguration(isA(byte[].class));
    expectLastCall().andThrow(new RuntimeException());
    replayAll();
    new RemoteConfigurationManager().pushConfiguration("10.0.0.3", new RemoteLoggingConfigurator("127.0.0.1"));
    // verify results
    verifyAll();
}
Also used : RemoteLoggingConfigurator(com.axway.ats.agent.core.configuration.RemoteLoggingConfigurator) RemoteConfigurationManager(com.axway.ats.agent.webapp.client.configuration.RemoteConfigurationManager) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

RemoteConfigurationManager (com.axway.ats.agent.webapp.client.configuration.RemoteConfigurationManager)6 RemoteLoggingConfigurator (com.axway.ats.agent.core.configuration.RemoteLoggingConfigurator)5 Test (org.junit.Test)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 Configurator (com.axway.ats.agent.core.configuration.Configurator)2 AgentException (com.axway.ats.agent.core.exceptions.AgentException)2 AgentException_Exception (com.axway.ats.agent.webapp.client.AgentException_Exception)2 ArrayList (java.util.ArrayList)2 AgentConfigurator (com.axway.ats.agent.core.configuration.AgentConfigurator)1 EnvironmentConfigurator (com.axway.ats.agent.core.configuration.EnvironmentConfigurator)1 GenericAgentConfigurator (com.axway.ats.agent.core.configuration.GenericAgentConfigurator)1 AgentService (com.axway.ats.agent.webapp.client.AgentService)1