Search in sources :

Example 6 with Timeout

use of org.junit.jupiter.api.Timeout 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 7 with Timeout

use of org.junit.jupiter.api.Timeout in project SEPA by arces-wot.

the class ITPattern method produce.

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

Example 8 with Timeout

use of org.junit.jupiter.api.Timeout in project SEPA by arces-wot.

the class StressUsingSPARQLProtocol method Subscribe3xN.

@RepeatedTest(ConfigurationProvider.REPEATED_TEST)
@Timeout(60)
public void Subscribe3xN() throws SEPAPropertiesException, SEPASecurityException, SEPAProtocolException, InterruptedException {
    int n = 10;
    for (int i = 0; i < n; i++) {
        subscribers.add(new Subscriber(provider, "ALL", sync));
        subscribers.add(new Subscriber(provider, "RANDOM", sync));
        subscribers.add(new Subscriber(provider, "RANDOM1", sync));
    }
    for (Subscriber sub : subscribers) sub.start();
    sync.waitSubscribes(subscribers.size());
    sync.waitEvents(subscribers.size());
    assertFalse(sync.getSubscribes() != subscribers.size(), "Subscribes:" + sync.getSubscribes() + "(" + subscribers.size() + ")");
    assertFalse(sync.getEvents() != subscribers.size(), "Events:" + sync.getEvents() + "(" + subscribers.size() + ")");
}
Also used : Subscriber(it.unibo.arces.wot.sepa.Subscriber) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Timeout(org.junit.jupiter.api.Timeout)

Example 9 with Timeout

use of org.junit.jupiter.api.Timeout in project SEPA by arces-wot.

the class ITWebSocketSubscriptionProtocol method Subscribe.

@RepeatedTest(ConfigurationProvider.REPEATED_TEST)
@Timeout(5)
public void Subscribe() throws SEPAPropertiesException, SEPASecurityException, SEPAProtocolException, IOException, InterruptedException {
    WebsocketSubscriptionProtocol client = new WebsocketSubscriptionProtocol(provider.getJsap().getSubscribeHost(), provider.getJsap().getSubscribePort(), provider.getJsap().getSubscribePath(), this, provider.getClientSecurityManager());
    client.subscribe(provider.buildSubscribeRequest("ALL"));
    synchronized (mutex) {
        while (ITWebSocketSubscriptionProtocol.spuid == null) mutex.wait();
    }
    client.close();
}
Also used : WebsocketSubscriptionProtocol(it.unibo.arces.wot.sepa.api.protocols.websocket.WebsocketSubscriptionProtocol) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Timeout(org.junit.jupiter.api.Timeout)

Example 10 with Timeout

use of org.junit.jupiter.api.Timeout in project neo4j by neo4j.

the class DijkstraIncreasingWeightTest method testForLoops.

@Test
@Timeout(5)
void testForLoops() {
    /*
         *
         *            (b)
         *           /  \         0
         *          0    0       / \            - 0 - (c1) - 0 -
         *           \  /        \/           /                 \
         * (s) - 1 - (a1) - 1 - (a2) - 1 - (a3)                (a4) - 1 - (t)
         *                                    \                 /
         *                                     - 0 - (c2) - 0 -
         *
         */
    try (Transaction transaction = graphDb.beginTx()) {
        Node s = graph.makeNode(transaction, "s");
        Node t = graph.makeNode(transaction, "t");
        // Blob loop
        graph.makeEdge(transaction, "s", "a1", "length", 1);
        graph.makeEdge(transaction, "a1", "b", "length", 0);
        graph.makeEdge(transaction, "b", "a1", "length", 0);
        // Self loop
        graph.makeEdge(transaction, "a1", "a2", "length", 1);
        graph.makeEdge(transaction, "a2", "a2", "length", 0);
        // Diamond loop
        graph.makeEdge(transaction, "a2", "a3", "length", 1);
        graph.makeEdge(transaction, "a3", "c1", "length", 0);
        graph.makeEdge(transaction, "a3", "c2", "length", 0);
        graph.makeEdge(transaction, "c1", "a4", "length", 0);
        graph.makeEdge(transaction, "c1", "a4", "length", 0);
        graph.makeEdge(transaction, "a4", "t", "length", 1);
        PathExpander<Double> expander = PathExpanders.allTypesAndDirections();
        Dijkstra algo = new Dijkstra(expander, CommonEvaluators.doubleCostEvaluator("length"), DEFAULT_EPSILON, PathInterestFactory.all(DEFAULT_EPSILON));
        Iterator<WeightedPath> paths = algo.findAllPaths(s, t).iterator();
        assertTrue(paths.hasNext(), "Expected at least one path");
        assertEquals(6, paths.next().length(), "Expected first path of length 6");
        assertTrue(paths.hasNext(), "Expected at least two paths");
        assertEquals(6, paths.next().length(), "Expected second path of length 6");
        assertFalse(paths.hasNext(), "Expected exactly two paths");
        transaction.commit();
    }
}
Also used : WeightedPath(org.neo4j.graphalgo.WeightedPath) Transaction(org.neo4j.graphdb.Transaction) Node(org.neo4j.graphdb.Node) Dijkstra(org.neo4j.graphalgo.impl.path.Dijkstra) Test(org.junit.jupiter.api.Test) Timeout(org.junit.jupiter.api.Timeout)

Aggregations

Timeout (org.junit.jupiter.api.Timeout)291 Test (org.junit.jupiter.api.Test)235 CountDownLatch (java.util.concurrent.CountDownLatch)71 ZooKeeper (org.apache.zookeeper.ZooKeeper)33 AtomicReference (java.util.concurrent.atomic.AtomicReference)32 ArrayList (java.util.ArrayList)31 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)29 RepeatedTest (org.junit.jupiter.api.RepeatedTest)29 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)29 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)28 LocalChannel (io.netty.channel.local.LocalChannel)27 CountdownWatcher (org.apache.zookeeper.test.ClientBase.CountdownWatcher)26 ServerBootstrap (io.netty.bootstrap.ServerBootstrap)25 IOException (java.io.IOException)25 Bootstrap (io.netty.bootstrap.Bootstrap)24 MethodSource (org.junit.jupiter.params.provider.MethodSource)24 Channel (io.netty.channel.Channel)23 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)21 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)19 ChannelInboundHandlerAdapter (io.netty.channel.ChannelInboundHandlerAdapter)19