use of javax.jms.IllegalStateException in project activemq-artemis by apache.
the class DurableSubscriptionTest method testSubscribeWithActiveSubscription.
@Test
public void testSubscribeWithActiveSubscription() throws Exception {
Connection conn = createConnection();
conn.setClientID("zeke");
Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
TopicSubscriber dursub1 = s.createDurableSubscriber(ActiveMQServerTestCase.topic1, "dursub1");
try {
s.createDurableSubscriber(ActiveMQServerTestCase.topic1, "dursub1");
ProxyAssertSupport.fail();
} catch (IllegalStateException e) {
// Ok - it is illegal to have more than one active subscriber on a subscrtiption at any one time
}
dursub1.close();
s.unsubscribe("dursub1");
}
use of javax.jms.IllegalStateException in project activemq-artemis by apache.
the class SecurityTest method testSetClientIDAfterOp.
/*
* Try setting client ID after an operation has been performed on the connection
*/
@Test
public void testSetClientIDAfterOp() throws Exception {
Connection conn = createConnection();
conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
try {
conn.setClientID("myID");
ProxyAssertSupport.fail();
} catch (IllegalStateException e) {
// Expected
}
}
use of javax.jms.IllegalStateException in project activemq-artemis by apache.
the class SecurityTest method testSetClientIDPreConf.
/**
* Try setting client ID on preconfigured connection - should throw exception
*/
@Test
public void testSetClientIDPreConf() throws Exception {
Connection conn = null;
try {
ActiveMQServerTestCase.deployConnectionFactory("dilbert-id", "preConfcf", "preConfcf");
ConnectionFactory cf = (ConnectionFactory) getInitialContext().lookup("preConfcf");
conn = cf.createConnection("guest", "guest");
conn.setClientID("myID");
ProxyAssertSupport.fail();
} catch (IllegalStateException e) {
// Expected
} finally {
if (conn != null) {
conn.close();
}
ActiveMQServerTestCase.undeployConnectionFactory("preConfcf");
}
}
use of javax.jms.IllegalStateException in project spring-framework by spring-projects.
the class MessageListenerAdapterTests method testFailsIfNoDefaultListenerMethodNameIsSupplied.
@Test
public void testFailsIfNoDefaultListenerMethodNameIsSupplied() throws Exception {
final TextMessage message = mock(TextMessage.class);
given(message.getText()).willReturn(TEXT);
final MessageListenerAdapter adapter = new MessageListenerAdapter() {
@Override
protected void handleListenerException(Throwable ex) {
assertTrue(ex instanceof IllegalStateException);
}
};
adapter.setDefaultListenerMethod(null);
adapter.onMessage(message);
}
use of javax.jms.IllegalStateException in project karaf by apache.
the class ConnectionPool method createSession.
public Session createSession(boolean transacted, int ackMode) throws JMSException {
SessionKey key = new SessionKey(transacted, ackMode);
PooledSession session;
try {
session = sessionPool.borrowObject(key);
} catch (Exception e) {
IllegalStateException illegalStateException = new IllegalStateException(e.toString());
illegalStateException.initCause(e);
throw illegalStateException;
}
return session;
}
Aggregations