Search in sources :

Example 6 with AgentException_Exception

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

the class RemoteConfigurationManager method pushConfiguration.

/**
     * Push the provided configuration to the remote Agent
     *
     * @param atsAgent host to push the configuration to
     * @param configurator the configurator
     * @throws AgentException
     */
public void pushConfiguration(String atsAgent, Configurator configurator) throws AgentException {
    // get the client instance
    AgentService agentServicePort = AgentServicePool.getInstance().getClient(atsAgent);
    List<Configurator> configurators = new ArrayList<Configurator>();
    configurators.add(configurator);
    String checkServerLogsStr = ". Check server logs for more details.";
    try {
        // serialize the configurators
        ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
        ObjectOutputStream objectOutStream = new ObjectOutputStream(byteOutStream);
        objectOutStream.writeObject(configurators);
        agentServicePort.pushConfiguration(byteOutStream.toByteArray());
        log.info("Successfully set the " + configurator.getDescription() + " on ATS Agent at '" + atsAgent + "'");
    } catch (IOException ioe) {
        // log hint for further serialization issue investigation
        String msg = "Could not serialize configurators" + checkServerLogsStr;
        log.error(msg, ioe);
        throw new AgentException(msg, ioe);
    } catch (AgentException_Exception ae) {
        String msg = ae.getMessage() + checkServerLogsStr;
        log.error(msg, ae);
        throw new AgentException(msg, ae.getCause());
    } catch (Exception e) {
        String msg = e.getMessage() + checkServerLogsStr;
        log.error(msg, e);
        throw new AgentException(msg, e);
    }
}
Also used : AgentService(com.axway.ats.agent.webapp.client.AgentService) Configurator(com.axway.ats.agent.core.configuration.Configurator) AgentException(com.axway.ats.agent.core.exceptions.AgentException) ArrayList(java.util.ArrayList) AgentException_Exception(com.axway.ats.agent.webapp.client.AgentException_Exception) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream) AgentException(com.axway.ats.agent.core.exceptions.AgentException) AgentException_Exception(com.axway.ats.agent.webapp.client.AgentException_Exception) IOException(java.io.IOException)

Example 7 with AgentException_Exception

use of com.axway.ats.agent.webapp.client.AgentException_Exception 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)

Aggregations

AgentException (com.axway.ats.agent.core.exceptions.AgentException)7 AgentException_Exception (com.axway.ats.agent.webapp.client.AgentException_Exception)7 AgentService (com.axway.ats.agent.webapp.client.AgentService)6 IOException (java.io.IOException)5 InternalComponentException (com.axway.ats.agent.webapp.client.InternalComponentException)4 InternalComponentException_Exception (com.axway.ats.agent.webapp.client.InternalComponentException_Exception)4 ArrayList (java.util.ArrayList)3 RemoteLoggingConfigurator (com.axway.ats.agent.core.configuration.RemoteLoggingConfigurator)2 RemoteConfigurationManager (com.axway.ats.agent.webapp.client.configuration.RemoteConfigurationManager)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ObjectOutputStream (java.io.ObjectOutputStream)2 ActionRequest (com.axway.ats.agent.core.action.ActionRequest)1 Configurator (com.axway.ats.agent.core.configuration.Configurator)1 ImportantThread (com.axway.ats.agent.core.threading.ImportantThread)1 LoaderDataConfig (com.axway.ats.agent.core.threading.data.config.LoaderDataConfig)1 ThreadingPattern (com.axway.ats.agent.core.threading.patterns.ThreadingPattern)1 ActionWrapper (com.axway.ats.agent.webapp.client.ActionWrapper)1 ArgumentWrapper (com.axway.ats.agent.webapp.client.ArgumentWrapper)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ObjectInputStream (java.io.ObjectInputStream)1