Adjusting tests

This commit is contained in:
Nelson R. Perez 2017-03-22 16:59:11 -05:00
parent aa642edce9
commit d7019a3689

View file

@ -48,9 +48,13 @@ public class TransactionTest {
private AssetAmount minToReceive = new AssetAmount(UnsignedLong.valueOf(520), BIT_USD); private AssetAmount minToReceive = new AssetAmount(UnsignedLong.valueOf(520), BIT_USD);
private long expiration; private long expiration;
// Lock object
private static final class Lock { } private static final class Lock { }
private final Object lockObject = new Lock(); private final Object lockObject = new Lock();
// Response
private BaseResponse baseResponse;
/** /**
* Generic witness response listener that will just release the lock created in * Generic witness response listener that will just release the lock created in
* main thread. * main thread.
@ -60,8 +64,7 @@ public class TransactionTest {
@Override @Override
public void onSuccess(WitnessResponse response) { public void onSuccess(WitnessResponse response) {
System.out.println("onSuccess"); System.out.println("onSuccess");
WitnessResponse<String> witnessResponse = response; baseResponse = response;
Assert.assertNull(witnessResponse.result);
synchronized (this){ synchronized (this){
this.notifyAll(); this.notifyAll();
} }
@ -69,9 +72,7 @@ public class TransactionTest {
@Override @Override
public void onError(BaseResponse.Error error) { public void onError(BaseResponse.Error error) {
System.out.println("onError"); System.out.println("onError. Msg: "+error.data.message);
System.out.println(error.data.message);
Assert.assertNull(error);
synchronized (this){ synchronized (this){
notifyAll(); notifyAll();
} }
@ -112,10 +113,12 @@ public class TransactionTest {
} }
}else{ }else{
// Otherwise we just use this listener as the lock // Otherwise we just use this listener as the lock
synchronized (this){ synchronized (responseListener){
this.wait(); responseListener.wait();
} }
} }
Assert.assertNotNull(baseResponse);
Assert.assertNull(baseResponse.error);
}catch(NoSuchAlgorithmException e){ }catch(NoSuchAlgorithmException e){
System.out.println("NoSuchAlgoritmException. Msg: " + e.getMessage()); System.out.println("NoSuchAlgoritmException. Msg: " + e.getMessage());
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -255,7 +258,7 @@ public class TransactionTest {
@Override @Override
public void onSuccess(WitnessResponse response) { public void onSuccess(WitnessResponse response) {
System.out.println("onSuccess.2"); System.out.println("onSuccess.2");
Assert.assertNull(response.result); baseResponse = response;
synchronized (this){ synchronized (this){
notifyAll(); notifyAll();
} }
@ -267,7 +270,6 @@ public class TransactionTest {
@Override @Override
public void onError(BaseResponse.Error error) { public void onError(BaseResponse.Error error) {
System.out.println("onError.2"); System.out.println("onError.2");
Assert.assertNull(error);
synchronized (this){ synchronized (this){
notifyAll(); notifyAll();
} }