}
public void testInvalidProperties() throws Exception {
// Null properties
try {
new JmsMessagingClient("4", this, null, false);
fail("Creating a Messagingient with null properties " +
"should throw an exception");
} catch(MessagingException me) {
assertTrue(me.getMessage().contains("Connection properties may not be null"));
}
// Missing all properties
properties = new Properties();
try {
new JmsMessagingClient("5", this, properties, false);
fail("Creating a Messaging Client with no properties " +
"should throw an exception");
} catch(MessagingException me) {
assertTrue(me.getMessage().contains("Propery values"));
assertTrue(me.getMessage().contains("must be provided"));
}
// Missing connection factory property
properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
properties.setProperty(Context.PROVIDER_URL,
"vm://localhost?broker.useShutdownHook=false&broker.persistent=false");
try {
new JmsMessagingClient("6", this, properties, false);
fail("Creating a Messaging Client with no connection factory " +
"property should throw an exception");
} catch(MessagingException me) {
assertTrue(me.getMessage().contains("Propery values"));
assertTrue(me.getMessage().contains("must be provided"));
}
// Missing provider url property
properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
properties.setProperty(JMSManager.CONNECTION_FACTORY_NAME,
"ConnectionFactory");
try {
new JmsMessagingClient("7", this, properties, false);
fail("Creating a Messaging Client with no provider url " +
"property should throw an exception");
} catch(MessagingException me) {
assertTrue(me.getMessage().contains("Propery values"));
assertTrue(me.getMessage().contains("must be provided"));
}
// Missing initial context factory property
properties = new Properties();
properties.setProperty(Context.PROVIDER_URL,
"vm://localhost?broker.useShutdownHook=false&broker.persistent=false");
properties.setProperty(JMSManager.CONNECTION_FACTORY_NAME,
"ConnectionFactory");
try {
new JmsMessagingClient("8", this, properties, false);
fail("Creating a Messaging Client with no initial context factory " +
"property should throw an exception");
} catch(MessagingException me) {
assertTrue(me.getMessage().contains("Propery values"));
assertTrue(me.getMessage().contains("must be provided"));