Skip to content

Commit

Permalink
Merge pull request #8 from reportportal/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
HardNorth authored Mar 6, 2024
2 parents 3350a3e + d1cce9f commit 914e181
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

## [Unreleased]
### Changed
- Awaitility and Hamcrest libraries now declared as `implementation`, by @HardNorth

## [0.0.3]
### Changed
- All dependencies are now declared as `compileOnly`, by @HardNorth

## [0.0.2]
### Changed
Expand Down
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ dependencies {
compileOnly 'com.google.code.findbugs:jsr305:3.0.2'
compileOnly 'org.apache.commons:commons-lang3:3.11'
compileOnly 'org.apache.commons:commons-io:1.3.2'
compileOnly('org.awaitility:awaitility:4.0.2') {

implementation 'org.hamcrest:hamcrest-core:2.2'
implementation('org.awaitility:awaitility:4.0.2') {
exclude group: 'org.hamcrest'
}
compileOnly 'org.hamcrest:hamcrest-core:2.2'

}

release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import javax.annotation.Nullable;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystems;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
Expand All @@ -52,7 +53,7 @@ private static String getPathToClass(@Nonnull Class<?> mainClass) {
public static Process buildProcess(boolean inheritOutput, @Nonnull Class<?> mainClass,
@Nullable Map<String, String> additionalEnvironmentVariables,
@Nullable Map<String, String> additionSystemVariables, String... params) throws IOException {
String fileSeparator = System.getProperty("file.separator");
String fileSeparator = FileSystems.getDefault().getSeparator();
String javaHome = System.getProperty("java.home");
String executablePath = joinWith(fileSeparator, javaHome, "bin", "java");
File executableFile = new File(executablePath);
Expand Down Expand Up @@ -136,7 +137,7 @@ public static String waitForLine(final BufferedReader reader, final BufferedRead
if (errorReader.ready()) {
errorLines = IOUtils.readLines(errorReader);
}
String lineSeparator = System.getProperty("line.separator");
String lineSeparator = System.lineSeparator();
throw new IllegalStateException("Unable to run test class: " + String.join(lineSeparator, errorLines));
}
}
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/com/epam/reportportal/util/test/SocketUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public List<String> call() throws Exception {
StringBuilder builder = new StringBuilder();
String line;
while ((line = in.readLine()) != null) {
if (line.equals("")) {
if (line.isEmpty()) {
break;
}
builder.append(line);
Expand Down Expand Up @@ -96,14 +96,19 @@ public static ServerSocket getServerSocketOnFreePort() throws IOException {
return new ServerSocket(0);
}

public static <T> Pair<List<String>, T> executeServerCallable(ServerCallable srvCall, Callable<T> clientCallable) throws Exception {
public static <T> Pair<List<String>, T> executeServerCallable(ServerCallable srvCall, Callable<T> clientCallable,
long timeoutSeconds) throws Exception {
ExecutorService serverExecutor = Executors.newSingleThreadExecutor();
Future<List<String>> future = serverExecutor.submit(srvCall);
T rs = clientCallable.call();
try {
return Pair.of(future.get(5, TimeUnit.SECONDS), rs);
return Pair.of(future.get(timeoutSeconds, TimeUnit.SECONDS), rs);
} finally {
CommonUtils.shutdownExecutorService(serverExecutor);
}
}

public static <T> Pair<List<String>, T> executeServerCallable(ServerCallable srvCall, Callable<T> clientCallable) throws Exception {
return executeServerCallable(srvCall, clientCallable, 5L);
}
}

0 comments on commit 914e181

Please sign in to comment.