Skip to content

Commit fc5cdc7

Browse files
committed
Fixed the problem with the integration tests. Turns out the tests were working perfectly and uncovered a defect. -> Removed old, unused connect(...) from Client.
1 parent f7c6a1e commit fc5cdc7

File tree

4 files changed

+9
-18
lines changed

4 files changed

+9
-18
lines changed

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,6 @@ public Client(Session session) {
5656
this.session = session;
5757
}
5858

59-
/**
60-
* Connect to server
61-
*
62-
* @param uri url and port of the server
63-
*/
64-
public void connect(String uri) {
65-
this.connect(uri, null);
66-
}
67-
6859
/**
6960
* Connect to server
7061
*

ocpp-common/src/test/java/eu/chargetime/ocpp/test/ClientTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ public class ClientTest extends TestUtilities {
6060
private Feature feature = mock(Feature.class);
6161
@Mock
6262
private Request request = mock(Request.class);
63+
@Mock
64+
ClientEvents events = mock(ClientEvents.class);
6365

6466
@Before
6567
public void setup() {
@@ -82,7 +84,7 @@ public void connect_connects() {
8284
String someUrl = "localhost";
8385

8486
// When
85-
client.connect(someUrl);
87+
client.connect(someUrl, events);
8688

8789
// Then
8890
verify(session, times(1)).open(eq(someUrl), anyObject());
@@ -91,7 +93,6 @@ public void connect_connects() {
9193
@Test
9294
public void connect_connectionOpenedEvent() {
9395
// Given
94-
ClientEvents events = mock(ClientEvents.class);
9596
client.connect(null, events);
9697

9798
// When
@@ -105,7 +106,6 @@ public void connect_connectionOpenedEvent() {
105106
@Test
106107
public void connect_connectionClosedEvent() {
107108
// Given
108-
ClientEvents events = mock(ClientEvents.class);
109109
client.connect(null, events);
110110

111111
// When
@@ -132,7 +132,7 @@ public void responseReceived_aMessageWasSend_PromiseIsCompleted() throws Excepti
132132
when(session.sendRequest(any(), any())).thenReturn(someUniqueId);
133133

134134
// When
135-
client.connect(null);
135+
client.connect(null, null);
136136
CompletableFuture<Confirmation> promise = client.send(request);
137137
eventHandler.handleConfirmation(someUniqueId, null);
138138

@@ -143,7 +143,7 @@ public void responseReceived_aMessageWasSend_PromiseIsCompleted() throws Excepti
143143
@Test
144144
public void handleRequest_returnsConfirmation() {
145145
// Given
146-
client.connect(null);
146+
client.connect(null, null);
147147
when(feature.handleRequest(null, request)).thenReturn(new TestConfirmation());
148148

149149
// When
@@ -156,7 +156,7 @@ public void handleRequest_returnsConfirmation() {
156156
@Test
157157
public void handleRequest_callsFeatureHandleRequest() {
158158
// Given
159-
client.connect(null);
159+
client.connect(null, null);
160160

161161
// When
162162
eventHandler.handleRequest(request);

ocpp-v1_6-test/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<configuration>
9797
<includes>
9898
<include>**/*Test.java</include>
99-
<!--<include>**/*Spec.java</include>-->
99+
<include>**/*Spec.java</include>
100100
</includes>
101101
</configuration>
102102
</plugin>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ private SOAPClient(SOAPCommunicator communicator) {
7777
* @param uri url and port of the server
7878
*/
7979
@Override
80-
public void connect(String uri) {
80+
public void connect(String uri, ClientEvents events) {
8181
communicator.setToUrl(uri);
82-
super.connect(uri);
82+
super.connect(uri, events);
8383
openWS();
8484
}
8585

0 commit comments

Comments
 (0)