public void testSendingTwoDifferentStreamDefinitionsWithSameStreamId() throws MalformedURLException, AuthenticationException, TransportException, AgentException, UndefinedEventTypeException, InterruptedException, DataBridgeException, MalformedStreamDefinitionException, StreamDefinitionException, DifferentStreamDefinitionAlreadyDefinedException { TestServer testServer = new TestServer(); testServer.start(7617); KeyStoreUtil.setTrustStoreParams(); Thread.sleep(2000); // according to the convention the authentication port will be 7611+100= 7711 and its host will // be the same DataPublisher dataPublisher = new DataPublisher("tcp://localhost:7617", "admin", "admin"); dataPublisher.defineStream( "{" + " 'name':'org.wso2.esb.MediatorStatistics3'," + " 'version':'2.3.0'," + " 'nickName': 'Stock Quote Information'," + " 'description': 'Some Desc'," + " 'tags':['foo', 'bar']," + " 'metaData':[" + " {'name':'ipAdd','type':'STRING'}" + " ]," + " 'payloadData':[" + " {'name':'symbol','type':'STRING'}," + " {'name':'price','type':'DOUBLE'}," + " {'name':'volume','type':'INT'}," + " {'name':'max','type':'DOUBLE'}," + " {'name':'min','type':'Double'}" + " ]" + "}"); Boolean exceptionOccurred = false; try { dataPublisher.defineStream( "{" + " 'name':'org.wso2.esb.MediatorStatistics3'," + " 'version':'2.3.0'," + " 'nickName': 'Stock Quote Information'," + " 'description': 'Some Desc'," + " 'tags':['foo', 'bar']," + " 'metaData':[" + " {'name':'ipAdd','type':'STRING'}" + " ]," + " 'payloadData':[" + " {'name':'symbol','type':'STRING'}," + " {'name':'price','type':'DOUBLE'}," + " {'name':'volume','type':'INT'}," + " {'name':'min','type':'Double'}" + " ]" + "}"); } catch (DifferentStreamDefinitionAlreadyDefinedException e) { exceptionOccurred = true; } Assert.assertTrue(exceptionOccurred); dataPublisher.stop(); testServer.stop(); }
public void testSendingSameStreamDefinitions() throws MalformedURLException, AuthenticationException, TransportException, AgentException, UndefinedEventTypeException, DifferentStreamDefinitionAlreadyDefinedException, InterruptedException, DataBridgeException, MalformedStreamDefinitionException, StreamDefinitionException { TestServer testServer = new TestServer(); testServer.start(7614); KeyStoreUtil.setTrustStoreParams(); Thread.sleep(2000); // according to the convention the authentication port will be 7611+100= 7711 and its host will // be the same DataPublisher dataPublisher = new DataPublisher("tcp://localhost:7614", "admin", "admin"); String id1 = dataPublisher.defineStream( "{" + " 'name':'org.wso2.esb.MediatorStatistics'," + " 'version':'2.3.0'," + " 'nickName': 'Stock Quote Information'," + " 'description': 'Some Desc'," + " 'tags':['foo', 'bar']," + " 'metaData':[" + " {'name':'ipAdd','type':'STRING'}" + " ]," + " 'payloadData':[" + " {'name':'symbol','type':'STRING'}," + " {'name':'price','type':'DOUBLE'}," + " {'name':'volume','type':'INT'}," + " {'name':'max','type':'DOUBLE'}," + " {'name':'min','type':'Double'}" + " ]" + "}"); String id2 = dataPublisher.defineStream( "{" + " 'name':'org.wso2.esb.MediatorStatistics'," + " 'version':'2.3.0'," + " 'nickName': 'Stock Quote Information'," + " 'description': 'Some Desc'," + " 'tags':['foo', 'bar']," + " 'metaData':[" + " {'name':'ipAdd','type':'STRING'}" + " ]," + " 'payloadData':[" + " {'name':'symbol','type':'STRING'}," + " {'name':'price','type':'DOUBLE'}," + " {'name':'volume','type':'INT'}," + " {'name':'max','type':'DOUBLE'}," + " {'name':'min','type':'Double'}" + " ]" + "}"); Assert.assertEquals(id1, id2); // In this case correlation data is null dataPublisher.publish( id1, new Object[] {"127.0.0.1"}, null, new Object[] {"IBM", 96.8, 300, 120.6, 70.4}); dataPublisher.stop(); testServer.stop(); }
@Before public void before() throws Exception { DateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); Date lastModifiedDate = df.parse(LAST_MODIFIED_DATE_MATCH); RestResource.setLastModifiedDate(lastModifiedDate); client = new DefaultHttpClient(); server = new TestServer(); server.start(); }
@Before public void setUp() throws Exception { server.start(); }
/** Starts a Test server. */ public static void start(TestServer server) { server.start(); }