tested = new ActiveTransmissionLoader(fileSystem, mockDispatcher, mockStateFetcher(), 2); if (!putFilesFirst) { boolean ok = tested.load(true); assertTrue("Failed to load", ok); boolean ok = tested.load(true); assertTrue("Failed to load", ok); tested.stop(1L, TimeUnit.SECONDS);
private void testIllegalState(final TransmissionDispatcher dispatcher, int numberOfThreads) throws Exception { File folder = null; try { String filesPath = System.getProperty("java.io.tmpdir") + File.separator + TEMP_TEST_FOLDER; folder = new File(filesPath); if (folder.exists()) { FileUtils.deleteDirectory(folder); } if (!folder.exists()) { folder.mkdir(); } TransmissionFileSystemOutput mock = new TransmissionFileSystemOutput(filesPath); new ActiveTransmissionLoader(mock, dispatcher, mockStateFetcher(), numberOfThreads); } finally { if (folder != null && folder.exists()) { FileUtils.deleteDirectory(folder); } } }
@Test(expected = NullPointerException.class) public void testNullFileSystem() throws Exception { new ActiveTransmissionLoader(null, Mockito.mock(TransmissionDispatcher.class), mockStateFetcher(), 1); }
@Override public TelemetriesTransmitter create(String endpoint, String maxTransmissionStorageCapacity, boolean throttlingIsEnabled, int maxInstanceRetries) { // An active object with the network sender TransmissionOutput actualNetworkSender = TestThreadLocalData.getTransmissionOutput(); final TransmissionPolicyManager transmissionPolicyManager = new TransmissionPolicyManager(throttlingIsEnabled); transmissionPolicyManager.addTransmissionHandler(new ErrorHandler(transmissionPolicyManager)); transmissionPolicyManager.addTransmissionHandler(new PartialSuccessHandler(transmissionPolicyManager)); transmissionPolicyManager.addTransmissionHandler(new ThrottlingHandler(transmissionPolicyManager)); transmissionPolicyManager.setMaxInstantRetries(maxInstanceRetries); TransmissionPolicyStateFetcher stateFetcher = transmissionPolicyManager.getTransmissionPolicyState(); TransmissionOutput networkSender = new ActiveTransmissionNetworkOutput(actualNetworkSender, stateFetcher); // An active object with the file system sender TransmissionFileSystemOutput fileSystemSender = new TransmissionFileSystemOutput(); TransmissionOutput activeFileSystemOutput = new ActiveTransmissionFileSystemOutput(fileSystemSender, stateFetcher); // The dispatcher works with the two active senders TransmissionDispatcher dispatcher = new NonBlockingDispatcher(new TransmissionOutput[] {networkSender, activeFileSystemOutput}); // The loader works with the file system loader as the active one does TransmissionsLoader transmissionsLoader = new ActiveTransmissionLoader(fileSystemSender, stateFetcher, dispatcher); // The Transmitter manage all TelemetriesTransmitter telemetriesTransmitter = new TransmitterImpl(dispatcher, new GzipTelemetrySerializer(), transmissionsLoader); return telemetriesTransmitter; } }
TransmissionsLoader transmissionsLoader = new ActiveTransmissionLoader(fileSystemSender, stateFetcher, dispatcher);