Skip to content

Commit

Permalink
Remove testcontainers; use JDK 11 for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
slominskir committed Nov 10, 2022
1 parent 31cd42a commit ff4145b
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 401 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG BUILD_IMAGE=gradle:7.4-jdk17-alpine
ARG RUN_IMAGE=tomcat:9.0.39-jdk8-adoptopenjdk-hotspot
ARG RUN_IMAGE=tomcat:9.0.68-jdk11-temurin

################## Stage 0
FROM ${BUILD_IMAGE} as builder
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ A gateway server and accompanying JavaScript client API to monitor EPICS Channel
- [API](https://github.com/JeffersonLab/epics2web#api)
- [Configure](https://github.com/JeffersonLab/epics2web#configure)
- [Build](https://github.com/JeffersonLab/epics2web#build)
- [Test](https://github.com/JeffersonLab/epics2web#test)
- [Release](https://github.com/JeffersonLab/epics2web#release)
- [See Also](https://github.com/JeffersonLab/epics2web#see-also)
---
Expand Down Expand Up @@ -53,7 +54,7 @@ PV name: `HELLO`
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).

## Build
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:
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:

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

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

## Test
```
docker compose -f build.yml up
```
Wait for containers to start then:
```
gradlew integrationTest
```
## Release
1. Bump the version number and release date in build.gradle and commit and push to GitHub (using [Semantic Versioning](https://semver.org/)).
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.
Expand Down
41 changes: 18 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,30 @@ plugins {

description = "EPICS to web gateway"
group 'org.jlab'
version '1.13.0'
version '1.14.0'

ext {
releaseDate = 'March 21 2022'
releaseDate = 'Nov 9 2022'
productionRelease = 'true'
}

repositories {
mavenCentral()
compileJava {
options.release = 8
}

compileTestJava {
options.release = 11
}

tasks.withType(JavaCompile) {
options.release = 8
options.encoding = 'UTF-8'
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}

repositories {
mavenCentral()
}

sourceSets {
integration {
java.srcDir "${projectDir}/src/integration/java"
Expand All @@ -32,22 +39,17 @@ sourceSets {
}

configurations {
testImplementation.extendsFrom compileOnly
integrationImplementation.extendsFrom implementation
integrationImplementation.extendsFrom testImplementation
integrationRuntimeOnly.extendsFrom runtimeOnly
}

dependencies {
implementation 'javax.servlet:jstl:1.2',
'org.glassfish:javax.json:1.1.4',
files('lib/jca-2.4.6.jar')
//implementation 'org.epics:jca:2.4.6' // Only works with Java 11 runtime
providedCompile 'javax:javaee-api:7.0'

testImplementation 'junit:junit:4.13'
'org.epics:jca:2.4.7'
providedCompile 'javax:javaee-api:8.0.1'

integrationImplementation 'org.testcontainers:testcontainers:1.16.3',
'org.slf4j:slf4j-log4j12:1.7.28'
testImplementation 'junit:junit:4.13.2'
}

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

testClassesDirs = sourceSets.integration.output.classesDirs
classpath = sourceSets.integration.runtimeClasspath
//shouldRunAfter test

testLogging {
showStandardStreams = true
}
}

test {
classpath = project.sourceSets.test.runtimeClasspath + files("${projectDir}/examples/softioc-db")

testLogging {
events "passed", "skipped", "failed"
exceptionFormat "full"
showStandardStreams = true
}
}
Expand Down
43 changes: 43 additions & 0 deletions src/integration/java/org/jlab/epics2web/GetTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.jlab.epics2web;

import org.junit.Test;

import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonObject;
import javax.json.JsonReader;
import java.io.IOException;
import java.io.StringReader;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

import static org.junit.Assert.assertEquals;

public class GetTest {
@Test
public void doTest() throws IOException, InterruptedException {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder().uri(URI.create("http://localhost:8080/epics2web/caget?pv=channel1")).build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

System.out.println(response.body());

assertEquals(200, response.statusCode());

try(JsonReader reader = Json.createReader(new StringReader(response.body()))) {
JsonObject json = reader.readObject();

JsonArray data = json.getJsonArray("data");

JsonObject first = data.getJsonObject(0);

String name = first.getString("name");
double value = first.getJsonNumber("value").doubleValue();

assertEquals("channel1", name);
assertEquals(0.0, value, 0.1);
}
}
}
Loading

0 comments on commit ff4145b

Please sign in to comment.