-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #236 from RADAR-base/release-0.5.11.1
Release 0.5.11.1
- Loading branch information
Showing
9 changed files
with
113 additions
and
5 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
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
69 changes: 69 additions & 0 deletions
69
...ar-schemas-tools/src/test/java/org/radarcns/schema/service/SourceCatalogueServerTest.java
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,69 @@ | ||
package org.radarcns.schema.service; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import java.io.IOException; | ||
import java.nio.file.Paths; | ||
import okhttp3.OkHttpClient; | ||
import okhttp3.Request; | ||
import okhttp3.Response; | ||
import okhttp3.ResponseBody; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.ErrorCollector; | ||
import org.radarcns.schema.specification.SourceCatalogue; | ||
|
||
public class SourceCatalogueServerTest { | ||
@Rule | ||
public ErrorCollector errorCollector = new ErrorCollector(); | ||
private SourceCatalogueServer server; | ||
private Thread serverThread; | ||
|
||
@Before | ||
public void setUp() { | ||
server = new SourceCatalogueServer(9876); | ||
serverThread = new Thread(() -> { | ||
try { | ||
SourceCatalogue sourceCatalog = SourceCatalogue.load(Paths.get("../..")); | ||
server.start(sourceCatalog); | ||
server.close(); | ||
} catch (InterruptedException | IllegalStateException e) { | ||
// this is acceptable | ||
} catch (Exception e) { | ||
errorCollector.addError(e); | ||
} | ||
}); | ||
serverThread.start(); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
server.stop(); | ||
serverThread.join(); | ||
} | ||
|
||
@Test | ||
public void sourceTypesTest() throws IOException, InterruptedException { | ||
Thread.sleep(5000L); | ||
|
||
OkHttpClient client = new OkHttpClient(); | ||
Request request = new Request.Builder() | ||
.url("http://localhost:9876/source-types") | ||
.build(); | ||
|
||
try (Response response = client.newCall(request).execute()) { | ||
assertTrue(response.isSuccessful()); | ||
ResponseBody body = response.body(); | ||
assertNotNull(body); | ||
JsonNode node = new ObjectMapper().readTree(body.byteStream()); | ||
assertTrue(node.isObject()); | ||
assertTrue(node.has("passive-source-types")); | ||
assertTrue(node.get("passive-source-types").isArray()); | ||
} | ||
} | ||
} |
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