/** * Creates an instance of this class. */ public ForecastingFilterTest() { this.controller = new AnalysisController(); }
@Override protected boolean performTask() { boolean success = false; try { new AnalysisController(new File(this.kaxFilename)).run(); success = true; } catch (final IOException ex) { LOG.error("The given file could not be loaded", ex); } catch (final AnalysisConfigurationException ex) { LOG.error("The given configuration file is invalid", ex); } catch (final Exception ex) { // NOPMD NOCS (log all errors) LOG.error("Error", ex); } return success; }
public static void main(final String[] args) { final IAnalysisController analysisController = new AnalysisController("TCPThroughput"); TestTCPReader.createAndConnectPlugins(analysisController); try { analysisController.run(); } catch (final AnalysisConfigurationException ex) { TestTCPReader.LOGGER.error("Failed to start the example project.", ex); } }
private boolean isConfigurationCorrect(final Class<?> clazz) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { final IAnalysisController ac = new AnalysisController(); final AbstractPlugin pluginInstance = (AbstractPlugin) clazz.getConstructor(Configuration.class, IProjectContext.class).newInstance(new Configuration(), ac); final Property[] expectedProperties = this.getExpectedProperties(clazz); final Configuration actualConfiguration = this.getActualProperties(pluginInstance); for (final Property property : expectedProperties) { if (!(actualConfiguration.containsKey(property.name()))) { return false; } } return true; }
/** * Creates a new instance of this class. */ public TestTraceReconstructionFilter() { final SystemModelRepository systemEntityFactory = new SystemModelRepository(new Configuration(), new AnalysisController()); final ExecutionFactory executionFactory = new ExecutionFactory(systemEntityFactory); // Manually create Executions for a trace this.exec0_0__bookstore_searchBook = executionFactory.genExecution("Bookstore", "bookstore", "searchBook", TestTraceReconstructionFilter.TRACE_ID, TestTraceReconstructionFilter.SESSION_ID, 1 * (1000 * 1000), 10 * (1000 * 1000), 0, 0); this.exec1_1__catalog_getBook = executionFactory.genExecution("Catalog", "catalog", "getBook", TestTraceReconstructionFilter.TRACE_ID, TestTraceReconstructionFilter.SESSION_ID, 2 * (1000 * 1000), 4 * (1000 * 1000), 1, 1); this.exec2_1__crm_getOrders = executionFactory.genExecution("CRM", "crm", "getOrders", TestTraceReconstructionFilter.TRACE_ID, TestTraceReconstructionFilter.SESSION_ID, 5 * (1000 * 1000), 8 * (1000 * 1000), 2, 1); this.exec3_2__catalog_getBook = executionFactory.genExecution("Catalog", "catalog", "getBook", TestTraceReconstructionFilter.TRACE_ID, TestTraceReconstructionFilter.SESSION_ID, 6 * (1000 * 1000), 7 * (1000 * 1000), 3, 2); }
/** * This test makes sure that the read method of the JmsReader returns true (this was a bug, reported in #758). */ @Test public void testReadReturnsTrue() { final IAnalysisController ac = new AnalysisController(); final Configuration jmsReaderConfig = new Configuration(); jmsReaderConfig.setProperty(JmsReader.CONFIG_PROPERTY_NAME_FACTORYLOOKUP, FakeInitialContextFactory.class.getName()); final JmsReader jmsReader = new JmsReader(jmsReaderConfig, ac); jmsReader.terminate(false); Assert.assertTrue(jmsReader.read()); } }
private void executeAnalysis(final File tempFile, final boolean append, final List<Integer> objectsToWrite) throws IllegalStateException, AnalysisConfigurationException { final Configuration configuration = new Configuration(); configuration.setProperty(TeeFilter.CONFIG_PROPERTY_NAME_APPEND, Boolean.toString(append)); configuration.setProperty(TeeFilter.CONFIG_PROPERTY_NAME_STREAM, tempFile.getAbsolutePath()); final IAnalysisController analysisController = new AnalysisController(); final TeeFilter teeFilter = new TeeFilter(configuration, analysisController); final ListReader<Integer> simpleListReader = new ListReader<Integer>(new Configuration(), analysisController); analysisController.connect(simpleListReader, ListReader.OUTPUT_PORT_NAME, teeFilter, TeeFilter.INPUT_PORT_NAME_EVENTS); simpleListReader.addAllObjects(objectsToWrite); analysisController.run(); }
@BeforeClass public static void prepareSetup() throws AnalysisConfigurationException { final AnalysisController analysisController = new AnalysisController(); final ComponentDependencyGraphAllocationFilter filter = new ComponentDependencyGraphAllocationFilter(new Configuration(), analysisController); final String inputPortName = AbstractMessageTraceProcessingFilter.INPUT_PORT_NAME_MESSAGE_TRACES; final String repositoryPortName = AbstractTraceAnalysisFilter.REPOSITORY_PORT_NAME_SYSTEM_MODEL; testSetup = DependencyGraphTestUtil.prepareEnvironmentForProducerTest(analysisController, filter, inputPortName, repositoryPortName, ComponentAllocationDependencyGraphTest.createExecutionRecords()); }
/** * This test makes sure that an empty string is returned, if a plugin searches for a non existing key. */ @Test public void testNoGlobalConfiguration() { final IAnalysisController analysisController = new AnalysisController(); final PropertyFilter filter = new PropertyFilter(new Configuration(), analysisController); Assert.assertEquals("", filter.getProperty("key")); }
/** * This test makes sure that a filter can access the default global configuration. */ @Test public void testDefaultGlobalConfiguration() { final IAnalysisController analysisController = new AnalysisController(); final PropertyFilter filter = new PropertyFilter(new Configuration(), analysisController); Assert.assertEquals("NANOSECONDS", filter.getProperty(IProjectContext.CONFIG_PROPERTY_NAME_RECORDS_TIME_UNIT)); }
/** * This method initializes the setup. */ @Before public void before() { this.controller = new AnalysisController(); this.reader = new ListReader<>(new Configuration(), this.controller); this.sinkPlugin = new ListCollectionFilter<>(new Configuration(), this.controller); }
@Test public void testOverwrittenDefaultGlobalConfigurationInvalidValue() { final Configuration globalConfiguration = new Configuration(); globalConfiguration.setProperty(IProjectContext.CONFIG_PROPERTY_NAME_RECORDS_TIME_UNIT, "NOTIMEUNITVALUE"); final IAnalysisController analysisController = new AnalysisController(globalConfiguration); final PropertyFilter filter = new PropertyFilter(new Configuration(), analysisController); Assert.assertEquals("NANOSECONDS", filter.getProperty(IProjectContext.CONFIG_PROPERTY_NAME_RECORDS_TIME_UNIT)); }
/** * This test makes sure that a filter can access an overwritten property of the default global configuration. */ @Test public void testOverwrittenDefaultGlobalConfiguration() { final Configuration globalConfiguration = new Configuration(); globalConfiguration.setProperty(IProjectContext.CONFIG_PROPERTY_NAME_RECORDS_TIME_UNIT, "SECONDS"); final IAnalysisController analysisController = new AnalysisController(globalConfiguration); final PropertyFilter filter = new PropertyFilter(new Configuration(), analysisController); Assert.assertEquals("SECONDS", filter.getProperty(IProjectContext.CONFIG_PROPERTY_NAME_RECORDS_TIME_UNIT)); }
/** * This test makes sure that a filter can access the global configuration. */ @Test public void testGlobalConfiguration() { final Configuration globalConfiguration = new Configuration(); globalConfiguration.setProperty("key", "value"); final IAnalysisController analysisController = new AnalysisController(globalConfiguration); final PropertyFilter filter = new PropertyFilter(new Configuration(), analysisController); Assert.assertEquals("value", filter.getProperty("key")); }
/** * This test makes sure that the reader stores its configuration. */ @Test public void testConfigurationConservation() { final Configuration configuration = new Configuration(); configuration.setProperty(TimeReader.CONFIG_PROPERTY_NAME_NUMBER_IMPULSES, "50"); configuration.setProperty(TimeReader.CONFIG_PROPERTY_NAME_DELAY_NS, "42"); configuration.setProperty(TimeReader.CONFIG_PROPERTY_NAME_UPDATE_INTERVAL_NS, "21"); final TimeReader tr = new TimeReader(configuration, new AnalysisController()); Assert.assertEquals(42, tr.getCurrentConfiguration().getLongProperty(TimeReader.CONFIG_PROPERTY_NAME_DELAY_NS)); Assert.assertEquals(21, tr.getCurrentConfiguration().getLongProperty(TimeReader.CONFIG_PROPERTY_NAME_UPDATE_INTERVAL_NS)); Assert.assertEquals(50, tr.getCurrentConfiguration().getLongProperty(TimeReader.CONFIG_PROPERTY_NAME_NUMBER_IMPULSES)); }
/** * This is a test using only one reader. * * @throws IllegalStateException * If the analysis is in an invalid state (should not happen). * @throws AnalysisConfigurationException * If there is a configuration error in the analysis (should not happen). */ @Test public void testOnlyReader() throws IllegalStateException, AnalysisConfigurationException { final IAnalysisController ctrl = new AnalysisController(); final ShutdownReader r1 = new ShutdownReader(new Configuration(), ctrl); ctrl.run(); Assert.assertEquals(0, r1.shutdownNr); Assert.assertEquals(AnalysisController.STATE.TERMINATED, ctrl.getState()); }
/** * This method prepares the test setup. * * @throws IllegalStateException * If something went wrong during the test setup (should not happen). * @throws AnalysisConfigurationException * If something went wrong during the test setup (should not happen). */ @Before public void before() throws IllegalStateException, AnalysisConfigurationException { this.analysisController = new AnalysisController(); this.countingFilter = new CountingFilter(new Configuration(), this.analysisController); this.simpleListReader = new ListReader<Object>(new Configuration(), this.analysisController); this.analysisController.connect(this.simpleListReader, ListReader.OUTPUT_PORT_NAME, this.countingFilter, CountingFilter.INPUT_PORT_NAME_EVENTS); }
@Before public void setUp() throws Exception { final AnalysisController analysisController = new AnalysisController(); final Configuration pipeReaderConfig = new Configuration(); pipeReaderConfig.setProperty(PipeReader.CONFIG_PROPERTY_NAME_PIPENAME, BasicNamedRecordPipeWriterReaderTest.PIPE_NAME); final PipeReader pipeReader = new PipeReader(pipeReaderConfig, analysisController); this.sinkFilter = new ListCollectionFilter<IMonitoringRecord>(new Configuration(), analysisController); analysisController.connect(pipeReader, PipeReader.OUTPUT_PORT_NAME_RECORDS, this.sinkFilter, ListCollectionFilter.INPUT_PORT_NAME); final AnalysisControllerThread analysisThread = new AnalysisControllerThread(analysisController); analysisThread.start(); }
@Ignore // NOCS @Test public void testRecords() throws IOException, IllegalStateException, AnalysisConfigurationException { final IAnalysisController analysisController = new AnalysisController(); final Configuration configurationFSReader = new Configuration(); configurationFSReader.setProperty(FSReader.CONFIG_PROPERTY_NAME_INPUTDIRS, this.tmpFolder.getRoot().getCanonicalPath()); final FSReader reader = new FSReader(configurationFSReader, analysisController); final CountingFilter sink = new CountingFilter(new Configuration(), analysisController); analysisController.connect(reader, FSReader.OUTPUT_PORT_NAME_RECORDS, sink, CountingFilter.INPUT_PORT_NAME_EVENTS); analysisController.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, analysisController.getState()); Assert.assertEquals(5L, sink.getMessageCount()); // 5 records are expected } }
private List<IMonitoringRecord> readLog(final String[] monitoringLogDirs) throws AnalysisConfigurationException { final AnalysisController analysisController = new AnalysisController(); final Configuration readerConfiguration = new Configuration(); readerConfiguration.setProperty(AsciiLogReader.CONFIG_PROPERTY_NAME_INPUTDIRS, Configuration.toProperty(monitoringLogDirs)); readerConfiguration.setProperty(AsciiLogReader.CONFIG_PROPERTY_NAME_IGNORE_UNKNOWN_RECORD_TYPES, "false"); final AbstractReaderPlugin reader = new AsciiLogReader(readerConfiguration, analysisController); final ListCollectionFilter<IMonitoringRecord> sinkPlugin = new ListCollectionFilter<>(new Configuration(), analysisController); analysisController.connect(reader, AsciiLogReader.OUTPUT_PORT_NAME_RECORDS, sinkPlugin, ListCollectionFilter.INPUT_PORT_NAME); analysisController.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, analysisController.getState()); return sinkPlugin.getList(); } }