Java Code Examples for org.testng.AssertJUnit#assertNull()

The following examples show how to use org.testng.AssertJUnit#assertNull() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaDriverTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public void executeAsyncScriptWithNullReturn() throws Throwable {
    try {
        driver = new JavaDriver();
        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                frame.setLocationRelativeTo(null);
                frame.setVisible(true);
            }
        });
        WebElement element1 = driver.findElement(By.name("text-field"));
        WebElement element2 = (WebElement) ((JavascriptExecutor) driver).executeAsyncScript("$2.call(null);", element1);
        AssertJUnit.assertNull(element2);
    } finally {
        JavaElementFactory.reset();
    }
}
 
Example 2
Source File: JTableTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public void clickHeaderItem() throws Throwable {
    driver = new JavaDriver();
    WebElement header = driver.findElement(By.cssSelector("table::header"));
    final WebElement firstItem = header.findElement(By.cssSelector(".::nth-item(1)"));
    AssertJUnit.assertNull(firstItem.getAttribute("icon"));
    firstItem.click();
    new WebDriverWait(driver, 3).until(new Function<WebDriver, Boolean>() {
        @Override
        public Boolean apply(WebDriver input) {
            return firstItem.getAttribute("icon") != null;
        }
    });
    AssertJUnit.assertTrue(firstItem.getAttribute("icon").length() > 0);
    WebElement secondItem = header.findElement(By.cssSelector(".::nth-item(2)"));
    AssertJUnit.assertNull(secondItem.getAttribute("icon"));
    secondItem.click();
    AssertJUnit.assertTrue(secondItem.getAttribute("icon").length() > 0);
}
 
Example 3
Source File: TestRawZkClient.java    From helix with Apache License 2.0 6 votes vote down vote up
@Test()
void testGetStat() {
  String path = "/tmp/getStatTest";
  _zkClient.deleteRecursively(path);

  Stat stat, newStat;
  stat = _zkClient.getStat(path);
  AssertJUnit.assertNull(stat);
  _zkClient.createPersistent(path, true);

  stat = _zkClient.getStat(path);
  AssertJUnit.assertNotNull(stat);

  newStat = _zkClient.getStat(path);
  AssertJUnit.assertEquals(stat, newStat);

  _zkClient.writeData(path, "Test");
  newStat = _zkClient.getStat(path);
  AssertJUnit.assertNotSame(stat, newStat);
}
 
Example 4
Source File: DetectOnTheFlyLogImporterTest.java    From otroslogviewer with Apache License 2.0 6 votes vote down vote up
@Test
public void testImportEmptyFile() throws IOException, InitializationException {
  // given
  InputStream inputStream = new ByteArrayInputStream(new byte[0]);
  DetectOnTheFlyLogImporter importer = new DetectOnTheFlyLogImporter(logImporters);
  ParsingContext context = new ParsingContext();
  LogDataCollector collector = new ProxyLogDataCollector();
  importer.init(new Properties());
  importer.initParsingContext(context);

  // when
  importer.importLogs(inputStream, collector, context);

  // then
  AssertJUnit.assertNull("Log importer detected", context.getCustomConextProperties().get(DetectOnTheFlyLogImporter.PROPERTY_LOG_IMPORTER));
  AssertJUnit.assertEquals(0, collector.getLogData().length);
}
 
Example 5
Source File: TestZKUtil.java    From helix with Apache License 2.0 5 votes vote down vote up
@Test()
public void testSubtract() {
  String path = PropertyPathBuilder.instanceConfig(clusterName, "id5");
  ZNRecord record = new ZNRecord("id5");
  record.setSimpleField("key1", "value1");
  _gZkClient.createPersistent(path, record);
  ZKUtil.subtract(_gZkClient, path, record);
  record = _gZkClient.readData(path);
  AssertJUnit.assertNull(record.getSimpleField("key1"));
}
 
