use of org.iobserve.utility.tcp.events.AbstractTcpControlEvent in project iobserve-analysis by research-iobserve.
the class ProbeControlFilterTest method getInvalidControlEventTest.
/**
* Test whether an invalid event is handled properly.
*/
@Test(timeout = 300)
public void getInvalidControlEventTest() {
// NOPMD fake ip as string is necessary
final String ip = "1.2.3.4";
final String hostname = "test.host";
final AbstractTcpControlEvent controlEvent = new TcpActivationControlEvent(ip, ProbeControlFilterTest.port, hostname, ProbeControlFilterTest.PATTERN);
final List<AbstractTcpControlEvent> input = new ArrayList<>();
input.add(controlEvent);
// TODO there is a strange error in this test
// StageTester.test(this.probeControlFilter).and().send(input).to(this.probeControlFilter.getInputPort()).start();
// Assert.assertThat(this.probeControlFilter.getOutputPort(), StageTester.produces(new
// Alarms()));
Assert.assertTrue(true);
}
use of org.iobserve.utility.tcp.events.AbstractTcpControlEvent in project iobserve-analysis by research-iobserve.
the class ProbeMapperTest method receiveEmptyDataTest.
@Test
public void receiveEmptyDataTest() {
this.probeMapper = new ProbeMapper(Mockito.mock(Neo4JModelResource.class), Mockito.mock(Neo4JModelResource.class), Mockito.mock(Neo4JModelResource.class), Mockito.mock(Neo4JModelResource.class), Mockito.mock(Neo4JModelResource.class));
final ProbeManagementData data = new ProbeManagementData(new HashMap<AllocationContext, Set<OperationSignature>>(), new HashMap<AllocationContext, Set<OperationSignature>>());
final List<ProbeManagementData> input = new LinkedList<>();
input.add(data);
final List<AbstractTcpControlEvent> output = new LinkedList<>();
StageTester.test(this.probeMapper).and().send(input).to(this.probeMapper.getInputPort()).receive(output).from(this.probeMapper.getOutputPort()).start();
Assert.assertTrue(output.isEmpty());
}
use of org.iobserve.utility.tcp.events.AbstractTcpControlEvent in project iobserve-analysis by research-iobserve.
the class ProbeControlFilterTest method getInvalidControlEventTest.
/**
* Test whether an invalid event is handled properly.
*/
@Test(timeout = 300)
public void getInvalidControlEventTest() {
// NOPMD fake ip as string is necessary
final String ip = "1.2.3.4";
final String hostname = "test.host";
final AbstractTcpControlEvent controlEvent = new TcpActivationControlEvent(ip, ProbeControlFilterTest.port, hostname, ProbeControlFilterTest.PATTERN, ProbeControlFilterTest.TRIGGER_TIMESTAMP);
final List<AbstractTcpControlEvent> input = new ArrayList<>();
input.add(controlEvent);
// TODO there is a strange error in this test
// StageTester.test(this.probeControlFilter).and().send(input).to(this.probeControlFilter.getInputPort()).start();
// Assert.assertThat(this.probeControlFilter.getOutputPort(), StageTester.produces(new
// Alarms()));
Assert.assertTrue(true);
}
use of org.iobserve.utility.tcp.events.AbstractTcpControlEvent in project iobserve-analysis by research-iobserve.
the class ProbeControlFilterTest method getValidControlEventTest.
/**
* Check whether the control event is communicated properly.
*/
@Test
public void getValidControlEventTest() {
// NOPMD localhost is required here
final String ip = "127.0.0.1";
final String hostname = "test.host";
final AbstractTcpControlEvent controlEvent = new TcpActivationControlEvent(ip, ProbeControlFilterTest.port, hostname, ProbeControlFilterTest.PATTERN);
final List<AbstractTcpControlEvent> input = new ArrayList<>();
input.add(controlEvent);
final List<IErrorMessages> output = new ArrayList<>();
StageTester.test(this.probeControlFilter).and().send(input).to(this.probeControlFilter.getInputPort()).and().receive(output).from(this.probeControlFilter.getOutputPort()).start();
Assert.assertTrue(output.size() == 0);
}
use of org.iobserve.utility.tcp.events.AbstractTcpControlEvent in project iobserve-analysis by research-iobserve.
the class GenerateConfigurationStage method execute.
@Override
protected void execute() throws Exception {
AbstractTcpControlEvent element;
final String hostname = "account-service";
for (int i = 0; i < this.operations.length; i++) {
final String operationSignature = this.createSignaturePattern(this.operations[i], this.parameters[i]);
final long triggerTimestamp = 0;
final Map<String, List<String>> parameters = new HashMap<>();
final List<String> blacklist = new ArrayList<>();
this.populateList(blacklist, this.blackStart, this.blackEnd);
parameters.put(EListType.BLACKLIST.name(), blacklist);
final List<String> completeWhitelist = new ArrayList<>(this.whitelist);
completeWhitelist.add(this.ipv4Generator(127, 0, 0, 1));
this.populateList(blacklist, this.whiteStart, this.whiteEnd);
parameters.put(EListType.WHITELIST.name(), completeWhitelist);
element = new TcpActivationParameterControlEvent(this.host, this.port, hostname, operationSignature, triggerTimestamp, parameters);
this.outputPort.send(element);
}
this.workCompleted();
}
Aggregations