This commit is contained in:
Michael Pearce 2018-01-10 16:19:55 +00:00 committed by Michael André Pearce
commit 9e68d84645
7 changed files with 180 additions and 13 deletions

View File

@ -195,7 +195,9 @@ public class ActiveMQConnectionFactory extends JNDIStorable implements Connectio
serverLocator = locatorParser.newObject(uri, null);
parser.populateObject(uri, this);
} catch (Exception e) {
throw new InvalidObjectException(e.getMessage());
InvalidObjectException ex = new InvalidObjectException(e.getMessage());
ex.initCause(e);
throw ex;
}
}

View File

@ -231,7 +231,11 @@ public class ActiveMQDestination extends JNDIStorable implements Destination, Se
*/
private SimpleString simpleAddress;
private final TYPE type;
private final boolean temporary;
private final boolean queue;
private transient TYPE thetype;
private final transient ActiveMQSession session;
@ -242,9 +246,13 @@ public class ActiveMQDestination extends JNDIStorable implements Destination, Se
final ActiveMQSession session) {
this.simpleAddress = SimpleString.toSimpleString(address);
this.type = type;
this.thetype = type;
this.session = session;
this.temporary = TYPE.isTemporary(type);
this.queue = TYPE.isQueue(type);
}
protected ActiveMQDestination(final SimpleString address,
@ -252,9 +260,13 @@ public class ActiveMQDestination extends JNDIStorable implements Destination, Se
final ActiveMQSession session) {
this.simpleAddress = address;
this.type = type;
this.thetype = type;
this.session = session;
this.temporary = TYPE.isTemporary(type);
this.queue = TYPE.isQueue(type);
}
public void setAddress(String address) {
@ -283,7 +295,7 @@ public class ActiveMQDestination extends JNDIStorable implements Destination, Se
}
public boolean isQueue() {
return TYPE.isQueue(type);
return queue;
}
// Public --------------------------------------------------------
@ -301,11 +313,26 @@ public class ActiveMQDestination extends JNDIStorable implements Destination, Se
}
public boolean isTemporary() {
return TYPE.isTemporary(type);
return temporary;
}
public TYPE getType() {
return type;
if (thetype == null) {
if (temporary) {
if (isQueue()) {
thetype = TYPE.TEMP_QUEUE;
} else {
thetype = TYPE.TEMP_TOPIC;
}
} else {
if (isQueue()) {
thetype = TYPE.QUEUE;
} else {
thetype = TYPE.TOPIC;
}
}
}
return thetype;
}
@Override

View File