Example 6
Source File: TestBestPossibleCalcStageCompatibility.java    From helix with Apache License 2.0 5 votes vote down vote up
@Test
public void testCustomModeCompatibility() {
  System.out.println("START TestBestPossibleStateCalcStage at "
      + new Date(System.currentTimeMillis()));

  String[] resources = new String[] {
    "testResourceName"
  };
  setupIdealStateDeprecated(5, resources, 10, 1, IdealStateModeProperty.CUSTOMIZED);
  setupLiveInstances(5);
  setupStateModel();

  Map<String, Resource> resourceMap = getResourceMap();
  CurrentStateOutput currentStateOutput = new CurrentStateOutput();
  event.addAttribute(AttributeName.RESOURCES.name(), resourceMap);
  event.addAttribute(AttributeName.RESOURCES_TO_REBALANCE.name(), resourceMap);
  event.addAttribute(AttributeName.CURRENT_STATE.name(), currentStateOutput);
  event.addAttribute(AttributeName.ControllerDataProvider.name(),
      new ResourceControllerDataProvider());

  ReadClusterDataStage stage1 = new ReadClusterDataStage();
  runStage(event, stage1);
  BestPossibleStateCalcStage stage2 = new BestPossibleStateCalcStage();
  runStage(event, stage2);

  BestPossibleStateOutput output =
      event.getAttribute(AttributeName.BEST_POSSIBLE_STATE.name());
  for (int p = 0; p < 5; p++) {
    Partition resource = new Partition("testResourceName_" + p);
    AssertJUnit.assertNull(output.getInstanceStateMap("testResourceName", resource).get(
        "localhost_" + (p + 1) % 5));
  }
  System.out.println("END TestBestPossibleStateCalcStage at "
      + new Date(System.currentTimeMillis()));
}
 
Example 7
Source File: ComplexEventChunkTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test
public void eventChunkRemoveTest4() {
    StreamEvent streamEvent1 = new StreamEvent(0, 0, 3);
    streamEvent1.setOutputData(new Object[]{"IBM", 700L, 100L});

    StreamEvent streamEvent2 = new StreamEvent(0, 0, 3);
    streamEvent2.setOutputData(new Object[]{"WSO2", 700L, 100L});

    StreamEvent streamEvent3 = new StreamEvent(0, 0, 3);
    streamEvent3.setOutputData(new Object[]{"WSO2", 700L, 100L});

    StreamEvent streamEvent4 = new StreamEvent(0, 0, 3);
    streamEvent4.setOutputData(new Object[]{"WSO2", 700L, 100L});

    streamEvent1.setNext(streamEvent2);
    streamEvent2.setNext(streamEvent3);
    streamEvent3.setNext(streamEvent4);

    StreamEventFactory streamEventFactory = new StreamEventFactory(0, 0, 3);
    ConversionStreamEventChunk streamEventChunk = new ConversionStreamEventChunk(streamEventConverter,
            streamEventFactory);
    streamEventChunk.convertAndAssign(streamEvent1);

    while (streamEventChunk.hasNext()) {
        count++;
        streamEventChunk.next();
        if (count == 2 || count == 4) {
            streamEventChunk.remove();
        }
    }
    StreamEvent streamEvent = streamEventChunk.getFirst();
    AssertJUnit.assertEquals(streamEvent1, streamEvent);
    AssertJUnit.assertEquals(streamEvent3, streamEvent.getNext());
    AssertJUnit.assertNull(streamEvent.getNext().getNext());
}
 
Example 8
Source File: ComplexEventChunkTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test
public void eventChunkRemoveTest3() {
    StreamEvent streamEvent1 = new StreamEvent(0, 0, 3);
    streamEvent1.setOutputData(new Object[]{"IBM", 700L, 100L});

    StreamEvent streamEvent2 = new StreamEvent(0, 0, 3);
    streamEvent2.setOutputData(new Object[]{"WSO2", 700L, 100L});

    StreamEvent streamEvent3 = new StreamEvent(0, 0, 3);
    streamEvent3.setOutputData(new Object[]{"WSO2", 700L, 100L});

    StreamEvent streamEvent4 = new StreamEvent(0, 0, 3);
    streamEvent4.setOutputData(new Object[]{"WSO2", 700L, 100L});

    streamEvent1.setNext(streamEvent2);
    streamEvent2.setNext(streamEvent3);
    streamEvent3.setNext(streamEvent4);

    StreamEventFactory streamEventFactory = new StreamEventFactory(0, 0, 3);
    ConversionStreamEventChunk streamEventChunk = new ConversionStreamEventChunk(streamEventConverter,
            streamEventFactory);
    streamEventChunk.convertAndAssign(streamEvent1);

    while (streamEventChunk.hasNext()) {
        streamEventChunk.next();
        streamEventChunk.remove();
    }

    AssertJUnit.assertNull(streamEventChunk.getFirst());
}
 
