NO-JIRA de-duplicate class
This commit is contained in:
parent
5edf940ed0
commit
a138a27adb
|
@ -82,7 +82,7 @@ import org.apache.activemq.artemis.protocol.amqp.broker.ProtonProtocolManagerFac
|
|||
import org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport;
|
||||
import org.apache.activemq.artemis.protocol.amqp.proton.ProtonServerReceiverContext;
|
||||
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
|
||||
import org.apache.activemq.artemis.tests.integration.mqtt.imported.util.Wait;
|
||||
import org.apache.activemq.artemis.tests.util.Wait;
|
||||
import org.apache.activemq.artemis.utils.ByteUtil;
|
||||
import org.apache.activemq.artemis.utils.TimeUtils;
|
||||
import org.apache.activemq.artemis.utils.VersionLoader;
|
||||
|
@ -829,7 +829,7 @@ public class ProtonTest extends ProtonTestBase {
|
|||
|
||||
Wait.waitFor(new Wait.Condition() {
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
public boolean isSatisfied() throws Exception {
|
||||
return amqpConnection.isClosed();
|
||||
}
|
||||
});
|
||||
|
@ -853,7 +853,7 @@ public class ProtonTest extends ProtonTestBase {
|
|||
|
||||
Wait.waitFor(new Wait.Condition() {
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
public boolean isSatisfied() throws Exception {
|
||||
return amqpConnection.isClosed();
|
||||
}
|
||||
});
|
||||
|
@ -1003,7 +1003,7 @@ public class ProtonTest extends ProtonTestBase {
|
|||
try {
|
||||
Wait.waitFor(new Wait.Condition() {
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
public boolean isSatisfied() throws Exception {
|
||||
return remote.isActive();
|
||||
}
|
||||
});
|
||||
|
@ -1024,7 +1024,7 @@ public class ProtonTest extends ProtonTestBase {
|
|||
try {
|
||||
Wait.waitFor(new Wait.Condition() {
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
public boolean isSatisfied() throws Exception {
|
||||
return remote.getConnectionCount() > 0;
|
||||
}
|
||||
});
|
||||
|
@ -1033,7 +1033,7 @@ public class ProtonTest extends ProtonTestBase {
|
|||
lifeCycleListener.stop();
|
||||
Wait.waitFor(new Wait.Condition() {
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
public boolean isSatisfied() throws Exception {
|
||||
return remote.getConnectionCount() == 0;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -30,8 +30,8 @@ import org.apache.activemq.artemis.api.core.client.ServerLocator;
|
|||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.Queue;
|
||||
import org.apache.activemq.artemis.core.server.RoutingType;
|
||||
import org.apache.activemq.artemis.tests.integration.mqtt.imported.util.Wait;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.apache.activemq.artemis.tests.util.Wait;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -151,7 +151,7 @@ public class ReceiveTest extends ActiveMQTestBase {
|
|||
|
||||
Wait.waitFor(new Wait.Condition() {
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
public boolean isSatisfied() throws Exception {
|
||||
return queue.getMessageCount() == 3;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -61,8 +61,8 @@ import org.apache.activemq.artemis.jlibaio.LibaioContext;
|
|||
import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
|
||||
import org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule;
|
||||
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
|
||||
import org.apache.activemq.artemis.tests.integration.mqtt.imported.util.Wait;
|
||||
import org.apache.activemq.artemis.tests.unit.core.config.impl.fakes.FakeConnectorServiceFactory;
|
||||
import org.apache.activemq.artemis.tests.util.Wait;
|
||||
import org.apache.activemq.artemis.utils.RandomUtil;
|
||||
import org.apache.activemq.artemis.utils.UUIDGenerator;
|
||||
import org.junit.Assert;
|
||||
|
@ -312,7 +312,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
|
|||
serverControl.destroyQueue(name.toString(), true);
|
||||
Wait.waitFor(new Wait.Condition() {
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
public boolean isSatisfied() throws Exception {
|
||||
return consumer.isClosed();
|
||||
}
|
||||
}, 1000, 100);
|
||||
|
|
|
@ -42,7 +42,7 @@ import org.apache.activemq.artemis.core.protocol.mqtt.MQTTConnectionManager;
|
|||
import org.apache.activemq.artemis.core.protocol.mqtt.MQTTSession;
|
||||
import org.apache.activemq.artemis.core.server.RoutingType;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
import org.apache.activemq.artemis.tests.integration.mqtt.imported.util.Wait;
|
||||
import org.apache.activemq.artemis.tests.util.Wait;
|
||||
import org.fusesource.mqtt.client.BlockingConnection;
|
||||
import org.fusesource.mqtt.client.MQTT;
|
||||
import org.fusesource.mqtt.client.Message;
|
||||
|
@ -789,7 +789,7 @@ public class MQTTTest extends MQTTTestSupport {
|
|||
|
||||
Wait.waitFor(new Wait.Condition() {
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
public boolean isSatisfied() throws Exception {
|
||||
return publishList.size() == 2;
|
||||
}
|
||||
}, 5000);
|
||||
|
@ -802,7 +802,7 @@ public class MQTTTest extends MQTTTestSupport {
|
|||
|
||||
Wait.waitFor(new Wait.Condition() {
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
public boolean isSatisfied() throws Exception {
|
||||
return publishList.size() == 4;
|
||||
}
|
||||
}, 5000);
|
||||
|
@ -964,7 +964,7 @@ public class MQTTTest extends MQTTTestSupport {
|
|||
connection.connect();
|
||||
Wait.waitFor(new Wait.Condition() {
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
public boolean isSatisfied() throws Exception {
|
||||
return connection.isConnected();
|
||||
}
|
||||
});
|
||||
|
@ -983,7 +983,7 @@ public class MQTTTest extends MQTTTestSupport {
|
|||
newConnection.connect();
|
||||
Wait.waitFor(new Wait.Condition() {
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
public boolean isSatisfied() throws Exception {
|
||||
return newConnection.isConnected();
|
||||
}
|
||||
});
|
||||
|
@ -1125,7 +1125,7 @@ public class MQTTTest extends MQTTTestSupport {
|
|||
assertTrue("KeepAlive didn't work properly", Wait.waitFor(new Wait.Condition() {
|
||||
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
public boolean isSatisfied() throws Exception {
|
||||
return connection.isConnected();
|
||||
}
|
||||
}));
|
||||
|
@ -1148,7 +1148,7 @@ public class MQTTTest extends MQTTTestSupport {
|
|||
assertTrue("KeepAlive didn't work properly", Wait.waitFor(new Wait.Condition() {
|
||||
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
public boolean isSatisfied() throws Exception {
|
||||
return connection.isConnected();
|
||||
}
|
||||
}));
|
||||
|
@ -1216,14 +1216,14 @@ public class MQTTTest extends MQTTTestSupport {
|
|||
|
||||
assertTrue("Duplicate client disconnected", Wait.waitFor(new Wait.Condition() {
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
public boolean isSatisfied() throws Exception {
|
||||
return connection1.isConnected();
|
||||
}
|
||||
}));
|
||||
|
||||
assertTrue("Old client still connected", Wait.waitFor(new Wait.Condition() {
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
public boolean isSatisfied() throws Exception {
|
||||
return !connection.isConnected();
|
||||
}
|
||||
}));
|
||||
|
@ -1413,7 +1413,7 @@ public class MQTTTest extends MQTTTestSupport {
|
|||
assertTrue("KeepAlive didn't work properly", Wait.waitFor(new Wait.Condition() {
|
||||
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
public boolean isSatisfied() throws Exception {
|
||||
return connection.isConnected();
|
||||
}
|
||||
}));
|
||||
|
@ -1611,7 +1611,7 @@ public class MQTTTest extends MQTTTestSupport {
|
|||
assertTrue("KeepAlive didn't work properly", Wait.waitFor(new Wait.Condition() {
|
||||
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
public boolean isSatisfied() throws Exception {
|
||||
return connection.isConnected();
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.activemq.artemis.tests.integration.mqtt.imported.util;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class Wait {
|
||||
|
||||
public static final long MAX_WAIT_MILLIS = 30 * 1000;
|
||||
public static final int SLEEP_MILLIS = 1000;
|
||||
|
||||
public interface Condition {
|
||||
|
||||
boolean isSatisified() throws Exception;
|
||||
}
|
||||
|
||||
public static boolean waitFor(Condition condition) throws Exception {
|
||||
return waitFor(condition, MAX_WAIT_MILLIS);
|
||||
}
|
||||
|
||||
public static boolean waitFor(final Condition condition, final long duration) throws Exception {
|
||||
return waitFor(condition, duration, SLEEP_MILLIS);
|
||||
}
|
||||
|
||||
public static boolean waitFor(final Condition condition,
|
||||
final long duration,
|
||||
final int sleepMillis) throws Exception {
|
||||
|
||||
final long expiry = System.currentTimeMillis() + duration;
|
||||
boolean conditionSatisified = condition.isSatisified();
|
||||
while (!conditionSatisified && System.currentTimeMillis() < expiry) {
|
||||
TimeUnit.MILLISECONDS.sleep(sleepMillis);
|
||||
conditionSatisified = condition.isSatisified();
|
||||
}
|
||||
return conditionSatisified;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue