Changeset 10 for profileconnection


Ignore:
Timestamp:
01/28/20 10:19:54 (5 years ago)
Author:
bart
Message:

Update 28 jan 2020

Location:
profileconnection/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • profileconnection/src/main/java/geniusweb/profileconnection/ProfileInterface.java

    r9 r10  
    11package geniusweb.profileconnection;
     2
     3import java.io.IOException;
    24
    35import geniusweb.profile.Profile;
     
    1214         * @return the latest version of the profile. May change at any time, after
    1315         *         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;
    1819}
  • profileconnection/src/main/java/geniusweb/profileconnection/WebsocketProfileConnector.java

    r9 r10  
    6969
    7070        @Override
    71         public Profile getProfile() {
     71        public Profile getProfile() throws IOException {
    7272                int remaining_wait = TIMEOUT_MS;
    7373                try {
     
    8080                                        e);
    8181                }
     82                if (profile == null) {
     83                        throw new IOException("Failed to fetch profile");
     84                }
    8285                return profile;
    8386        }
  • profileconnection/src/test/java/geniusweb/profileconnection/WebsocketProfileConnectorTest.java

    r1 r10  
    33import static org.junit.Assert.assertEquals;
    44import static org.junit.Assert.assertNotNull;
    5 import static org.junit.Assert.assertNull;
    65import static org.mockito.Matchers.any;
    76import static org.mockito.Mockito.mock;
     
    2221
    2322import geniusweb.profile.Profile;
    24 import geniusweb.profileconnection.WebsocketProfileConnector;
    2523import tudelft.utilities.logging.Reporter;
    2624
     
    4240
    4341        @Test
    44         public void testOnOpen()
     42        public void onOpenSmokeTest()
    4543                        throws IOException, DeploymentException, URISyntaxException {
    4644                WebsocketProfileConnector connector = new WebsocketProfileConnector(
    4745                                new URI("ws://someprofile"), reporter, wscontainer);
    4846                connector.onOpen(session);
    49                 assertNull(connector.getProfile());
    5047        }
    5148
     
    9390        }
    9491
    95         @Test
     92        @Test(expected = IOException.class)
    9693        public void testGetProfileTimeout()
    9794                        throws DeploymentException, IOException, URISyntaxException {
     
    116113                        }
    117114                }).start();
    118                 Profile profile = connector.getProfile();
    119                 assertNull(profile);
     115                connector.getProfile();
    120116        }
    121117
Note: See TracChangeset for help on using the changeset viewer.