Changeset 9 for simplerunner/src
- Timestamp:
- 11/28/19 14:40:48 (5 years ago)
- Location:
- simplerunner/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
simplerunner/src/main/java/geniusweb/simplerunner/BasicConnection.java
r1 r9 4 4 import java.net.URI; 5 5 6 import geniusweb.connection.Connection ;6 import geniusweb.connection.ConnectionEnd; 7 7 import geniusweb.references.Reference; 8 8 import tudelft.utilities.listener.DefaultListenable; … … 17 17 */ 18 18 public class BasicConnection<IN, OUT> extends DefaultListenable<IN> 19 implements Connection <IN, OUT> {19 implements ConnectionEnd<IN, OUT> { 20 20 private final Reference reference; 21 21 private final URI uri; -
simplerunner/src/main/java/geniusweb/simplerunner/ClassPathConnectionFactory.java
r1 r9 13 13 import geniusweb.party.Party; 14 14 import geniusweb.party.inform.Inform; 15 import geniusweb.protocol.partyconnection. ConnectionWithParty;16 import geniusweb.protocol.partyconnection. ConnectionWithPartyFactory;15 import geniusweb.protocol.partyconnection.ProtocolToPartyConn; 16 import geniusweb.protocol.partyconnection.ProtocolToPartyConnFactory; 17 17 import geniusweb.references.Reference; 18 18 import tudelft.utilities.repository.NoResourcesNowException; … … 25 25 * 26 26 */ 27 public class ClassPathConnectionFactory implements ConnectionWithPartyFactory {27 public class ClassPathConnectionFactory implements ProtocolToPartyConnFactory { 28 28 private static final String SCHEME = "classpath"; 29 29 private static int serialcounter = 1; … … 31 31 32 32 @Override 33 public ConnectionWithPartyconnect(Reference reference) {33 public ProtocolToPartyConn connect(Reference reference) { 34 34 // set up the whole other party including the connection to it. 35 35 String classpath = getClassPath(reference.getURI()); … … 42 42 uri("classpath:" + reference.getURI().getSchemeSpecificPart() 43 43 + "." + (serialcounter++))); 44 party2protocol.init(action -> protocol2party.notify Change(action));45 protocol2party.init(info -> party2protocol.notify Change(info));44 party2protocol.init(action -> protocol2party.notifyListeners(action)); 45 protocol2party.init(info -> party2protocol.notifyListeners(info)); 46 46 47 47 party.connect(party2protocol); … … 102 102 103 103 @Override 104 public List< ConnectionWithParty> connect(List<Reference> references)104 public List<ProtocolToPartyConn> connect(List<Reference> references) 105 105 throws IOException, NoResourcesNowException { 106 List< ConnectionWithParty> connections = new LinkedList<>();106 List<ProtocolToPartyConn> connections = new LinkedList<>(); 107 107 for (Reference partyref : references) { 108 108 connections.add(connect(partyref)); … … 114 114 115 115 class BasicConnectionWithParty extends BasicConnection<Action, Inform> 116 implements ConnectionWithParty{116 implements ProtocolToPartyConn { 117 117 118 118 private PartyId id; -
simplerunner/src/main/java/geniusweb/simplerunner/NegoRunner.java
r1 r9 13 13 import geniusweb.protocol.NegoProtocol; 14 14 import geniusweb.protocol.NegoSettings; 15 import geniusweb.protocol.partyconnection. ConnectionWithPartyFactory;15 import geniusweb.protocol.partyconnection.ProtocolToPartyConnFactory; 16 16 import geniusweb.protocol.session.SessionSettings; 17 17 import tudelft.utilities.logging.ReportToLogger; … … 27 27 private final NegoSettings settings; 28 28 private final NegoProtocol protocol; 29 private final ConnectionWithPartyFactory connectionfactory;29 private final ProtocolToPartyConnFactory connectionfactory; 30 30 private final Reporter log; 31 31 private final static ObjectMapper jackson = new ObjectMapper(); 32 32 33 33 public NegoRunner(NegoSettings settings, 34 ConnectionWithPartyFactory connectionfactory, Reporter logger) {34 ProtocolToPartyConnFactory connectionfactory, Reporter logger) { 35 35 if (settings == null || connectionfactory == null) { 36 36 throw new NullPointerException("Arguments must be not null"); -
simplerunner/src/test/java/geniusweb/simplerunner/ClassPathConnectionFactoryTest.java
r1 r9 10 10 11 11 import geniusweb.actions.Action; 12 import geniusweb.connection.Connection ;12 import geniusweb.connection.ConnectionEnd; 13 13 import geniusweb.party.inform.Inform; 14 14 import geniusweb.references.PartyRef; … … 42 42 @Test 43 43 public void testRandomParty() throws IOException, URISyntaxException { 44 Connection <Action, Inform> party = factory.connect(new PartyRef(44 ConnectionEnd<Action, Inform> party = factory.connect(new PartyRef( 45 45 "classpath:geniusweb.exampleparties.randomparty.RandomParty")); 46 46 assertNotNull(party); -
simplerunner/src/test/java/geniusweb/simplerunner/SessionRunnerTest.java
r1 r9 18 18 import geniusweb.protocol.CurrentNegoState; 19 19 import geniusweb.protocol.ProtocolException; 20 import geniusweb.protocol.partyconnection. ConnectionWithPartyFactory;20 import geniusweb.protocol.partyconnection.ProtocolToPartyConnFactory; 21 21 import geniusweb.protocol.session.SessionProtocol; 22 22 import geniusweb.protocol.session.SessionSettings; … … 47 47 public void smokeTest() { 48 48 new NegoRunner(mock(SessionSettings.class), 49 mock( ConnectionWithPartyFactory.class), logger);49 mock(ProtocolToPartyConnFactory.class), logger); 50 50 } 51 51 … … 56 56 when(settings.getProtocol(logger)).thenReturn(protocol); 57 57 @SuppressWarnings("unchecked") 58 ConnectionWithPartyFactory factory = mock(59 ConnectionWithPartyFactory.class);58 ProtocolToPartyConnFactory factory = mock( 59 ProtocolToPartyConnFactory.class); 60 60 61 61 NegoRunner runner = spy( … … 80 80 Reporter logger = mock(Reporter.class); 81 81 @SuppressWarnings("unchecked") 82 ConnectionWithPartyFactory factory = mock(83 ConnectionWithPartyFactory.class);82 ProtocolToPartyConnFactory factory = mock( 83 ProtocolToPartyConnFactory.class); 84 84 NegoRunner runner = spy( 85 85 new NegoRunner(settings, factory, logger)); … … 107 107 when(protocol.getState()).thenReturn(state); 108 108 @SuppressWarnings("unchecked") 109 ConnectionWithPartyFactory factory = mock(110 ConnectionWithPartyFactory.class);109 ProtocolToPartyConnFactory factory = mock( 110 ProtocolToPartyConnFactory.class); 111 111 NegoRunner runner = spy( 112 112 new NegoRunner(settings, factory, logger));
Note:
See TracChangeset
for help on using the changeset viewer.