Change-Id: Iabb655c4bf6f03e80c7822cbbc19e79d8f1db30e
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
import java.util.concurrent.TimeUnit;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.concurrent.TimeUnit;
import static com.google.common.base.Preconditions.checkNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
for (TestingThread thread : threads) {
thread.join();
for (TestingThread thread : threads) {
thread.join();
- assertTrue(thread.success);
+ if(thread.thrownException.isPresent()) {
+ Exception exception = thread.thrownException.get();
+ logger.error("Thread for testing client failed", exception);
+ fail("Client thread " + thread + " failed: " + exception.getMessage());
+ }
for (BlockingThread thread : threads) {
thread.join();
for (BlockingThread thread : threads) {
thread.join();
- assertTrue(thread.success);
+ if(thread.thrownException.isPresent()) {
+ Exception exception = thread.thrownException.get();
+ logger.error("Thread for testing client failed", exception);
+ fail("Client thread " + thread + " failed: " + exception.getMessage());
+ }
}
}
class BlockingThread extends Thread {
}
}
class BlockingThread extends Thread {
+ private Optional<Exception> thrownException;
public BlockingThread(String name) {
super("client-" + name);
public BlockingThread(String name) {
super("client-" + name);
public void run() {
try {
run2();
public void run() {
try {
run2();
+ thrownException = Optional.absent();
- success = false;
- throw new RuntimeException(e);
+ thrownException = Optional.of(e);
private final String clientId;
private final int attempts;
private final String clientId;
private final int attempts;
- private Boolean success;
+ private Optional<Exception> thrownException;
TestingThread(String clientId, int attempts) {
this.clientId = clientId;
TestingThread(String clientId, int attempts) {
this.clientId = clientId;
logger.info("Client with sessionid {} got result {}", sessionId, result);
netconfClient.close();
logger.info("Client with session id {} ended", sessionId);
logger.info("Client with sessionid {} got result {}", sessionId, result);
netconfClient.close();
logger.info("Client with session id {} ended", sessionId);
+ thrownException = Optional.absent();
} catch (final Exception e) {
} catch (final Exception e) {
- success = false;
- throw new RuntimeException(e);
+ thrownException = Optional.of(e);