Search in sources :

Example 1 with ConsumerTestUnit

use of it.unibo.arces.wot.sepa.ConsumerTestUnit in project SEPA by arces-wot.

the class ITPattern method notification.

@RepeatedTest(ConfigurationProvider.REPEATED_TEST)
@Timeout(10)
public void notification() throws InterruptedException, SEPASecurityException, IOException, SEPAPropertiesException, SEPAProtocolException, SEPABindingsException {
    consumerAll = new ConsumerTestUnit(provider, "ALL");
    consumerAll.syncSubscribe(provider.TIMEOUT, provider.NRETRY);
    randomProducer = new Producer(provider.getJsap(), "RANDOM");
    Response ret = randomProducer.update(provider.TIMEOUT, provider.NRETRY);
    assertFalse(ret.isError(), ret.toString());
    consumerAll.waitNotification();
}
Also used : ConsumerTestUnit(it.unibo.arces.wot.sepa.ConsumerTestUnit) Response(it.unibo.arces.wot.sepa.commons.response.Response) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Timeout(org.junit.jupiter.api.Timeout)

Example 2 with ConsumerTestUnit

use of it.unibo.arces.wot.sepa.ConsumerTestUnit in project SEPA by arces-wot.

the class ITPattern method aggregation.

@RepeatedTest(ConfigurationProvider.REPEATED_TEST)
@Timeout(10)
public void aggregation() throws InterruptedException, SEPASecurityException, IOException, SEPAPropertiesException, SEPAProtocolException, SEPABindingsException {
    logger.debug("Aggregator");
    consumerRandom1 = new ConsumerTestUnit(provider, "RANDOM1");
    consumerRandom1.syncSubscribe(provider.TIMEOUT, provider.NRETRY);
    logger.debug("Aggregator first subscribe ok");
    randomAggregator = new AggregatorTestUnit(provider, "RANDOM", "RANDOM1");
    randomAggregator.syncSubscribe(provider.TIMEOUT, provider.NRETRY);
    logger.debug("Aggregator second subscribe ok");
    randomProducer = new Producer(provider.getJsap(), "RANDOM");
    Response ret = randomProducer.update(provider.TIMEOUT, provider.NRETRY);
    assertFalse(ret.isError(), ret.toString());
    logger.debug("Aggregator Update Done");
    randomAggregator.waitNotification();
    consumerRandom1.waitNotification();
    logger.debug("Aggregator stop");
}
Also used : ConsumerTestUnit(it.unibo.arces.wot.sepa.ConsumerTestUnit) Response(it.unibo.arces.wot.sepa.commons.response.Response) AggregatorTestUnit(it.unibo.arces.wot.sepa.AggregatorTestUnit) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Timeout(org.junit.jupiter.api.Timeout)

Example 3 with ConsumerTestUnit

use of it.unibo.arces.wot.sepa.ConsumerTestUnit in project SEPA by arces-wot.

the class StressUsingPAC method subscribeAndUpdateRaceDetection.

