当前位置: 首页>>代码示例>>Java>>正文


Java IllegalStateRuntimeException类代码示例

本文整理汇总了Java中javax.jms.IllegalStateRuntimeException的典型用法代码示例。如果您正苦于以下问题:Java IllegalStateRuntimeException类的具体用法?Java IllegalStateRuntimeException怎么用?Java IllegalStateRuntimeException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IllegalStateRuntimeException类属于javax.jms包,在下文中一共展示了IllegalStateRuntimeException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createProducer

import javax.jms.IllegalStateRuntimeException; //导入依赖的package包/类
@Override
public JMSProducer createProducer() {
    if (connectionRefCount.get() == 0) {
        throw new IllegalStateRuntimeException("The Connection is closed");
    }

    try {
        if (sharedProducer == null) {
            synchronized (this) {
                if (sharedProducer == null) {
                    sharedProducer = (JmsPoolMessageProducer) getSession().createProducer(null);
                }
            }
        }

        return new JmsPoolJMSProducer(getSession(), sharedProducer);
    } catch (JMSException jmse) {
        throw JMSExceptionSupport.createRuntimeException(jmse);
    }
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:21,代码来源:JmsPoolJMSContext.java

示例2: testRuntimeExceptionFromSendMessage

import javax.jms.IllegalStateRuntimeException; //导入依赖的package包/类
@Test
public void testRuntimeExceptionFromSendMessage() throws JMSException {
    JMSProducer producer = context.createProducer();

    MockJMSConnection connection = (MockJMSConnection) context.getConnection();
    connection.addConnectionListener(new MockJMSDefaultConnectionListener() {

        @Override
        public void onMessageSend(MockJMSSession session, Message message) throws JMSException {
            throw new IllegalStateException("Send Failed");
        }
    });

    try {
        producer.send(context.createTemporaryQueue(), context.createMessage());
        fail("Should have thrown an exception");
    } catch (IllegalStateRuntimeException isre) {}
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:19,代码来源:JmsPoolJMSProducerTest.java

示例3: testRuntimeExceptionFromSendByteBody

import javax.jms.IllegalStateRuntimeException; //导入依赖的package包/类
@Test
public void testRuntimeExceptionFromSendByteBody() throws JMSException {
    JMSProducer producer = context.createProducer();

    MockJMSConnection connection = (MockJMSConnection) context.getConnection();
    connection.addConnectionListener(new MockJMSDefaultConnectionListener() {

        @Override
        public void onMessageSend(MockJMSSession session, Message message) throws JMSException {
            throw new IllegalStateException("Send Failed");
        }
    });

    try {
        producer.send(context.createTemporaryQueue(), new byte[0]);
        fail("Should have thrown an exception");
    } catch (IllegalStateRuntimeException isre) {}
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:19,代码来源:JmsPoolJMSProducerTest.java

示例4: testRuntimeExceptionFromSendMapBody

import javax.jms.IllegalStateRuntimeException; //导入依赖的package包/类
@Test
public void testRuntimeExceptionFromSendMapBody() throws JMSException {
    JMSProducer producer = context.createProducer();

    MockJMSConnection connection = (MockJMSConnection) context.getConnection();
    connection.addConnectionListener(new MockJMSDefaultConnectionListener() {

        @Override
        public void onMessageSend(MockJMSSession session, Message message) throws JMSException {
            throw new IllegalStateException("Send Failed");
        }
    });

    try {
        producer.send(context.createTemporaryQueue(), Collections.<String, Object>emptyMap());
        fail("Should have thrown an exception");
    } catch (IllegalStateRuntimeException isre) {}
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:19,代码来源:JmsPoolJMSProducerTest.java

示例5: testRuntimeExceptionFromSendSerializableBody

import javax.jms.IllegalStateRuntimeException; //导入依赖的package包/类
@Test
public void testRuntimeExceptionFromSendSerializableBody() throws JMSException {
    JMSProducer producer = context.createProducer();

    MockJMSConnection connection = (MockJMSConnection) context.getConnection();
    connection.addConnectionListener(new MockJMSDefaultConnectionListener() {

        @Override
        public void onMessageSend(MockJMSSession session, Message message) throws JMSException {
            throw new IllegalStateException("Send Failed");
        }
    });

    try {
        producer.send(context.createTemporaryQueue(), UUID.randomUUID());
        fail("Should have thrown an exception");
    } catch (IllegalStateRuntimeException isre) {}
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:19,代码来源:JmsPoolJMSProducerTest.java

示例6: testRuntimeExceptionFromSendStringBody

import javax.jms.IllegalStateRuntimeException; //导入依赖的package包/类
@Test
public void testRuntimeExceptionFromSendStringBody() throws JMSException {
    JMSProducer producer = context.createProducer();

    MockJMSConnection connection = (MockJMSConnection) context.getConnection();
    connection.addConnectionListener(new MockJMSDefaultConnectionListener() {

        @Override
        public void onMessageSend(MockJMSSession session, Message message) throws JMSException {
            throw new IllegalStateException("Send Failed");
        }
    });

    try {
        producer.send(context.createTemporaryQueue(), "test");
        fail("Should have thrown an exception");
    } catch (IllegalStateRuntimeException isre) {}
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:19,代码来源:JmsPoolJMSProducerTest.java

示例7: createProducer

import javax.jms.IllegalStateRuntimeException; //导入依赖的package包/类
@Override
public JMSProducer createProducer() {
    if (connectionRefCount.get() == 0) {
        throw new IllegalStateRuntimeException("The Connection is closed");
    }

    try {
        if (sharedProducer == null) {
            synchronized (this) {
                if (sharedProducer == null) {
                    sharedProducer = (MockJMSMessageProducer) getSession().createProducer(null);
                }
            }
        }

        return new MockJMSProducer(getSession(), sharedProducer);
    } catch (JMSException jmse) {
        throw JMSExceptionSupport.createRuntimeException(jmse);
    }
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:21,代码来源:MockJMSContext.java

示例8: testRun

import javax.jms.IllegalStateRuntimeException; //导入依赖的package包/类
@Test(timeout = 60000)
public void testRun() throws Exception {
    JmsPoolConnection connection = (JmsPoolConnection) cf.createConnection();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

    try {
        session.run();
        fail("Session should be unable to run outside EE.");
    } catch (JMSRuntimeException jmsre) {}

    session.close();

    try {
        session.run();
        fail("Session should be closed.");
    } catch (IllegalStateRuntimeException isre) {}
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:18,代码来源:JmsPoolSessionTest.java

示例9: testSetClientIDTwiceWithSameID

import javax.jms.IllegalStateRuntimeException; //导入依赖的package包/类
@Test(timeout = 60000)
public void testSetClientIDTwiceWithSameID() throws Exception {
    JMSContext context = cf.createContext();

    // test: call setClientID("newID") twice
    // this should be tolerated and not result in an exception
    context.setClientID("newID");

    try {
        context.setClientID("newID");
        context.start();
        context.close();
    } catch (IllegalStateRuntimeException ise) {
        LOG.error("Repeated calls to newID2.setClientID(\"newID\") caused " + ise.getMessage());
        fail("Repeated calls to newID2.setClientID(\"newID\") caused " + ise.getMessage());
    } finally {
        cf.stop();
    }

    LOG.debug("Test finished.");
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:22,代码来源:JmsPoolJMSContextTest.java

示例10: testSetClientIDTwiceWithDifferentID

import javax.jms.IllegalStateRuntimeException; //导入依赖的package包/类
@Test(timeout = 60000)
public void testSetClientIDTwiceWithDifferentID() throws Exception {
    JMSContext context = cf.createContext();

    // test: call setClientID() twice with different IDs
    // this should result in an IllegalStateException
    context.setClientID("newID1");
    try {
        context.setClientID("newID2");
        fail("calling Connection.setClientID() twice with different clientID must raise an IllegalStateException");
    } catch (IllegalStateRuntimeException ise) {
        LOG.debug("Correctly received " + ise);
    } finally {
        context.close();
        cf.stop();
    }

    LOG.debug("Test finished.");
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:20,代码来源:JmsPoolJMSContextTest.java

示例11: testSetClientIDAfterConnectionStart

import javax.jms.IllegalStateRuntimeException; //导入依赖的package包/类
@Test(timeout = 60000)
public void testSetClientIDAfterConnectionStart() throws Exception {
    JMSContext context = cf.createContext();

    // test: try to call setClientID() after start()
    // should result in an exception
    try {
        context.start();
        context.setClientID("newID3");
        fail("Calling setClientID() after start() mut raise a JMSException.");
    } catch (IllegalStateRuntimeException ise) {
        LOG.debug("Correctly received " + ise);
    } finally {
        context.close();
        cf.stop();
    }

    LOG.debug("Test finished.");
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:20,代码来源:JmsPoolJMSContextTest.java

示例12: getSession

import javax.jms.IllegalStateRuntimeException; //导入依赖的package包/类
protected Session getSession() {
    if (session == null) {
        synchronized (this) {
            if (closed)
                throw new IllegalStateRuntimeException("Context is closed");
            if (session == null) {
                try {
                    session = connection.createSession(sessionMode);
                } catch (JMSException e) {
                    throw Utils.convertToRuntimeException(e);
                }
            }
        }
    }
    return session;
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.transx,代码行数:17,代码来源:JMSContextImpl.java

示例13: checkSession

import javax.jms.IllegalStateRuntimeException; //导入依赖的package包/类
/**
 *
 */
private void checkSession() {
   if (session == null) {
      synchronized (this) {
         if (closed)
            throw new IllegalStateRuntimeException("Context is closed");
         if (session == null) {
            try {
               if (xa) {
                  session = ((XAConnection) connection).createXASession();
               } else {
                  session = connection.createSession(sessionMode);
               }
            } catch (JMSException e) {
               throw JmsExceptionUtils.convertToRuntimeException(e);
            }
         }
      }
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:23,代码来源:ActiveMQJMSContext.java

示例14: testRuntimeExceptionFromSendMessage

import javax.jms.IllegalStateRuntimeException; //导入依赖的package包/类
@Test
public void testRuntimeExceptionFromSendMessage() throws JMSException {
    JmsSession session = Mockito.mock(JmsSession.class);
    JmsMessageProducer messageProducer = Mockito.mock(JmsMessageProducer.class);
    Message message = Mockito.mock(Message.class);

    Mockito.when(session.createTemporaryQueue()).thenReturn(new JmsTemporaryQueue());
    Mockito.when(session.createMessage()).thenReturn(message);

    Mockito.doThrow(IllegalStateException.class).when(message).setJMSCorrelationID(anyString());

    JmsProducer producer = new JmsProducer(session, messageProducer);

    producer.setJMSCorrelationID("id");

    try {
        producer.send(session.createTemporaryQueue(), session.createMessage());
        fail("Should have thrown an exception");
    } catch (IllegalStateRuntimeException isre) {}
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:21,代码来源:JmsProducerTest.java

示例15: testRuntimeExceptionFromSendByteBody

import javax.jms.IllegalStateRuntimeException; //导入依赖的package包/类
@Test
public void testRuntimeExceptionFromSendByteBody() throws JMSException {
    JmsSession session = Mockito.mock(JmsSession.class);
    JmsMessageProducer messageProducer = Mockito.mock(JmsMessageProducer.class);

    Mockito.when(session.createTemporaryQueue()).thenReturn(new JmsTemporaryQueue());
    Mockito.when(session.createMessage()).thenReturn(Mockito.mock(Message.class));

    Mockito.doThrow(IllegalStateException.class).when(session).createBytesMessage();

    JmsProducer producer = new JmsProducer(session, messageProducer);

    try {
        producer.send(session.createTemporaryQueue(), new byte[0]);
        fail("Should have thrown an exception");
    } catch (IllegalStateRuntimeException isre) {}
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:18,代码来源:JmsProducerTest.java


注:本文中的javax.jms.IllegalStateRuntimeException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。