类javax.jms.InvalidSelectorException源码实例Demo

下面列出了怎么用javax.jms.InvalidSelectorException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: qpid-jms   文件: SessionIntegrationTest.java
@Test(timeout = 20000)
public void testInvalidSelector() throws Exception {
    try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
        Connection connection = testFixture.establishConnecton(testPeer);
        connection.start();

        testPeer.expectBegin();
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

        String topicName = "myTopic";
        Topic destination = session.createTopic(topicName);

        try {
            session.createConsumer(destination, "3+5");
            fail("Should have thrown a invalid selector exception");
        } catch (InvalidSelectorException jmsse) {
        }

        testPeer.expectClose();
        connection.close();

        testPeer.waitForAllHandlersToComplete(1000);
    }
}
 
源代码2 项目: activemq-artemis   文件: SelectorParserTest.java
public void testFunctionCall() throws Exception {
   Object filter = parse("REGEX('sales.*', group)");
   assertTrue("expected type", filter instanceof BooleanFunctionCallExpr);
   LOG.info("function exp:" + filter);

   // non existent function
   try {
      parse("DoesNotExist('sales.*', group)");
      fail("expect ex on non existent function");
   } catch (InvalidSelectorException expected) {
   }

}
 
源代码3 项目: activemq-artemis   文件: SelectorTest.java
protected void assertInvalidSelector(Message message, String text) throws JMSException {
   try {
      SelectorParser.parse(text);
      fail("Created a valid selector");
   } catch (InvalidSelectorException e) {
   }
}
 
@Test
public void testInvalidSelectorOnSubscription() throws Exception {
   TopicConnection c = createTopicConnection();
   c.setClientID("something");

   TopicSession s = c.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);

   try {
      s.createSubscriber(ActiveMQServerTestCase.topic1, "=TEST 'test'", false);
      ProxyAssertSupport.fail("this should fail");
   } catch (InvalidSelectorException e) {
      // OK
   }
}
 
@Test
public void testInvalidSelectorException() throws Exception {
   Connection c = createConnection();
   c.setClientID("sofiavergara");
   Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);

   try {
      s.createDurableSubscriber(ActiveMQServerTestCase.topic1, "mysubscribption", "=TEST 'test'", true);
      ProxyAssertSupport.fail("this should fail");
   } catch (InvalidSelectorException e) {
      // OK
   }
}
 
源代码6 项目: activemq-artemis   文件: JmsExceptionUtils.java
/**
 * Converts instances of sub-classes of {@link JMSException} into the corresponding sub-class of
 * {@link JMSRuntimeException}.
 *
 * @param e
 * @return
 */
public static JMSRuntimeException convertToRuntimeException(JMSException e) {
   if (e instanceof javax.jms.IllegalStateException) {
      return new IllegalStateRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof InvalidClientIDException) {
      return new InvalidClientIDRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof InvalidDestinationException) {
      return new InvalidDestinationRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof InvalidSelectorException) {
      return new InvalidSelectorRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof JMSSecurityException) {
      return new JMSSecurityRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof MessageFormatException) {
      return new MessageFormatRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof MessageNotWriteableException) {
      return new MessageNotWriteableRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof ResourceAllocationException) {
      return new ResourceAllocationRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof TransactionInProgressException) {
      return new TransactionInProgressRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof TransactionRolledBackException) {
      return new TransactionRolledBackRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   return new JMSRuntimeException(e.getMessage(), e.getErrorCode(), e);
}
 
源代码7 项目: qpid-jms   文件: JmsSession.java
static String checkSelector(String selector) throws InvalidSelectorException {
    if (selector != null) {
        if (selector.trim().length() == 0) {
            return null;
        }

        try {
            SelectorParser.parse(selector);
        } catch (FilterException e) {
            throw new InvalidSelectorException(e.getMessage());
        }
    }
    return selector;
}
 
源代码8 项目: tomee   文件: JMS2.java
public static JMSRuntimeException toRuntimeException(final JMSException e) {
    if (e instanceof javax.jms.IllegalStateException) {
        return new IllegalStateRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof InvalidClientIDException) {
        return new InvalidClientIDRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof InvalidDestinationException) {
        return new InvalidDestinationRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof InvalidSelectorException) {
        return new InvalidSelectorRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof JMSSecurityException) {
        return new JMSSecurityRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof MessageFormatException) {
        return new MessageFormatRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof MessageNotWriteableException) {
        return new MessageNotWriteableRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof ResourceAllocationException) {
        return new ResourceAllocationRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof TransactionInProgressException) {
        return new TransactionInProgressRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof TransactionRolledBackException) {
        return new TransactionRolledBackRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    return new JMSRuntimeException(e.getMessage(), e.getErrorCode(), e);
}
 
源代码9 项目: pooled-jms   文件: JMSExceptionSupportTest.java
@Test(expected = InvalidSelectorRuntimeException.class)
public void testConvertsInvalidSelectorExceptionToInvalidSelectorRuntimeException() {
    throw JMSExceptionSupport.createRuntimeException(new InvalidSelectorException("error"));
}
 
@Override
public void setSelector(String selector) throws InvalidSelectorException, UnsupportedOperationException {
}
 
源代码11 项目: activemq-artemis   文件: JMSExceptionHelperTest.java
@Test
public void testINVALID_FILTER_EXPRESSION() throws Exception {
   doConvertException(INVALID_FILTER_EXPRESSION, InvalidSelectorException.class);
}
 
源代码12 项目: qpid-jms   文件: JmsExceptionSupportTest.java
@Test(expected = InvalidSelectorRuntimeException.class)
public void testConvertsInvalidSelectorExceptionToInvalidSelectorRuntimeException() {
    throw JmsExceptionSupport.createRuntimeException(new InvalidSelectorException("error"));
}
 
 类所在包
 同包方法