You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2015/05/20 15:28:19 UTC
[1/2] qpid-jms git commit: QPIDJMS-54: remove indirection around
selector check, no longer needed
Repository: qpid-jms
Updated Branches:
refs/heads/master 021867fd1 -> 6b7320052
QPIDJMS-54: remove indirection around selector check, no longer needed
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/760e0224
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/760e0224
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/760e0224
Branch: refs/heads/master
Commit: 760e0224f9d25ad043c74fa83e38737d9edce299
Parents: 021867f
Author: Robert Gemmell <ro...@apache.org>
Authored: Wed May 20 10:57:51 2015 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Wed May 20 14:27:16 2015 +0100
----------------------------------------------------------------------
.../java/org/apache/qpid/jms/JmsSession.java | 35 ++++----------------
1 file changed, 6 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/760e0224/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsSession.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsSession.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsSession.java
index 3f6ef07..19d86e5 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsSession.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsSession.java
@@ -79,7 +79,6 @@ import org.slf4j.LoggerFactory;
/**
* JMS Session implementation
*/
-@SuppressWarnings("static-access")
public class JmsSession implements Session, QueueSession, TopicSession, JmsMessageDispatcher {
private static final Logger LOG = LoggerFactory.getLogger(JmsSession.class);
@@ -821,38 +820,16 @@ public class JmsSession implements Session, QueueSession, TopicSession, JmsMessa
}
}
- // This extra wrapping class around SelectorParser is used to avoid
- // ClassNotFoundException if SelectorParser is not in the class path.
- static class OptionalSectorParser {
- public static void check(String selector) throws InvalidSelectorException {
- try {
- SelectorParser.parse(selector);
- } catch (FilterException e) {
- throw new InvalidSelectorException(e.getMessage());
- }
- }
- }
-
- static final OptionalSectorParser SELECTOR_PARSER;
- static {
- OptionalSectorParser parser;
- try {
- // lets verify it's working..
- parser = new OptionalSectorParser();
- parser.check("x=1");
- } catch (Throwable e) {
- parser = null;
- }
- SELECTOR_PARSER = parser;
- }
-
- public static String checkSelector(String selector) throws InvalidSelectorException {
+ static String checkSelector(String selector) throws InvalidSelectorException {
if (selector != null) {
if (selector.trim().length() == 0) {
return null;
}
- if (SELECTOR_PARSER != null) {
- SELECTOR_PARSER.check(selector);
+
+ try {
+ SelectorParser.parse(selector);
+ } catch (FilterException e) {
+ throw new InvalidSelectorException(e.getMessage());
}
}
return selector;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[2/2] qpid-jms git commit: QPIDJMS-49, QPIDJMS-52,
QPIDJMS-53: add some integration tests to verify the pieces are wired
up
Posted by ro...@apache.org.
QPIDJMS-49, QPIDJMS-52, QPIDJMS-53: add some integration tests to verify the pieces are wired up
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/6b732005
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/6b732005
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/6b732005
Branch: refs/heads/master
Commit: 6b7320052b26fb2345bd3c7aac44e94857c98cbd
Parents: 760e022
Author: Robert Gemmell <ro...@apache.org>
Authored: Wed May 20 13:03:21 2015 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Wed May 20 14:27:36 2015 +0100
----------------------------------------------------------------------
.../BytesMessageIntegrationTest.java | 32 ++++++-
.../integration/TextMessageIntegrationTest.java | 87 ++++++++++++++++++++
2 files changed, 115 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/6b732005/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/BytesMessageIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/BytesMessageIntegrationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/BytesMessageIntegrationTest.java
index c3a5c36..71fe052 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/BytesMessageIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/BytesMessageIntegrationTest.java
@@ -25,10 +25,12 @@ import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
+import java.io.IOException;
import java.util.Arrays;
import javax.jms.BytesMessage;
import javax.jms.Connection;
+import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
@@ -89,7 +91,26 @@ public class BytesMessageIntegrationTest extends QpidJmsTestCase {
}
@Test(timeout = 5000)
- public void testReceiveBasicBytesMessageWithContentUsingDataSection() throws Exception {
+ public void testReceiveBytesMessageUsingDataSectionWithContentTypeOctectStream() throws Exception {
+ doReceiveBasicBytesMessageUsingDataSectionTestImpl(AmqpMessageSupport.OCTET_STREAM_CONTENT_TYPE, true);
+ }
+
+ @Test(timeout = 5000)
+ public void testReceiveBytesMessageUsingDataSectionWithContentTypeOctectStreamNoTypeAnnotation() throws Exception {
+ doReceiveBasicBytesMessageUsingDataSectionTestImpl(AmqpMessageSupport.OCTET_STREAM_CONTENT_TYPE, false);
+ }
+
+ @Test(timeout = 5000)
+ public void testReceiveBasicBytesMessageUsingDataSectionWithContentTypeEmptyNoTypeAnnotation() throws Exception {
+ doReceiveBasicBytesMessageUsingDataSectionTestImpl("", false);
+ }
+
+ @Test(timeout = 5000)
+ public void testReceiveBasicBytesMessageUsingDataSectionWithContentTypeUnknownNoTypeAnnotation() throws Exception {
+ doReceiveBasicBytesMessageUsingDataSectionTestImpl("type/unknown", false);
+ }
+
+ private void doReceiveBasicBytesMessageUsingDataSectionTestImpl(String contentType, boolean typeAnnotation) throws JMSException, InterruptedException, Exception, IOException {
try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
Connection connection = testFixture.establishConnecton(testPeer);
connection.start();
@@ -100,10 +121,13 @@ public class BytesMessageIntegrationTest extends QpidJmsTestCase {
Queue queue = session.createQueue("myQueue");
PropertiesDescribedType properties = new PropertiesDescribedType();
- properties.setContentType(Symbol.valueOf(AmqpMessageSupport.OCTET_STREAM_CONTENT_TYPE));
+ properties.setContentType(Symbol.valueOf(contentType));
- MessageAnnotationsDescribedType msgAnnotations = new MessageAnnotationsDescribedType();
- msgAnnotations.setSymbolKeyedAnnotation(AmqpMessageSupport.JMS_MSG_TYPE, AmqpMessageSupport.JMS_BYTES_MESSAGE);
+ MessageAnnotationsDescribedType msgAnnotations = null;
+ if (typeAnnotation) {
+ msgAnnotations = new MessageAnnotationsDescribedType();
+ msgAnnotations.setSymbolKeyedAnnotation(AmqpMessageSupport.JMS_MSG_TYPE, AmqpMessageSupport.JMS_BYTES_MESSAGE);
+ }
final byte[] expectedContent = "expectedContent".getBytes();
DescribedType dataContent = new DataDescribedType(new Binary(expectedContent));
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/6b732005/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/TextMessageIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/TextMessageIntegrationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/TextMessageIntegrationTest.java
index c6af404..96f0924 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/TextMessageIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/TextMessageIntegrationTest.java
@@ -24,7 +24,10 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import java.io.IOException;
+
import javax.jms.Connection;
+import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
@@ -35,12 +38,16 @@ import javax.jms.TextMessage;
import org.apache.qpid.jms.test.QpidJmsTestCase;
import org.apache.qpid.jms.test.testpeer.TestAmqpPeer;
import org.apache.qpid.jms.test.testpeer.describedtypes.sections.AmqpValueDescribedType;
+import org.apache.qpid.jms.test.testpeer.describedtypes.sections.DataDescribedType;
+import org.apache.qpid.jms.test.testpeer.describedtypes.sections.PropertiesDescribedType;
import org.apache.qpid.jms.test.testpeer.matchers.sections.MessageAnnotationsSectionMatcher;
import org.apache.qpid.jms.test.testpeer.matchers.sections.MessageHeaderSectionMatcher;
import org.apache.qpid.jms.test.testpeer.matchers.sections.MessagePropertiesSectionMatcher;
import org.apache.qpid.jms.test.testpeer.matchers.sections.TransferPayloadCompositeMatcher;
import org.apache.qpid.jms.test.testpeer.matchers.types.EncodedAmqpValueMatcher;
+import org.apache.qpid.proton.amqp.Binary;
import org.apache.qpid.proton.amqp.DescribedType;
+import org.apache.qpid.proton.amqp.Symbol;
import org.junit.Test;
public class TextMessageIntegrationTest extends QpidJmsTestCase {
@@ -157,4 +164,84 @@ public class TextMessageIntegrationTest extends QpidJmsTestCase {
assertNull(((TextMessage) receivedMessage).getText());
}
}
+
+ @Test(timeout = 5000)
+ public void testReceiveTextMessageUsingDataSectionWithContentTypeTextPlainNoTypeAnnotation() throws Exception {
+ String expectedString = "expectedContent";
+ final byte[] sentBytes = expectedString.getBytes("UTF-8");
+
+ doReceiveTextMessageUsingDataSectionTestImpl("text/plain", sentBytes, expectedString);
+ }
+
+ @Test(timeout = 5000)
+ public void testReceiveTextMessageUsingDataSectionWithContentTypeTextPlainCharsetUtf8NoTypeAnnotation() throws Exception {
+ String expectedString = "expectedContent";
+ final byte[] sentBytes = expectedString.getBytes("UTF-8");
+
+ doReceiveTextMessageUsingDataSectionTestImpl("text/plain;charset=utf-8", sentBytes, expectedString);
+ }
+
+ @Test(timeout = 5000)
+ public void testReceiveTextMessageUsingDataSectionWithContentTypeTextPlainCharsetUtf16NoTypeAnnotation() throws Exception {
+ String expectedString = "expectedContent";
+ final byte[] sentBytes = expectedString.getBytes("UTF-16");
+
+ doReceiveTextMessageUsingDataSectionTestImpl("text/plain;charset=utf-16", sentBytes, expectedString);
+ }
+
+ @Test(timeout = 5000)
+ public void testReceiveTextMessageUsingDataSectionWithContentTypeTextOtherNoTypeAnnotation() throws Exception {
+ String expectedString = "expectedContent";
+ final byte[] sentBytes = expectedString.getBytes("UTF-8");
+
+ doReceiveTextMessageUsingDataSectionTestImpl("text/other", sentBytes, expectedString);
+ }
+
+ @Test(timeout = 5000)
+ public void testReceiveTextMessageUsingDataSectionWithContentTypeApplicationJsonNoTypeAnnotation() throws Exception {
+ String expectedString = "expectedContent";
+ final byte[] sentBytes = expectedString.getBytes("UTF-8");
+
+ doReceiveTextMessageUsingDataSectionTestImpl("application/json", sentBytes, expectedString);
+ }
+
+ @Test(timeout = 5000)
+ public void testReceiveTextMessageUsingDataSectionWithContentTypeApplicationXmlNoTypeAnnotation() throws Exception {
+ String expectedString = "expectedContent";
+ final byte[] sentBytes = expectedString.getBytes("UTF-8");
+
+ doReceiveTextMessageUsingDataSectionTestImpl("application/xml", sentBytes, expectedString);
+ }
+
+ private void doReceiveTextMessageUsingDataSectionTestImpl(String contentType, byte[] sentBytes, String expectedString)
+ throws JMSException, InterruptedException, Exception, IOException {
+ try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
+ Connection connection = testFixture.establishConnecton(testPeer);
+ connection.start();
+
+ testPeer.expectBegin(true);
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Queue queue = session.createQueue("myQueue");
+
+ PropertiesDescribedType properties = new PropertiesDescribedType();
+ properties.setContentType(Symbol.valueOf(contentType));
+
+ DescribedType dataContent = new DataDescribedType(new Binary(sentBytes));
+
+ testPeer.expectReceiverAttach();
+ testPeer.expectLinkFlowRespondWithTransfer(null, null, properties, null, dataContent);
+ testPeer.expectDispositionThatIsAcceptedAndSettled();
+
+ MessageConsumer messageConsumer = session.createConsumer(queue);
+ Message receivedMessage = messageConsumer.receive(1000);
+ testPeer.waitForAllHandlersToComplete(3000);
+
+ assertNotNull(receivedMessage);
+ assertTrue(receivedMessage instanceof TextMessage);
+ String text = ((TextMessage) receivedMessage).getText();
+
+ assertEquals(expectedString, text);
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org