-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove testcontainers; use JDK 11 for tests
- Loading branch information
1 parent
31cd42a
commit ff4145b
Showing
6 changed files
with
140 additions
and
401 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
Oops, something went wrong.