Changeset 21 for simplerunner/src/test
- Timestamp:
- 09/22/20 08:52:04 (4 years ago)
- Location:
- simplerunner/src/test
- Files:
-
- 1 added
- 6 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 -
simplerunner/src/test/resources/jobs/jobs1.json
r1 r21 34 34 "discreteutils": { 35 35 "valueUtilities": { 36 "yes": 1,37 "no": 036 "yes": 1, 37 "no": 0 38 38 } 39 39 } … … 42 42 "discreteutils": { 43 43 "valueUtilities": { 44 "yes": 1,45 "no": 044 "yes": 1, 45 "no": 0 46 46 } 47 47 } … … 50 50 "discreteutils": { 51 51 "valueUtilities": { 52 "low": 0,53 "medium": 0.5,54 "high": 152 "low": 0, 53 "medium": 0.5, 54 "high": 1 55 55 } 56 56 } … … 112 112 } 113 113 }, 114 "name": "jobs1" 114 "name": "jobs1", 115 "reservationBid": { 116 "issuevalues": { 117 "salary": "3500", 118 "fte": "0.8", 119 "work from home": "1", 120 "lease car": "no", 121 "permanent contract": "yes", 122 "career development opportunities": "medium" 123 } 124 } 115 125 } 116 126 } -
simplerunner/src/test/resources/jobs/jobs2.json
r1 r21 34 34 "discreteutils": { 35 35 "valueUtilities": { 36 "yes": 0,37 "no": 136 "yes": 0, 37 "no": 1 38 38 } 39 39 } … … 42 42 "discreteutils": { 43 43 "valueUtilities": { 44 "yes": 0.23809523809523808,45 "no": 0.76190476190476244 "yes": 0.23809523809523808, 45 "no": 0.761904761904762 46 46 } 47 47 } … … 50 50 "discreteutils": { 51 51 "valueUtilities": { 52 "low": 1.0,53 "medium": 0.5,54 "high": 052 "low": 1.0, 53 "medium": 0.5, 54 "high": 0 55 55 } 56 56 } … … 112 112 } 113 113 }, 114 "name": "jobs2" 114 "name": "jobs2", 115 "reservationBid": { 116 "issuevalues": { 117 "salary": "3000", 118 "fte": "0.8", 119 "work from home": "0", 120 "lease car": "no", 121 "permanent contract": "no", 122 "career development opportunities": "medium" 123 } 124 } 115 125 } 116 126 } -
simplerunner/src/test/resources/shaoptoursettings.json
r18 r21 34 34 { 35 35 "ProfileList": [ 36 "file:src/test/resources/jobs/jobs1partial.json ?partial=10",36 "file:src/test/resources/jobs/jobs1partial.json", 37 37 "file:src/test/resources/jobs/jobs1partial.json" 38 38 … … 41 41 { 42 42 "ProfileList": [ 43 "file:src/test/resources/jobs/jobs2.json ?partial=15",43 "file:src/test/resources/jobs/jobs2.json", 44 44 "file:src/test/resources/jobs/jobs2.json" 45 45 … … 55 55 "deadlinerounds": { 56 56 "rounds": 10, 57 "durationms": 1000 057 "durationms": 1000 58 58 } 59 59 }
Note:
See TracChangeset
for help on using the changeset viewer.