NO-JIRA Fixing intermittent failure on a REST test
This commit is contained in:
parent
27c7385315
commit
c0c638d61f
|
@ -39,6 +39,10 @@ public class Wait {
|
||||||
long getCount() throws Exception;
|
long getCount() throws Exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface ObjectCondition {
|
||||||
|
Object getObject() throws Exception;
|
||||||
|
}
|
||||||
|
|
||||||
public interface IntCondition {
|
public interface IntCondition {
|
||||||
int getCount() throws Exception;
|
int getCount() throws Exception;
|
||||||
}
|
}
|
||||||
|
@ -47,6 +51,10 @@ public class Wait {
|
||||||
return waitFor(condition, MAX_WAIT_MILLIS);
|
return waitFor(condition, MAX_WAIT_MILLIS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void assertEquals(Object obj, ObjectCondition condition) throws Exception {
|
||||||
|
assertEquals(obj, condition, MAX_WAIT_MILLIS, SLEEP_MILLIS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void assertEquals(long size, LongCondition condition) throws Exception {
|
public static void assertEquals(long size, LongCondition condition) throws Exception {
|
||||||
assertEquals(size, condition, MAX_WAIT_MILLIS);
|
assertEquals(size, condition, MAX_WAIT_MILLIS);
|
||||||
|
@ -73,6 +81,15 @@ public class Wait {
|
||||||
assertEquals(size, condition, timeout, SLEEP_MILLIS);
|
assertEquals(size, condition, timeout, SLEEP_MILLIS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void assertEquals(Object obj, ObjectCondition condition, long timeout, long sleepMillis) throws Exception {
|
||||||
|
boolean result = waitFor(() -> (obj == condition || obj.equals(condition.getObject())), timeout, sleepMillis);
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
|
Assert.assertEquals(obj, condition.getObject());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void assertEquals(int size, IntCondition condition, long timeout, long sleepMillis) throws Exception {
|
public static void assertEquals(int size, IntCondition condition, long timeout, long sleepMillis) throws Exception {
|
||||||
boolean result = waitFor(() -> condition.getCount() == size, timeout, sleepMillis);
|
boolean result = waitFor(() -> condition.getCount() == size, timeout, sleepMillis);
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,12 @@
|
||||||
<artifactId>artemis-commons</artifactId>
|
<artifactId>artemis-commons</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.activemq</groupId>
|
||||||
|
<artifactId>artemis-commons</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.geronimo.specs</groupId>
|
<groupId>org.apache.geronimo.specs</groupId>
|
||||||
<artifactId>geronimo-jms_2.0_spec</artifactId>
|
<artifactId>geronimo-jms_2.0_spec</artifactId>
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.activemq.artemis.rest.HttpHeaderProperty;
|
||||||
import org.apache.activemq.artemis.rest.queue.push.xml.XmlLink;
|
import org.apache.activemq.artemis.rest.queue.push.xml.XmlLink;
|
||||||
import org.apache.activemq.artemis.rest.topic.PushTopicRegistration;
|
import org.apache.activemq.artemis.rest.topic.PushTopicRegistration;
|
||||||
import org.apache.activemq.artemis.rest.topic.TopicDeployment;
|
import org.apache.activemq.artemis.rest.topic.TopicDeployment;
|
||||||
|
import org.apache.activemq.artemis.utils.Wait;
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
import org.jboss.resteasy.client.ClientRequest;
|
import org.jboss.resteasy.client.ClientRequest;
|
||||||
import org.jboss.resteasy.client.ClientResponse;
|
import org.jboss.resteasy.client.ClientResponse;
|
||||||
|
@ -207,33 +208,27 @@ public class SelectorTest extends MessageTestBase {
|
||||||
order.setName("1");
|
order.setName("1");
|
||||||
order.setAmount("$5.00");
|
order.setAmount("$5.00");
|
||||||
publish(prefixedTopicName, order, null, "1");
|
publish(prefixedTopicName, order, null, "1");
|
||||||
Thread.sleep(200);
|
Wait.assertEquals(order, () -> PushReceiver.oneOrder);
|
||||||
Assert.assertEquals(order, PushReceiver.oneOrder);
|
|
||||||
|
|
||||||
order.setName("2");
|
order.setName("2");
|
||||||
publish(prefixedTopicName, order, null, "2");
|
publish(prefixedTopicName, order, null, "2");
|
||||||
Thread.sleep(200);
|
Wait.assertEquals(order, () -> PushReceiver.twoOrder);
|
||||||
Assert.assertEquals(order, PushReceiver.twoOrder);
|
|
||||||
|
|
||||||
order.setName("3");
|
order.setName("3");
|
||||||
publish(prefixedTopicName, order, null, "2");
|
publish(prefixedTopicName, order, null, "2");
|
||||||
Thread.sleep(200);
|
Wait.assertEquals(order, () -> PushReceiver.twoOrder);
|
||||||
Assert.assertEquals(order, PushReceiver.twoOrder);
|
|
||||||
|
|
||||||
order.setName("4");
|
order.setName("4");
|
||||||
publish(prefixedTopicName, order, null, "1");
|
publish(prefixedTopicName, order, null, "1");
|
||||||
Thread.sleep(200);
|
Wait.assertEquals(order, () -> PushReceiver.oneOrder);
|
||||||
Assert.assertEquals(order, PushReceiver.oneOrder);
|
|
||||||
|
|
||||||
order.setName("5");
|
order.setName("5");
|
||||||
publish(prefixedTopicName, order, null, "1");
|
publish(prefixedTopicName, order, null, "1");
|
||||||
Thread.sleep(200);
|
Wait.assertEquals(order, () -> PushReceiver.oneOrder);
|
||||||
Assert.assertEquals(order, PushReceiver.oneOrder);
|
|
||||||
|
|
||||||
order.setName("6");
|
order.setName("6");
|
||||||
publish(prefixedTopicName, order, null, "1");
|
publish(prefixedTopicName, order, null, "1");
|
||||||
Thread.sleep(200);
|
Wait.assertEquals(order, () -> PushReceiver.oneOrder);
|
||||||
Assert.assertEquals(order, PushReceiver.oneOrder);
|
|
||||||
|
|
||||||
response = oneSubscription.request().delete();
|
response = oneSubscription.request().delete();
|
||||||
response.releaseConnection();
|
response.releaseConnection();
|
||||||
|
|
Loading…
Reference in New Issue