@Test public void testReloadingVirtualSensor() throws InstantiationException, IllegalAccessException, SQLException { VSensorLoader loader = new VSensorLoader(); InputStream is = new InputStream(); StreamSource ss = new StreamSource() .setAlias("my-stream1") .setAddressing(addressing) .setSqlQuery("select * from wrapper") .setRawHistorySize("2") .setInputStream(is); ss.setSamplingRate(1); assertTrue(ss.validate()); // assertTrue(loader.prepareStreamSource(is,ss)); assertTrue(sm.tableExists(ss.getWrapper().getDBAliasInStr())); assertTrue(sm.tableExists(ss.getUIDStr())); assertFalse(is.getRenamingMapping().isEmpty()); loader.releaseStreamSource(ss); assertTrue(is.getRenamingMapping().isEmpty()); assertFalse(sm.tableExists(ss.getUIDStr())); assertFalse(ss.getWrapper().isActive()); assertFalse(sm.tableExists(ss.getWrapper().getDBAliasInStr())); assertTrue(is.getRenamingMapping().isEmpty()); ss = new StreamSource() .setAlias("my-stream1") .setAddressing(addressing) .setSqlQuery("select * from wrapper") .setRawHistorySize("2") .setInputStream(is); ss.setSamplingRate(1); // assertTrue(loader.prepareStreamSource(is,ss)); }
@Test public void testOneInputStreamUsingTwoStreamSources() throws InstantiationException, IllegalAccessException, SQLException { VSensorLoader loader = new VSensorLoader(); InputStream is = new InputStream(); StreamSource ss1 = new StreamSource() .setAlias("my-stream1") .setAddressing(new AddressBean[] {new AddressBean("mock-test")}) .setSqlQuery("select * from wrapper") .setRawHistorySize("2") .setInputStream(is); ss1.setSamplingRate(1); assertTrue(ss1.validate()); // assertTrue(loader.prepareStreamSource(is,ss1)); StreamSource ss2 = new StreamSource() .setAlias("my-stream2") .setAddressing(new AddressBean[] {new AddressBean("mock-test")}) .setSqlQuery("select * from wrapper") .setRawHistorySize("20") .setInputStream(is); ss2.setSamplingRate(1); assertTrue(ss2.validate()); // assertTrue(loader.prepareStreamSource(is,ss2)); ss1.getWrapper().releaseResources(); assertFalse(sm.tableExists(ss1.getWrapper().getDBAliasInStr())); }