Changeset 10 for profileconnection/src
- Timestamp:
- 01/28/20 10:19:54 (5 years ago)
- Location:
- profileconnection/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
profileconnection/src/main/java/geniusweb/profileconnection/ProfileInterface.java
r9 r10 1 1 package geniusweb.profileconnection; 2 3 import java.io.IOException; 2 4 3 5 import geniusweb.profile.Profile; … … 12 14 * @return the latest version of the profile. May change at any time, after 13 15 * someone updates the version on the server. Call to this may block 14 * for limited time if the profile is not yet available. May return 15 * null if the profile is not available. 16 */ 17 public Profile getProfile(); 16 * for limited time if the profile is not yet available. 17 * @throws IOException if profile can not be fetched */ 18 public Profile getProfile() throws IOException; 18 19 } -
profileconnection/src/main/java/geniusweb/profileconnection/WebsocketProfileConnector.java
r9 r10 69 69 70 70 @Override 71 public Profile getProfile() {71 public Profile getProfile() throws IOException { 72 72 int remaining_wait = TIMEOUT_MS; 73 73 try { … … 80 80 e); 81 81 } 82 if (profile == null) { 83 throw new IOException("Failed to fetch profile"); 84 } 82 85 return profile; 83 86 } -
profileconnection/src/test/java/geniusweb/profileconnection/WebsocketProfileConnectorTest.java
r1 r10 3 3 import static org.junit.Assert.assertEquals; 4 4 import static org.junit.Assert.assertNotNull; 5 import static org.junit.Assert.assertNull;6 5 import static org.mockito.Matchers.any; 7 6 import static org.mockito.Mockito.mock; … … 22 21 23 22 import geniusweb.profile.Profile; 24 import geniusweb.profileconnection.WebsocketProfileConnector;25 23 import tudelft.utilities.logging.Reporter; 26 24 … … 42 40 43 41 @Test 44 public void testOnOpen()42 public void onOpenSmokeTest() 45 43 throws IOException, DeploymentException, URISyntaxException { 46 44 WebsocketProfileConnector connector = new WebsocketProfileConnector( 47 45 new URI("ws://someprofile"), reporter, wscontainer); 48 46 connector.onOpen(session); 49 assertNull(connector.getProfile());50 47 } 51 48 … … 93 90 } 94 91 95 @Test 92 @Test(expected = IOException.class) 96 93 public void testGetProfileTimeout() 97 94 throws DeploymentException, IOException, URISyntaxException { … … 116 113 } 117 114 }).start(); 118 Profile profile = connector.getProfile(); 119 assertNull(profile); 115 connector.getProfile(); 120 116 } 121 117
Note:
See TracChangeset
for help on using the changeset viewer.