Skip to content

Commit 59f3aa6

Browse files
committed
Trying to fix integration tests
1 parent 6e2f96a commit 59f3aa6

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

ocpp-common/src/main/java/eu/chargetime/ocpp/Communicator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public void accept(CommunicatorEvents events) {
148148
* @param action action name of the {@link eu.chargetime.ocpp.feature.Feature}.
149149
* @param request the outgoing {@link Request}
150150
*/
151-
public void sendCall(String uniqueId, String action, Request request) {
151+
synchronized public void sendCall(String uniqueId, String action, Request request) {
152152
Object call = makeCall(uniqueId, action, packPayload(request));
153153
try {
154154
if (request.transactionRelated() && transactionQueue.size() > 0) {

ocpp-common/src/main/java/eu/chargetime/ocpp/Session.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public void onCallResult(String id, String action, Object payload) {
134134
}
135135

136136
@Override
137-
public void onCall(String id, String action, Object payload) {
137+
synchronized public void onCall(String id, String action, Object payload) {
138138
Feature feature = events.findFeatureByAction(action);
139139
if (feature == null) {
140140
communicator.sendCallError(id, action, "NotImplemented", "Requested Action is not known by receiver");

ocpp-v1_6/src/main/java/eu/chargetime/ocpp/TimeoutSession.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public void handleConfirmation(String uniqueId, Confirmation confirmation) {
102102
}
103103

104104
@Override
105-
public Confirmation handleRequest(Request request) {
105+
synchronized public Confirmation handleRequest(Request request) {
106106
resetTimer();
107107
Confirmation confirmation = eventHandler.handleRequest(request);
108108

ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/TimeoutSessionTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ public class TimeoutSessionTest {
6060
public void setup() throws Exception {
6161
when(sessionEvents.findFeatureByAction(any())).thenReturn(feature);
6262
when(sessionEvents.findFeatureByRequest(any())).thenReturn(feature);
63-
session = new TimeoutSession(communicator, queue);
6463
doAnswer(invocation -> eventHandler = invocation.getArgumentAt(1, CommunicatorEvents.class)).when(communicator).connect(any(), any());
6564
doAnswer(invocation -> eventHandler = invocation.getArgumentAt(0, CommunicatorEvents.class)).when(communicator).accept(any());
6665

66+
session = new TimeoutSession(communicator, queue);
6767
session.setTimeoutTimer(timeoutTimer);
6868
}
6969

@@ -118,8 +118,8 @@ public void onDisconnected_accepted_endTimeout() throws Exception {
118118
@Test
119119
public void onCall_request_resetTimeout() throws Exception {
120120
// Given
121-
session.open(null, sessionEvents);
122121
when(communicator.unpackPayload(any(), any())).thenReturn(new TestRequest());
122+
session.open(null, sessionEvents);
123123

124124
// When
125125
eventHandler.onCall("", null, null);
@@ -131,8 +131,8 @@ public void onCall_request_resetTimeout() throws Exception {
131131
@Test
132132
public void onCall_confirmation_resetTimeout() throws Exception {
133133
// Given
134-
session.open(null, sessionEvents);
135134
when(communicator.unpackPayload(any(), any())).thenReturn(new TestConfirmation());
135+
session.open(null, sessionEvents);
136136

137137
// When
138138
eventHandler.onCallResult("", null, null);

0 commit comments

Comments
 (0)