List of usage examples for javax.websocket Session Session
Session
From source file:org.wso2.carbon.data.provider.RDBMSQueriesIT.java
@BeforeMethod public void init() { try {// w ww. j a v a 2 s . co m RDBMSTableTestUtils.initDatabaseTable(); RDBMSDataProviderConfBean rdbmsDataProviderConfBean = new RDBMSDataProviderConfBean(); DataProviderValueHolder.getDataProviderHelper() .setDataProvider(RDBMSBatchDataProvider.class.getSimpleName(), new RDBMSBatchDataProvider()); DataProviderValueHolder.getDataProviderHelper().setDataProvider( RDBMSStreamingDataProvider.class.getSimpleName(), new RDBMSStreamingDataProvider()); DataSourceService dataSourceService = new DataSourceService() { public Object getDataSource(String s) throws DataSourceException { return RDBMSTableTestUtils.getDataSource(); } public Object createDataSource(DataSourceDefinition dataSourceDefinition) throws DataSourceException { return RDBMSTableTestUtils.getDataSource(); } }; Queries queries = new Queries(); queries.setVersion("default"); queries.setType("H2"); Map queriesMap = new HashMap(); queriesMap.put("record_delete", "DELETE TOP {{LIMIT_VALUE}} FROM {{TABLE_NAME}}" + " {{INCREMENTAL_COLUMN}} ASC LIMIT {{LIMIT_VALUE}}"); queriesMap.put("total_record_count", "SELECT COUNT(*) FROM {{TABLE_NAME}}"); queriesMap.put("record_limit", " ORDER BY {{INCREMENTAL_COLUMN}} ASC LIMIT {{LIMIT_VALUE}}"); queriesMap.put("record_greater_than", " WHERE {{INCREMENTAL_COLUMN}} > {{LAST_RECORD_VALUE}}"); queries.setMappings(queriesMap); ArrayList arrayList = new ArrayList(); arrayList.add(queries); rdbmsDataProviderConfBean.setQueries(arrayList); ConfigProvider configProvider = new ConfigProvider() { @Override public <T> T getConfigurationObject(Class<T> aClass) throws ConfigurationException { return (T) rdbmsDataProviderConfBean; } @Override public Object getConfigurationObject(String s) throws ConfigurationException { return rdbmsDataProviderConfBean; } @Override public <T> T getConfigurationObject(String s, Class<T> aClass) throws ConfigurationException { return (T) rdbmsDataProviderConfBean; } }; basic = new RemoteEndpoint.Basic() { @Override public void sendText(String s) throws IOException { if (rdbmsDataProviderConfBean != null) { responseCallBackListener.responseListener(s); } } @Override public void sendBinary(ByteBuffer byteBuffer) throws IOException { } @Override public void sendText(String s, boolean b) throws IOException { } @Override public void sendBinary(ByteBuffer byteBuffer, boolean b) throws IOException { } @Override public OutputStream getSendStream() throws IOException { return null; } @Override public Writer getSendWriter() throws IOException { return null; } @Override public void sendObject(Object o) throws IOException, EncodeException { } @Override public void setBatchingAllowed(boolean b) throws IOException { } @Override public boolean getBatchingAllowed() { return false; } @Override public void flushBatch() throws IOException { } @Override public void sendPing(ByteBuffer byteBuffer) throws IOException, IllegalArgumentException { } @Override public void sendPong(ByteBuffer byteBuffer) throws IOException, IllegalArgumentException { } }; session = new Session() { @Override public WebSocketContainer getContainer() { return null; } @Override public void addMessageHandler(MessageHandler messageHandler) throws IllegalStateException { } @Override public <T> void addMessageHandler(Class<T> aClass, MessageHandler.Whole<T> whole) { } @Override public <T> void addMessageHandler(Class<T> aClass, MessageHandler.Partial<T> partial) { } @Override public Set<MessageHandler> getMessageHandlers() { return null; } @Override public void removeMessageHandler(MessageHandler messageHandler) { } @Override public String getProtocolVersion() { return null; } @Override public String getNegotiatedSubprotocol() { return null; } @Override public List<Extension> getNegotiatedExtensions() { return null; } @Override public boolean isSecure() { return false; } @Override public boolean isOpen() { return false; } @Override public long getMaxIdleTimeout() { return 0; } @Override public void setMaxIdleTimeout(long l) { } @Override public void setMaxBinaryMessageBufferSize(int i) { } @Override public int getMaxBinaryMessageBufferSize() { return 0; } @Override public void setMaxTextMessageBufferSize(int i) { } @Override public int getMaxTextMessageBufferSize() { return 0; } @Override public RemoteEndpoint.Async getAsyncRemote() { return null; } @Override public RemoteEndpoint.Basic getBasicRemote() { return basic; } @Override public String getId() { return "foo-session"; } @Override public void close() throws IOException { } @Override public void close(CloseReason closeReason) throws IOException { } @Override public URI getRequestURI() { return null; } @Override public Map<String, List<String>> getRequestParameterMap() { return null; } @Override public String getQueryString() { return null; } @Override public Map<String, String> getPathParameters() { return null; } @Override public Map<String, Object> getUserProperties() { return null; } @Override public Principal getUserPrincipal() { return null; } @Override public Set<Session> getOpenSessions() { return null; } }; DataProviderValueHolder.getDataProviderHelper().setDataSourceService(dataSourceService); DataProviderValueHolder.getDataProviderHelper().setConfigProvider(configProvider); } catch (SQLException e) { log.info("Test case ignored due to " + e.getMessage()); } }