Search in sources :

Example 1 with AbstractTcpControlEvent

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);
}
Also used : AbstractTcpControlEvent(org.iobserve.utility.tcp.events.AbstractTcpControlEvent) TcpActivationControlEvent(org.iobserve.utility.tcp.events.TcpActivationControlEvent) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 2 with AbstractTcpControlEvent

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());
}
Also used : ProbeMapper(org.iobserve.service.privacy.violation.filter.ProbeMapper) AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) AbstractTcpControlEvent(org.iobserve.utility.tcp.events.AbstractTcpControlEvent) Set(java.util.Set) ProbeManagementData(org.iobserve.service.privacy.violation.data.ProbeManagementData) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 3 with AbstractTcpControlEvent

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);
}
Also used : AbstractTcpControlEvent(org.iobserve.utility.tcp.events.AbstractTcpControlEvent) TcpActivationControlEvent(org.iobserve.utility.tcp.events.TcpActivationControlEvent) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 4 with AbstractTcpControlEvent

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);
}
Also used : AbstractTcpControlEvent(org.iobserve.utility.tcp.events.AbstractTcpControlEvent) TcpActivationControlEvent(org.iobserve.utility.tcp.events.TcpActivationControlEvent) ArrayList(java.util.ArrayList) IErrorMessages(org.iobserve.stages.data.IErrorMessages) Test(org.junit.Test)

Example 5 with AbstractTcpControlEvent

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();
}
Also used : AbstractTcpControlEvent(org.iobserve.utility.tcp.events.AbstractTcpControlEvent) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TcpActivationParameterControlEvent(org.iobserve.utility.tcp.events.TcpActivationParameterControlEvent) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

AbstractTcpControlEvent (org.iobserve.utility.tcp.events.AbstractTcpControlEvent)7 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 TcpActivationControlEvent (org.iobserve.utility.tcp.events.TcpActivationControlEvent)4 LinkedList (java.util.LinkedList)2 ProbeManagementData (org.iobserve.service.privacy.violation.data.ProbeManagementData)2 ProbeMapper (org.iobserve.service.privacy.violation.filter.ProbeMapper)2 IErrorMessages (org.iobserve.stages.data.IErrorMessages)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Set (java.util.Set)1 TcpActivationParameterControlEvent (org.iobserve.utility.tcp.events.TcpActivationParameterControlEvent)1 AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)1