This is an automated email from the ASF dual-hosted git repository. ningjiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git
commit 8c455ad87396052ba24d4a45c5e0581c0eef485a Author: seanyinx <sean....@huawei.com> AuthorDate: Thu Jan 11 15:58:16 2018 +0800 SCB-212 attempted to fix test failure Signed-off-by: seanyinx <sean....@huawei.com> --- .../saga/alpha/server/AlphaIntegrationTest.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaIntegrationTest.java b/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaIntegrationTest.java index 4997c00..9f13a8f 100644 --- a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaIntegrationTest.java +++ b/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaIntegrationTest.java @@ -29,10 +29,10 @@ import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; import java.util.Date; -import java.util.List; import java.util.Map; +import java.util.Queue; import java.util.UUID; -import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.ConcurrentLinkedQueue; import org.apache.servicecomb.saga.alpha.core.EventType; import org.apache.servicecomb.saga.alpha.core.OmegaCallback; @@ -94,7 +94,7 @@ public class AlphaIntegrationTest { @Autowired private TxConsistentService consistentService; - private static final List<GrpcCompensateCommand> receivedCommands = new CopyOnWriteArrayList<>(); + private static final Queue<GrpcCompensateCommand> receivedCommands = new ConcurrentLinkedQueue<>(); private final CompensateStreamObserver compensateResponseObserver = new CompensateStreamObserver(); @AfterClass @@ -219,11 +219,12 @@ public class AlphaIntegrationTest { blockingStub.onTxEvent(someGrpcEvent(TxAbortedEvent)); await().atMost(1, SECONDS).until(() -> !receivedCommands.isEmpty()); - assertThat(receivedCommands.get(0).getGlobalTxId(), is(globalTxId)); - assertThat(receivedCommands.get(0).getLocalTxId(), is(localTxId)); - assertThat(receivedCommands.get(0).getParentTxId(), is(parentTxId)); - assertThat(receivedCommands.get(0).getCompensateMethod(), is(compensationMethod)); - assertThat(receivedCommands.get(0).getPayloads().toByteArray(), is(payload.getBytes())); + GrpcCompensateCommand command = receivedCommands.poll(); + assertThat(command.getGlobalTxId(), is(globalTxId)); + assertThat(command.getLocalTxId(), is(localTxId)); + assertThat(command.getParentTxId(), is(parentTxId)); + assertThat(command.getCompensateMethod(), is(compensationMethod)); + assertThat(command.getPayloads().toByteArray(), is(payload.getBytes())); } @Test @@ -244,7 +245,7 @@ public class AlphaIntegrationTest { await().atMost(1, SECONDS).until(() -> !receivedCommands.isEmpty()); assertThat(receivedCommands.size(), is(1)); - assertThat(receivedCommands.get(0).getGlobalTxId(), is(globalTxId)); + assertThat(receivedCommands.poll().getGlobalTxId(), is(globalTxId)); anotherBlockingStub.onDisconnected(anotherServiceConfig); } -- To stop receiving notification emails like this one, please contact "commits@servicecomb.apache.org" <commits@servicecomb.apache.org>.