Search in sources :

Example 6 with Test

use of org.testng.annotations.Test in project storm by apache.

the class RankableObjectWithFieldsTest method shouldCreateRankableObjectFromTuple.

@Test
public void shouldCreateRankableObjectFromTuple() {
    // given
    Tuple tuple = mock(Tuple.class);
    List<Object> tupleValues = Lists.newArrayList(ANY_OBJECT, ANY_COUNT, ANY_FIELD);
    when(tuple.getValues()).thenReturn(tupleValues);
    // when
    RankableObjectWithFields r = RankableObjectWithFields.from(tuple);
    // then
    assertThat(r.getObject()).isEqualTo(ANY_OBJECT);
    assertThat(r.getCount()).isEqualTo(ANY_COUNT);
    List<Object> fields = new ArrayList<Object>();
    fields.add(ANY_FIELD);
    assertThat(r.getFields()).isEqualTo(fields);
}
Also used : ArrayList(java.util.ArrayList) Tuple(org.apache.storm.tuple.Tuple) Test(org.testng.annotations.Test)

Example 7 with Test

use of org.testng.annotations.Test in project storm by apache.

the class RankingsTest method updatingWithNewRankablesShouldBeThreadSafe.

@Test
public void updatingWithNewRankablesShouldBeThreadSafe() throws InterruptedException {
    // given
    final List<Rankable> entries = ImmutableList.of(A, B, C, D);
    final Rankings rankings = new Rankings(entries.size());
    // We are capturing exceptions thrown in Blitzer's child threads into this data structure so that we can properly
    // pass/fail this test.  The reason is that Blitzer doesn't report exceptions, which is a known bug in Blitzer
    // (JMOCK-263).  See https://github.com/jmock-developers/jmock-library/issues/22 for more information.
    final List<Exception> exceptions = Lists.newArrayList();
    Blitzer blitzer = new Blitzer(1000);
    // when
    blitzer.blitz(new Runnable() {

        public void run() {
            for (Rankable r : entries) {
                try {
                    rankings.updateWith(r);
                } catch (RuntimeException e) {
                    synchronized (exceptions) {
                        exceptions.add(e);
                    }
                }
            }
        }
    });
    blitzer.shutdown();
    //
    if (!exceptions.isEmpty()) {
        for (Exception e : exceptions) {
            System.err.println(Throwables.getStackTraceAsString(e));
        }
    }
    assertThat(exceptions).isEmpty();
}
Also used : Blitzer(org.jmock.lib.concurrent.Blitzer) Test(org.testng.annotations.Test)

Example 8 with Test

use of org.testng.annotations.Test in project storm by apache.

the class DemoTest method testExclamationTopology.

@Test
public void testExclamationTopology() throws Exception {
    topo = new TopoWrap(cluster, topologyName, ExclamationTopology.getStormTopology());
    topo.submitSuccessfully();
    final int minExclaim2Emits = 500;
    final int minSpountEmits = 10000;
    for (int i = 0; i < 10; ++i) {
        TopologyInfo topologyInfo = topo.getInfo();
        log.info(topologyInfo.toString());
        long wordSpoutEmittedCount = topo.getAllTimeEmittedCount(ExclamationTopology.WORD);
        long exclaim1EmittedCount = topo.getAllTimeEmittedCount(ExclamationTopology.EXCLAIM_1);
        long exclaim2EmittedCount = topo.getAllTimeEmittedCount(ExclamationTopology.EXCLAIM_2);
        log.info("wordSpoutEmittedCount for spout 'word' = " + wordSpoutEmittedCount);
        log.info("exclaim1EmittedCount = " + exclaim1EmittedCount);
        log.info("exclaim2EmittedCount = " + exclaim2EmittedCount);
        if (exclaim2EmittedCount > minExclaim2Emits || wordSpoutEmittedCount > minSpountEmits) {
            break;
        }
        TimeUtil.sleepSec(6);
    }
    List<TopoWrap.ExecutorURL> boltUrls = topo.getLogUrls(ExclamationTopology.WORD);
    log.info(boltUrls.toString());
    final String actualOutput = topo.getLogs(ExclamationTopology.EXCLAIM_2);
    for (String oneExpectedOutput : exclaim2Oputput) {
        Assert.assertTrue(actualOutput.contains(oneExpectedOutput), "Couldn't find " + oneExpectedOutput + " in urls");
    }
}
Also used : TopoWrap(org.apache.storm.st.wrapper.TopoWrap) TopologyInfo(org.apache.storm.generated.TopologyInfo) Test(org.testng.annotations.Test) AbstractTest(org.apache.storm.st.helper.AbstractTest)

Example 9 with Test

use of org.testng.annotations.Test in project storm by apache.

the class SlidingWindowTest method testTimeWindow.

@Test(dataProvider = "generateTimeWindows")
public void testTimeWindow(int windowSec, int slideSec) throws Exception {
    final SlidingTimeCorrectness testable = new SlidingTimeCorrectness(windowSec, slideSec);
    final String topologyName = this.getClass().getSimpleName() + "w" + windowSec + "s" + slideSec;
    if (windowSec <= 0 || slideSec <= 0) {
        try {
            testable.newTopology();
            Assert.fail("Expected IllegalArgumentException was not thrown.");
        } catch (IllegalArgumentException ignore) {
            return;
        }
    }
    topo = new TopoWrap(cluster, topologyName, testable.newTopology());
    runAndVerifyTime(windowSec, slideSec, testable, topo);
}
Also used : TopoWrap(org.apache.storm.st.wrapper.TopoWrap) SlidingTimeCorrectness(org.apache.storm.st.topology.window.SlidingTimeCorrectness) Test(org.testng.annotations.Test) AbstractTest(org.apache.storm.st.helper.AbstractTest)

Example 10 with Test

use of org.testng.annotations.Test in project storm by apache.

the class TumblingWindowTest method testTumbleCount.

@Test(dataProvider = "generateWindows")
public void testTumbleCount(int tumbleSize) throws Exception {
    final TumblingWindowCorrectness testable = new TumblingWindowCorrectness(tumbleSize);
    final String topologyName = this.getClass().getSimpleName() + "t" + tumbleSize;
    if (tumbleSize <= 0) {
        try {
            testable.newTopology();
            Assert.fail("Expected IllegalArgumentException was not thrown.");
        } catch (IllegalArgumentException ignore) {
            return;
        }
    }
    topo = new TopoWrap(cluster, topologyName, testable.newTopology());
    SlidingWindowTest.runAndVerifyCount(tumbleSize, tumbleSize, testable, topo);
}
Also used : TumblingWindowCorrectness(org.apache.storm.st.topology.window.TumblingWindowCorrectness) TopoWrap(org.apache.storm.st.wrapper.TopoWrap) Test(org.testng.annotations.Test) AbstractTest(org.apache.storm.st.helper.AbstractTest)

Aggregations

Test (org.testng.annotations.Test)24007 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2438 Task (com.evolveum.midpoint.task.api.Task)2069 File (java.io.File)1433 ArrayList (java.util.ArrayList)1237 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)1188 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)1078 HashMap (java.util.HashMap)965 CommandLineProgramTest (org.broadinstitute.hellbender.CommandLineProgramTest)814 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)692 BeforeTest (org.testng.annotations.BeforeTest)692 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)690 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)651 Parameters (org.testng.annotations.Parameters)610 BaseTest (org.xdi.oxauth.BaseTest)582 BigDecimal (java.math.BigDecimal)574 List (java.util.List)558 LocalDate (org.joda.time.LocalDate)553 HashSet (java.util.HashSet)548 BaseTest (util.BaseTest)537