- Location:
- /src
- Files:
-
- 3 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
/src/main/webapp/domainsrepo/7issues/7issues.json
r3 r1 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
r3 r1 9 9 "highValue": 9, 10 10 "highUtility": 0.99 11 11 12 } 12 13 }, … … 17 18 "highValue": 9, 18 19 "highUtility": 0.97 20 19 21 } 20 22 }, … … 25 27 "highValue": 9, 26 28 "highUtility": 0.96 29 27 30 } 28 31 }, … … 33 36 "highValue": 9, 34 37 "highUtility": 0.94 38 35 39 } 36 40 }, … … 41 45 "highValue": 9, 42 46 "highUtility": 0.93 47 43 48 } 44 49 }, … … 49 54 "highValue": 9, 50 55 "highUtility": 0.92 56 51 57 } 52 58 }, … … 57 63 "highValue": 9, 58 64 "highUtility": 0.91 65 59 66 } 60 67 } … … 73 80 "issuesValues": { 74 81 "i1": { 75 "range": [ 76 0, 77 9, 78 1 79 ] 82 "range": ["0", "9", "1"] 80 83 }, 81 84 "i2": { 82 "range": [ 83 0, 84 9, 85 1 86 ] 85 "range": ["0", "9", "1"] 87 86 }, 88 87 "i3": { 89 "range": [ 90 0, 91 9, 92 1 93 ] 88 "range": ["0", "9", "1"] 94 89 }, 95 90 "i4": { 96 "range": [ 97 0, 98 9, 99 1 100 ] 91 "range": ["0", "9", "1"] 101 92 }, 102 93 "i5": { 103 "range": [ 104 0, 105 9, 106 1 107 ] 94 "range": ["0", "9", "1"] 108 95 }, 109 96 "i6": { 110 "range": [ 111 0, 112 9, 113 1 114 ] 97 "range": ["0", "9", "1"] 115 98 }, 116 99 "i7": { 117 "range": [ 118 0, 119 9, 120 1 121 ] 100 "range": ["0", "9", "1"] 122 101 } 123 102 } -
/src/main/webapp/domainsrepo/7issues/7issues2.json
r3 r1 9 9 "highValue": 9, 10 10 "highUtility": 0.11 11 11 12 } 12 13 }, … … 17 18 "highValue": 9, 18 19 "highUtility": 0.21 20 19 21 } 20 22 }, … … 25 27 "highValue": 9, 26 28 "highUtility": 0.13 29 27 30 } 28 31 }, … … 33 36 "highValue": 9, 34 37 "highUtility": 0.14 38 35 39 } 36 40 }, … … 41 45 "highValue": 9, 42 46 "highUtility": 0.15 47 43 48 } 44 49 }, … … 49 54 "highValue": 9, 50 55 "highUtility": 0.16 56 51 57 } 52 58 }, … … 57 63 "highValue": 9, 58 64 "highUtility": 0.17 65 59 66 } 60 67 } … … 73 80 "issuesValues": { 74 81 "i1": { 75 "range": [ 76 0, 77 9, 78 1 79 ] 82 "range": ["0", "9", "1"] 80 83 }, 81 84 "i2": { 82 "range": [ 83 0, 84 9, 85 1 86 ] 85 "range": ["0", "9", "1"] 87 86 }, 88 87 "i3": { 89 "range": [ 90 0, 91 9, 92 1 93 ] 88 "range": ["0", "9", "1"] 94 89 }, 95 90 "i4": { 96 "range": [ 97 0, 98 9, 99 1 100 ] 91 "range": ["0", "9", "1"] 101 92 }, 102 93 "i5": { 103 "range": [ 104 0, 105 9, 106 1 107 ] 94 "range": ["0", "9", "1"] 108 95 }, 109 96 "i6": { 110 "range": [ 111 0, 112 9, 113 1 114 ] 97 "range": ["0", "9", "1"] 115 98 }, 116 99 "i7": { 117 "range": [ 118 0, 119 9, 120 1 121 ] 100 "range": ["0", "9", "1"] 122 101 } 123 102 } -
/src/main/webapp/index.jsp
r3 r1 15 15 these may contain files with errors, and thus are not available for 16 16 use. 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 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> 21 70 </body> 22 71 </html> -
/src/test/java/geniusweb/clienttest/JavaClientTest.java
r3 r1 5 5 6 6 import java.io.IOException; 7 import java.util.HashMap;8 7 import java.util.LinkedList; 9 8 import java.util.List; 10 import java.util.Map;11 9 12 10 import org.junit.AfterClass; … … 15 13 import org.python.util.PythonInterpreter; 16 14 17 import com.fasterxml.jackson.core.type.TypeReference;18 import com.fasterxml.jackson.databind.ObjectMapper;19 15 import com.neovisionaries.ws.client.WebSocket; 20 16 import com.neovisionaries.ws.client.WebSocketAdapter; … … 60 56 @Test 61 57 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"); 64 62 } 65 63 66 64 @Test 67 public void testGetList() throws IOException, InterruptedException, WebSocketException { 65 public void testGetList() 66 throws IOException, InterruptedException, WebSocketException { 68 67 final List<String> received = new LinkedList<>(); 69 68 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"); 72 73 73 74 ws.addListener(new WebSocketAdapter() { 74 75 @Override 75 public void onTextMessage(WebSocket websocket, String message) throws Exception { 76 public void onTextMessage(WebSocket websocket, String message) 77 throws Exception { 76 78 System.out.println("received message: " + message); 77 79 received.add(message); … … 82 84 83 85 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); 98 89 } 99 90 100 91 @Test 101 public void testExample() throws WebSocketException, InterruptedException, IOException { 92 public void testExample() 93 throws WebSocketException, InterruptedException, IOException { 102 94 DownloadProfileExample test = new DownloadProfileExample(); 103 95 test.run(); … … 106 98 107 99 @Test 108 public void testExample2() throws WebSocketException, InterruptedException, IOException { 100 public void testExample2() 101 throws WebSocketException, InterruptedException, IOException { 109 102 DownloadProfileExample2 test = new DownloadProfileExample2(); 110 103 assertEquals(JOBS1PROFILE, test.getReceived()); … … 119 112 120 113 // Create factory and coerce Jython calculator object 121 JythonObjectFactory factory = new JythonObjectFactory(WebSocketAdapter.class, "PythonDownloadProfile", 114 JythonObjectFactory factory = new JythonObjectFactory( 115 WebSocketAdapter.class, "PythonDownloadProfile", 122 116 "PythonDownloadProfile"); 123 117 factory.createObject(); -
/src/test/java/geniusweb/profilesserver/AutoUpdatingProfilesFactoryTest.java
r3 r1 119 119 @Test 120 120 public void getDomainsTest() { 121 assertTrue(factory.getDomains().size() > 2); 122 assertTrue(factory.getDomains().contains(JOBS)); 123 assertTrue(factory.getDomains().contains(JOBS)); 124 assertTrue(factory.getDomains().contains("7issues")); 121 assertEquals(2, factory.getDomains().size()); 122 assertEquals(JOBS, factory.getDomains().get(0)); 123 assertEquals("7issues", factory.getDomains().get(1)); 125 124 126 125 } … … 145 144 Thread.sleep(HIGHRATE); 146 145 147 assertEquals( 4, changes.size());146 assertEquals(3, changes.size()); 148 147 assertTrue(changes.get(0) instanceof ProfileChangeEvent); 149 148 assertTrue(changes.get(1) instanceof ProfileChangeEvent); 150 assertTrue(changes.get(2) instanceof ProfileChangeEvent); 151 assertTrue(changes.get(3) instanceof DomainChangeEvent); 149 assertTrue(changes.get(2) instanceof DomainChangeEvent); 152 150 assertEquals(1, warnings.size()); // jobs domain file missing 153 151 assertNull(factory.getDomain(JOBS)); … … 163 161 Thread.sleep(HIGHRATE); 164 162 165 assertEquals( 4, changes.size());163 assertEquals(3, changes.size()); 166 164 assertTrue(changes.get(0) instanceof ProfileChangeEvent); 167 165 assertTrue(changes.get(1) instanceof ProfileChangeEvent); 168 assertTrue(changes.get(2) instanceof ProfileChangeEvent); 169 assertTrue(changes.get(3) instanceof DomainChangeEvent); 166 assertTrue(changes.get(2) instanceof DomainChangeEvent); 170 167 assertEquals(1, warnings.size()); // wrong domain file, wrong profile 171 168 assertNull(factory.getDomain(JOBS)); … … 234 231 assertNull(factory.getProfile(JOB1)); 235 232 236 assertEquals( 4, changes.size());233 assertEquals(3, changes.size()); 237 234 assertTrue(changes.get(0) instanceof ProfileChangeEvent); 238 235 assertTrue(changes.get(1) instanceof ProfileChangeEvent); 239 assertTrue(changes.get(2) instanceof ProfileChangeEvent); 240 assertTrue(changes.get(3) instanceof DomainChangeEvent); 236 assertTrue(changes.get(2) instanceof DomainChangeEvent); 241 237 assertEquals(0, warnings.size()); 242 238 }
Note:
See TracChangeset
for help on using the changeset viewer.