@Override public FeedbackHandler getFeedbackHandler() { return m_agentContext.getHandler(FeedbackHandler.class); } }
@Override public AgentUpdateHandler getAgentUpdateHandler() { return m_agentContext.getHandler(AgentUpdateHandler.class); }
private LoggingHandler getLoggingHandler() { return m_agentContext.getHandler(LoggingHandler.class); }
protected final ConnectionHandler getConnectionHandler() { return getAgentContext().getHandler(ConnectionHandler.class); }
protected final DeploymentHandler getDeploymentHandler() { return getAgentContext().getHandler(DeploymentHandler.class); }
protected final AgentUpdateHandler getAgentUpdateHandler() { return getAgentContext().getHandler(AgentUpdateHandler.class); }
protected final EventsHandler getEventsHandler() { return getAgentContext().getHandler(EventsHandler.class); }
@Test public void testBadURLConfig() throws Exception { ConfigurationHandler configurationHandler = m_agentContext.getHandler(ConfigurationHandler.class); configureAgent(configurationHandler, AgentConstants.CONFIG_DISCOVERY_SERVERURLS, "invalidURL", AgentConstants.CONFIG_DISCOVERY_CHECKING, "true"); DiscoveryHandler discoveryHandler = m_agentContext.getHandler(DiscoveryHandler.class); assertNull(discoveryHandler.getServerUrl()); // we cannot resolve this during the configuration change... }
@Test public void testEmptyURLConfig() throws Exception { ConfigurationHandler configurationHandler = m_agentContext.getHandler(ConfigurationHandler.class); configureAgent(configurationHandler, AgentConstants.CONFIG_DISCOVERY_SERVERURLS, "", AgentConstants.CONFIG_DISCOVERY_CHECKING, "true"); DiscoveryHandler discoveryHandler = m_agentContext.getHandler(DiscoveryHandler.class); assertEquals(discoveryHandler.getServerUrl(), m_unavailableURL1); }
@Test public void testUnavailableURL_unavailable() throws Exception { ConfigurationHandler configurationHandler = m_agentContext.getHandler(ConfigurationHandler.class); configureAgent(configurationHandler, AgentConstants.CONFIG_DISCOVERY_SERVERURLS, concat(m_unavailableURL1, m_unavailableURL2), AgentConstants.CONFIG_DISCOVERY_CHECKING, "true"); DiscoveryHandler discoveryHandler = m_agentContext.getHandler(DiscoveryHandler.class); assertNull(discoveryHandler.getServerUrl()); }
@Test public void testAvailableURL() throws Exception { ConfigurationHandler configurationHandler = m_agentContext.getHandler(ConfigurationHandler.class); configureAgent(configurationHandler, AgentConstants.CONFIG_DISCOVERY_SERVERURLS, concat(m_availableURL1, m_availableURL2), AgentConstants.CONFIG_DISCOVERY_CHECKING, "true"); DiscoveryHandler discoveryHandler = m_agentContext.getHandler(DiscoveryHandler.class); assertEquals(discoveryHandler.getServerUrl(), m_availableURL1); }
@Test public void testAvailableAfterUnavailableURL() throws Exception { ConfigurationHandler configurationHandler = m_agentContext.getHandler(ConfigurationHandler.class); configureAgent(configurationHandler, AgentConstants.CONFIG_DISCOVERY_SERVERURLS, concat(m_unavailableURL1, m_availableURL1), AgentConstants.CONFIG_DISCOVERY_CHECKING, "true"); DiscoveryHandler discoveryHandler = m_agentContext.getHandler(DiscoveryHandler.class); assertEquals(discoveryHandler.getServerUrl(), m_availableURL1); }
@Test public void testNoIdentification() throws Exception { ConfigurationHandler configurationHandler = m_agentContext.getHandler(ConfigurationHandler.class); reset(configurationHandler); expect(configurationHandler.get(eq(AgentConstants.CONFIG_IDENTIFICATION_AGENTID), anyObject(String.class))) .andReturn(null).once(); replay(configurationHandler); IdentificationHandler identificationHandler = m_agentContext.getHandler(IdentificationHandler.class); assertNull(identificationHandler.getAgentId()); }
@Test public void testEmptyIdentification() throws Exception { ConfigurationHandler configurationHandler = m_agentContext.getHandler(ConfigurationHandler.class); reset(configurationHandler); expect(configurationHandler.get(eq(AgentConstants.CONFIG_IDENTIFICATION_AGENTID), anyObject(String.class))) .andReturn(null).once(); replay(configurationHandler); IdentificationHandler identificationHandler = m_agentContext.getHandler(IdentificationHandler.class); assertNull(identificationHandler.getAgentId()); } }
@Test public void testAvailableIdentification() throws Exception { ConfigurationHandler configurationHandler = m_agentContext.getHandler(ConfigurationHandler.class); reset(configurationHandler); expect(configurationHandler.get(eq(AgentConstants.CONFIG_IDENTIFICATION_AGENTID), anyObject(String.class))) .andReturn("qqq").once(); replay(configurationHandler); IdentificationHandler identificationHandler = m_agentContext.getHandler(IdentificationHandler.class); assertEquals(identificationHandler.getAgentId(), "qqq"); }
@Test public void testUnavailableAfterConfigUpdate() throws Exception { ConfigurationHandler configurationHandler = m_agentContext.getHandler(ConfigurationHandler.class); configureAgent(configurationHandler, AgentConstants.CONFIG_DISCOVERY_SERVERURLS, concat(m_availableURL1, m_availableURL2), AgentConstants.CONFIG_DISCOVERY_CHECKING, "true"); DiscoveryHandler discoveryHandler = m_agentContext.getHandler(DiscoveryHandler.class); assertEquals(discoveryHandler.getServerUrl(), m_availableURL1); configureAgent(configurationHandler, AgentConstants.CONFIG_DISCOVERY_SERVERURLS, concat(m_unavailableURL1, m_unavailableURL2)); assertNull(discoveryHandler.getServerUrl()); }
@Test public void testAvailableAfterConfigUpdate() throws Exception { ConfigurationHandler configurationHandler = m_agentContext.getHandler(ConfigurationHandler.class); configureAgent(configurationHandler, AgentConstants.CONFIG_DISCOVERY_SERVERURLS, concat(m_unavailableURL1, m_unavailableURL2), AgentConstants.CONFIG_DISCOVERY_CHECKING, "true"); DiscoveryHandler discoveryHandler = m_agentContext.getHandler(DiscoveryHandler.class); assertNull(discoveryHandler.getServerUrl()); configureAgent(configurationHandler, AgentConstants.CONFIG_DISCOVERY_SERVERURLS, concat(m_availableURL1)); assertEquals(discoveryHandler.getServerUrl(), m_availableURL1); }
@Test public void testFailed404_noresume_result() throws Exception { DownloadHandler downloadHandler = m_agentContext.getHandler(DownloadHandler.class); DownloadHandle handle = downloadHandler.getHandle(m_404url); Future<DownloadResult> future = handle.start(null); assertIOException(future); }
@Test public void testSuccessful_noresume_result() throws Exception { DownloadHandler downloadHandler = m_agentContext.getHandler(DownloadHandler.class); DownloadHandle handle = downloadHandler.getHandle(m_200url); handle.discard(); Future<DownloadResult> result = handle.start(null); assertSuccessful(result, m_200digest); }
@Test public void testFailed503_noresume_result() throws Exception { DownloadHandler downloadHandler = m_agentContext.getHandler(DownloadHandler.class); DownloadHandle handle = downloadHandler.getHandle(m_503url); assertRetryException(handle.start(null)); assertRetryException(handle.start(null)); }