Example 9
Source File: EventTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test
public void testSimpleStreamEventConverter() {
    Attribute price = new Attribute("price", Attribute.Type.DOUBLE);
    Attribute symbol = new Attribute("symbol", Attribute.Type.STRING);

    MetaStreamEvent metaStreamEvent = new MetaStreamEvent();
    metaStreamEvent.addOutputData(symbol);
    metaStreamEvent.addOutputData(price);

    StreamDefinition streamDefinition = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type
            .STRING).attribute("price", Attribute.Type.DOUBLE).attribute("volume", Attribute.Type.INT);
    Event event = new Event(System.currentTimeMillis(), new Object[]{"WSO2", 200, 50});

    metaStreamEvent.addInputDefinition(streamDefinition);
    StreamEventConverter converter = StreamEventConverterFactory.constructEventConverter(metaStreamEvent);
    StreamEventFactory eventPool = new StreamEventFactory(metaStreamEvent);
    StreamEvent newEvent = eventPool.newInstance();
    converter.convertEvent(event, newEvent);

    AssertJUnit.assertTrue(converter instanceof SimpleStreamEventConverter);
    AssertJUnit.assertNull(newEvent.getBeforeWindowData());
    AssertJUnit.assertNull(newEvent.getOnAfterWindowData());
    AssertJUnit.assertEquals(2, newEvent.getOutputData().length);

    AssertJUnit.assertEquals(200, newEvent.getOutputData()[1]);
    AssertJUnit.assertEquals("WSO2", newEvent.getOutputData()[0]);
}
 
Example 10
Source File: DurableTreeNGTest.java    From mnemonic with Apache License 2.0 5 votes vote down vote up
@Test(enabled = true)
public void testInsertString() {
  DurableType gtypes[] = {DurableType.STRING};
  DurableTree<String> tree = DurableTreeFactory.create(m_act, null, gtypes, false);

  //strings are sorted lexicographically
  Long handler = tree.getHandler();
  tree.insert("bob");
  tree.insert("Alice");
  tree.insert("Dog");
  tree.insert("Fun");
  tree.insert("Ele");
  tree.insert("Cat");

  AssertJUnit.assertTrue(tree.isValidTree());

  AssertJUnit.assertTrue(tree.contains("Fun"));
  AssertJUnit.assertFalse(tree.contains("is"));
  AssertJUnit.assertTrue(tree.contains("Cat"));
  AssertJUnit.assertFalse(tree.contains("Bob"));

  AssertJUnit.assertEquals(tree.successor("Ele"), "Fun");
  AssertJUnit.assertEquals(tree.predecessor("Dog"), "Cat");
  AssertJUnit.assertNull(tree.predecessor("Alice"));
  AssertJUnit.assertEquals(tree.successor("Alice"), "Cat");
  AssertJUnit.assertEquals(tree.predecessor("Fun"), "Ele");
  AssertJUnit.assertNull(tree.successor("bob"));

  tree.remove("Cat", true);
  AssertJUnit.assertEquals(tree.predecessor("Dog"), "Alice");
  AssertJUnit.assertEquals(tree.successor("Alice"), "Dog");
  AssertJUnit.assertTrue(tree.isValidTree());
  tree.remove("Alice", true);
  AssertJUnit.assertNull(tree.predecessor("Dog"));

  tree.destroy();
}
 
Example 11
Source File: TestPropertyStoreException.java    From helix with Apache License 2.0 5 votes vote down vote up
@Test(groups = {
  "unitTest"
})
public void testPropertyStoreException() {
  PropertyStoreException exception = new PropertyStoreException("msg");
  AssertJUnit.assertEquals(exception.getMessage(), "msg");

  exception = new PropertyStoreException();
  AssertJUnit.assertNull(exception.getMessage());
}
 
