• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IllegalStateRuntimeException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testRuntimeExceptionFromSendMapBody

import javax.jms.IllegalStateRuntimeException; //导入依赖的package包/类
@Test
public void testRuntimeExceptionFromSendMapBody() 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).createMapMessage();

    JmsProducer producer = new JmsProducer(session, messageProducer);

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


示例17: testRuntimeExceptionFromSendSerializableBody

import javax.jms.IllegalStateRuntimeException; //导入依赖的package包/类
@Test
public void testRuntimeExceptionFromSendSerializableBody() 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).createObjectMessage();

    JmsProducer producer = new JmsProducer(session, messageProducer);

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


示例18: testRuntimeExceptionFromSendStringBody

import javax.jms.IllegalStateRuntimeException; //导入依赖的package包/类
@Test
public void testRuntimeExceptionFromSendStringBody() 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).createTextMessage(anyString());

    JmsProducer producer = new JmsProducer(session, messageProducer);

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


示例19: testRuntimeExceptionOnGetMessageListener

import javax.jms.IllegalStateRuntimeException; //导入依赖的package包/类
@Test
public void testRuntimeExceptionOnGetMessageListener() throws JMSException {
    JmsSession session = Mockito.mock(JmsSession.class);
    JmsMessageConsumer messageConsumer = Mockito.mock(JmsMessageConsumer.class);
    JmsConsumer consumer = new JmsConsumer(session, messageConsumer);

    Mockito.doThrow(IllegalStateException.class).when(messageConsumer).getMessageListener();

    try {
        consumer.getMessageListener();
        fail("Should throw ISRE");
    } catch (IllegalStateRuntimeException isre) {
    } finally {
        consumer.close();
    }
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:17,代码来源:JmsConsumerTest.java


示例20: testRuntimeExceptionOnSetMessageListener

import javax.jms.IllegalStateRuntimeException; //导入依赖的package包/类
@Test
public void testRuntimeExceptionOnSetMessageListener() throws JMSException {
    JmsSession session = Mockito.mock(JmsSession.class);
    JmsMessageConsumer messageConsumer = Mockito.mock(JmsMessageConsumer.class);
    JmsConsumer consumer = new JmsConsumer(session, messageConsumer);

    Mockito.doThrow(IllegalStateException.class).when(messageConsumer).setMessageListener(null);

    try {
        consumer.setMessageListener(null);
        fail("Should throw ISRE");
    } catch (IllegalStateRuntimeException isre) {
    } finally {
        consumer.close();
    }
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:17,代码来源:JmsConsumerTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RRset类代码示例发布时间:2022-05-22
下一篇:
Java RESTMapper类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap