Changeset 5 for src/test/java/geniusweb
- Timestamp:
- 09/24/19 14:13:24 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/test/java/geniusweb/clienttest/JavaClientTest.java
r3 r5 60 60 @Test 61 61 public void clientSmokeTest() throws IOException { 62 WebSocketFactory factory = new WebSocketFactory().setConnectionTimeout(5000); 63 WebSocket ws = factory.createSocket("ws://localhost:8080/profilesserver/websocket/liststream"); 62 WebSocketFactory factory = new WebSocketFactory() 63 .setConnectionTimeout(5000); 64 WebSocket ws = factory.createSocket( 65 "ws://localhost:8080/profilesserver/websocket/liststream"); 64 66 } 65 67 66 68 @Test 67 public void testGetList() throws IOException, InterruptedException, WebSocketException { 69 public void testGetList() 70 throws IOException, InterruptedException, WebSocketException { 68 71 final List<String> received = new LinkedList<>(); 69 72 Thread.sleep(5000); 70 WebSocketFactory factory = new WebSocketFactory().setConnectionTimeout(20000); 71 WebSocket ws = factory.createSocket("ws://localhost:8080/profilesserver/websocket/liststream"); 73 WebSocketFactory factory = new WebSocketFactory() 74 .setConnectionTimeout(20000); 75 WebSocket ws = factory.createSocket( 76 "ws://localhost:8080/profilesserver/websocket/liststream"); 72 77 73 78 ws.addListener(new WebSocketAdapter() { 74 79 @Override 75 public void onTextMessage(WebSocket websocket, String message) throws Exception { 80 public void onTextMessage(WebSocket websocket, String message) 81 throws Exception { 76 82 System.out.println("received message: " + message); 77 83 received.add(message); … … 81 87 assertTrue(ws.isOpen()); 82 88 83 Thread.sleep( 2000);89 Thread.sleep(15000); 84 90 85 91 assertEquals(1, received.size()); // 1 answer received … … 90 96 Map<String, Object> map = mapper.readValue(received.get(0), typeRef); 91 97 92 List<String> domains = new LinkedList<>();93 for (String key : map.keySet()) {98 List<String> domains = new LinkedList<>(); 99 for (String key : map.keySet()) { 94 100 domains.add(key.substring(key.indexOf("get"))); 95 101 } 96 102 assertTrue(domains.contains("get/jobs")); 97 103 assertTrue(domains.contains("get/7issues")); … … 99 105 100 106 @Test 101 public void testExample() throws WebSocketException, InterruptedException, IOException { 107 public void testExample() 108 throws WebSocketException, InterruptedException, IOException { 102 109 DownloadProfileExample test = new DownloadProfileExample(); 103 110 test.run(); … … 106 113 107 114 @Test 108 public void testExample2() throws WebSocketException, InterruptedException, IOException { 115 public void testExample2() 116 throws WebSocketException, InterruptedException, IOException { 109 117 DownloadProfileExample2 test = new DownloadProfileExample2(); 110 118 assertEquals(JOBS1PROFILE, test.getReceived()); … … 119 127 120 128 // Create factory and coerce Jython calculator object 121 JythonObjectFactory factory = new JythonObjectFactory(WebSocketAdapter.class, "PythonDownloadProfile", 129 JythonObjectFactory factory = new JythonObjectFactory( 130 WebSocketAdapter.class, "PythonDownloadProfile", 122 131 "PythonDownloadProfile"); 123 132 factory.createObject();
Note:
See TracChangeset
for help on using the changeset viewer.