Example 12
Source File: DurableHashMapNGTest.java    From mnemonic with Apache License 2.0 4 votes vote down vote up
@Test(enabled = true)
public void testAutoResizeMaps() {
  DurableType gtypes[] = {DurableType.STRING, DurableType.INTEGER};
  DurableHashMap<String, Integer> map = DurableHashMapFactory.create(m_act, null, gtypes, mInitialCapacity, false);
  Long handler = map.getHandler();
  Iterator<MapEntry<String, Integer>> iter = null;
  MapEntry<String, Integer> entry = null;
  int count = 0;
  Integer val = 0;
  for (int i = 0; i < 200; i++) {
    val = map.put("str" + i, i);
    AssertJUnit.assertNull(val);
  }

  iter = map.iterator();
  while (iter.hasNext()) {
    entry = iter.next();
    count++;
  }
  AssertJUnit.assertEquals(count, 200);
  AssertJUnit.assertEquals(map.getSize(), 200);
  for (int i = 0; i < 200; i++) {
    AssertJUnit.assertEquals(map.get("str" + i).intValue(), i);
  } 
  DurableHashMap<String, Integer> restoredMap = DurableHashMapFactory.restore(m_act, null, gtypes, handler, 
      false);
  AssertJUnit.assertEquals(restoredMap.getSize(), 200);
  for (int i = 0; i < 200; i++) {
    AssertJUnit.assertEquals(restoredMap.get("str" + i).intValue(), i);
  }

  iter = restoredMap.iterator();
  count = 0;
  while (iter.hasNext()) {
    entry = iter.next();
    count++;
  }
  AssertJUnit.assertEquals(count, 200);

  for (int i = 0; i < 100; i++) {
    AssertJUnit.assertEquals(restoredMap.remove("str" + i).intValue(), i);
  }
  AssertJUnit.assertEquals(restoredMap.getSize(), 100);
  for (int i = 0; i < 200; i++) {
    if (i < 100) {
      AssertJUnit.assertNull(restoredMap.get("str" + i));
    } else {
    AssertJUnit.assertEquals(restoredMap.get("str" + i).intValue(), i);
    }
  }

  iter = restoredMap.iterator();
  count = 0;
  while (iter.hasNext()) {
    entry = iter.next();
    count++;
  }
  AssertJUnit.assertEquals(count, 100);

  iter = restoredMap.iterator();
  count = 0;
  while (iter.hasNext()) {
    entry = iter.next();
    count++;
    if (count > 50) {
      iter.remove();
    }
  }
  AssertJUnit.assertEquals(restoredMap.getSize(), 50);

  iter = restoredMap.iterator();
  count = 0;
  while (iter.hasNext()) {
    entry = iter.next();
    count++;
  }
  AssertJUnit.assertEquals(count, 50);

  restoredMap.destroy();
}
 
