Changeset 21 for simplerunner/src/test/java/geniusweb
- Timestamp:
- 09/22/20 08:52:04 (4 years ago)
- Location:
- simplerunner/src/test/java/geniusweb/simplerunner
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
simplerunner/src/test/java/geniusweb/simplerunner/ClassPathConnectionFactoryTest.java
r9 r21 11 11 import geniusweb.actions.Action; 12 12 import geniusweb.connection.ConnectionEnd; 13 import geniusweb. party.inform.Inform;13 import geniusweb.inform.Inform; 14 14 import geniusweb.references.PartyRef; 15 import geniusweb.simplerunner.ClassPathConnectionFactory;16 15 17 16 public class ClassPathConnectionFactoryTest { -
simplerunner/src/test/java/geniusweb/simplerunner/SessionRunnerE2ETest.java
r10 r21 1 1 package geniusweb.simplerunner; 2 3 import static org.junit.Assert.assertTrue; 2 4 3 5 import java.io.IOException; … … 27 29 @RunWith(Parameterized.class) 28 30 public class SessionRunnerE2ETest { 31 private static final int TEST_RUNTIME = 5000; 29 32 private final ObjectMapper jackson = new ObjectMapper(); 30 33 private NegoRunner runner; … … 37 40 .asList(new Object[][] { { "src/test/resources/settings.json" }, 38 41 { "src/test/resources/settings2.json" }, 39 { "src/test/resources/shaoptoursettings.json" } }); 42 { "src/test/resources/shaoptoursettings.json" }, 43 { "src/test/resources/mopac.json" } }); 40 44 } 41 45 … … 53 57 54 58 runner = new NegoRunner(settings, new ClassPathConnectionFactory(), 55 logger );59 logger, TEST_RUNTIME); 56 60 57 61 } … … 64 68 public void runTest() throws IOException { 65 69 runner.run(); 70 assertTrue(runner.isProperlyStopped()); 71 System.out.println("Final state:\n" + runner.getProtocol().getState()); 66 72 } 67 73 -
simplerunner/src/test/java/geniusweb/simplerunner/SessionRunnerTest.java
r18 r21 16 16 import org.mockito.ArgumentCaptor; 17 17 18 import geniusweb.actions.PartyId; 18 19 import geniusweb.protocol.CurrentNegoState; 19 20 import geniusweb.protocol.NegoState; … … 29 30 public class SessionRunnerTest { 30 31 private static final ProtocolException PROTOCOL_EXC = new ProtocolException( 31 "fake protocol exception", "test");32 "fake protocol exception", new PartyId("test")); 32 33 private CurrentNegoState finishedEvent; 33 34 private final long NOW = 1000; … … 47 48 public void smokeTest() { 48 49 new NegoRunner(mock(SessionSettings.class), 49 mock(ProtocolToPartyConnFactory.class), logger );50 mock(ProtocolToPartyConnFactory.class), logger, 5000); 50 51 } 51 52 … … 59 60 ProtocolToPartyConnFactory.class); 60 61 61 NegoRunner runner = spy(new NegoRunner(settings, factory, logger)); 62 NegoRunner runner = spy( 63 new NegoRunner(settings, factory, logger, 5000)); 62 64 runner.run(); 63 65 … … 75 77 when(settings.getProtocol(any())).thenReturn(protocol); 76 78 SessionState state = mock(SessionState.class); 77 when(state.getError()).thenReturn(null);78 79 when(protocol.getState()).thenReturn(state); 79 80 Reporter logger = mock(Reporter.class); … … 81 82 ProtocolToPartyConnFactory factory = mock( 82 83 ProtocolToPartyConnFactory.class); 83 NegoRunner runner = spy(new NegoRunner(settings, factory, logger) { 84 @Override 85 protected void logFinal(Level level, NegoState state) { 86 log.log(level, state.toString()); 87 } 88 }); 84 NegoRunner runner = spy( 85 new NegoRunner(settings, factory, logger, 5000) { 86 @Override 87 protected void logFinal(Level level, NegoState state) { 88 log.log(level, state.toString()); 89 } 90 }); 89 91 ArgumentCaptor<Listener> listener = ArgumentCaptor 90 92 .forClass(Listener.class); … … 107 109 when(settings.getProtocol(any())).thenReturn(protocol); 108 110 SessionState state = mock(SessionState.class); 109 when(state.getError()).thenReturn(PROTOCOL_EXC);110 111 when(protocol.getState()).thenReturn(state); 111 112 @SuppressWarnings("unchecked") 112 113 ProtocolToPartyConnFactory factory = mock( 113 114 ProtocolToPartyConnFactory.class); 114 NegoRunner runner = spy(new NegoRunner(settings, factory, logger) { 115 @Override 116 protected void logFinal(Level level, NegoState state) { 117 log.log(level, state.toString()); 118 } 119 }); 115 NegoRunner runner = spy( 116 new NegoRunner(settings, factory, logger, 5000) { 117 @Override 118 protected void logFinal(Level level, NegoState state) { 119 log.log(level, state.toString()); 120 } 121 }); 120 122 ArgumentCaptor<Listener> listener = ArgumentCaptor 121 123 .forClass(Listener.class); … … 126 128 listener.getValue().notifyChange(finishedEvent); 127 129 verify(runner, times(1)).stop(); 128 // check that the protocol error is logged properly 129 verify(logger, times(1)).log(eq(Level.WARNING), any(String.class)); 130 // check final state is logged 131 String statestr = state.toString(); 132 verify(logger, times(1)).log(any(), eq(statestr)); 133 130 134 } 131 135
Note:
See TracChangeset
for help on using the changeset viewer.