Skip to content

Commit ff4145b

Browse files
committed
Remove testcontainers; use JDK 11 for tests
1 parent 31cd42a commit ff4145b

File tree

6 files changed

+140
-401
lines changed

6 files changed

+140
-401
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG BUILD_IMAGE=gradle:7.4-jdk17-alpine
2-
ARG RUN_IMAGE=tomcat:9.0.39-jdk8-adoptopenjdk-hotspot
2+
ARG RUN_IMAGE=tomcat:9.0.68-jdk11-temurin
33

44
################## Stage 0
55
FROM ${BUILD_IMAGE} as builder

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ A gateway server and accompanying JavaScript client API to monitor EPICS Channel
1010
- [API](https://github.com/JeffersonLab/epics2web#api)
1111
- [Configure](https://github.com/JeffersonLab/epics2web#configure)
1212
- [Build](https://github.com/JeffersonLab/epics2web#build)
13+
- [Test](https://github.com/JeffersonLab/epics2web#test)
1314
- [Release](https://github.com/JeffersonLab/epics2web#release)
1415
- [See Also](https://github.com/JeffersonLab/epics2web#see-also)
1516
---
@@ -53,7 +54,7 @@ PV name: `HELLO`
5354
This application uses the [Java Channel Access](https://github.com/epics-base/jca) library. It requires a working EPICS channel access environment with the environment variable *EPICS_CA_ADDR_LIST* set. See Also: [Advanced Configuration](https://github.com/JeffersonLab/epics2web/wiki/Advanced-Configuration).
5455

5556
## Build
56-
This project is built with [Java 17](https://adoptium.net/) (compiled to Java 8 bytecode), and uses the [Gradle 7](https://gradle.org/) build tool to automatically download dependencies and build the project from source:
57+
This project is built with [Java 17](https://adoptium.net/) (compiled to Java 11 bytecode), and uses the [Gradle 7](https://gradle.org/) build tool to automatically download dependencies and build the project from source:
5758

5859
```
5960
git clone https://github.com/JeffersonLab/epics2web
@@ -66,6 +67,14 @@ gradlew build
6667

6768
**See**: [Docker Development Quick Reference](https://gist.github.com/slominskir/a7da801e8259f5974c978f9c3091d52c#development-quick-reference)
6869

70+
## Test
71+
```
72+
docker compose -f build.yml up
73+
```
74+
Wait for containers to start then:
75+
```
76+
gradlew integrationTest
77+
```
6978
## Release
7079
1. Bump the version number and release date in build.gradle and commit and push to GitHub (using [Semantic Versioning](https://semver.org/)).
7180
2. Create a new release on the GitHub [Releases](https://github.com/JeffersonLab/epics2web/releases) page corresponding to same version in build.gradle (Enumerate changes and link issues). Attach war file for users to download.

build.gradle

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,30 @@ plugins {
55

66
description = "EPICS to web gateway"
77
group 'org.jlab'
8-
version '1.13.0'
8+
version '1.14.0'
99

1010
ext {
11-
releaseDate = 'March 21 2022'
11+
releaseDate = 'Nov 9 2022'
1212
productionRelease = 'true'
1313
}
1414

15-
repositories {
16-
mavenCentral()
15+
compileJava {
16+
options.release = 8
17+
}
18+
19+
compileTestJava {
20+
options.release = 11
1721
}
1822

1923
tasks.withType(JavaCompile) {
20-
options.release = 8
2124
options.encoding = 'UTF-8'
2225
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
2326
}
2427

28+
repositories {
29+
mavenCentral()
30+
}
31+
2532
sourceSets {
2633
integration {
2734
java.srcDir "${projectDir}/src/integration/java"
@@ -32,22 +39,17 @@ sourceSets {
3239
}
3340

3441
configurations {
35-
testImplementation.extendsFrom compileOnly
36-
integrationImplementation.extendsFrom implementation
42+
integrationImplementation.extendsFrom testImplementation
3743
integrationRuntimeOnly.extendsFrom runtimeOnly
3844
}
3945

4046
dependencies {
4147
implementation 'javax.servlet:jstl:1.2',
4248
'org.glassfish:javax.json:1.1.4',
43-
files('lib/jca-2.4.6.jar')
44-
//implementation 'org.epics:jca:2.4.6' // Only works with Java 11 runtime
45-
providedCompile 'javax:javaee-api:7.0'
46-
47-
testImplementation 'junit:junit:4.13'
49+
'org.epics:jca:2.4.7'
50+
providedCompile 'javax:javaee-api:8.0.1'
4851

49-
integrationImplementation 'org.testcontainers:testcontainers:1.16.3',
50-
'org.slf4j:slf4j-log4j12:1.7.28'
52+
testImplementation 'junit:junit:4.13.2'
5153
}
5254

5355
task integrationTest(type: Test) {
@@ -56,17 +58,10 @@ task integrationTest(type: Test) {
5658

5759
testClassesDirs = sourceSets.integration.output.classesDirs
5860
classpath = sourceSets.integration.runtimeClasspath
59-
//shouldRunAfter test
60-
61-
testLogging {
62-
showStandardStreams = true
63-
}
64-
}
65-
66-
test {
67-
classpath = project.sourceSets.test.runtimeClasspath + files("${projectDir}/examples/softioc-db")
6861

6962
testLogging {
63+
events "passed", "skipped", "failed"
64+
exceptionFormat "full"
7065
showStandardStreams = true
7166
}
7267
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package org.jlab.epics2web;
2+
3+
import org.junit.Test;
4+
5+
import javax.json.Json;
6+
import javax.json.JsonArray;
7+
import javax.json.JsonObject;
8+
import javax.json.JsonReader;
9+
import java.io.IOException;
10+
import java.io.StringReader;
11+
import java.net.URI;
12+
import java.net.http.HttpClient;
13+
import java.net.http.HttpRequest;
14+
import java.net.http.HttpResponse;
15+
16+
import static org.junit.Assert.assertEquals;
17+
18+
public class GetTest {
19+
@Test
20+
public void doTest() throws IOException, InterruptedException {
21+
HttpClient client = HttpClient.newHttpClient();
22+
HttpRequest request = HttpRequest.newBuilder().uri(URI.create("http://localhost:8080/epics2web/caget?pv=channel1")).build();
23+
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
24+
25+
System.out.println(response.body());
26+
27+
assertEquals(200, response.statusCode());
28+
29+
try(JsonReader reader = Json.createReader(new StringReader(response.body()))) {
30+
JsonObject json = reader.readObject();
31+
32+
JsonArray data = json.getJsonArray("data");
33+
34+
JsonObject first = data.getJsonObject(0);
35+
36+
String name = first.getString("name");
37+
double value = first.getJsonNumber("value").doubleValue();
38+
39+
assertEquals("channel1", name);
40+
assertEquals(0.0, value, 0.1);
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)