Java Code Examples for org.testng.AssertJUnit#fail()
The following examples show how to use
org.testng.AssertJUnit#fail() .
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: AtlasSimpleAuthorizerTest.java From atlas with Apache License 2.0 | 6 votes |
@Test(enabled = true) public void testAccessAllowedForUserAndGroup() { try { AtlasEntityAccessRequest request = new AtlasEntityAccessRequest(null, AtlasPrivilege.ENTITY_UPDATE); request.setUser("admin", Collections.singleton("ROLE_ADMIN")); boolean isAccessAllowed = authorizer.isAccessAllowed(request); AssertJUnit.assertEquals(true, isAccessAllowed); } catch (Exception e) { LOG.error("Exception in AtlasSimpleAuthorizerTest", e); AssertJUnit.fail(); } }
Example 2
Source File: AtlasSimpleAuthorizerTest.java From atlas with Apache License 2.0 | 6 votes |
@Test(enabled = true) public void testAccessAllowedForGroup() { try { AtlasEntityAccessRequest request = new AtlasEntityAccessRequest(null, AtlasPrivilege.ENTITY_UPDATE); request.setUser("nonmappeduser", Collections.singleton("ROLE_ADMIN")); boolean isAccessAllowed = authorizer.isAccessAllowed(request); AssertJUnit.assertEquals(true, isAccessAllowed); } catch (AtlasAuthorizationException e) { LOG.error("Exception in AtlasSimpleAuthorizerTest", e); AssertJUnit.fail(); } }
Example 3
Source File: AtlasSimpleAuthorizerTest.java From atlas with Apache License 2.0 | 6 votes |
@Test(enabled = true) public void testAccessNotAllowedForUserAndGroup() { try { AtlasEntityAccessRequest request = new AtlasEntityAccessRequest(null, AtlasPrivilege.ENTITY_UPDATE); request.setUser("nonmappeduser", Collections.singleton("GROUP-NOT-IN-POLICYFILE")); boolean isAccessAllowed = authorizer.isAccessAllowed(request); AssertJUnit.assertEquals(false, isAccessAllowed); } catch (AtlasAuthorizationException e) { LOG.error("Exception in AtlasSimpleAuthorizerTest", e); AssertJUnit.fail(); } }
Example 4
Source File: AbstractITest.java From hawkular-agent with Apache License 2.0 | 6 votes |
protected void assertResourceCount(ModelControllerClient mcc, ModelNode address, String childType, int expectedCount) throws IOException { ModelNode request = new ModelNode(); request.get(ModelDescriptionConstants.ADDRESS).set(address); request.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.READ_CHILDREN_RESOURCES_OPERATION); request.get(ModelDescriptionConstants.CHILD_TYPE).set(childType); request.get(ModelDescriptionConstants.INCLUDE_RUNTIME).set(true); ModelNode response = mcc.execute(request); if (response.hasDefined(ModelDescriptionConstants.OUTCOME) && response.get(ModelDescriptionConstants.OUTCOME) .asString().equals(ModelDescriptionConstants.SUCCESS)) { ModelNode result = response.get(ModelDescriptionConstants.RESULT); List<Property> nodes = result.asPropertyList(); AssertJUnit.assertEquals("Number of child nodes of [" + address + "] " + response, expectedCount, nodes.size()); } else if (expectedCount != 0) { AssertJUnit .fail("Path [" + address + "] has no child nodes, expected [" + expectedCount + "]: " + response); } }
Example 5
Source File: ExceptionHandlerTestCase.java From siddhi with Apache License 2.0 | 6 votes |
/** * Send 6 test events (2 valid -> 2 invalid -> 2 valid) * * @param inputHandler input handler * @throws Exception */ private void sendTestInvalidEvents(InputHandler inputHandler) throws Exception { // Send 2 valid events inputHandler.send(new Object[]{"GOOD_0", 700.0f, 100L}); Thread.sleep(100); inputHandler.send(new Object[]{"GOOD_1", 60.5f, 200L}); Thread.sleep(100); try { // Send 2 invalid event inputHandler.send(new Object[]{"BAD_2", "EBAY", 200L}); Thread.sleep(100); inputHandler.send(new Object[]{"BAD_3", "WSO2", 700f}); Thread.sleep(100); } catch (Exception ex) { AssertJUnit.fail("Disruptor exception can't be caught by try-catch"); throw ex; } // Send 2 valid events inputHandler.send(new Object[]{"GOOD_4", 700.0f, 100L}); Thread.sleep(100); inputHandler.send(new Object[]{"GOOD_5", 60.5f, 200L}); Thread.sleep(100); }
Example 6
Source File: InvertSelectionNGTest.java From constellation with Apache License 2.0 | 4 votes |
private void generateData() throws InterruptedException { graph = new StoreGraph(); attrX = graph.addAttribute(GraphElementType.VERTEX, FloatAttributeDescription.ATTRIBUTE_NAME, "x", "x", 0.0, null); if (attrX == Graph.NOT_FOUND) { AssertJUnit.fail(); } attrY = graph.addAttribute(GraphElementType.VERTEX, FloatAttributeDescription.ATTRIBUTE_NAME, "y", "y", 0.0, null); if (attrY == Graph.NOT_FOUND) { AssertJUnit.fail(); } attrZ = graph.addAttribute(GraphElementType.VERTEX, FloatAttributeDescription.ATTRIBUTE_NAME, "z", "z", 0.0, null); if (attrZ == Graph.NOT_FOUND) { AssertJUnit.fail(); } vAttrId = graph.addAttribute(GraphElementType.VERTEX, BooleanAttributeDescription.ATTRIBUTE_NAME, "selected", "selected", false, null); if (vAttrId == Graph.NOT_FOUND) { AssertJUnit.fail(); } tAttrId = graph.addAttribute(GraphElementType.TRANSACTION, BooleanAttributeDescription.ATTRIBUTE_NAME, "selected", "selected", false, null); if (tAttrId == Graph.NOT_FOUND) { AssertJUnit.fail(); } vxId1 = graph.addVertex(); graph.setFloatValue(attrX, vxId1, 1.0f); graph.setFloatValue(attrY, vxId1, 1.0f); graph.setBooleanValue(vAttrId, vxId1, true); vxId2 = graph.addVertex(); graph.setFloatValue(attrX, vxId2, 5.0f); graph.setFloatValue(attrY, vxId2, 1.0f); graph.setBooleanValue(vAttrId, vxId2, true); vxId3 = graph.addVertex(); graph.setFloatValue(attrX, vxId3, 1.0f); graph.setFloatValue(attrY, vxId3, 5.0f); graph.setBooleanValue(vAttrId, vxId3, false); vxId4 = graph.addVertex(); graph.setFloatValue(attrX, vxId4, 5.0f); graph.setFloatValue(attrY, vxId4, 5.0f); graph.setBooleanValue(vAttrId, vxId4, false); vxId5 = graph.addVertex(); graph.setFloatValue(attrX, vxId5, 10.0f); graph.setFloatValue(attrY, vxId5, 10.0f); graph.setBooleanValue(vAttrId, vxId5, false); txId1 = graph.addTransaction(vxId1, vxId2, true); graph.setBooleanValue(tAttrId, txId1, true); txId2 = graph.addTransaction(vxId2, vxId3, true); graph.setBooleanValue(tAttrId, txId2, true); txId3 = graph.addTransaction(vxId1, vxId3, false); graph.setBooleanValue(tAttrId, txId3, false); }
Example 7
Source File: TableNGTest.java From constellation with Apache License 2.0 | 4 votes |
@Test public void checkColumnClassTest() throws InterruptedException { final DualGraph graph = new DualGraph(null); final int xAttr, yAttr, zAttr; final int selectedAttr; final HashMap<String, String> fields = new HashMap<>(); WritableGraph wg = graph.getWritableGraph("", true); try { xAttr = wg.addAttribute(GraphElementType.VERTEX, FloatAttributeDescription.ATTRIBUTE_NAME, "x", "x", 0.0, null); if (xAttr == Graph.NOT_FOUND) { fail(); } fields.put("x", "float"); yAttr = wg.addAttribute(GraphElementType.VERTEX, FloatAttributeDescription.ATTRIBUTE_NAME, "y", "y", 0.0, null); if (yAttr == Graph.NOT_FOUND) { fail(); } fields.put("y", "float"); zAttr = wg.addAttribute(GraphElementType.VERTEX, FloatAttributeDescription.ATTRIBUTE_NAME, "z", "z", 0.0, null); if (zAttr == Graph.NOT_FOUND) { fail(); } fields.put("z", "float"); selectedAttr = wg.addAttribute(GraphElementType.VERTEX, BooleanAttributeDescription.ATTRIBUTE_NAME, "selected", "selected", false, null); if (selectedAttr == Graph.NOT_FOUND) { fail(); } fields.put("selected", "boolean"); } finally { wg.commit(); } GraphTableModel m = new GraphTableModel(graph, GraphElementType.VERTEX); ReadableGraph rg = graph.getReadableGraph(); try { for (int position = 0; position < rg.getAttributeCount(GraphElementType.VERTEX); position++) { final int attrId = rg.getAttribute(GraphElementType.VERTEX, position); final Attribute attr = new GraphAttribute(rg, attrId); if (!attr.getAttributeType().equals("float") && !attr.getAttributeType().equals("boolean")) { AssertJUnit.fail("Forgot a native type!"); } AssertJUnit.assertEquals( String.format("expected class=[%s] actual class=[%s]", attr.getAttributeType(), fields.get(attr.getName())), attr.getAttributeType(), fields.get(attr.getName())); } } finally { rg.release(); } }
Example 8
Source File: AtlasSimpleAuthorizerTest.java From atlas with Apache License 2.0 | 4 votes |
@Test(enabled = true) public void testBusinessMetadata() { try { AtlasEntityAccessRequest request = new AtlasEntityAccessRequest(null, AtlasPrivilege.ENTITY_UPDATE_BUSINESS_METADATA); request.setUser(USER_DATA_SCIENTIST, Collections.emptySet()); boolean isAccessAllowed = authorizer.isAccessAllowed(request); AssertJUnit.assertEquals("user " + USER_DATA_SCIENTIST + " shouldn't be allowed to update business-metadata", false, isAccessAllowed); request.setUser(USER_DATA_STEWARD, Collections.emptySet()); isAccessAllowed = authorizer.isAccessAllowed(request); AssertJUnit.assertEquals("user " + USER_DATA_STEWARD + " should be allowed to update business-metadata", true, isAccessAllowed); } catch (AtlasAuthorizationException e) { LOG.error("Exception in AtlasSimpleAuthorizerTest", e); AssertJUnit.fail(); } }
Example 9
Source File: JsonSinkMapperTestCase.java From siddhi-map-json with Apache License 2.0 | 4 votes |
@Test public void jsonSinkMapperTestCase1() throws InterruptedException { log.info("JsonSinkMapperTestCase 1"); InMemoryBroker.Subscriber subscriberWSO2 = new InMemoryBroker.Subscriber() { @Override public void onMessage(Object msg) { String jsonString; switch (wso2Count.incrementAndGet()) { case 1: jsonString = "{\"event\":{\"symbol\":\"WSO2\",\"price\":55.6,\"volume\":100}}"; AssertJUnit.assertEquals(jsonString , msg); break; case 2: jsonString = "{\"event\":{\"symbol\":\"WSO2\",\"price\":57.678,\"volume\":100}}"; AssertJUnit.assertEquals(jsonString, msg); break; case 3: jsonString = "{\"event\":{\"symbol\":\"WSO2\",\"price\":50.0,\"volume\":100}}"; AssertJUnit.assertEquals(jsonString , msg); break; case 4: jsonString = "{\"event\":{\"symbol\":\"WSO2#$%\",\"price\":50.0,\"volume\":100}}"; AssertJUnit.assertEquals(jsonString , msg); break; case 5: jsonString = "[{\"event\":{\"symbol\":\"WSO2\",\"price\":55.6,\"volume\":100}}," + "{\"event\":{\"symbol\":\"IBM\",\"price\":32.6,\"volume\":160}}]"; AssertJUnit.assertEquals(jsonString , msg); break; default: AssertJUnit.fail(); } } @Override public String getTopic() { return "WSO2"; } }; //subscribe to "inMemory" broker per topic InMemoryBroker.subscribe(subscriberWSO2); String streams = "" + "@App:name('TestSiddhiApp')" + "define stream FooStream (symbol string, price float, volume long); " + "@sink(type='inMemory', topic='WSO2', @map(type='json')) " + "define stream BarStream (symbol string, price float, volume long); "; String query = "" + "from FooStream " + "select * " + "insert into BarStream; "; SiddhiManager siddhiManager = new SiddhiManager(); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query); InputHandler stockStream = siddhiAppRuntime.getInputHandler("FooStream"); siddhiAppRuntime.start(); Event wso2Event = new Event(); Event ibmEvent = new Event(); Object[] wso2Data = {"WSO2", 55.6f, 100L}; Object[] ibmData = {"IBM", 32.6f, 160L}; wso2Event.setData(wso2Data); ibmEvent.setData(ibmData); stockStream.send(new Object[]{"WSO2", 55.6f, 100L}); stockStream.send(new Object[]{"WSO2", 57.678f, 100L}); stockStream.send(new Object[]{"WSO2", 50f, 100L}); stockStream.send(new Object[]{"WSO2#$%", 50f, 100L}); stockStream.send(new Event[]{wso2Event, ibmEvent}); SiddhiTestHelper.waitForEvents(waitTime, 5, wso2Count, timeout); //assert event count AssertJUnit.assertEquals(5, wso2Count.get()); siddhiAppRuntime.shutdown(); //unsubscribe from "inMemory" broker per topic InMemoryBroker.unsubscribe(subscriberWSO2); }
Example 10
Source File: JsonSinkMapperTestCase.java From siddhi-map-json with Apache License 2.0 | 4 votes |
@Test public void jsonSinkMapperTestCase2() throws InterruptedException { log.info("JsonSinkMapperTestCase 2"); InMemoryBroker.Subscriber subscriberWSO2 = new InMemoryBroker.Subscriber() { @Override public void onMessage(Object msg) { String jsonString; switch (wso2Count.incrementAndGet()) { case 1: jsonString = "{\"event\":{\"symbol\":\"WSO2\",\"price\":55.6,\"volume\":\"undefined\"}}"; AssertJUnit.assertEquals(jsonString, msg); break; case 2: jsonString = "{\"event\":{\"symbol\":\"WSO2\",\"price\":\"undefined\",\"volume\":100}}"; AssertJUnit.assertEquals(jsonString, msg); break; case 3: jsonString = "{\"event\":{\"symbol\":\"undefined\",\"price\":55.6,\"volume\":100}}"; AssertJUnit.assertEquals(jsonString, msg); break; default: AssertJUnit.fail(); } } @Override public String getTopic() { return "WSO2"; } }; //subscribe to "inMemory" broker per topic InMemoryBroker.subscribe(subscriberWSO2); String streams = "" + "@App:name('TestSiddhiApp')" + "define stream FooStream (symbol string, price float, volume long); " + "@sink(type='inMemory', topic='WSO2', @map(type='json')) " + "define stream BarStream (symbol string, price float, volume long); "; String query = "" + "from FooStream " + "select * " + "insert into BarStream; "; SiddhiManager siddhiManager = new SiddhiManager(); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query); InputHandler stockStream = siddhiAppRuntime.getInputHandler("FooStream"); siddhiAppRuntime.start(); stockStream.send(new Object[]{"WSO2", 55.6f, null}); stockStream.send(new Object[]{"WSO2", null, 100L}); stockStream.send(new Object[]{null, 55.6f, 100L}); SiddhiTestHelper.waitForEvents(waitTime, 3, wso2Count, timeout); //assert event count AssertJUnit.assertEquals(3, wso2Count.get()); siddhiAppRuntime.shutdown(); //unsubscribe from "inMemory" broker per topic InMemoryBroker.unsubscribe(subscriberWSO2); }
Example 11
Source File: JsonSinkMapperTestCase.java From siddhi-map-json with Apache License 2.0 | 4 votes |
@Test public void jsonSinkMapperTestCase3() throws InterruptedException { log.info("JsonSinkMapperTestCase 3"); InMemoryBroker.Subscriber subscriberWSO2 = new InMemoryBroker.Subscriber() { @Override public void onMessage(Object msg) { String jsonString; switch (wso2Count.incrementAndGet()) { case 1: jsonString = "{\"portfolio\":" + "{\"company\":{\"event\":{\"symbol\":\"WSO2\",\"price\":55.6,\"volume\":100}}}}"; AssertJUnit.assertEquals(jsonString, msg); break; case 2: jsonString = "{\"portfolio\":" + "{\"company\":{\"event\":{\"symbol\":\"WSO2\",\"price\":56.6,\"volume\":200}}}}"; AssertJUnit.assertEquals(jsonString, msg); break; case 3: jsonString = "{\"portfolio\":" + "{\"company\":{\"event\":{\"symbol\":\"WSO2\",\"price\":57.6,\"volume\":300}}}}"; AssertJUnit.assertEquals(jsonString, msg); break; default: AssertJUnit.fail(); } } @Override public String getTopic() { return "WSO2"; } }; //subscribe to "inMemory" broker per topic InMemoryBroker.subscribe(subscriberWSO2); String streams = "" + "@App:name('TestSiddhiApp')" + "define stream FooStream (symbol string, price float, volume long); " + "@sink(type='inMemory', topic='WSO2', @map(type='json', " + "enclosing.element=\"$.portfolio.company\")) " + "define stream BarStream (symbol string, price float, volume long); "; String query = "" + "from FooStream " + "select * " + "insert into BarStream; "; SiddhiManager siddhiManager = new SiddhiManager(); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query); InputHandler stockStream = siddhiAppRuntime.getInputHandler("FooStream"); siddhiAppRuntime.start(); stockStream.send(new Object[]{"WSO2", 55.6f, 100L}); stockStream.send(new Object[]{"WSO2", 56.6f, 200L}); stockStream.send(new Object[]{"WSO2", 57.6f, 300L}); SiddhiTestHelper.waitForEvents(waitTime, 3, wso2Count, timeout); //assert event count AssertJUnit.assertEquals(3, wso2Count.get()); siddhiAppRuntime.shutdown(); //unsubscribe from "inMemory" broker per topic InMemoryBroker.unsubscribe(subscriberWSO2); }
Example 12
Source File: JsonSinkMapperTestCase.java From siddhi-map-json with Apache License 2.0 | 4 votes |
@Test public void jsonSinkMapperTestCase14() throws InterruptedException { log.info("JsonSinkMapperTestCase with test default MultipleEvent"); InMemoryBroker.Subscriber subscriberWSO2 = new InMemoryBroker.Subscriber() { @Override public void onMessage(Object msg) { String jsonString; switch (wso2Count.incrementAndGet()) { case 1: jsonString = "{\"portfolio\":{\"company\":{\"event\":{\"symbol\":\"WSO2\",\"price\":55.6," + "\"volume\":100}}}}"; AssertJUnit.assertEquals(jsonString , msg); break; case 2: jsonString = "{\"portfolio\":{\"company\":{\"event\":{\"symbol\":\"WSO2\",\"price\":57.678," + "\"volume\":100}}}}"; AssertJUnit.assertEquals(jsonString, msg); break; case 3: jsonString = "{\"portfolio\":{\"company\":{\"event\":{\"symbol\":\"WSO2\",\"price\":50.0," + "\"volume\":100}}}}"; AssertJUnit.assertEquals(jsonString , msg); break; case 4: jsonString = "{\"portfolio\":{\"company\":{\"event\":{\"symbol\":\"WSO2#$%\",\"price\":50.0," + "\"volume\":100}}}}"; AssertJUnit.assertEquals(jsonString , msg); break; case 5: jsonString = "{\"portfolio\":{\"company\":[{\"event\":{\"symbol\":\"WSO2\",\"price\":55.6," + "\"volume\":100}}," + "{\"event\":{\"symbol\":\"IBM\",\"price\":32.6,\"volume\":160}}]}}"; AssertJUnit.assertEquals(jsonString , msg); break; default: AssertJUnit.fail(); } } @Override public String getTopic() { return "WSO2"; } }; //subscribe to "inMemory" broker per topic InMemoryBroker.subscribe(subscriberWSO2); String streams = "" + "@App:name('TestSiddhiApp')" + "define stream FooStream (symbol string, price float, volume long); " + "@sink(type='inMemory', topic='WSO2', @map(type='json'," + " enclosing.element=\"$.portfolio.company\")) " + "define stream BarStream (symbol string, price float, volume long); "; String query = "" + "from FooStream " + "select * " + "insert into BarStream; "; SiddhiManager siddhiManager = new SiddhiManager(); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query); InputHandler stockStream = siddhiAppRuntime.getInputHandler("FooStream"); siddhiAppRuntime.start(); Event wso2Event = new Event(); Event ibmEvent = new Event(); Object[] wso2Data = {"WSO2", 55.6f, 100L}; Object[] ibmData = {"IBM", 32.6f, 160L}; wso2Event.setData(wso2Data); ibmEvent.setData(ibmData); stockStream.send(new Object[]{"WSO2", 55.6f, 100L}); stockStream.send(new Object[]{"WSO2", 57.678f, 100L}); stockStream.send(new Object[]{"WSO2", 50f, 100L}); stockStream.send(new Object[]{"WSO2#$%", 50f, 100L}); stockStream.send(new Event[]{wso2Event, ibmEvent}); SiddhiTestHelper.waitForEvents(waitTime, 5, wso2Count, timeout); //assert event count AssertJUnit.assertEquals(5, wso2Count.get()); siddhiAppRuntime.shutdown(); //unsubscribe from "inMemory" broker per topic InMemoryBroker.unsubscribe(subscriberWSO2); }
Example 13
Source File: JsonSinkMapperTestCase.java From siddhi-map-json with Apache License 2.0 | 4 votes |
@Test public void jsonSinkDefaultMapperForInt() throws InterruptedException { log.info("JsonSinkDefaultMapper Test case for integers greater than 100000"); InMemoryBroker.Subscriber subscriberWSO2 = new InMemoryBroker.Subscriber() { @Override public void onMessage(Object msg) { String jsonString; if (wso2Count.incrementAndGet() == 1) { jsonString = "{\"event\":{\"symbol\":\"WSO2\",\"price\":55.6,\"volume\":100000}}"; AssertJUnit.assertEquals(jsonString, msg); } else { AssertJUnit.fail(); } } @Override public String getTopic() { return "WSO2"; } }; //subscribe to "inMemory" broker per topic InMemoryBroker.subscribe(subscriberWSO2); String streams = "" + "@App:name('TestSiddhiApp')" + "define stream FooStream (symbol string, price float, volume long); " + "@sink(type='inMemory', topic='WSO2', @map(type='json')) " + "define stream BarStream (symbol string, price float, volume long); "; String query = "" + "from FooStream " + "select * " + "insert into BarStream; "; SiddhiManager siddhiManager = new SiddhiManager(); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query); InputHandler stockStream = siddhiAppRuntime.getInputHandler("FooStream"); siddhiAppRuntime.start(); stockStream.send(new Object[]{"WSO2", 55.6f, 100000L}); SiddhiTestHelper.waitForEvents(waitTime, 1, wso2Count, timeout); //assert event count AssertJUnit.assertEquals(1, wso2Count.get()); siddhiAppRuntime.shutdown(); //unsubscribe from "inMemory" broker per topic InMemoryBroker.unsubscribe(subscriberWSO2); }
Example 14
Source File: Aggregation1TestCase.java From siddhi with Apache License 2.0 | 4 votes |
@Test(dependsOnMethods = {"incrementalStreamProcessorTest24"}) public void incrementalStreamProcessorTest25() throws InterruptedException { LOG.info("incrementalStreamProcessorTest25"); SiddhiManager siddhiManager = new SiddhiManager(); String stockStream = "define stream stockStream (symbol string, price float, lastClosingPrice float, volume long , " + "quantity int, timestamp long);"; String query = " define aggregation stockAggregation " + "from stockStream " + "select symbol, avg(price) as avgPrice, sum(price) as totalPrice, (price * quantity) " + "as lastTradeValue " + "group by symbol " + "aggregate by timestamp every sec...hour ;"; SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(stockStream + query); InputHandler stockStreamInputHandler = siddhiAppRuntime.getInputHandler("stockStream"); siddhiAppRuntime.start(); stockStreamInputHandler.send(new Object[]{"WSO2", 50f, 60f, 90L, 6, 1496289950000L}); stockStreamInputHandler.send(new Object[]{"WSO2", 70f, null, 40L, 10, 1496289950000L}); stockStreamInputHandler.send(new Object[]{"WSO2", 60f, 44f, 200L, 56, 1496289952000L}); stockStreamInputHandler.send(new Object[]{"WSO2", 100f, null, 200L, 16, 1496289952000L}); stockStreamInputHandler.send(new Object[]{"IBM", 100f, null, 200L, 26, 1496289954000L}); stockStreamInputHandler.send(new Object[]{"IBM", 100f, null, 200L, 96, 1496289954000L}); Thread.sleep(2000); Event[] events = siddhiAppRuntime.query("from stockAggregation " + "within \"2017-06-** **:**:**\" " + "per \"seconds\" " + "select * " + "order by AGG_TIMESTAMP ;"); EventPrinter.print(events); Assert.assertNotNull(events); AssertJUnit.assertEquals(3, events.length); for (int i = 0; i < events.length; i++) { switch (i) { case 0: AssertJUnit.assertArrayEquals(new Object[]{1496289950000L, "WSO2", 60.0, 120.0, 700f}, events[i].getData()); break; case 1: AssertJUnit.assertArrayEquals(new Object[]{1496289952000L, "WSO2", 80.0, 160.0, 1600f}, events[i].getData()); break; case 2: AssertJUnit.assertArrayEquals(new Object[]{1496289954000L, "IBM", 100.0, 200.0, 9600f}, events[i].getData()); break; default: //Not reached AssertJUnit.fail(); } } siddhiAppRuntime.shutdown(); }
Example 15
Source File: Aggregation1TestCase.java From siddhi with Apache License 2.0 | 4 votes |
@Test(dependsOnMethods = {"incrementalStreamProcessorTest30"}) public void incrementalStreamProcessorTest31() throws InterruptedException { LOG.info("incrementalStreamProcessorTest31"); SiddhiManager siddhiManager = new SiddhiManager(); String stockStream = "define stream stockStream (symbol string, price float, lastClosingPrice float, volume long , " + "quantity int, timestamp long);"; String query = " define aggregation stockAggregation " + "from stockStream " + "select symbol, avg(price) as avgPrice, sum(price) as totalPrice, (price * quantity) " + "as lastTradeValue " + "group by symbol " + "aggregate by timestamp every sec...hour ;"; SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(stockStream + query); InputHandler stockStreamInputHandler = siddhiAppRuntime.getInputHandler("stockStream"); siddhiAppRuntime.start(); stockStreamInputHandler.send(new Object[]{"WSO2", 50f, 60f, 90L, 6, 1496289950000L}); stockStreamInputHandler.send(new Object[]{"WSO2", 70f, null, 40L, 10, 1496289950000L}); stockStreamInputHandler.send(new Object[]{"WSO2", 60f, 44f, 200L, 56, 1496289952000L}); stockStreamInputHandler.send(new Object[]{"WSO2", 100f, null, 200L, 16, 1496289952000L}); stockStreamInputHandler.send(new Object[]{"IBM", 100f, null, 200L, 26, 1496289954000L}); stockStreamInputHandler.send(new Object[]{"IBM", 100f, null, 200L, 96, 1496289954000L}); stockStreamInputHandler.send(new Object[]{"CISCO", 100f, null, 200L, 26, 1513578087000L}); stockStreamInputHandler.send(new Object[]{"CISCO", 100f, null, 200L, 96, 1513578087000L}); Thread.sleep(2000); Event[] events = siddhiAppRuntime.query("from stockAggregation " + "within \"2017-**-** **:**:**\" " + "per \"seconds\" " + "select * " + "order by AGG_TIMESTAMP ;"); EventPrinter.print(events); Assert.assertNotNull(events); AssertJUnit.assertEquals(4, events.length); for (int i = 0; i < events.length; i++) { switch (i) { case 0: AssertJUnit.assertArrayEquals(new Object[]{1496289950000L, "WSO2", 60.0, 120.0, 700f}, events[i].getData()); break; case 1: AssertJUnit.assertArrayEquals(new Object[]{1496289952000L, "WSO2", 80.0, 160.0, 1600f}, events[i].getData()); break; case 2: AssertJUnit.assertArrayEquals(new Object[]{1496289954000L, "IBM", 100.0, 200.0, 9600f}, events[i].getData()); break; case 3: AssertJUnit.assertArrayEquals(new Object[]{1513578087000L, "CISCO", 100.0, 200.0, 9600f}, events[i].getData()); break; default: AssertJUnit.fail(); } } Thread.sleep(100); siddhiAppRuntime.shutdown(); }
Example 16
Source File: AtlasSimpleAuthorizerTest.java From atlas with Apache License 2.0 | 3 votes |
@Test(enabled = true) public void testLabels() { try { AtlasEntityAccessRequest request = new AtlasEntityAccessRequest(null, AtlasPrivilege.ENTITY_ADD_LABEL); request.setUser(USER_DATA_SCIENTIST, Collections.emptySet()); boolean isAccessAllowed = authorizer.isAccessAllowed(request); AssertJUnit.assertEquals("user " + USER_DATA_SCIENTIST + " shouldn't be allowed to add label", false, isAccessAllowed); request.setUser(USER_DATA_STEWARD, Collections.emptySet()); isAccessAllowed = authorizer.isAccessAllowed(request); AssertJUnit.assertEquals("user " + USER_DATA_STEWARD + " should be allowed to add label", true, isAccessAllowed); request = new AtlasEntityAccessRequest(null, AtlasPrivilege.ENTITY_REMOVE_LABEL); request.setUser(USER_DATA_SCIENTIST, Collections.emptySet()); isAccessAllowed = authorizer.isAccessAllowed(request); AssertJUnit.assertEquals("user " + USER_DATA_SCIENTIST + " shouldn't be allowed to remove label", false, isAccessAllowed); request.setUser(USER_DATA_STEWARD, Collections.emptySet()); isAccessAllowed = authorizer.isAccessAllowed(request); AssertJUnit.assertEquals("user " + USER_DATA_STEWARD + " should be allowed to remove label", true, isAccessAllowed); } catch (AtlasAuthorizationException e) { LOG.error("Exception in AtlasSimpleAuthorizerTest", e); AssertJUnit.fail(); } }