Example 13
Source File: CacheExpireTestCase.java    From siddhi with Apache License 2.0 4 votes vote down vote up
@Test(dependsOnMethods = {"cacheExpireTestCase0"})
public void cacheExpireTestCase1() throws InterruptedException {
    log.info("cacheExpireTestCase1");
    SiddhiManager siddhiManager2 = new SiddhiManager();
    String streams = "" +
            "define stream StockStream2 (symbol string, price float, volume long); " +
            "define stream DeleteStream (symbol string); " +
            "@Store(type=\"testStoreDummyForCache\", @Cache(size=\"10\", cache.policy=\"LRU\", " +
            "retention.period=\"1 sec\", purge.interval=\"1 sec\"))\n" +
            //"@Index(\"volume\")" +
            "define table StockTable2 (symbol string, price float, volume long); ";

    String query1 = "" +
            "@info(name = 'query1') " +
            "from StockStream2\n" +
            "select symbol, price, volume\n" +
            "insert into StockTable2 ;" +
            "@info(name = 'query2') " +
            "from DeleteStream " +
            "delete StockTable2 " +
            "on StockTable2.symbol == symbol";
    SiddhiAppRuntime siddhiAppRuntime2 = siddhiManager2.createSiddhiAppRuntime(streams + query1);
    InputHandler stockStream2 = siddhiAppRuntime2.getInputHandler("StockStream2");
    InputHandler deleteStream = siddhiAppRuntime2.getInputHandler("DeleteStream");
    siddhiAppRuntime2.start();

    Event[] events;
    stockStream2.send(new Object[]{"WSO2", 55.6f, 1L});
    Thread.sleep(1300);
    events = siddhiAppRuntime2.query("" +
            "from StockTable2 ");
    AssertJUnit.assertNull(events);

    stockStream2.send(new Object[]{"WSO4", 55.6f, 2L});
    stockStream2.send(new Object[]{"WSO1", 55.6f, 3L});
    Thread.sleep(1300);
    events = siddhiAppRuntime2.query("" +
            "from StockTable2 ");
    AssertJUnit.assertNull(events);

    stockStream2.send(new Object[]{"IBM", 75.6f, 4L});
    stockStream2.send(new Object[]{"WS2", 55.6f, 5L});
    stockStream2.send(new Object[]{"WSOr", 55.6f, 6L});
    Thread.sleep(1300);

    events = siddhiAppRuntime2.query("" +
            "from StockTable2 ");
    AssertJUnit.assertNull(events);
    siddhiAppRuntime2.shutdown();
}
 
Example 14
Source File: CacheExpireTestCase.java    From siddhi with Apache License 2.0 4 votes vote down vote up
@Test
public void cacheExpireTestCase0() throws InterruptedException {
    log.info("cacheExpireTestCase0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String streams = "" +
            "define stream StockStream (symbol string, price float, volume long); " +
            "define stream DeleteStream (symbol string); " +
            "@Store(type=\"testStoreDummyForCache\", @Cache(size=\"10\", cache.policy=\"FIFO\", " +
            "retention.period=\"1 sec\", purge.interval=\"1 sec\"))\n" +
            "define table StockTable (symbol string, price float, volume long); ";

    String query1 = "" +
            "@info(name = 'query1') " +
            "from StockStream\n" +
            "select symbol, price, volume\n" +
            "insert into StockTable ;" +
            "@info(name = 'query2') " +
            "from DeleteStream " +
            "delete StockTable " +
            "on StockTable.symbol == symbol";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query1);
    InputHandler stockStream = siddhiAppRuntime.getInputHandler("StockStream");
    InputHandler deleteStream = siddhiAppRuntime.getInputHandler("DeleteStream");
    siddhiAppRuntime.start();

    Event[] events;
    stockStream.send(new Object[]{"WSO2", 55.6f, 1L});
    Thread.sleep(1300);
    events = siddhiAppRuntime.query("" +
            "from StockTable ");
    AssertJUnit.assertNull(events);

    stockStream.send(new Object[]{"WSO4", 55.6f, 2L});
    stockStream.send(new Object[]{"WSO1", 55.6f, 3L});
    Thread.sleep(1300);
    events = siddhiAppRuntime.query("" +
            "from StockTable ");
    AssertJUnit.assertNull(events);

    stockStream.send(new Object[]{"IBM", 75.6f, 4L});
    stockStream.send(new Object[]{"WS2", 55.6f, 5L});
    stockStream.send(new Object[]{"WSOr", 55.6f, 6L});
    Thread.sleep(1300);

    events = siddhiAppRuntime.query("" +
            "from StockTable ");
    AssertJUnit.assertNull(events);
    siddhiAppRuntime.shutdown();
}
 
