Search in sources :

Example 1 with TcpActivationControlEvent

use of org.iobserve.utility.tcp.events.TcpActivationControlEvent 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 TcpActivationControlEvent

use of org.iobserve.utility.tcp.events.TcpActivationControlEvent 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 3 with TcpActivationControlEvent

use of org.iobserve.utility.tcp.events.TcpActivationControlEvent in project iobserve-analysis by research-iobserve.

the class ProbeMapper method createMethodsToActivate.

private void createMethodsToActivate(final ProbeManagementData element) throws ControlEventCreationFailedException, InvocationException, DBException {
    final Map<AllocationContext, Set<OperationSignature>> methodsToActivate = element.getMethodsToActivate();
    if (methodsToActivate != null) {
        this.logger.debug("methods to activate");
        for (final AllocationContext allocation : methodsToActivate.keySet()) {
            this.logger.debug("AllocationContext to activate {}", allocation.getEntityName());
            for (final OperationSignature operationSignature : methodsToActivate.get(allocation)) {
                this.logger.debug("AllocationContext activate operation {}", operationSignature.getEntityName());
                try {
                    final String pattern = this.computeAllocationComponentIdentifierPattern(allocation, operationSignature);
                    this.logger.debug("AllocationContext activate operation {} -- {}", operationSignature.getEntityName(), pattern);
                    final TcpActivationControlEvent currentEvent = this.createActivationEvent(pattern, element.getTriggerTime(), element.getWhitelist());
                    this.fillTcpControlEvent(currentEvent, allocation);
                    this.outputPort.send(currentEvent);
                } catch (final ControlEventCreationFailedException e) {
                    this.logger.error("Could not construct activation event for: " + operationSignature.toString(), e);
                }
            }
        }
    }
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) TcpActivationControlEvent(org.iobserve.utility.tcp.events.TcpActivationControlEvent) Set(java.util.Set) OperationSignature(org.palladiosimulator.pcm.repository.OperationSignature) ControlEventCreationFailedException(org.iobserve.service.privacy.violation.exceptions.ControlEventCreationFailedException)

Example 4 with TcpActivationControlEvent

use of org.iobserve.utility.tcp.events.TcpActivationControlEvent 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 TcpActivationControlEvent

use of org.iobserve.utility.tcp.events.TcpActivationControlEvent 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, ProbeControlFilterTest.TRIGGER_TIMESTAMP);
    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.isEmpty());
}
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)

Aggregations

TcpActivationControlEvent (org.iobserve.utility.tcp.events.TcpActivationControlEvent)5 ArrayList (java.util.ArrayList)4 AbstractTcpControlEvent (org.iobserve.utility.tcp.events.AbstractTcpControlEvent)4 Test (org.junit.Test)4 IErrorMessages (org.iobserve.stages.data.IErrorMessages)2 Set (java.util.Set)1 ControlEventCreationFailedException (org.iobserve.service.privacy.violation.exceptions.ControlEventCreationFailedException)1 AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)1 OperationSignature (org.palladiosimulator.pcm.repository.OperationSignature)1