private void scheduleStore() { if (!m_timer.schedule()) { logWarning("Cannot schedule task to store configuration. Executor is shut down!"); } }
@Override protected void onInit() throws Exception { loadConfig(); m_timer = new ResettableTimer(getExecutorService(), this, 5, TimeUnit.SECONDS); }
@Override public void progress(long bytesRead) { getController().logDebug("%d bytes of %s update downloaded...", bytesRead, m_type); }
@BeforeClass public void setUpAgain() throws Exception { m_agentContextImpl = mockAgentContext(); replayTestMocks(); BundleContext bc = mockBundleContext(); m_agentContextImpl.setHandler(FeedbackHandler.class, new FeedbackHandlerImpl()); m_agentContextImpl.setHandler(EventsHandler.class, new EventsHandlerImpl(bc)); m_agentContextImpl.setHandler(ConfigurationHandler.class, new ConfigurationHandlerImpl(bc)); m_agentContextImpl.start(); }
@BeforeClass(alwaysRun = true) public void setUpOnceAgain() throws Exception { m_agentContext = mockAgentContext(); BundleContext bc = mockBundleContext(); m_eventsHandler = new EventsHandlerImpl(bc); m_agentContext.setHandler(EventsHandler.class, m_eventsHandler); m_agentContext.setHandler(ConfigurationHandler.class, new ConfigurationHandlerImpl(bc)); m_agentContext.setHandler(FeedbackHandler.class, new TestFeedbackHandler()); replayTestMocks(); m_agentContext.start(); }
@BeforeClass public void setUp() throws Exception { m_agentContext = mockAgentContext(); m_agentContext.setHandler(DownloadHandler.class, new DownloadHandlerImpl(m_agentContext.getWorkDir())); m_agentContext.setHandler(ConnectionHandler.class, new ConnectionHandlerImpl()); replayTestMocks(); m_agentContext.start(); }
/** * Tests that we can read non-partial content and return the expected contents. */ @Test(expectedExceptions = IOException.class) public void testReadClosedStreamFail() throws Exception { ConnectionHandler handler = new TestConnectionHandler(new CompleteContentConnection(m_content, true)); ContentRangeInputStream is = new ContentRangeInputStream(handler, m_testURL); is.close(); // simulate an early close... is.read(); // should fail! }
@BeforeClass public void setUpAgain() throws Exception { m_agentContextImpl = mockAgentContext(); m_agentContext = m_agentContextImpl; m_agentContextImpl.setHandler(IdentificationHandler.class, new IdentificationHandlerImpl()); m_agentContextImpl.start(); replayTestMocks(); }
/** * Tests that we can read non-partial content and return the expected contents. */ @Test public void testReadNonPartialEmptyContentOk() throws Exception { String content = ""; ConnectionHandler handler = new TestConnectionHandler(new CompleteContentConnection(content, true)); ContentRangeInputStream is = new ContentRangeInputStream(handler, m_testURL); assertEquals(slurpAsStringWithBuffer(is), content); }
/** * Tests that we can read partial content and return the expected contents. */ @Test public void testReadPartialContentWithDeferredTotalLengthOk() throws Exception { String content = m_content; ConnectionHandler handler = new TestConnectionHandler(new PartialContentConnection(content, true)); ContentRangeInputStream is = new ContentRangeInputStream(handler, m_testURL); assertEquals(slurpAsStringWithBuffer(is), content); }
private void resetConfigurationHandler(ConfigurationHandler configurationHandler) throws Exception { ConfigurationHandler oldConfigurationHandler = m_agentContextImpl.getHandler(ConfigurationHandler.class); if (oldConfigurationHandler instanceof ComponentBase) { ((ComponentBase) oldConfigurationHandler).stop(); } m_agentContextImpl.setHandler(ConfigurationHandler.class, configurationHandler); m_agentContextImpl.start(); } }
/** * Tests that we can read partial content and return the expected contents. */ @Test public void testReadPartialContentByteForByteOk() throws Exception { String content = m_content; ConnectionHandler handler = new TestConnectionHandler(new PartialContentConnection(content, false)); ContentRangeInputStream is = new ContentRangeInputStream(handler, m_testURL); assertEquals(slurpAsStringByteForByte(is), content); }
protected InputStream getInputStream(URL packageURL) throws RetryAfterException, IOException { return new ContentRangeInputStream(getConnectionHandler(), packageURL); }
public DeploymentHandlerImpl(BundleContext bundleContext, PackageAdmin packageAdmin) { super("deployment"); m_ownDeploymentAdmin = true; m_deploymentAdmin = new DeploymentAdminImpl(); configureField(m_deploymentAdmin, BundleContext.class, bundleContext); configureField(m_deploymentAdmin, PackageAdmin.class, packageAdmin); configureField(m_deploymentAdmin, EventAdmin.class, new EventAdminBridge(bundleContext)); configureField(m_deploymentAdmin, LogService.class, new LogServiceBridge()); }
/** * Tests that we call {@link InputStream#close()} multiple times. */ @Test public void testDoubleClosedStreamOk() throws Exception { ConnectionHandler handler = new TestConnectionHandler(new CompleteContentConnection(m_content, true)); ContentRangeInputStream is = new ContentRangeInputStream(handler, m_testURL); is.close(); // simulate an early close... is.close(); // not a problem... }
/** * Tests that we can read non-partial content and return the expected contents. */ @Test public void testReadNonPartialContentOk() throws Exception { String content = m_content; ConnectionHandler handler = new TestConnectionHandler(new CompleteContentConnection(content, true)); ContentRangeInputStream is = new ContentRangeInputStream(handler, m_testURL); assertEquals(slurpAsStringWithBuffer(is), content); }
/** * Tests that we can read partial content and return the expected contents. */ @Test public void testReadPartialEmptyContentOk() throws Exception { String content = ""; ConnectionHandler handler = new TestConnectionHandler(new PartialContentConnection(content, false)); ContentRangeInputStream is = new ContentRangeInputStream(handler, m_testURL); assertEquals(slurpAsStringWithBuffer(is), content); }
/** * Tests that we can read partial content and return the expected contents. */ @Test public void testReadPartialEmptyContentByteForByteOk() throws Exception { String content = ""; ConnectionHandler handler = new TestConnectionHandler(new PartialContentConnection(content, false)); ContentRangeInputStream is = new ContentRangeInputStream(handler, m_testURL); assertEquals(slurpAsStringByteForByte(is), content); }
/** * Tests that we can read non-partial content and return the expected contents. */ @Test public void testReadNonPartialWithoutContentLengthOk() throws Exception { String content = ""; ConnectionHandler handler = new TestConnectionHandler(new CompleteContentConnection(content, false)); ContentRangeInputStream is = new ContentRangeInputStream(handler, m_testURL); assertEquals(slurpAsStringWithBuffer(is), content); }
/** * Tests that we can read partial content and return the expected contents. */ @Test public void testReadPartialContentOk() throws Exception { String content = m_content; ConnectionHandler handler = new TestConnectionHandler(new PartialContentConnection(content, false)); ContentRangeInputStream is = new ContentRangeInputStream(handler, m_testURL); assertEquals(slurpAsStringWithBuffer(is), content); }