Skip to content

Commit

Permalink
Some test fixes to improve test suite stability
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Oct 8, 2019
1 parent f36cf38 commit df9758d
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ public void execute(BuildContext context) {
}

ProtocolMetaData metadata = new ProtocolMetaData();
URI uri = URI.create(TestHTTPResourceManager.getUri());

String testUri = TestHTTPResourceManager.getUri();
System.setProperty("test.url", testUri);
URI uri = URI.create(testUri);
HTTPContext httpContext = new HTTPContext(uri.getHost(), uri.getPort());
// This is to work around https://github.com/arquillian/arquillian-core/issues/216
httpContext.add(new Servlet("dummy", "/"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public NativeImageLauncher(Class<?> testClass, int port, long imageWaitTime) {

public void start() throws IOException {

System.setProperty("test.url", TestHTTPResourceManager.getUri());

String path = System.getProperty("native.image.path");
if (path == null) {
path = guessPath(testClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ public static String getUri() {
String host = config.getOptionalValue("quarkus.http.host", String.class).orElse("localhost");
String port = config.getOptionalValue("quarkus.http.test-port", String.class).orElse("8081");
String contextPath = config.getOptionalValue("quarkus.servlet.context-path", String.class).orElse("");
String testUrl = "http://" + host + ":" + port + contextPath;
System.setProperty("test.url", testUrl);
return testUrl;
return "http://" + host + ":" + port + contextPath;
}

public static void inject(Object testCase) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,15 +339,18 @@ void modifyFile(String name, Function<String, String> mutator, Path path) {
}

public void sleepForFileChanges(Path path) {
long currentTime = System.currentTimeMillis();
try {
//we want to make sure the last modified time is larger than both the current time
//and the current last modified time. Some file systems only resolve file
//time to the nearest second, so this is necessary for dev mode to pick up the changes
long timeToBeat = Math.max(System.currentTimeMillis(), Files.getLastModifiedTime(path).toMillis());
for (;;) {
Files.setLastModifiedTime(path, FileTime.fromMillis(System.currentTimeMillis()));
long fm = Files.getLastModifiedTime(path).toMillis();
if (fm > currentTime) {
Thread.sleep(10);
if (fm > timeToBeat) {
return;
}
Thread.sleep(50);
}
} catch (Exception e) {
throw new RuntimeException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ public void execute(BuildContext context) {
fail("The build was expected to fail");
}
started = true;
System.setProperty("test.url", TestHTTPResourceManager.getUri());
Instance<?> factory;
try {
factory = CDI.current()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ public void execute(BuildContext context) {
.build();
runtimeRunner.run();

System.setProperty("test.url", TestHTTPResourceManager.getUri());

Closeable shutdownTask = new Closeable() {
@Override
public void close() throws IOException {
Expand Down

0 comments on commit df9758d

Please sign in to comment.