- Location:
- /src
- Files:
-
- 11 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
/src/main/webapp/domainsrepo/7issues/7issues.json
r1 r3 3 3 "issuesValues": { 4 4 "i1": { 5 "range": [ "0", "9", "1"]5 "range": [0, 9, 1] 6 6 }, 7 7 "i2": { 8 "range": [ "0", "9", "1"]8 "range": [0, 9, 1] 9 9 }, 10 10 "i3": { 11 "range": [ "0", "9", "1"]11 "range": [0, 9, 1] 12 12 }, 13 13 "i4": { 14 "range": [ "0", "9", "1"]14 "range": [0, 9, 1] 15 15 }, 16 16 "i5": { 17 "range": [ "0", "9", "1"]17 "range": [0, 9, 1] 18 18 }, 19 19 "i6": { 20 "range": [ "0", "9", "1"]20 "range": [0, 9, 1] 21 21 }, 22 22 "i7": { 23 "range": [ "0", "9", "1"]23 "range": [0, 9, 1] 24 24 } 25 25 } -
/src/main/webapp/domainsrepo/7issues/7issues1.json
r1 r3 9 9 "highValue": 9, 10 10 "highUtility": 0.99 11 12 11 } 13 12 }, … … 18 17 "highValue": 9, 19 18 "highUtility": 0.97 20 21 19 } 22 20 }, … … 27 25 "highValue": 9, 28 26 "highUtility": 0.96 29 30 27 } 31 28 }, … … 36 33 "highValue": 9, 37 34 "highUtility": 0.94 38 39 35 } 40 36 }, … … 45 41 "highValue": 9, 46 42 "highUtility": 0.93 47 48 43 } 49 44 }, … … 54 49 "highValue": 9, 55 50 "highUtility": 0.92 56 57 51 } 58 52 }, … … 63 57 "highValue": 9, 64 58 "highUtility": 0.91 65 66 59 } 67 60 } … … 80 73 "issuesValues": { 81 74 "i1": { 82 "range": ["0", "9", "1"] 75 "range": [ 76 0, 77 9, 78 1 79 ] 83 80 }, 84 81 "i2": { 85 "range": ["0", "9", "1"] 82 "range": [ 83 0, 84 9, 85 1 86 ] 86 87 }, 87 88 "i3": { 88 "range": ["0", "9", "1"] 89 "range": [ 90 0, 91 9, 92 1 93 ] 89 94 }, 90 95 "i4": { 91 "range": ["0", "9", "1"] 96 "range": [ 97 0, 98 9, 99 1 100 ] 92 101 }, 93 102 "i5": { 94 "range": ["0", "9", "1"] 103 "range": [ 104 0, 105 9, 106 1 107 ] 95 108 }, 96 109 "i6": { 97 "range": ["0", "9", "1"] 110 "range": [ 111 0, 112 9, 113 1 114 ] 98 115 }, 99 116 "i7": { 100 "range": ["0", "9", "1"] 117 "range": [ 118 0, 119 9, 120 1 121 ] 101 122 } 102 123 } -
/src/main/webapp/domainsrepo/7issues/7issues2.json
r1 r3 9 9 "highValue": 9, 10 10 "highUtility": 0.11 11 12 11 } 13 12 }, … … 18 17 "highValue": 9, 19 18 "highUtility": 0.21 20 21 19 } 22 20 }, … … 27 25 "highValue": 9, 28 26 "highUtility": 0.13 29 30 27 } 31 28 }, … … 36 33 "highValue": 9, 37 34 "highUtility": 0.14 38 39 35 } 40 36 }, … … 45 41 "highValue": 9, 46 42 "highUtility": 0.15 47 48 43 } 49 44 }, … … 54 49 "highValue": 9, 55 50 "highUtility": 0.16 56 57 51 } 58 52 }, … … 63 57 "highValue": 9, 64 58 "highUtility": 0.17 65 66 59 } 67 60 } … … 80 73 "issuesValues": { 81 74 "i1": { 82 "range": ["0", "9", "1"] 75 "range": [ 76 0, 77 9, 78 1 79 ] 83 80 }, 84 81 "i2": { 85 "range": ["0", "9", "1"] 82 "range": [ 83 0, 84 9, 85 1 86 ] 86 87 }, 87 88 "i3": { 88 "range": ["0", "9", "1"] 89 "range": [ 90 0, 91 9, 92 1 93 ] 89 94 }, 90 95 "i4": { 91 "range": ["0", "9", "1"] 96 "range": [ 97 0, 98 9, 99 1 100 ] 92 101 }, 93 102 "i5": { 94 "range": ["0", "9", "1"] 103 "range": [ 104 0, 105 9, 106 1 107 ] 95 108 }, 96 109 "i6": { 97 "range": ["0", "9", "1"] 110 "range": [ 111 0, 112 9, 113 1 114 ] 98 115 }, 99 116 "i7": { 100 "range": ["0", "9", "1"] 117 "range": [ 118 0, 119 9, 120 1 121 ] 101 122 } 102 123 } -
/src/main/webapp/index.jsp
r1 r3 15 15 these may contain files with errors, and thus are not available for 16 16 use. 17 18 <h2> 19 Adding domains and profiles 20 </h1> 21 You can add and remove domains and profiles by dragging your .json 22 files into and out of the repo directory. 23 24 <h2> 25 Access 26 </h1> 27 Your agent has JSON based access to the repo through websockets. Two 28 examples are provided, one based on javax.websocket and one on 29 neovisionaries websocket 30 31 32 <h3>Example with javax websocket</h3> 33 The example code is available 34 <a 35 href="https://tracinsy.ewi.tudelft.nl/trac/Genius2ProfilesServer/browser/src/test/java/geniusweb/examples/DownloadProfileExample.java">here</a> 36 and also is part of the JavaClientTest junit test in this project (run with <code>mvn test</code>) 37 To compile that example you need the javax websocket 38 dependency in your pom: 39 <code> 40 <pre> 41 <dependency> 42 <groupId>javax.websocket</groupId> 43 <artifactId>javax.websocket-api</artifactId> 44 <version>1.1</version> 45 </dependency> 46 47 48 </code> 49 </pre> 50 51 52 <h3>Example with neovisionaries websocket</h3> 53 The example code is available 54 <a 55 href="https://tracinsy.ewi.tudelft.nl/trac/Genius2ProfilesServer/browser/src/test/java/geniusweb/examples/DownloadProfileExample.java">here</a> 56 and also is part of the JavaClientTest junit test in this project (run with <code>mvn test</code>) 57 To compile that example you need the neovisionaries websocket 58 dependency in your pom: 59 <code> 60 <pre> 61 <dependency> 62 <groupId>com.neovisionaries</groupId> 63 <artifactId>nv-websocket-client</artifactId> 64 <version>2.6</version> 65 </dependency> 66 67 68 </code> 69 </pre> 17 <p> 18 For creating a profile or adding it to the server please check the <a 19 href="https://tracinsy.ewi.tudelft.nl/pubtrac/GeniusWebProfilesServer">wiki</a>. 20 70 21 </body> 71 22 </html> -
/src/test/java/geniusweb/clienttest/JavaClientTest.java
r1 r3 5 5 6 6 import java.io.IOException; 7 import java.util.HashMap; 7 8 import java.util.LinkedList; 8 9 import java.util.List; 10 import java.util.Map; 9 11 10 12 import org.junit.AfterClass; … … 13 15 import org.python.util.PythonInterpreter; 14 16 17 import com.fasterxml.jackson.core.type.TypeReference; 18 import com.fasterxml.jackson.databind.ObjectMapper; 15 19 import com.neovisionaries.ws.client.WebSocket; 16 20 import com.neovisionaries.ws.client.WebSocketAdapter; … … 56 60 @Test 57 61 public void clientSmokeTest() throws IOException { 58 WebSocketFactory factory = new WebSocketFactory() 59 .setConnectionTimeout(5000); 60 WebSocket ws = factory.createSocket( 61 "ws://localhost:8080/profilesserver/websocket/liststream"); 62 WebSocketFactory factory = new WebSocketFactory().setConnectionTimeout(5000); 63 WebSocket ws = factory.createSocket("ws://localhost:8080/profilesserver/websocket/liststream"); 62 64 } 63 65 64 66 @Test 65 public void testGetList() 66 throws IOException, InterruptedException, WebSocketException { 67 public void testGetList() throws IOException, InterruptedException, WebSocketException { 67 68 final List<String> received = new LinkedList<>(); 68 69 Thread.sleep(5000); 69 WebSocketFactory factory = new WebSocketFactory() 70 .setConnectionTimeout(20000); 71 WebSocket ws = factory.createSocket( 72 "ws://localhost:8080/profilesserver/websocket/liststream"); 70 WebSocketFactory factory = new WebSocketFactory().setConnectionTimeout(20000); 71 WebSocket ws = factory.createSocket("ws://localhost:8080/profilesserver/websocket/liststream"); 73 72 74 73 ws.addListener(new WebSocketAdapter() { 75 74 @Override 76 public void onTextMessage(WebSocket websocket, String message) 77 throws Exception { 75 public void onTextMessage(WebSocket websocket, String message) throws Exception { 78 76 System.out.println("received message: " + message); 79 77 received.add(message); … … 84 82 85 83 Thread.sleep(2000); 86 assertEquals(1, received.size()); 87 assertTrue(received.get(0).matches(JSON)); 88 System.out.println(JSON); 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")); 89 98 } 90 99 91 100 @Test 92 public void testExample() 93 throws WebSocketException, InterruptedException, IOException { 101 public void testExample() throws WebSocketException, InterruptedException, IOException { 94 102 DownloadProfileExample test = new DownloadProfileExample(); 95 103 test.run(); … … 98 106 99 107 @Test 100 public void testExample2() 101 throws WebSocketException, InterruptedException, IOException { 108 public void testExample2() throws WebSocketException, InterruptedException, IOException { 102 109 DownloadProfileExample2 test = new DownloadProfileExample2(); 103 110 assertEquals(JOBS1PROFILE, test.getReceived()); … … 112 119 113 120 // Create factory and coerce Jython calculator object 114 JythonObjectFactory factory = new JythonObjectFactory( 115 WebSocketAdapter.class, "PythonDownloadProfile", 121 JythonObjectFactory factory = new JythonObjectFactory(WebSocketAdapter.class, "PythonDownloadProfile", 116 122 "PythonDownloadProfile"); 117 123 factory.createObject(); -
/src/test/java/geniusweb/profilesserver/AutoUpdatingProfilesFactoryTest.java
r1 r3 119 119 @Test 120 120 public void getDomainsTest() { 121 assertEquals(2, factory.getDomains().size()); 122 assertEquals(JOBS, factory.getDomains().get(0)); 123 assertEquals("7issues", factory.getDomains().get(1)); 121 assertTrue(factory.getDomains().size() > 2); 122 assertTrue(factory.getDomains().contains(JOBS)); 123 assertTrue(factory.getDomains().contains(JOBS)); 124 assertTrue(factory.getDomains().contains("7issues")); 124 125 125 126 } … … 144 145 Thread.sleep(HIGHRATE); 145 146 146 assertEquals( 3, changes.size());147 assertEquals(4, changes.size()); 147 148 assertTrue(changes.get(0) instanceof ProfileChangeEvent); 148 149 assertTrue(changes.get(1) instanceof ProfileChangeEvent); 149 assertTrue(changes.get(2) instanceof DomainChangeEvent); 150 assertTrue(changes.get(2) instanceof ProfileChangeEvent); 151 assertTrue(changes.get(3) instanceof DomainChangeEvent); 150 152 assertEquals(1, warnings.size()); // jobs domain file missing 151 153 assertNull(factory.getDomain(JOBS)); … … 161 163 Thread.sleep(HIGHRATE); 162 164 163 assertEquals( 3, changes.size());165 assertEquals(4, changes.size()); 164 166 assertTrue(changes.get(0) instanceof ProfileChangeEvent); 165 167 assertTrue(changes.get(1) instanceof ProfileChangeEvent); 166 assertTrue(changes.get(2) instanceof DomainChangeEvent); 168 assertTrue(changes.get(2) instanceof ProfileChangeEvent); 169 assertTrue(changes.get(3) instanceof DomainChangeEvent); 167 170 assertEquals(1, warnings.size()); // wrong domain file, wrong profile 168 171 assertNull(factory.getDomain(JOBS)); … … 231 234 assertNull(factory.getProfile(JOB1)); 232 235 233 assertEquals( 3, changes.size());236 assertEquals(4, changes.size()); 234 237 assertTrue(changes.get(0) instanceof ProfileChangeEvent); 235 238 assertTrue(changes.get(1) instanceof ProfileChangeEvent); 236 assertTrue(changes.get(2) instanceof DomainChangeEvent); 239 assertTrue(changes.get(2) instanceof ProfileChangeEvent); 240 assertTrue(changes.get(3) instanceof DomainChangeEvent); 237 241 assertEquals(0, warnings.size()); 238 242 }
Note:
See TracChangeset
for help on using the changeset viewer.