AMQ-5592: remove some unused stale functionlity, bring into line with latest missed commits from current almost-0.9 codebase.

https://issues.apache.org/jira/browse/AMQ-5592
This commit is contained in:
Robert Gemmell 2015-02-19 19:43:11 +00:00
parent 45e59e6e83
commit 37b1b6a211
7 changed files with 63 additions and 316 deletions

View File

@ -42,11 +42,4 @@ public class AutoOutboundTransformer extends JMSMappingOutboundTransformer {
return transformer.transform(msg);
}
}
@Override
public void setUseByteDestinationTypeAnnotations(boolean useByteDestinationTypeAnnotations)
{
super.setUseByteDestinationTypeAnnotations(useByteDestinationTypeAnnotations);
transformer.setUseByteDestinationTypeAnnotations(useByteDestinationTypeAnnotations);
}
}

View File

@ -63,22 +63,12 @@ public abstract class InboundTransformer {
int defaultPriority = javax.jms.Message.DEFAULT_PRIORITY;
long defaultTtl = javax.jms.Message.DEFAULT_TIME_TO_LIVE;
private boolean useByteDestinationTypeAnnotations = false;
public InboundTransformer(JMSVendor vendor) {
this.vendor = vendor;
}
abstract public Message transform(EncodedMessage amqpMessage) throws Exception;
public boolean isUseByteDestinationTypeAnnotations() {
return useByteDestinationTypeAnnotations;
}
public void setUseByteDestinationTypeAnnotations(boolean useByteDestinationTypeAnnotations) {
this.useByteDestinationTypeAnnotations = useByteDestinationTypeAnnotations;
}
public int getDefaultDeliveryMode() {
return defaultDeliveryMode;
}
@ -151,16 +141,8 @@ public abstract class InboundTransformer {
}
}
Class<? extends Destination> toAttributes = null;
Class<? extends Destination> replyToAttributes = null;
if (isUseByteDestinationTypeAnnotations()) {
toAttributes = Queue.class;
replyToAttributes = Queue.class;
} else {
toAttributes = Destination.class;
replyToAttributes = Destination.class;
}
Class<? extends Destination> toAttributes = Destination.class;
Class<? extends Destination> replyToAttributes = Destination.class;
final MessageAnnotations ma = amqp.getMessageAnnotations();
if (ma != null) {
@ -169,9 +151,9 @@ public abstract class InboundTransformer {
if ("x-opt-jms-type".equals(key.toString()) && entry.getValue() != null) {
jms.setJMSType(entry.getValue().toString());
} else if ("x-opt-to-type".equals(key.toString())) {
toAttributes = toClassFromAttributes(entry.getValue());
toAttributes = toClassFromAttributes(entry.getValue().toString());
} else if ("x-opt-reply-type".equals(key.toString())) {
replyToAttributes = toClassFromAttributes(entry.getValue());
replyToAttributes = toClassFromAttributes(entry.getValue().toString());
} else {
setProperty(jms, prefixVendor + prefixMessageAnnotations + key, entry.getValue());
}
@ -274,48 +256,27 @@ public abstract class InboundTransformer {
return Collections.unmodifiableSet(s);
}
Class<? extends Destination> toClassFromAttributes(Object value) {
if (isUseByteDestinationTypeAnnotations()) {
if (value instanceof Byte) {
switch ((Byte) value) {
case JMSVendor.QUEUE_TYPE:
return Queue.class;
case JMSVendor.TOPIC_TYPE:
return Topic.class;
case JMSVendor.TEMP_QUEUE_TYPE:
return TemporaryQueue.class;
case JMSVendor.TEMP_TOPIC_TYPE:
return TemporaryTopic.class;
default:
return Queue.class;
}
}
return Queue.class;
} else {
if (value == null) {
return null;
}
String valueString = value.toString();
HashSet<String> attributes = new HashSet<String>();
for (String x : valueString.split("\\s*,\\s*")) {
attributes.add(x);
}
if (QUEUE_ATTRIBUTES.equals(attributes)) {
return Queue.class;
}
if (TOPIC_ATTRIBUTES.equals(attributes)) {
return Topic.class;
}
if (TEMP_QUEUE_ATTRIBUTES.equals(attributes)) {
return TemporaryQueue.class;
}
if (TEMP_TOPIC_ATTRIBUTES.equals(attributes)) {
return TemporaryTopic.class;
}
return Destination.class;
Class<? extends Destination> toClassFromAttributes(String value) {
if( value ==null ) {
return null;
}
HashSet<String> attributes = new HashSet<String>();
for( String x: value.split("\\s*,\\s*") ) {
attributes.add(x);
}
if( QUEUE_ATTRIBUTES.equals(attributes) ) {
return Queue.class;
}
if( TOPIC_ATTRIBUTES.equals(attributes) ) {
return Topic.class;
}
if( TEMP_QUEUE_ATTRIBUTES.equals(attributes) ) {
return TemporaryQueue.class;
}
if( TEMP_TOPIC_ATTRIBUTES.equals(attributes) ) {
return TemporaryTopic.class;
}
return Destination.class;
}
private void setProperty(Message msg, String key, Object value) throws JMSException {

View File

@ -276,39 +276,21 @@ public class JMSMappingOutboundTransformer extends OutboundTransformer {
return (ProtonJMessage) org.apache.qpid.proton.message.Message.Factory.create(header, da, ma, props, ap, body, footer);
}
private Object destinationAttributes(Destination destination) {
if (isUseByteDestinationTypeAnnotations()) {
if (destination instanceof Queue) {
if (destination instanceof TemporaryQueue) {
return JMSVendor.TEMP_QUEUE_TYPE;
} else {
return JMSVendor.QUEUE_TYPE;
}
private static String destinationAttributes(Destination destination) {
if (destination instanceof Queue) {
if (destination instanceof TemporaryQueue) {
return "temporary,queue";
} else {
return "queue";
}
if (destination instanceof Topic) {
if (destination instanceof TemporaryTopic) {
return JMSVendor.TEMP_TOPIC_TYPE;
} else {
return JMSVendor.TOPIC_TYPE;
}
}
return JMSVendor.QUEUE_TYPE;
} else {
if (destination instanceof Queue) {
if (destination instanceof TemporaryQueue) {
return "temporary,queue";
} else {
return "queue";
}
}
if (destination instanceof Topic) {
if (destination instanceof TemporaryTopic) {
return "temporary,topic";
} else {
return "topic";
}
}
return "";
}
if (destination instanceof Topic) {
if (destination instanceof TemporaryTopic) {
return "temporary,topic";
} else {
return "topic";
}
}
return "";
}
}

View File

@ -26,11 +26,6 @@ import javax.jms.TextMessage;
abstract public class JMSVendor {
public static final byte QUEUE_TYPE = 0x00;
public static final byte TOPIC_TYPE = 0x01;
public static final byte TEMP_QUEUE_TYPE = 0x02;
public static final byte TEMP_TOPIC_TYPE = 0x03;
public abstract BytesMessage createBytesMessage();
public abstract StreamMessage createStreamMessage();

View File

@ -38,25 +38,13 @@ public abstract class OutboundTransformer {
String replyToGroupIDKey;
String prefixFooterKey;
private boolean useByteDestinationTypeAnnotations;
public OutboundTransformer(JMSVendor vendor) {
public OutboundTransformer(JMSVendor vendor) {
this.vendor = vendor;
this.setPrefixVendor("JMS_AMQP_");
}
public abstract EncodedMessage transform(Message jms) throws Exception;
public boolean isUseByteDestinationTypeAnnotations()
{
return useByteDestinationTypeAnnotations;
}
public void setUseByteDestinationTypeAnnotations(boolean useByteDestinationTypeAnnotations)
{
this.useByteDestinationTypeAnnotations = useByteDestinationTypeAnnotations;
}
public String getPrefixVendor() {
return prefixVendor;
}

View File

@ -59,67 +59,35 @@ public class JMSMappingInboundTransformerTest {
// ======= JMSDestination Handling =========
// --- String type annotation ---
@Test
public void testTransformWithNoToTypeDestinationTypeAnnotation() throws Exception {
doTransformWithToTypeDestinationTypeAnnotationTestImpl(null, Destination.class, false);
doTransformWithToTypeDestinationTypeAnnotationTestImpl(null, Destination.class);
}
@Test
public void testTransformWithQueueStringToTypeDestinationTypeAnnotation() throws Exception {
doTransformWithToTypeDestinationTypeAnnotationTestImpl("queue", Queue.class, false);
doTransformWithToTypeDestinationTypeAnnotationTestImpl("queue", Queue.class);
}
@Test
public void testTransformWithTemporaryQueueStringToTypeDestinationTypeAnnotation() throws Exception {
doTransformWithToTypeDestinationTypeAnnotationTestImpl("queue,temporary", TemporaryQueue.class, false);
doTransformWithToTypeDestinationTypeAnnotationTestImpl("queue,temporary", TemporaryQueue.class);
}
@Test
public void testTransformWithTopicStringToTypeDestinationTypeAnnotation() throws Exception {
doTransformWithToTypeDestinationTypeAnnotationTestImpl("topic", Topic.class, false);
doTransformWithToTypeDestinationTypeAnnotationTestImpl("topic", Topic.class);
}
@Test
public void testTransformWithTemporaryTopicStringToTypeDestinationTypeAnnotation() throws Exception {
doTransformWithToTypeDestinationTypeAnnotationTestImpl("topic,temporary", TemporaryTopic.class, false);
doTransformWithToTypeDestinationTypeAnnotationTestImpl("topic,temporary", TemporaryTopic.class);
}
// --- byte type annotation ---
@Test
public void testTransformWithNoToTypeDestinationTypeAnnotationUsingByteAnnotation() throws Exception {
doTransformWithToTypeDestinationTypeAnnotationTestImpl(null, Queue.class, true);
}
@Test
public void testTransformWithQueueByteToTypeDestinationTypeAnnotation() throws Exception {
doTransformWithToTypeDestinationTypeAnnotationTestImpl(JMSVendor.QUEUE_TYPE, Queue.class, true);
}
@Test
public void testTransformWithTemporaryQueueByteToTypeDestinationTypeAnnotation() throws Exception {
doTransformWithToTypeDestinationTypeAnnotationTestImpl(JMSVendor.TEMP_QUEUE_TYPE, TemporaryQueue.class, true);
}
@Test
public void testTransformWithTopicByteToTypeDestinationTypeAnnotation() throws Exception {
doTransformWithToTypeDestinationTypeAnnotationTestImpl(JMSVendor.TOPIC_TYPE, Topic.class, true);
}
@Test
public void testTransformWithTemporaryTopicByteToTypeDestinationTypeAnnotation() throws Exception {
doTransformWithToTypeDestinationTypeAnnotationTestImpl(JMSVendor.TEMP_TOPIC_TYPE, TemporaryTopic.class, true);
}
private void doTransformWithToTypeDestinationTypeAnnotationTestImpl(Object toTypeAnnotationValue, Class<? extends Destination> expectedClass,
boolean byteType) throws Exception {
private void doTransformWithToTypeDestinationTypeAnnotationTestImpl(Object toTypeAnnotationValue, Class<? extends Destination> expectedClass) throws Exception {
TextMessage mockTextMessage = createMockTextMessage();
JMSVendor mockVendor = createMockVendor(mockTextMessage);
JMSMappingInboundTransformer transformer = new JMSMappingInboundTransformer(mockVendor);
if (byteType) {
transformer.setUseByteDestinationTypeAnnotations(true);
}
String toAddress = "toAddress";
Message amqp = Message.Factory.create();
@ -144,66 +112,35 @@ public class JMSMappingInboundTransformerTest {
// ======= JMSReplyTo Handling =========
// --- String type annotation ---
@Test
public void testTransformWithNoReplyToTypeDestinationTypeAnnotation() throws Exception {
doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl(null, Destination.class, false);
doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl(null, Destination.class);
}
@Test
public void testTransformWithQueueStringReplyToTypeDestinationTypeAnnotation() throws Exception {
doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl("queue", Queue.class, false);
doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl("queue", Queue.class);
}
@Test
public void testTransformWithTemporaryQueueStringReplyToTypeDestinationTypeAnnotation() throws Exception {
doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl("queue,temporary", TemporaryQueue.class, false);
doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl("queue,temporary", TemporaryQueue.class);
}
@Test
public void testTransformWithTopicStringReplyToTypeDestinationTypeAnnotation() throws Exception {
doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl("topic", Topic.class, false);
doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl("topic", Topic.class);
}
@Test
public void testTransformWithTemporaryTopicStringReplyToTypeDestinationTypeAnnotation() throws Exception {
doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl("topic,temporary", TemporaryTopic.class, false);
doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl("topic,temporary", TemporaryTopic.class);
}
// --- byte type annotation ---
@Test
public void testTransformWithNoReplyToTypeDestinationTypeAnnotationUsingByteAnnotation() throws Exception {
doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl(null, Queue.class, true);
}
@Test
public void testTransformWithQueueByteReplyToTypeDestinationTypeAnnotation() throws Exception {
doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl(JMSVendor.QUEUE_TYPE, Queue.class, true);
}
@Test
public void testTransformWithTemporaryQueueByteReplyToTypeDestinationTypeAnnotation() throws Exception {
doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl(JMSVendor.TEMP_QUEUE_TYPE, TemporaryQueue.class, true);
}
@Test
public void testTransformWithTopicByteReplyToTypeDestinationTypeAnnotation() throws Exception {
doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl(JMSVendor.TOPIC_TYPE, Topic.class, true);
}
@Test
public void testTransformWithTemporaryTopicByteReplyToTypeDestinationTypeAnnotation() throws Exception {
doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl(JMSVendor.TEMP_TOPIC_TYPE, TemporaryTopic.class, true);
}
private void doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl(Object replyToTypeAnnotationValue, Class<? extends Destination> expectedClass,
boolean byteType) throws Exception {
private void doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl(Object replyToTypeAnnotationValue, Class<? extends Destination> expectedClass) throws Exception {
TextMessage mockTextMessage = createMockTextMessage();
JMSVendor mockVendor = createMockVendor(mockTextMessage);
JMSMappingInboundTransformer transformer = new JMSMappingInboundTransformer(mockVendor);
if (byteType) {
transformer.setUseByteDestinationTypeAnnotations(true);
}
String replyToAddress = "replyToAddress";
Message amqp = Message.Factory.create();

View File

@ -57,103 +57,42 @@ public class JMSMappingOutboundTransformerTest {
assertEquals(contentString, ((AmqpValue) amqp.getBody()).getValue());
}
@Test
public void testDefaultsTolStringDestinationTypeAnnotationValues() {
JMSVendor mockVendor = createMockVendor();
JMSMappingOutboundTransformer transformer = new JMSMappingOutboundTransformer(mockVendor);
assertFalse("Expected the older string style annotation values to be used by default", transformer.isUseByteDestinationTypeAnnotations());
}
@Test
public void testSetGetIsUseByteDestinationTypeAnnotations() {
JMSVendor mockVendor = createMockVendor();
JMSMappingOutboundTransformer transformer = new JMSMappingOutboundTransformer(mockVendor);
assertFalse(transformer.isUseByteDestinationTypeAnnotations());
transformer.setUseByteDestinationTypeAnnotations(true);
assertTrue(transformer.isUseByteDestinationTypeAnnotations());
}
// ======= JMSDestination Handling =========
// --- String type annotation ---
@Test
public void testConvertMessageWithJMSDestinationNull() throws Exception {
doTestConvertMessageWithJMSDestination(null, null, false);
doTestConvertMessageWithJMSDestination(null, null);
}
@Test
public void testConvertMessageWithJMSDestinationQueue() throws Exception {
Queue mockDest = Mockito.mock(Queue.class);
doTestConvertMessageWithJMSDestination(mockDest, "queue", false);
doTestConvertMessageWithJMSDestination(mockDest, "queue");
}
@Test
public void testConvertMessageWithJMSDestinationTemporaryQueue() throws Exception {
TemporaryQueue mockDest = Mockito.mock(TemporaryQueue.class);
doTestConvertMessageWithJMSDestination(mockDest, "temporary,queue", false);
doTestConvertMessageWithJMSDestination(mockDest, "temporary,queue");
}
@Test
public void testConvertMessageWithJMSDestinationTopic() throws Exception {
Topic mockDest = Mockito.mock(Topic.class);
doTestConvertMessageWithJMSDestination(mockDest, "topic", false);
doTestConvertMessageWithJMSDestination(mockDest, "topic");
}
@Test
public void testConvertMessageWithJMSDestinationTemporaryTopic() throws Exception {
TemporaryTopic mockDest = Mockito.mock(TemporaryTopic.class);
doTestConvertMessageWithJMSDestination(mockDest, "temporary,topic", false);
doTestConvertMessageWithJMSDestination(mockDest, "temporary,topic");
}
// --- byte type annotation ---
@Test
public void testConvertMessageWithJMSDestinationNullUsingByteAnnotation() throws Exception {
doTestConvertMessageWithJMSDestination(null, null, true);
}
@Test
public void testConvertMessageWithJMSDestinationQueueUsingByteAnnotation() throws Exception {
Queue mockDest = Mockito.mock(Queue.class);
doTestConvertMessageWithJMSDestination(mockDest, JMSVendor.QUEUE_TYPE, true);
}
@Test
public void testConvertMessageWithJMSDestinationTemporaryQueueUsingByteAnnotation() throws Exception {
TemporaryQueue mockDest = Mockito.mock(TemporaryQueue.class);
doTestConvertMessageWithJMSDestination(mockDest, JMSVendor.TEMP_QUEUE_TYPE, true);
}
@Test
public void testConvertMessageWithJMSDestinationTopicUsingByteAnnotation() throws Exception {
Topic mockDest = Mockito.mock(Topic.class);
doTestConvertMessageWithJMSDestination(mockDest, JMSVendor.TOPIC_TYPE, true);
}
@Test
public void testConvertMessageWithJMSDestinationTemporaryTopicUsingByteAnnotation() throws Exception {
TemporaryTopic mockDest = Mockito.mock(TemporaryTopic.class);
doTestConvertMessageWithJMSDestination(mockDest, JMSVendor.TEMP_TOPIC_TYPE, true);
}
@Test
public void testConvertMessageWithJMSDestinationUnkownUsingByteAnnotation() throws Exception {
Destination mockDest = Mockito.mock(Destination.class);
doTestConvertMessageWithJMSDestination(mockDest, JMSVendor.QUEUE_TYPE, true);
}
private void doTestConvertMessageWithJMSDestination(Destination jmsDestination, Object expectedAnnotationValue, boolean byteType) throws Exception {
private void doTestConvertMessageWithJMSDestination(Destination jmsDestination, Object expectedAnnotationValue) throws Exception {
TextMessage mockTextMessage = createMockTextMessage();
Mockito.when(mockTextMessage.getText()).thenReturn("myTextMessageContent");
Mockito.when(mockTextMessage.getJMSDestination()).thenReturn(jmsDestination);
@ -164,9 +103,6 @@ public class JMSMappingOutboundTransformerTest {
}
JMSMappingOutboundTransformer transformer = new JMSMappingOutboundTransformer(mockVendor);
if (byteType) {
transformer.setUseByteDestinationTypeAnnotations(true);
}
Message amqp = transformer.convert(mockTextMessage);
@ -186,82 +122,40 @@ public class JMSMappingOutboundTransformerTest {
// ======= JMSReplyTo Handling =========
// --- String type annotation ---
@Test
public void testConvertMessageWithJMSReplyToNull() throws Exception {
doTestConvertMessageWithJMSReplyTo(null, null, false);
doTestConvertMessageWithJMSReplyTo(null, null);
}
@Test
public void testConvertMessageWithJMSReplyToQueue() throws Exception {
Queue mockDest = Mockito.mock(Queue.class);
doTestConvertMessageWithJMSReplyTo(mockDest, "queue", false);
doTestConvertMessageWithJMSReplyTo(mockDest, "queue");
}
@Test
public void testConvertMessageWithJMSReplyToTemporaryQueue() throws Exception {
TemporaryQueue mockDest = Mockito.mock(TemporaryQueue.class);
doTestConvertMessageWithJMSReplyTo(mockDest, "temporary,queue", false);
doTestConvertMessageWithJMSReplyTo(mockDest, "temporary,queue");
}
@Test
public void testConvertMessageWithJMSReplyToTopic() throws Exception {
Topic mockDest = Mockito.mock(Topic.class);
doTestConvertMessageWithJMSReplyTo(mockDest, "topic", false);
doTestConvertMessageWithJMSReplyTo(mockDest, "topic");
}
@Test
public void testConvertMessageWithJMSReplyToTemporaryTopic() throws Exception {
TemporaryTopic mockDest = Mockito.mock(TemporaryTopic.class);
doTestConvertMessageWithJMSReplyTo(mockDest, "temporary,topic", false);
doTestConvertMessageWithJMSReplyTo(mockDest, "temporary,topic");
}
// --- byte type annotation ---
@Test
public void testConvertMessageWithJMSReplyToNullUsingByteAnnotation() throws Exception {
doTestConvertMessageWithJMSReplyTo(null, null, true);
}
@Test
public void testConvertMessageWithJMSReplyToQueueUsingByteAnnotation() throws Exception {
Queue mockDest = Mockito.mock(Queue.class);
doTestConvertMessageWithJMSReplyTo(mockDest, JMSVendor.QUEUE_TYPE, true);
}
@Test
public void testConvertMessageWithJMSReplyToTemporaryQueueUsingByteAnnotation() throws Exception {
TemporaryQueue mockDest = Mockito.mock(TemporaryQueue.class);
doTestConvertMessageWithJMSReplyTo(mockDest, JMSVendor.TEMP_QUEUE_TYPE, true);
}
@Test
public void testConvertMessageWithJMSReplyToTopicUsingByteAnnotation() throws Exception {
Topic mockDest = Mockito.mock(Topic.class);
doTestConvertMessageWithJMSReplyTo(mockDest, JMSVendor.TOPIC_TYPE, true);
}
@Test
public void testConvertMessageWithJMSReplyToTemporaryTopicUsingByteAnnotation() throws Exception {
TemporaryTopic mockDest = Mockito.mock(TemporaryTopic.class);
doTestConvertMessageWithJMSReplyTo(mockDest, JMSVendor.TEMP_TOPIC_TYPE, true);
}
@Test
public void testConvertMessageWithJMSReplyToUnkownUsingByteAnnotation() throws Exception {
Destination mockDest = Mockito.mock(Destination.class);
doTestConvertMessageWithJMSReplyTo(mockDest, JMSVendor.QUEUE_TYPE, true);
}
private void doTestConvertMessageWithJMSReplyTo(Destination jmsReplyTo, Object expectedAnnotationValue, boolean byteType) throws Exception {
private void doTestConvertMessageWithJMSReplyTo(Destination jmsReplyTo, Object expectedAnnotationValue) throws Exception {
TextMessage mockTextMessage = createMockTextMessage();
Mockito.when(mockTextMessage.getText()).thenReturn("myTextMessageContent");
Mockito.when(mockTextMessage.getJMSReplyTo()).thenReturn(jmsReplyTo);
@ -272,9 +166,6 @@ public class JMSMappingOutboundTransformerTest {
}
JMSMappingOutboundTransformer transformer = new JMSMappingOutboundTransformer(mockVendor);
if (byteType) {
transformer.setUseByteDestinationTypeAnnotations(true);
}
Message amqp = transformer.convert(mockTextMessage);