This commit is contained in:
Clebert Suconic 2020-09-15 11:08:16 -04:00
commit 1dd901a8e7
4 changed files with 31 additions and 15 deletions

View File

@ -39,6 +39,10 @@ public class Wait {
long getCount() throws Exception;
}
public interface ObjectCondition {
Object getObject() throws Exception;
}
public interface IntCondition {
int getCount() throws Exception;
}
@ -47,6 +51,10 @@ public class Wait {
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 {
assertEquals(size, condition, MAX_WAIT_MILLIS);
@ -73,6 +81,15 @@ public class Wait {
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 {
boolean result = waitFor(() -> condition.getCount() == size, timeout, sleepMillis);

View File

@ -124,6 +124,12 @@
<artifactId>artemis-commons</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-commons</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_2.0_spec</artifactId>

View File

@ -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.topic.PushTopicRegistration;
import org.apache.activemq.artemis.rest.topic.TopicDeployment;
import org.apache.activemq.artemis.utils.Wait;
import org.jboss.logging.Logger;
import org.jboss.resteasy.client.ClientRequest;
import org.jboss.resteasy.client.ClientResponse;
@ -207,33 +208,27 @@ public class SelectorTest extends MessageTestBase {
order.setName("1");
order.setAmount("$5.00");
publish(prefixedTopicName, order, null, "1");
Thread.sleep(200);
Assert.assertEquals(order, PushReceiver.oneOrder);
Wait.assertEquals(order, () -> PushReceiver.oneOrder);
order.setName("2");
publish(prefixedTopicName, order, null, "2");
Thread.sleep(200);
Assert.assertEquals(order, PushReceiver.twoOrder);
Wait.assertEquals(order, () -> PushReceiver.twoOrder);
order.setName("3");
publish(prefixedTopicName, order, null, "2");
Thread.sleep(200);
Assert.assertEquals(order, PushReceiver.twoOrder);
Wait.assertEquals(order, () -> PushReceiver.twoOrder);
order.setName("4");
publish(prefixedTopicName, order, null, "1");
Thread.sleep(200);
Assert.assertEquals(order, PushReceiver.oneOrder);
Wait.assertEquals(order, () -> PushReceiver.oneOrder);
order.setName("5");
publish(prefixedTopicName, order, null, "1");
Thread.sleep(200);
Assert.assertEquals(order, PushReceiver.oneOrder);
Wait.assertEquals(order, () -> PushReceiver.oneOrder);
order.setName("6");
publish(prefixedTopicName, order, null, "1");
Thread.sleep(200);
Assert.assertEquals(order, PushReceiver.oneOrder);
Wait.assertEquals(order, () -> PushReceiver.oneOrder);
response = oneSubscription.request().delete();
response.releaseConnection();

View File

@ -138,15 +138,13 @@ public class RefsOperation extends TransactionOperationAbstract {
if (durableRefCount == 1) {
storageManager.storeMessageTransactional(ackedTX.getID(), message);
}
Queue queue = ref.getQueue();
storageManager.storeReferenceTransactional(ackedTX.getID(), queue.getID(), message.getMessageID());
ackedTX.setContainsPersistent();
}
// TODO-NOW: THIS MUST BE SOLVED BEFORE MERGED, DO NOT LET ME COMMIT THIS WITHOUT REVIEW
queue.refUp(message);
ref.getQueue().refUp(message);
}
ackedTX.commit(true);
} catch (Exception e) {