Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/test/java/geniusweb/clienttest/JavaClientTest.java

    r3 r1  
    55
    66import java.io.IOException;
    7 import java.util.HashMap;
    87import java.util.LinkedList;
    98import java.util.List;
    10 import java.util.Map;
    119
    1210import org.junit.AfterClass;
     
    1513import org.python.util.PythonInterpreter;
    1614
    17 import com.fasterxml.jackson.core.type.TypeReference;
    18 import com.fasterxml.jackson.databind.ObjectMapper;
    1915import com.neovisionaries.ws.client.WebSocket;
    2016import com.neovisionaries.ws.client.WebSocketAdapter;
     
    6056        @Test
    6157        public void clientSmokeTest() throws IOException {
    62                 WebSocketFactory factory = new WebSocketFactory().setConnectionTimeout(5000);
    63                 WebSocket ws = factory.createSocket("ws://localhost:8080/profilesserver/websocket/liststream");
     58                WebSocketFactory factory = new WebSocketFactory()
     59                                .setConnectionTimeout(5000);
     60                WebSocket ws = factory.createSocket(
     61                                "ws://localhost:8080/profilesserver/websocket/liststream");
    6462        }
    6563
    6664        @Test
    67         public void testGetList() throws IOException, InterruptedException, WebSocketException {
     65        public void testGetList()
     66                        throws IOException, InterruptedException, WebSocketException {
    6867                final List<String> received = new LinkedList<>();
    6968                Thread.sleep(5000);
    70                 WebSocketFactory factory = new WebSocketFactory().setConnectionTimeout(20000);
    71                 WebSocket ws = factory.createSocket("ws://localhost:8080/profilesserver/websocket/liststream");
     69                WebSocketFactory factory = new WebSocketFactory()
     70                                .setConnectionTimeout(20000);
     71                WebSocket ws = factory.createSocket(
     72                                "ws://localhost:8080/profilesserver/websocket/liststream");
    7273
    7374                ws.addListener(new WebSocketAdapter() {
    7475                        @Override
    75                         public void onTextMessage(WebSocket websocket, String message) throws Exception {
     76                        public void onTextMessage(WebSocket websocket, String message)
     77                                        throws Exception {
    7678                                System.out.println("received message: " + message);
    7779                                received.add(message);
     
    8284
    8385                Thread.sleep(2000);
    84 
    85                 assertEquals(1, received.size()); // 1 answer received
    86 
    87                 ObjectMapper mapper = new ObjectMapper();
    88                 TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() {
    89                 };
    90                 Map<String, Object> map = mapper.readValue(received.get(0), typeRef);
    91 
    92                 List<String> domains= new LinkedList<>();
    93                 for (String key: map.keySet()) {
    94                         domains.add(key.substring(key.indexOf("get")));
    95                         }
    96                 assertTrue(domains.contains("get/jobs"));
    97                 assertTrue(domains.contains("get/7issues"));
     86                assertEquals(1, received.size());
     87                assertTrue(received.get(0).matches(JSON));
     88                System.out.println(JSON);
    9889        }
    9990
    10091        @Test
    101         public void testExample() throws WebSocketException, InterruptedException, IOException {
     92        public void testExample()
     93                        throws WebSocketException, InterruptedException, IOException {
    10294                DownloadProfileExample test = new DownloadProfileExample();
    10395                test.run();
     
    10698
    10799        @Test
    108         public void testExample2() throws WebSocketException, InterruptedException, IOException {
     100        public void testExample2()
     101                        throws WebSocketException, InterruptedException, IOException {
    109102                DownloadProfileExample2 test = new DownloadProfileExample2();
    110103                assertEquals(JOBS1PROFILE, test.getReceived());
     
    119112
    120113                // Create factory and coerce Jython calculator object
    121                 JythonObjectFactory factory = new JythonObjectFactory(WebSocketAdapter.class, "PythonDownloadProfile",
     114                JythonObjectFactory factory = new JythonObjectFactory(
     115                                WebSocketAdapter.class, "PythonDownloadProfile",
    122116                                "PythonDownloadProfile");
    123117                factory.createObject();
Note: See TracChangeset for help on using the changeset viewer.