Skip to content

Commit f6af5d3

Browse files
authored
Merge pull request ChargeTimeEU#162 from MauroBono/patch-1
JSON Server and Client example application
2 parents 7b39c32 + 9462c0b commit f6af5d3

File tree

28 files changed

+939
-1
lines changed

28 files changed

+939
-1
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Example Applications of JSON Server and a JSON Client

ocpp-v1_6-example/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
HELP.md
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**/target/
5+
!**/src/test/**/target/
6+
7+
mvnw
8+
mvnw.cmd
9+
.mvn/
10+
11+
### STS ###
12+
.apt_generated
13+
.classpath
14+
.factorypath
15+
.project
16+
.settings
17+
.springBeans
18+
.sts4-cache
19+
20+
### IntelliJ IDEA ###
21+
.idea
22+
*.iws
23+
*.iml
24+
*.ipr
25+
26+
### NetBeans ###
27+
/nbproject/private/
28+
/nbbuild/
29+
/dist/
30+
/nbdist/
31+
/.nb-gradle/
32+
build/
33+
!**/src/main/**/build/
34+
!**/src/test/**/build/
35+
36+
### VS Code ###
37+
.vscode/
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>2.5.6</version>
9+
<relativePath/> <!-- lookup parent from repository -->
10+
</parent>
11+
<groupId>eu.chargetime.ocpp</groupId>
12+
<artifactId>json-client-implementation</artifactId>
13+
<version>0.0.1-SNAPSHOT</version>
14+
<name>json-client-implementation</name>
15+
<description>Demo project for a json client application, written in form of tests</description>
16+
<properties>
17+
<java.version>11</java.version>
18+
</properties>
19+
<dependencies>
20+
<dependency>
21+
<groupId>org.springframework.boot</groupId>
22+
<artifactId>spring-boot-starter</artifactId>
23+
</dependency>
24+
25+
<dependency>
26+
<groupId>org.springframework.boot</groupId>
27+
<artifactId>spring-boot-starter-test</artifactId>
28+
<scope>test</scope>
29+
</dependency>
30+
31+
<dependency>
32+
<groupId>org.projectlombok</groupId>
33+
<artifactId>lombok</artifactId>
34+
<optional>true</optional>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.java-websocket</groupId>
38+
<artifactId>Java-WebSocket</artifactId>
39+
<version>1.5.1</version>
40+
</dependency>
41+
<dependency>
42+
<groupId>com.google.code.gson</groupId>
43+
<artifactId>gson</artifactId>
44+
<version>2.8.8</version>
45+
</dependency>
46+
<dependency>
47+
<groupId>eu.chargetime.ocpp</groupId>
48+
<artifactId>v1_6</artifactId>
49+
<version>1.0.1</version>
50+
</dependency>
51+
<dependency>
52+
<groupId>org.testng</groupId>
53+
<artifactId>testng</artifactId>
54+
<version>RELEASE</version>
55+
<scope>test</scope>
56+
</dependency>
57+
<dependency>
58+
<groupId>junit</groupId>
59+
<artifactId>junit</artifactId>
60+
<scope>test</scope>
61+
</dependency>
62+
</dependencies>
63+
64+
<build>
65+
<plugins>
66+
<plugin>
67+
<groupId>org.springframework.boot</groupId>
68+
<artifactId>spring-boot-maven-plugin</artifactId>
69+
<configuration>
70+
<excludes>
71+
<exclude>
72+
<groupId>org.projectlombok</groupId>
73+
<artifactId>lombok</artifactId>
74+
</exclude>
75+
</excludes>
76+
</configuration>
77+
</plugin>
78+
</plugins>
79+
</build>
80+
81+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package eu.chargetime.ocpp.jsonclientimplementation;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class JsonClientImplementationApplication {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(JsonClientImplementationApplication.class, args);
11+
}
12+
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package eu.chargetime.ocpp.jsonclientimplementation.config;
2+
3+
import lombok.Getter;
4+
import lombok.Setter;
5+
import org.springframework.beans.factory.annotation.Value;
6+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
7+
import org.springframework.context.annotation.Configuration;
8+
9+
@Configuration
10+
@EnableConfigurationProperties
11+
@Getter
12+
@Setter
13+
public class ApiConfigurations {
14+
15+
@Value("${websocket.url}")
16+
private String webSocketBaseUrl;
17+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
websocket:
2+
url: "${WEB_SOCKET_URL:localhost:8080}"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package eu.chargetime.ocpp.jsonclientimplementation;
2+
3+
import org.junit.jupiter.api.Test;
4+
import org.springframework.boot.test.context.SpringBootTest;
5+
6+
@SpringBootTest
7+
class JsonClientImplementationApplicationTests {
8+
9+
@Test
10+
void contextLoads() {
11+
}
12+
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package eu.chargetime.ocpp.jsonclientimplementation.ocpphandler;
2+
3+
import eu.chargetime.ocpp.feature.profile.ClientCoreEventHandler;
4+
import eu.chargetime.ocpp.model.core.*;
5+
import lombok.extern.slf4j.Slf4j;
6+
import org.springframework.boot.test.context.TestConfiguration;
7+
import org.springframework.context.annotation.Bean;
8+
9+
@TestConfiguration
10+
@Slf4j
11+
public class ClientCoreEventHandlerConfig {
12+
13+
@Bean
14+
public ClientCoreEventHandler configTestClient() {
15+
return new ClientCoreEventHandler() {
16+
@Override
17+
public ChangeAvailabilityConfirmation handleChangeAvailabilityRequest(ChangeAvailabilityRequest request) {
18+
19+
System.out.println(request);
20+
// ... handle event
21+
22+
return new ChangeAvailabilityConfirmation(AvailabilityStatus.Accepted);
23+
}
24+
25+
@Override
26+
public GetConfigurationConfirmation handleGetConfigurationRequest(GetConfigurationRequest request) {
27+
28+
System.out.println(request);
29+
// ... handle event
30+
31+
return null; // returning null means unsupported feature
32+
}
33+
34+
@Override
35+
public ChangeConfigurationConfirmation handleChangeConfigurationRequest(ChangeConfigurationRequest request) {
36+
37+
System.out.println(request);
38+
// ... handle event
39+
40+
return null; // returning null means unsupported feature
41+
}
42+
43+
@Override
44+
public ClearCacheConfirmation handleClearCacheRequest(ClearCacheRequest request) {
45+
46+
System.out.println(request);
47+
// ... handle event
48+
49+
return null; // returning null means unsupported feature
50+
}
51+
52+
@Override
53+
public DataTransferConfirmation handleDataTransferRequest(DataTransferRequest request) {
54+
55+
System.out.println(request);
56+
// ... handle event
57+
58+
return null; // returning null means unsupported feature
59+
}
60+
61+
@Override
62+
public RemoteStartTransactionConfirmation handleRemoteStartTransactionRequest(RemoteStartTransactionRequest request) {
63+
64+
System.out.println(request);
65+
// ... handle event
66+
67+
return null; // returning null means unsupported feature
68+
}
69+
70+
@Override
71+
public RemoteStopTransactionConfirmation handleRemoteStopTransactionRequest(RemoteStopTransactionRequest request) {
72+
73+
System.out.println(request);
74+
// ... handle event
75+
76+
return null; // returning null means unsupported feature
77+
}
78+
79+
@Override
80+
public ResetConfirmation handleResetRequest(ResetRequest request) {
81+
82+
System.out.println(request);
83+
// ... handle event
84+
85+
return null; // returning null means unsupported feature
86+
}
87+
88+
@Override
89+
public UnlockConnectorConfirmation handleUnlockConnectorRequest(UnlockConnectorRequest request) {
90+
91+
System.out.println(request);
92+
// ... handle event
93+
94+
return null; // returning null means unsupported feature
95+
}
96+
};
97+
}
98+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package eu.chargetime.ocpp.jsonclientimplementation.ocpphandler;
2+
3+
import eu.chargetime.ocpp.feature.profile.ClientCoreEventHandler;
4+
import eu.chargetime.ocpp.feature.profile.ClientCoreProfile;
5+
import lombok.extern.slf4j.Slf4j;
6+
import org.springframework.boot.test.context.TestConfiguration;
7+
import org.springframework.context.annotation.Bean;
8+
9+
@TestConfiguration
10+
@Slf4j
11+
public class ClientCoreProfileConfig {
12+
13+
@Bean
14+
public ClientCoreProfile configureClientCoreProfile(ClientCoreEventHandler clientCoreEventHandler) {
15+
return new ClientCoreProfile(clientCoreEventHandler);
16+
}
17+
}

0 commit comments

Comments
 (0)