Example 15
Source File: DurableTreeNGTest.java    From mnemonic with Apache License 2.0 4 votes vote down vote up
@Test(enabled = true)
public void testInsertIntegers() {
  DurableType gtypes[] = {DurableType.INTEGER};
  DurableTree<Integer> tree = DurableTreeFactory.create(m_act, null, gtypes, false);

  Long handler = tree.getHandler();
  tree.insert(5);
  tree.insert(3);
  tree.insert(4);
  tree.insert(1);
  tree.insert(7);
  tree.insert(6);
  AssertJUnit.assertTrue(tree.isValidTree());

  AssertJUnit.assertTrue(tree.contains(4));
  AssertJUnit.assertFalse(tree.contains(8));
  AssertJUnit.assertTrue(tree.contains(7));
  AssertJUnit.assertTrue(tree.contains(5));

  AssertJUnit.assertEquals(tree.successor(4).intValue(), 5);
  AssertJUnit.assertEquals(tree.predecessor(4).intValue(), 3);
  AssertJUnit.assertNull(tree.predecessor(1));
  AssertJUnit.assertEquals(tree.successor(1).intValue(), 3);
  AssertJUnit.assertEquals(tree.predecessor(7).intValue(), 6);
  AssertJUnit.assertNull(tree.successor(7));

  AssertJUnit.assertTrue(tree.contains(3));
  tree.remove(3, true);
  AssertJUnit.assertFalse(tree.contains(3));
  AssertJUnit.assertEquals(tree.successor(1).intValue(), 4);
  AssertJUnit.assertEquals(tree.predecessor(4).intValue(), 1);
  AssertJUnit.assertTrue(tree.isValidTree());
  tree.remove(7, true);
  AssertJUnit.assertFalse(tree.contains(7));
  AssertJUnit.assertNull(tree.successor(6));
  AssertJUnit.assertTrue(tree.isValidTree());

  tree.insert(3);
  tree.insert(7);

  DurableTree<Integer> restoredTree = DurableTreeFactory.restore(m_act, null, gtypes, handler, false);

  AssertJUnit.assertTrue(restoredTree.isValidTree());

  AssertJUnit.assertTrue(restoredTree.contains(4));
  AssertJUnit.assertFalse(restoredTree.contains(8));
  AssertJUnit.assertTrue(restoredTree.contains(7));
  AssertJUnit.assertTrue(restoredTree.contains(5));

  AssertJUnit.assertEquals(restoredTree.successor(4).intValue(), 5);
  AssertJUnit.assertEquals(restoredTree.predecessor(4).intValue(), 3);
  AssertJUnit.assertNull(restoredTree.predecessor(1));
  AssertJUnit.assertEquals(restoredTree.successor(1).intValue(), 3);
  AssertJUnit.assertEquals(restoredTree.predecessor(7).intValue(), 6);
  AssertJUnit.assertNull(restoredTree.successor(7));

  restoredTree.insert(10);
  AssertJUnit.assertEquals(restoredTree.successor(1).intValue(), 3);
  AssertJUnit.assertEquals(restoredTree.predecessor(10).intValue(), 7);

  restoredTree.destroy();
}
 
Example 16
Source File: JavaElementTest.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public void getAttributeNotAvailable() throws Throwable {
    AssertJUnit.assertNull(ejText.getAttribute("sizeX"));
}
 
Example 17
Source File: CacheExpireTestCase.java    From siddhi with Apache License 2.0 4 votes vote down vote up
@Test(dependsOnMethods = {"cacheExpireTestCase1"})
public void cacheExpireTestCase2() throws InterruptedException, SQLException {
    log.info("cacheExpireTestCase2");
    SiddhiManager siddhiManager = new SiddhiManager();
    String streams = "" +
            "define stream StockStream (symbol string, price float, volume long); " +
            "define stream DeleteStream (symbol string); " +
            "@Store(type=\"testStoreDummyForCache\", @Cache(size=\"10\", cache.policy=\"LFU\", " +
            "retention.period=\"1 sec\", purge.interval=\"1 sec\"))\n" +
            "define table StockTable (symbol string, price float, volume long); ";

    String query1 = "" +
            "@info(name = 'query1') " +
            "from StockStream\n" +
            "select symbol, price, volume\n" +
            "insert into StockTable ;" +
            "@info(name = 'query2') " +
            "from DeleteStream " +
            "delete StockTable " +
            "on StockTable.symbol == symbol";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query1);
    InputHandler stockStream = siddhiAppRuntime.getInputHandler("StockStream");
    InputHandler deleteStream = siddhiAppRuntime.getInputHandler("DeleteStream");
    siddhiAppRuntime.start();

    Event[] events;
    stockStream.send(new Object[]{"WSO2", 55.6f, 1L});
    Thread.sleep(1300);
    events = siddhiAppRuntime.query("" +
            "from StockTable ");
    AssertJUnit.assertNull(events);

    stockStream.send(new Object[]{"WSO4", 55.6f, 2L});
    stockStream.send(new Object[]{"WSO1", 55.6f, 3L});
    Thread.sleep(1300);
    events = siddhiAppRuntime.query("" +
            "from StockTable ");
    AssertJUnit.assertNull(events);

    stockStream.send(new Object[]{"IBM", 75.6f, 4L});
    stockStream.send(new Object[]{"WS2", 55.6f, 5L});
    stockStream.send(new Object[]{"WSOr", 55.6f, 6L});
    Thread.sleep(1300);

    events = siddhiAppRuntime.query("" +
            "from StockTable ");
    AssertJUnit.assertNull(events);
    siddhiAppRuntime.shutdown();
}
 
