NO-JIRA fixing test failures

This commit is contained in:
Clebert Suconic 2019-03-13 11:36:14 -04:00
parent 3473618a06
commit 5a74b8b34d
5 changed files with 32 additions and 44 deletions

View File

@ -135,19 +135,33 @@ public class AcceptorControlTest extends ManagementTestBase {
acceptorControl.stop();
Assert.assertEquals(usingCore() ? 5 : 1, notifListener.getNotifications().size());
Notification notif = notifListener.getNotifications().get(usingCore() ? 2 : 0);
Assert.assertEquals(usingCore() ? 7 : 1, notifListener.getNotifications().size());
int i = findNotification(notifListener, CoreNotificationType.ACCEPTOR_STOPPED);
Notification notif = notifListener.getNotifications().get(i);
Assert.assertEquals(CoreNotificationType.ACCEPTOR_STOPPED, notif.getType());
Assert.assertEquals(NettyAcceptorFactory.class.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("factory")).toString());
acceptorControl.start();
Assert.assertEquals(usingCore() ? 10 : 2, notifListener.getNotifications().size());
notif = notifListener.getNotifications().get(usingCore() ? 7 : 1);
i = findNotification(notifListener, CoreNotificationType.ACCEPTOR_STARTED);
notif = notifListener.getNotifications().get(i);
Assert.assertEquals(CoreNotificationType.ACCEPTOR_STARTED, notif.getType());
Assert.assertEquals(NettyAcceptorFactory.class.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("factory")).toString());
}
private int findNotification(SimpleNotificationService.Listener notifListener, CoreNotificationType type) {
int i = 0;
for (i = 0; i < notifListener.getNotifications().size(); i++) {
if (notifListener.getNotifications().get(i).getType().equals(type)) {
break;
}
}
Assert.assertTrue(i < notifListener.getNotifications().size());
return i;
}
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------

View File

@ -112,11 +112,19 @@ public class SecurityNotificationTest extends ActiveMQTestBase {
} catch (Exception e) {
}
ClientMessage[] notifications = SecurityNotificationTest.consumeMessages(1, notifConsumer);
Assert.assertEquals(SECURITY_PERMISSION_VIOLATION.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString());
Assert.assertEquals("guest", notifications[0].getObjectProperty(ManagementHelper.HDR_USER).toString());
Assert.assertEquals(address.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_ADDRESS).toString());
Assert.assertEquals(CheckType.CREATE_DURABLE_QUEUE.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_CHECK_TYPE).toString());
ClientMessage[] notifications = SecurityNotificationTest.consumeMessages(2, notifConsumer);
int i = 0;
for (i = 0; i < notifications.length; i++) {
if (SECURITY_PERMISSION_VIOLATION.toString().equals(notifications[i].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString())) {
break;
}
}
Assert.assertTrue(i < notifications.length);
Assert.assertEquals(SECURITY_PERMISSION_VIOLATION.toString(), notifications[i].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString());
Assert.assertEquals("guest", notifications[i].getObjectProperty(ManagementHelper.HDR_USER).toString());
Assert.assertEquals(address.toString(), notifications[i].getObjectProperty(ManagementHelper.HDR_ADDRESS).toString());
Assert.assertEquals(CheckType.CREATE_DURABLE_QUEUE.toString(), notifications[i].getObjectProperty(ManagementHelper.HDR_CHECK_TYPE).toString());
guestSession.close();
}

View File

@ -16,18 +16,13 @@
*/
package org.apache.activemq.artemis.tests.integration.mqtt.imported;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.postoffice.Binding;
import org.apache.activemq.artemis.core.protocol.mqtt.MQTTSession;
import org.apache.activemq.artemis.core.server.QueueQueryResult;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -36,23 +31,6 @@ public class MQTTFQQNTest extends MQTTTestSupport {
private static final Logger LOG = LoggerFactory.getLogger(MQTTFQQNTest.class);
@Override
@Before
public void setUp() throws Exception {
Field sessions = MQTTSession.class.getDeclaredField("SESSIONS");
sessions.setAccessible(true);
sessions.set(null, new ConcurrentHashMap<>());
super.setUp();
}
@Override
@After
public void tearDown() throws Exception {
super.tearDown();
}
@Test
public void testMQTTSubNames() throws Exception {
final MQTTClientProvider subscriptionProvider = getMQTTClientProvider();

View File

@ -16,9 +16,7 @@
*/
package org.apache.activemq.artemis.tests.integration.mqtt.imported;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@ -27,25 +25,14 @@ import io.netty.handler.codec.mqtt.MqttMessage;
import io.netty.handler.codec.mqtt.MqttPublishMessage;
import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.apache.activemq.artemis.core.protocol.mqtt.MQTTInterceptor;
import org.apache.activemq.artemis.core.protocol.mqtt.MQTTSession;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.felix.resolver.util.ArrayMap;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ErrorCollector;
public class MQTTInterceptorPropertiesTest extends MQTTTestSupport {
@Override
@Before
public void setUp() throws Exception {
Field sessions = MQTTSession.class.getDeclaredField("SESSIONS");
sessions.setAccessible(true);
sessions.set(null, new ConcurrentHashMap<>());
super.setUp();
}
private static final String ADDRESS = "address";
private static final String MESSAGE_TEXT = "messageText";
private static final String RETAINED = "retained";

View File

@ -132,6 +132,7 @@ public class QueueQueryTest extends ActiveMQTestBase {
server.getAddressSettingsRepository().addMatch(queueName.toString(), new AddressSettings());
JMSContext c = new ActiveMQConnectionFactory("vm://0").createContext();
c.createProducer().send(c.createQueue(queueName.toString()), c.createMessage());
Wait.assertEquals(1, server.locateQueue(queueName)::getMessageCount);
QueueQueryResult queueQueryResult = server.queueQuery(queueName);
assertTrue(queueQueryResult.isAutoCreateQueues());
assertEquals(null, queueQueryResult.getFilterString());