use of javax.jms.ConnectionMetaData in project spring-boot by spring-projects.
the class JmsHealthIndicatorTests method jmsBrokerIsUp.
@Test
public void jmsBrokerIsUp() throws JMSException {
ConnectionMetaData connectionMetaData = mock(ConnectionMetaData.class);
given(connectionMetaData.getJMSProviderName()).willReturn("JMS test provider");
Connection connection = mock(Connection.class);
given(connection.getMetaData()).willReturn(connectionMetaData);
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
given(connectionFactory.createConnection()).willReturn(connection);
JmsHealthIndicator indicator = new JmsHealthIndicator(connectionFactory);
Health health = indicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("provider")).isEqualTo("JMS test provider");
verify(connection, times(1)).close();
}
use of javax.jms.ConnectionMetaData in project spring-boot by spring-projects.
the class JmsHealthIndicatorTests method jmsBrokerCouldNotRetrieveProviderMetadata.
@Test
public void jmsBrokerCouldNotRetrieveProviderMetadata() throws JMSException {
ConnectionMetaData connectionMetaData = mock(ConnectionMetaData.class);
given(connectionMetaData.getJMSProviderName()).willThrow(new JMSException("test", "123"));
Connection connection = mock(Connection.class);
given(connection.getMetaData()).willReturn(connectionMetaData);
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
given(connectionFactory.createConnection()).willReturn(connection);
JmsHealthIndicator indicator = new JmsHealthIndicator(connectionFactory);
Health health = indicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(health.getDetails().get("provider")).isNull();
verify(connection, times(1)).close();
}
use of javax.jms.ConnectionMetaData in project activemq-artemis by apache.
the class ManifestTest method testManifestEntries.
// Constants -----------------------------------------------------
// Static --------------------------------------------------------
// Attributes ----------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
@Test
public void testManifestEntries() throws Exception {
Properties props = System.getProperties();
String userDir = props.getProperty("build.lib");
UnitTestLogger.LOGGER.trace("userDir is " + userDir);
// The jar must be there
File file = new File("build/jars", "activemq-core.jar");
Assert.assertTrue(file.exists());
// Open the jar and load MANIFEST.MF
JarFile jar = new JarFile(file);
Manifest manifest = jar.getManifest();
ActiveMQServer server = ActiveMQServers.newActiveMQServer(createBasicConfig());
ConnectionMetaData meta = new ActiveMQConnectionMetaData(server.getVersion());
// Compare the value from ConnectionMetaData and MANIFEST.MF
Attributes attrs = manifest.getMainAttributes();
Assert.assertEquals(meta.getProviderVersion(), attrs.getValue("ActiveMQ-Version"));
}
use of javax.jms.ConnectionMetaData in project activemq-artemis by apache.
the class JMSXPropertyTest method supportsJMSXDeliveryCount.
/**
* checks if the JMSX property <code>JMSXDeliveryCount</code> is supported.
*/
private boolean supportsJMSXDeliveryCount() throws Exception {
ConnectionMetaData metaData = senderConnection.getMetaData();
Enumeration enumeration = metaData.getJMSXPropertyNames();
while (enumeration.hasMoreElements()) {
String jmsxPropertyName = (String) enumeration.nextElement();
if (jmsxPropertyName.equals("JMSXDeliveryCount")) {
return true;
}
}
return false;
}
use of javax.jms.ConnectionMetaData in project activemq-artemis by apache.
the class JMSXPropertyTest method testSupportsJMSXGroupID.
/**
* Test that the JMSX property <code>JMSXGroupID</code> is supported.
*/
@Test
public void testSupportsJMSXGroupID() {
try {
boolean found = false;
ConnectionMetaData metaData = senderConnection.getMetaData();
Enumeration enumeration = metaData.getJMSXPropertyNames();
while (enumeration.hasMoreElements()) {
String jmsxPropertyName = (String) enumeration.nextElement();
if (jmsxPropertyName.equals("JMSXGroupID")) {
found = true;
}
}
Assert.assertTrue("JMSXGroupID property is not supported", found);
} catch (JMSException e) {
fail(e);
}
}
Aggregations