Example 18
Source File: DurableHashMapNGTest.java    From mnemonic with Apache License 2.0 4 votes vote down vote up
@Test(enabled = true)
public void testGetPutRemovePrimitives() {
  DurableType gtypes[] = {DurableType.STRING, DurableType.INTEGER};
  DurableHashMap<String, Integer> map = DurableHashMapFactory.create(m_act, null, gtypes, mInitialCapacity, false);
  
  Long handler = map.getHandler();
  Integer val = map.put("hello", 1);
  AssertJUnit.assertNull(val);
  val = map.put("hello", 1);
  AssertJUnit.assertEquals(1, val.intValue());
  val = map.put("world", 2);
  AssertJUnit.assertNull(val);
  val = map.put("hello", 2);
  AssertJUnit.assertEquals(1, val.intValue());
  val = map.put("hello", 3);
  AssertJUnit.assertEquals(2, val.intValue());

  val = map.get("hello");
  AssertJUnit.assertEquals(3, val.intValue());
  val = map.get("world"); 
  AssertJUnit.assertEquals(2, val.intValue());
  val = map.get("test");
  AssertJUnit.assertNull(val);
  val = map.put("testing", 5);
  AssertJUnit.assertNull(val);
  val = map.get("testing");
  AssertJUnit.assertEquals(5, val.intValue());
  val = map.remove("testing");
  AssertJUnit.assertEquals(5, val.intValue());
  val = map.get("testing");
  AssertJUnit.assertNull(val);
  val = map.remove("testing");
  AssertJUnit.assertNull(val);
  val = map.remove("world");
  AssertJUnit.assertEquals(2, val.intValue());

  Iterator<MapEntry<String, Integer>> iter = map.iterator();
  MapEntry<String, Integer> entry = null;
  int count = 0;
  while (iter.hasNext()) {
    entry = iter.next();
    count++;
  }
  AssertJUnit.assertEquals(count, 1);
  AssertJUnit.assertEquals(entry.getKey(), "hello");
  AssertJUnit.assertEquals(entry.getValue().intValue(), 3);

  DurableHashMap<String, Integer> restoredMap = DurableHashMapFactory.restore(m_act, null, gtypes, handler, 
      false);
  val = restoredMap.get("hello");
  AssertJUnit.assertEquals(3, val.intValue());
  val = restoredMap.get("world"); 
  AssertJUnit.assertNull(val);
  val = restoredMap.get("test");
  AssertJUnit.assertNull(val);
  val = map.get("testing");
  AssertJUnit.assertNull(val);
  val = map.put("test", 4);
  AssertJUnit.assertNull(val);
  val = restoredMap.get("test");
  AssertJUnit.assertEquals(4, val.intValue());

  restoredMap.destroy();
}
 
Example 19
Source File: JavaDriverTest.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public void quit() {
    driver = new JavaDriver();
    driver.quit();
    AssertJUnit.assertNull(((RemoteWebDriver) driver).getSessionId());
}
 
Example 20
Source File: JavaProfileTest.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public void getCommandLine() {
    JavaProfile profile = new JavaProfile();
    AssertJUnit.assertNull(profile.getCommandLine());
}