@RepeatedTest(ConfigurationProvider.REPEATED_TEST)
public // @Timeout(10)
void subscribeAndUpdateRaceDetection() throws InterruptedException, SEPASecurityException, IOException, SEPAPropertiesException, SEPAProtocolException, SEPABindingsException {
    Thread pub = new Thread() {

        public void run() {
            for (int i = 0; i < 500; i++) {
                try {
                    randomProducer.update(provider.TIMEOUT, provider.NRETRY);
                } catch (SEPASecurityException | SEPAPropertiesException | SEPABindingsException | SEPAProtocolException e) {
                    assertFalse(true, "Failed on update: " + i + " " + e.getMessage());
                }
            }
        }
    };
    Thread sub = new Thread() {

        public void run() {
            for (int i = 0; i < 500; i++) {
                try {
                    consumerRandom1 = new ConsumerTestUnit(provider, "RANDOM1");
                    consumerRandom1.syncSubscribe(provider.TIMEOUT, provider.NRETRY);
                    consumerRandom1.close();
                    consumerAll = new ConsumerTestUnit(provider, "ALL");
                    consumerAll.syncSubscribe(provider.TIMEOUT, provider.NRETRY);
                    consumerAll.close();
                } catch (SEPASecurityException | SEPAPropertiesException | SEPABindingsException | SEPAProtocolException | IOException | InterruptedException e) {
                    assertFalse(true, "Failed on subscribe: " + i + " " + e.getMessage());
                }
            }
        }
    };
    pub.start();
    sub.start();
    synchronized (pub) {
        pub.wait();
    }
    synchronized (sub) {
        sub.wait();
    }
}
Also used : ConsumerTestUnit(it.unibo.arces.wot.sepa.ConsumerTestUnit) SEPABindingsException(it.unibo.arces.wot.sepa.commons.exceptions.SEPABindingsException) SEPAProtocolException(it.unibo.arces.wot.sepa.commons.exceptions.SEPAProtocolException) SEPAPropertiesException(it.unibo.arces.wot.sepa.commons.exceptions.SEPAPropertiesException) SEPASecurityException(it.unibo.arces.wot.sepa.commons.exceptions.SEPASecurityException) IOException(java.io.IOException) RepeatedTest(org.junit.jupiter.api.RepeatedTest)

Example 4 with ConsumerTestUnit

use of it.unibo.arces.wot.sepa.ConsumerTestUnit in project SEPA by arces-wot.

the class StressUsingPAC method beginTest.

@BeforeEach
public void beginTest() throws SEPAProtocolException, SEPASecurityException, SEPAPropertiesException {
    consumerAll = new ConsumerTestUnit(provider, "ALL");
    randomProducer = new Producer(provider.getJsap(), "RANDOM");
    randomAggregator = new AggregatorTestUnit(provider, "RANDOM", "RANDOM1");
    consumerRandom1 = new ConsumerTestUnit(provider, "RANDOM1");
    genericClient = new GenericClient(provider.getJsap(), this);
}
Also used : ConsumerTestUnit(it.unibo.arces.wot.sepa.ConsumerTestUnit) GenericClient(it.unibo.arces.wot.sepa.pattern.GenericClient) Producer(it.unibo.arces.wot.sepa.pattern.Producer) AggregatorTestUnit(it.unibo.arces.wot.sepa.AggregatorTestUnit) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with ConsumerTestUnit

use of it.unibo.arces.wot.sepa.ConsumerTestUnit in project SEPA by arces-wot.

the class ITPattern method subscribeAndResults.

@RepeatedTest(ConfigurationProvider.REPEATED_TEST)
@Timeout(10)
public void subscribeAndResults() throws InterruptedException, SEPASecurityException, IOException, SEPAPropertiesException, SEPAProtocolException, SEPABindingsException {
    consumerAll = new ConsumerTestUnit(provider, "ALL");
    consumerAll.syncSubscribe(provider.TIMEOUT, provider.NRETRY);
    consumerAll.waitFirstNotification();
}
Also used : ConsumerTestUnit(it.unibo.arces.wot.sepa.ConsumerTestUnit) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Timeout(org.junit.jupiter.api.Timeout)

Aggregations

ConsumerTestUnit (it.unibo.arces.wot.sepa.ConsumerTestUnit)6 RepeatedTest (org.junit.jupiter.api.RepeatedTest)5 Timeout (org.junit.jupiter.api.Timeout)4 AggregatorTestUnit (it.unibo.arces.wot.sepa.AggregatorTestUnit)2 Response (it.unibo.arces.wot.sepa.commons.response.Response)2 SEPABindingsException (it.unibo.arces.wot.sepa.commons.exceptions.SEPABindingsException)1 SEPAPropertiesException (it.unibo.arces.wot.sepa.commons.exceptions.SEPAPropertiesException)1 SEPAProtocolException (it.unibo.arces.wot.sepa.commons.exceptions.SEPAProtocolException)1 SEPASecurityException (it.unibo.arces.wot.sepa.commons.exceptions.SEPASecurityException)1 GenericClient (it.unibo.arces.wot.sepa.pattern.GenericClient)1 Producer (it.unibo.arces.wot.sepa.pattern.Producer)1 IOException (java.io.IOException)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1