@ -138,7 +138,7 @@ public class ArtemisDependencyScanPlugin extends ArtemisAbstractPlugin {
private void setVariable(String classPathGenerated) {
if (variableName != null) {
project.getProperties().setProperty(variableName, classPathGenerated);
getLog().info("dependency-scan setting: " + variableName + "=" + classPathGenerated);
getLog().info("dependency-scan setting: -D" + variableName + "=\"" + classPathGenerated + "\"");
}
}

View File

@ -275,6 +275,11 @@
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.jboss.marshalling</groupId>
<artifactId>jboss-marshalling-river</artifactId>
<version>2.0.2.Final</version>
</dependency>
</dependencies>
<build>
@ -383,6 +388,7 @@
<arg>org.apache.activemq:artemis-amqp-protocol:1.5.5</arg>
<arg>org.apache.activemq:artemis-hornetq-protocol:1.5.5</arg>
<arg>org.codehaus.groovy:groovy-all:${groovy.version}</arg>
<arg>org.jboss.marshalling:jboss-marshalling-river:2.0.2.Final</arg>
</libListWithDeps>
<libList>
<arg>org.apache.activemq.tests:compatibility-tests:${project.version}</arg>

View File

@ -98,6 +98,13 @@ public class GroovyRun {
}
}
public static void assertFalse(boolean value) {
if (value) {
throw new RuntimeException("Expected false");
}
}
public static void assertEquals(Object value1, Object value2) {
if (!value1.equals(value2)) {
throw new RuntimeException(value1 + "!=" + value2);

View File

@ -0,0 +1,99 @@
package clients
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Create a client connection factory
import org.apache.activemq.artemis.tests.compatibility.GroovyRun
import org.jboss.marshalling.Marshaller
import org.jboss.marshalling.MarshallerFactory
import org.jboss.marshalling.Marshalling
import org.jboss.marshalling.MarshallingConfiguration
import org.jboss.marshalling.Unmarshaller
import javax.jms.*;
import org.apache.activemq.artemis.jms.client.*
file = arg[0]
method = arg[1]
System.out.println("File::" + file);
// Get the factory for the "river" marshalling protocol
final MarshallerFactory factory = Marshalling.getProvidedMarshallerFactory("river");
// Create a configuration
final MarshallingConfiguration configuration = new MarshallingConfiguration();
// Use version 3
configuration.setVersion(3);
if (method.equals("write")) {
cf = new ActiveMQConnectionFactory("tcp://localhost:61616?confirmationWindowSize=1048576&blockOnDurableSend=false");
queue = new ActiveMQQueue("queue");
topic = new ActiveMQTopic("topic")
temporary = ActiveMQDestination.createTemporaryQueue("whatever")
temporaryTopic = ActiveMQDestination.createTemporaryTopic("whatever")
Marshaller marshaller = factory.createMarshaller(configuration)
FileOutputStream fileOutputStream = new FileOutputStream(file)
marshaller.start(Marshalling.createByteOutput(fileOutputStream));
marshaller.writeObject(cf);
marshaller.writeObject(queue)
marshaller.writeObject(topic)
marshaller.writeObject(temporary)
marshaller.writeObject(temporaryTopic)
marshaller.finish()
fileOutputStream.close();
} else {
Unmarshaller unmarshaller = factory.createUnmarshaller(configuration)
FileInputStream inputfile = new FileInputStream(file)
unmarshaller.start(Marshalling.createByteInput(inputfile))
cf = unmarshaller.readObject();
queue = unmarshaller.readObject()
topic = unmarshaller.readObject()
temporary = unmarshaller.readObject()
temporaryTopic = unmarshaller.readObject()
}
GroovyRun.assertTrue(!cf.getServerLocator().isBlockOnDurableSend());
GroovyRun.assertEquals(1048576, cf.getServerLocator().getConfirmationWindowSize());
Connection connection = cf.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
ActiveMQDestination queueDest = (ActiveMQDestination)queue;
GroovyRun.assertTrue(queueDest.isQueue())
GroovyRun.assertFalse(queueDest.isTemporary())
ActiveMQDestination topicDest = (ActiveMQDestination)topic
GroovyRun.assertFalse(topicDest.isQueue())
GroovyRun.assertFalse(queueDest.isTemporary())
ActiveMQDestination temporaryDest = (ActiveMQDestination)temporary
GroovyRun.assertTrue(temporaryDest.isQueue())
GroovyRun.assertTrue(temporaryDest.isTemporary())
temporaryDest = (ActiveMQDestination)temporaryTopic
GroovyRun.assertFalse(temporaryDest.isQueue())
GroovyRun.assertTrue(temporaryDest.isTemporary())
MessageConsumer consumer = session.createConsumer(queue);
MessageProducer topicProducer = session.createProducer(topic)
connection.close();

View File

@ -22,6 +22,9 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.apache.activemq.artemis.utils.FileUtil;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@ -43,7 +46,7 @@ import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.SNAPSHOT
* Run->Edit Configuration->Add ArtemisMeshTest and add your properties.
*/
@RunWith(Parameterized.class)
public class SerializationTest extends ServerBaseTest {
public class SerializationTest extends VersionedBaseTest {
// this will ensure that all tests in this class are run twice,
// once with "true" passed to the class' constructor and once with "false"
@ -60,7 +63,7 @@ public class SerializationTest extends ServerBaseTest {
// combinations.add(new Object[]{SNAPSHOT, ONE_FIVE, ONE_FIVE});
// combinations.add(new Object[]{ONE_FIVE, ONE_FIVE, ONE_FIVE});
combinations.addAll(combinatory(new Object[]{SNAPSHOT}, new Object[]{ONE_FIVE, SNAPSHOT}, new Object[]{ONE_FIVE, SNAPSHOT}));
combinations.addAll(combinatory(new Object[]{null}, new Object[]{ONE_FIVE, SNAPSHOT}, new Object[]{ONE_FIVE, SNAPSHOT}));
return combinations;
}
@ -68,13 +71,36 @@ public class SerializationTest extends ServerBaseTest {
super(server, sender, receiver);
}
@Before
public void beforeTest() throws Throwable {
FileUtil.deleteDirectory(serverFolder.getRoot());
serverFolder.getRoot().mkdirs();
setVariable(senderClassloader, "persistent", false);
startServer(serverFolder.getRoot(), senderClassloader, "1");
}
@After
public void afterTest() {
try {
stopServer(senderClassloader);
} catch (Throwable ignored) {
ignored.printStackTrace();
}
}
@Test
public void testSerializeFactory() throws Throwable {
File file = serverFolder.newFile("objects.ser");
file.mkdirs();
callScript(senderClassloader, "serial/serial.groovy", file.getAbsolutePath(), "write");
callScript(receiverClassloader, "serial/serial.groovy", file.getAbsolutePath(), "read");
}
@Test
public void testJBMSerializeFactory() throws Throwable {
File file = serverFolder.newFile("objectsjbm.ser");
callScript(senderClassloader, "serial/jbmserial.groovy", file.getAbsolutePath(), "write");
callScript(receiverClassloader, "serial/jbmserial.groovy", file.getAbsolutePath(), "read");
}
}