You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2017/03/01 17:21:01 UTC
[07/23] activemq-artemis git commit: ARTEMIS-1009 Pure Message
Encoding.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/53887656/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/MessageJournalTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/MessageJournalTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/MessageJournalTest.java
new file mode 100644
index 0000000..1897bdd
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/MessageJournalTest.java
@@ -0,0 +1,133 @@
+/**
+ * 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.
+ */
+
+package org.apache.activemq.artemis.tests.integration.journal;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo;
+import org.apache.activemq.artemis.core.journal.RecordInfo;
+import org.apache.activemq.artemis.core.journal.TransactionFailureCallback;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
+import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager;
+import org.apache.activemq.artemis.core.protocol.core.impl.CoreProtocolManagerFactory;
+import org.apache.activemq.artemis.core.server.ActiveMQServer;
+import org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage;
+import org.apache.activemq.artemis.protocol.amqp.broker.ProtonProtocolManager;
+import org.apache.activemq.artemis.protocol.amqp.broker.ProtonProtocolManagerFactory;
+import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.qpid.proton.message.Message;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MessageJournalTest extends ActiveMQTestBase {
+
+ @Test
+ public void testStoreCore() throws Throwable {
+ ActiveMQServer server = createServer(true);
+
+ server.start();
+
+ CoreMessage message = new CoreMessage().initBuffer(10 * 1024).setDurable(true);
+
+ message.setMessageID(333);
+
+ CoreProtocolManagerFactory factory = (CoreProtocolManagerFactory) server.getRemotingService().getProtocolFactoryMap().get("CORE");
+
+ Assert.assertNotNull(factory);
+
+ message.getBodyBuffer().writeByte((byte)'Z');
+
+ message.setProtocol(factory.createProtocolManager(server, null, null, null));
+
+ server.getStorageManager().storeMessage(message);
+
+ server.getStorageManager().stop();
+
+ JournalStorageManager journalStorageManager = (JournalStorageManager) server.getStorageManager();
+
+ List<RecordInfo> committedRecords = new LinkedList<>();
+
+ List<PreparedTransactionInfo> preparedTransactions = new LinkedList<>();
+
+ TransactionFailureCallback transactionFailure = new TransactionFailureCallback() {
+ @Override
+ public void failedTransaction(long transactionID, List<RecordInfo> records, List<RecordInfo> recordsToDelete) {
+
+ }
+ };
+
+ try {
+ journalStorageManager.getMessageJournal().start();
+
+ journalStorageManager.getMessageJournal().load(committedRecords, preparedTransactions, transactionFailure);
+
+ Assert.assertEquals(1, committedRecords.size());
+ } finally {
+ journalStorageManager.getMessageJournal().stop();
+ }
+
+ }
+
+
+ @Test
+ public void testStoreAMQP() throws Throwable {
+ ActiveMQServer server = createServer(true);
+
+ server.start();
+
+ ProtonProtocolManagerFactory factory = (ProtonProtocolManagerFactory) server.getRemotingService().getProtocolFactoryMap().get("AMQP");
+
+ Message protonJMessage = Message.Factory.create();
+
+ AMQPMessage message = new AMQPMessage(protonJMessage, (ProtonProtocolManager)factory.createProtocolManager(server, null, null, null));
+
+ message.setMessageID(333);
+
+ Assert.assertNotNull(factory);
+
+ server.getStorageManager().storeMessage(message);
+
+ server.getStorageManager().stop();
+
+ JournalStorageManager journalStorageManager = (JournalStorageManager) server.getStorageManager();
+
+ List<RecordInfo> committedRecords = new LinkedList<>();
+
+ List<PreparedTransactionInfo> preparedTransactions = new LinkedList<>();
+
+ TransactionFailureCallback transactionFailure = new TransactionFailureCallback() {
+ @Override
+ public void failedTransaction(long transactionID, List<RecordInfo> records, List<RecordInfo> recordsToDelete) {
+
+ }
+ };
+
+ try {
+ journalStorageManager.getMessageJournal().start();
+
+ journalStorageManager.getMessageJournal().load(committedRecords, preparedTransactions, transactionFailure);
+
+ Assert.assertEquals(1, committedRecords.size());
+ } finally {
+ journalStorageManager.getMessageJournal().stop();
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/53887656/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java
index 38cc126..a0f23d0 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java
@@ -43,9 +43,9 @@ import org.apache.activemq.artemis.core.journal.impl.JournalCompactor;
import org.apache.activemq.artemis.core.journal.impl.JournalFile;
import org.apache.activemq.artemis.core.journal.impl.JournalFileImpl;
import org.apache.activemq.artemis.core.journal.impl.JournalImpl;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager;
import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
import org.apache.activemq.artemis.tests.unit.core.journal.impl.JournalImplTestBase;
import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
@@ -1656,13 +1656,13 @@ public class NIOJournalCompactTest extends JournalImplTestBase {
long id = seqGenerator.incrementAndGet();
values[i] = id;
- ServerMessageImpl message = new ServerMessageImpl(id, 100);
+ CoreMessage message = new CoreMessage(id, 100);
message.getBodyBuffer().writeBytes(new byte[1024]);
storage.storeMessageTransactional(tx, message);
}
- ServerMessageImpl message = new ServerMessageImpl(seqGenerator.incrementAndGet(), 100);
+ CoreMessage message = new CoreMessage(seqGenerator.incrementAndGet(), 100);
survivingMsgs.add(message.getMessageID());
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/53887656/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ContainerBaseTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ContainerBaseTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ContainerBaseTest.java
new file mode 100644
index 0000000..f055531
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ContainerBaseTest.java
@@ -0,0 +1,64 @@
+/**
+ * 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.
+ */
+
+package org.apache.activemq.artemis.tests.integration.karaf;
+
+import java.io.IOException;
+
+import org.junit.After;
+import org.ops4j.pax.exam.ExamSystem;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.TestAddress;
+import org.ops4j.pax.exam.TestContainer;
+import org.ops4j.pax.exam.TestProbeBuilder;
+import org.ops4j.pax.exam.TestProbeProvider;
+import org.ops4j.pax.exam.spi.PaxExamRuntime;
+
+/**
+ * This is useful for when you want to automate remote tests.
+ */
+public abstract class ContainerBaseTest extends KarafBaseTest {
+ protected ExamSystem system;
+ protected TestProbeBuilder builder;
+ protected TestAddress testToBeCalled;
+ protected TestProbeProvider probe;
+ protected TestContainer container;
+
+ protected void setupContainer(Class testToCall, String methodToCall, Option[] options) throws IOException {
+ system = PaxExamRuntime.createTestSystem(options);
+ builder = system.createProbe();
+ testToBeCalled = builder.addTest(testToCall, methodToCall);
+ probe = builder.build();
+ container = PaxExamRuntime.createContainer(system);
+ container.start();
+ container.install(probe.getStream());
+ }
+
+ @After
+ public void shutdownContainer() {
+ if (container != null) {
+ container.stop();
+ }
+ }
+
+
+ protected void executeRemoteTest() {
+ container.call(testToBeCalled);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/53887656/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/KarafBaseTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/KarafBaseTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/KarafBaseTest.java
new file mode 100644
index 0000000..22f1efc
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/KarafBaseTest.java
@@ -0,0 +1,212 @@
+/**
+ * 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.
+ */
+
+package org.apache.activemq.artemis.tests.integration.karaf;
+
+import javax.inject.Inject;
+import javax.security.auth.Subject;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.PrintStream;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.FutureTask;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.karaf.jaas.boot.principal.RolePrincipal;
+import org.apache.karaf.jaas.boot.principal.UserPrincipal;
+import org.apache.karaf.shell.api.console.Session;
+import org.apache.karaf.shell.api.console.SessionFactory;
+import org.apache.log4j.Logger;
+import org.junit.Assert;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.karaf.options.KarafDistributionOption;
+import org.ops4j.pax.exam.karaf.options.LogLevelOption;
+import org.ops4j.pax.exam.options.UrlReference;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.util.tracker.ServiceTracker;
+
+import static org.ops4j.pax.exam.CoreOptions.maven;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.debugConfiguration;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
+
+public class KarafBaseTest extends Assert {
+
+ private static Logger LOG = Logger.getLogger(KarafBaseTest.class.getName());
+
+ public static final long ASSERTION_TIMEOUT = 30000L;
+ public static final long COMMAND_TIMEOUT = 30000L;
+ public static final String USER = "karaf";
+ public static final String PASSWORD = "karaf";
+
+ /**
+ * plug to add more options on sub tests
+ */
+ protected void testOptions(List<Option> options) throws Exception {
+ }
+
+ public Option[] configureArtemisFeatures(boolean debug, String version, String... features) throws Exception {
+
+ ArrayList<String> featureArray = new ArrayList<>();
+ featureArray.addAll(Arrays.asList(features));
+
+ List<Option> optionList = new LinkedList<>();
+
+ optionList.add(karafDistributionConfiguration().
+ frameworkUrl(maven().groupId("org.apache.karaf").
+ artifactId("apache-karaf").type("tar.gz").
+ versionAsInProject()).unpackDirectory(new File("target/containertest/unpack/")));
+ optionList.add(KarafDistributionOption.keepRuntimeFolder());
+ optionList.add(logLevel(LogLevelOption.LogLevel.INFO));
+ optionList.add(editConfigurationFilePut("etc/config.properties", "karaf.startlevel.bundle", "50"));
+
+ if (debug) {
+ // uncomment this to debug it.
+ optionList.add(debugConfiguration("5005", true));
+ }
+
+ optionList.add(features(getArtemisMQKarafFeatureUrl(version), featureArray.toArray(new String[featureArray.size()])));
+
+ testOptions(optionList);
+
+ return optionList.toArray(new Option[optionList.size()]);
+ }
+
+ public UrlReference getArtemisMQKarafFeatureUrl(String version) {
+ String type = "xml/features";
+ UrlReference urlReference;
+
+ if (version == null) {
+ urlReference = mavenBundle().groupId("org.apache.activemq").
+ artifactId("artemis-features").versionAsInProject().type(type);
+ } else {
+ urlReference = mavenBundle().groupId("org.apache.activemq").
+ artifactId("artemis-features").version(version).type(type);
+ }
+ LOG.info("FeatureURL: " + urlReference.getURL());
+ return urlReference;
+ }
+
+ ExecutorService executor = Executors.newCachedThreadPool();
+
+ @Inject
+ BundleContext bundleContext;
+
+ @Inject
+ SessionFactory sessionFactory;
+
+ protected String executeCommand(final String command, final Long timeout, final Boolean silent) {
+ String response;
+ final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ final PrintStream printStream = new PrintStream(byteArrayOutputStream);
+ final Session commandSession = sessionFactory.create(System.in, printStream, printStream);
+ commandSession.put("APPLICATION", System.getProperty("karaf.name", "root"));
+ commandSession.put("USER", USER);
+ FutureTask<String> commandFuture = new FutureTask<>(new Callable<String>() {
+ @Override
+ public String call() {
+
+ Subject subject = new Subject();
+ subject.getPrincipals().add(new UserPrincipal("admin"));
+ subject.getPrincipals().add(new RolePrincipal("admin"));
+ subject.getPrincipals().add(new RolePrincipal("manager"));
+ subject.getPrincipals().add(new RolePrincipal("viewer"));
+ return Subject.doAs(subject, new PrivilegedAction<String>() {
+ @Override
+ public String run() {
+ try {
+ if (!silent) {
+ System.out.println(command);
+ System.out.flush();
+ }
+ commandSession.execute(command);
+ } catch (Exception e) {
+ e.printStackTrace(System.err);
+ }
+ printStream.flush();
+ return byteArrayOutputStream.toString();
+ }
+ });
+ }
+ });
+
+ try {
+ executor.submit(commandFuture);
+ response = commandFuture.get(timeout, TimeUnit.MILLISECONDS);
+ } catch (Exception e) {
+ e.printStackTrace(System.err);
+ response = "SHELL COMMAND TIMED OUT: ";
+ }
+ LOG.info("Execute: " + command + " - Response:" + response);
+ return response;
+ }
+
+ protected String executeCommand(final String command) {
+ return executeCommand(command, COMMAND_TIMEOUT, false);
+ }
+
+ protected boolean withinReason(Callable<Boolean> callable) throws Throwable {
+ long max = System.currentTimeMillis() + ASSERTION_TIMEOUT;
+ while (true) {
+ try {
+ return callable.call();
+ } catch (Throwable t) {
+ if (System.currentTimeMillis() < max) {
+ TimeUnit.SECONDS.sleep(1);
+ continue;
+ } else {
+ throw t;
+ }
+ }
+ }
+ }
+
+ public boolean verifyBundleInstalled(final String bundleName) throws Exception {
+ boolean found = false;
+ for (Bundle bundle : bundleContext.getBundles()) {
+ LOG.debug("Checking: " + bundle.getSymbolicName());
+ if (bundle.getSymbolicName().contains(bundleName)) {
+ found = true;
+ break;
+ }
+ }
+ return found;
+ }
+
+ protected Object waitForService(String filter, long timeout) throws InvalidSyntaxException, InterruptedException {
+ ServiceTracker<Object, Object> st = new ServiceTracker<>(bundleContext, bundleContext.createFilter(filter), null);
+ try {
+ st.open();
+ return st.waitForService(timeout);
+ } finally {
+ st.close();
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/53887656/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/distribution/ArtemisFeatureTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/distribution/ArtemisFeatureTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/distribution/ArtemisFeatureTest.java
new file mode 100644
index 0000000..b47a6e0
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/distribution/ArtemisFeatureTest.java
@@ -0,0 +1,101 @@
+/**
+ * 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.
+ */
+package org.apache.activemq.artemis.tests.integration.karaf.distribution;
+
+import javax.jms.Connection;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import java.util.concurrent.Callable;
+
+import org.apache.activemq.artemis.core.client.impl.ClientMessageImpl;
+import org.apache.activemq.artemis.tests.integration.karaf.KarafBaseTest;
+import org.apache.log4j.Logger;
+import org.apache.qpid.jms.JmsConnectionFactory;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.ProbeBuilder;
+import org.ops4j.pax.exam.TestProbeBuilder;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.osgi.framework.Constants;
+
+/**
+ * Useful docs about this test: https://ops4j1.jira.com/wiki/display/paxexam/FAQ
+ */
+@RunWith(PaxExam.class)
+public class ArtemisFeatureTest extends KarafBaseTest {
+
+ private static Logger LOG = Logger.getLogger(ArtemisFeatureTest.class.getName());
+
+ @ProbeBuilder
+ public TestProbeBuilder probeConfiguration(TestProbeBuilder probe) {
+ probe.setHeader(Constants.DYNAMICIMPORT_PACKAGE, "*,org.ops4j.pax.exam.options.*,org.apache.felix.service.*;status=provisional");
+ return probe;
+ }
+
+ @Configuration
+ public Option[] configure() throws Exception {
+ return configureArtemisFeatures(false, null, "artemis");
+ }
+ @Test
+ public void testSample() throws Throwable {
+ System.out.println("Hello!!!");
+ ClientMessageImpl message = new ClientMessageImpl();
+ }
+
+ @Test(timeout = 5 * 60 * 1000)
+ public void test() throws Throwable {
+ executeCommand("bundle:list");
+
+ withinReason(new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ assertTrue("artemis bundle installed", verifyBundleInstalled("artemis-server-osgi"));
+ return true;
+ }
+ });
+
+ Object service = waitForService("(objectClass=org.apache.activemq.artemis.core.server.ActiveMQServer)", 30000);
+ assertNotNull(service);
+ LOG.info("have service " + service);
+
+ executeCommand("service:list -n");
+
+ Connection connection = null;
+ try {
+ JmsConnectionFactory factory = new JmsConnectionFactory("amqp://localhost:5672");
+ connection = factory.createConnection(USER, PASSWORD);
+ connection.start();
+
+ javax.jms.Session sess = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
+ Queue queue = sess.createQueue("exampleQueue");
+ MessageProducer producer = sess.createProducer(queue);
+ producer.send(sess.createTextMessage("TEST"));
+
+ MessageConsumer consumer = sess.createConsumer(queue);
+ Message msg = consumer.receive(5000);
+ assertNotNull(msg);
+ } finally {
+ if (connection != null) {
+ connection.close();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/53887656/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/distribution/package-info.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/distribution/package-info.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/distribution/package-info.java
new file mode 100644
index 0000000..5af5077
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/distribution/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ * This contains tests that will validate the Artemis distribution
+ */
+package org.apache.activemq.artemis.tests.integration.karaf.distribution;
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/53887656/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/ProbeRemoteServer.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/ProbeRemoteServer.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/ProbeRemoteServer.java
new file mode 100644
index 0000000..7b4eea0
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/ProbeRemoteServer.java
@@ -0,0 +1,51 @@
+/**
+ * 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.
+ */
+
+package org.apache.activemq.artemis.tests.integration.karaf.version;
+
+import org.apache.activemq.artemis.core.client.impl.ClientMessageImpl;
+import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
+import org.apache.activemq.artemis.core.server.ActiveMQServer;
+import org.apache.activemq.artemis.core.server.ActiveMQServers;
+import org.apache.activemq.artemis.core.server.JournalType;
+import org.junit.Ignore;
+import org.junit.Test;
+
+// Ignored as this is executed by PaxExam on RemoteTest
+@Ignore
+public class ProbeRemoteServer {
+
+ ActiveMQServer server;
+
+ @Test
+ public void probe1() throws Exception {
+ System.out.println("probe1 with ");
+ ClientMessageImpl message = new ClientMessageImpl();
+
+ ConfigurationImpl config = new ConfigurationImpl().setSecurityEnabled(false).setJournalMinFiles(2).
+ setJournalFileSize(100 * 1024).setJournalType(JournalType.NIO).
+ setJournalDirectory("./data/journal").
+ setBindingsDirectory("./data/binding").
+ setPagingDirectory("./data/paging").
+ setLargeMessagesDirectory("./data/lm").setJournalCompactMinFiles(0).setJournalCompactPercentage(0).setClusterPassword("mycluster").setJournalDatasync(false).setSecurityEnabled(false);
+ config.addAcceptorConfiguration("netty", "tcp://localhost:61616");
+
+ server = ActiveMQServers.newActiveMQServer(config, false);
+
+ server.start();
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/53887656/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/RemoteTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/RemoteTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/RemoteTest.java
new file mode 100644
index 0000000..10e97b3
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/RemoteTest.java
@@ -0,0 +1,38 @@
+/**
+ * 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.
+ */
+
+package org.apache.activemq.artemis.tests.integration.karaf.version;
+
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.tests.integration.karaf.ContainerBaseTest;
+import org.junit.Test;
+
+public class RemoteTest extends ContainerBaseTest {
+
+ @Test
+ public void testValidateRemote() throws Exception {
+ setupContainer(ProbeRemoteServer.class, "probe1", configureArtemisFeatures(false, "1.5.1", "artemis-core"));
+
+ executeRemoteTest();
+
+ ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
+ factory.createConnection().close();
+
+ container.stop();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/53887656/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/VersionWireTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/VersionWireTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/VersionWireTest.java
new file mode 100644
index 0000000..be2fac5
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/VersionWireTest.java
@@ -0,0 +1,104 @@
+/**
+ * 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.
+ */
+package org.apache.activemq.artemis.tests.integration.karaf.version;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+import java.util.List;
+
+import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.core.client.impl.ClientMessageImpl;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.tests.integration.karaf.KarafBaseTest;
+import org.apache.log4j.Logger;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.ProbeBuilder;
+import org.ops4j.pax.exam.TestProbeBuilder;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
+
+import static org.ops4j.pax.exam.CoreOptions.vmOptions;
+
+// uncomment this to be able to debug it
+// import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.debugConfiguration;
+
+/**
+ * Useful docs about this test: https://ops4j1.jira.com/wiki/display/paxexam/FAQ
+ */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
+public class VersionWireTest extends KarafBaseTest {
+
+ File file = new File(System.getProperty("./target/generated.bin", System.getProperty("testFile", "./target/generated.bin")));
+
+
+ private static Logger LOG = Logger.getLogger(VersionWireTest.class.getName());
+
+ /**
+ * plug to add more options on sub tests
+ */
+ @Override
+ protected void testOptions(List<Option> options) throws Exception {
+ options.add(vmOptions("-DtestFile=" + file.getCanonicalPath()));
+ }
+
+ @ProbeBuilder
+ public TestProbeBuilder probeConfiguration(TestProbeBuilder probe) throws Exception {
+
+ file.deleteOnExit();
+ System.out.println("Path::" + file.getCanonicalPath());
+ PrintStream out = new PrintStream(new FileOutputStream(file));
+ out.println("hello");
+ out.close();
+ System.out.println("probing!!!");
+ Message message = new ClientMessageImpl();
+ System.out.println("probed!!!");
+ return probe;
+ }
+
+
+ @Configuration
+ public Option[] configure1_5() throws Exception {
+
+ ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
+ factory.setBlockOnDurableSend(false);
+
+ return configureArtemisFeatures(false, "1.5.0", "artemis-core");
+
+ }
+
+ @Configuration
+ public Option[] configure13() throws Exception {
+ return configureArtemisFeatures(false, null, "artemis-core");
+ }
+
+
+ @Test
+ public void testSample() throws Throwable {
+ System.out.println("Path::" + file.getCanonicalPath());
+
+ Assert.assertTrue(file.getCanonicalPath() + " don't exist", file.exists());
+ System.out.println("Hello!!!");
+ ClientMessageImpl message = new ClientMessageImpl();
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/53887656/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/package-info.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/package-info.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/package-info.java
new file mode 100644
index 0000000..459e912
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ * Tests to check wire compatibility.
+ */
+package org.apache.activemq.artemis.tests.integration.karaf.version;
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/53887656/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementServiceImplTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementServiceImplTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementServiceImplTest.java
index 1afc732..b6ea147 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementServiceImplTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementServiceImplTest.java
@@ -16,19 +16,19 @@
*/
package org.apache.activemq.artemis.tests.integration.management;
+import org.apache.activemq.artemis.api.core.Message;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.api.core.management.AddressControl;
import org.apache.activemq.artemis.api.core.management.ManagementHelper;
import org.apache.activemq.artemis.api.core.management.QueueControl;
import org.apache.activemq.artemis.api.core.management.ResourceNames;
import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
import org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServers;
import org.apache.activemq.artemis.core.server.Queue;
-import org.apache.activemq.artemis.core.server.ServerMessage;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
import org.apache.activemq.artemis.core.server.management.impl.ManagementServiceImpl;
import org.apache.activemq.artemis.tests.integration.server.FakeStorageManager;
import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue;
@@ -50,10 +50,10 @@ public class ManagementServiceImplTest extends ActiveMQTestBase {
server.start();
// invoke attribute and operation on the server
- ServerMessage message = new ServerMessageImpl(1, 100);
+ Message message = new CoreMessage(1, 100);
ManagementHelper.putOperationInvocation(message, ResourceNames.BROKER, "createQueue", queue, address);
- ServerMessage reply = server.getManagementService().handleMessage(message);
+ Message reply = server.getManagementService().handleMessage(message);
Assert.assertTrue(ManagementHelper.hasOperationSucceeded(reply));
}
@@ -66,10 +66,10 @@ public class ManagementServiceImplTest extends ActiveMQTestBase {
server.start();
// invoke attribute and operation on the server
- ServerMessage message = new ServerMessageImpl(1, 100);
+ Message message = new CoreMessage(1, 100);
ManagementHelper.putOperationInvocation(message, ResourceNames.BROKER, "thereIsNoSuchOperation");
- ServerMessage reply = server.getManagementService().handleMessage(message);
+ Message reply = server.getManagementService().handleMessage(message);
Assert.assertFalse(ManagementHelper.hasOperationSucceeded(reply));
Assert.assertNotNull(ManagementHelper.getResult(reply));
@@ -83,10 +83,10 @@ public class ManagementServiceImplTest extends ActiveMQTestBase {
server.start();
// invoke attribute and operation on the server
- ServerMessage message = new ServerMessageImpl(1, 100);
+ Message message = new CoreMessage(1, 100);
ManagementHelper.putOperationInvocation(message, "Resouce.Does.Not.Exist", "toString");
- ServerMessage reply = server.getManagementService().handleMessage(message);
+ Message reply = server.getManagementService().handleMessage(message);
Assert.assertFalse(ManagementHelper.hasOperationSucceeded(reply));
Assert.assertNotNull(ManagementHelper.getResult(reply));
@@ -100,11 +100,11 @@ public class ManagementServiceImplTest extends ActiveMQTestBase {
server.start();
// invoke attribute and operation on the server
- ServerMessage message = new ServerMessageImpl(1, 100);
+ Message message = new CoreMessage(1, 100);
ManagementHelper.putAttribute(message, ResourceNames.BROKER, "started");
- ServerMessage reply = server.getManagementService().handleMessage(message);
+ Message reply = server.getManagementService().handleMessage(message);
Assert.assertTrue(ManagementHelper.hasOperationSucceeded(reply));
Assert.assertTrue((Boolean) ManagementHelper.getResult(reply));
@@ -118,11 +118,11 @@ public class ManagementServiceImplTest extends ActiveMQTestBase {
server.start();
// invoke attribute and operation on the server
- ServerMessage message = new ServerMessageImpl(1, 100);
+ Message message = new CoreMessage(1, 100);
ManagementHelper.putAttribute(message, ResourceNames.BROKER, "attribute.Does.Not.Exist");
- ServerMessage reply = server.getManagementService().handleMessage(message);
+ Message reply = server.getManagementService().handleMessage(message);
Assert.assertFalse(ManagementHelper.hasOperationSucceeded(reply));
Assert.assertNotNull(ManagementHelper.getResult(reply));
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/53887656/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java
index 90f7c5f..615a924 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java
@@ -21,17 +21,17 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
+import org.apache.activemq.artemis.api.core.Message;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.config.StoreConfiguration;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
import org.apache.activemq.artemis.core.persistence.AddressBindingInfo;
import org.apache.activemq.artemis.core.persistence.GroupingInfo;
import org.apache.activemq.artemis.core.persistence.QueueBindingInfo;
import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager;
import org.apache.activemq.artemis.core.server.Queue;
-import org.apache.activemq.artemis.core.server.ServerMessage;
import org.apache.activemq.artemis.core.server.impl.PostOfficeJournalLoader;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue;
import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakePostOffice;
import org.junit.Assert;
@@ -40,8 +40,6 @@ import org.junit.runners.Parameterized;
public class DeleteMessagesOnStartupTest extends StorageManagerTestBase {
- volatile boolean deleteMessages = false;
-
ArrayList<Long> deletedMessage = new ArrayList<>();
public DeleteMessagesOnStartupTest(StoreConfiguration.StoreType storeType) {
@@ -63,12 +61,12 @@ public class DeleteMessagesOnStartupTest extends StorageManagerTestBase {
HashMap<Long, Queue> queues = new HashMap<>();
queues.put(100L, theQueue);
- ServerMessage msg = new ServerMessageImpl(1, 100);
+ Message msg = new CoreMessage(1, 100);
journal.storeMessage(msg);
for (int i = 2; i < 100; i++) {
- journal.storeMessage(new ServerMessageImpl(i, 100));
+ journal.storeMessage(new CoreMessage(i, 100));
}
journal.storeReference(100, 1, true);
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/53887656/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/replication/ReplicationTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/replication/ReplicationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/replication/ReplicationTest.java
index 1ae9527..ab32517 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/replication/ReplicationTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/replication/ReplicationTest.java
@@ -58,6 +58,7 @@ import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo;
import org.apache.activemq.artemis.core.journal.RecordInfo;
import org.apache.activemq.artemis.core.journal.TransactionFailureCallback;
import org.apache.activemq.artemis.core.journal.impl.JournalFile;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
import org.apache.activemq.artemis.core.paging.PagedMessage;
import org.apache.activemq.artemis.core.paging.PagingManager;
import org.apache.activemq.artemis.core.paging.PagingStore;
@@ -65,6 +66,7 @@ import org.apache.activemq.artemis.core.paging.impl.PagedMessageImpl;
import org.apache.activemq.artemis.core.paging.impl.PagingManagerImpl;
import org.apache.activemq.artemis.core.paging.impl.PagingStoreFactoryNIO;
import org.apache.activemq.artemis.core.persistence.OperationContext;
+import org.apache.activemq.artemis.core.persistence.Persister;
import org.apache.activemq.artemis.core.persistence.StorageManager;
import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager;
import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl;
@@ -74,10 +76,8 @@ import org.apache.activemq.artemis.core.replication.ReplicatedJournal;
import org.apache.activemq.artemis.core.replication.ReplicationManager;
import org.apache.activemq.artemis.core.server.ActiveMQComponent;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
-import org.apache.activemq.artemis.core.server.ServerMessage;
import org.apache.activemq.artemis.core.server.cluster.ClusterController;
import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
@@ -228,7 +228,7 @@ public final class ReplicationTest extends ActiveMQTestBase {
Assert.assertTrue("Expecting no active tokens:" + manager.getActiveTokens(), manager.getActiveTokens().isEmpty());
- ServerMessage msg = new ServerMessageImpl(1, 1024);
+ CoreMessage msg = new CoreMessage().initBuffer(1024).setMessageID(1);
SimpleString dummy = new SimpleString("dummy");
msg.setAddress(dummy);
@@ -259,12 +259,12 @@ public final class ReplicationTest extends ActiveMQTestBase {
blockOnReplication(storage, manager);
- ServerMessageImpl serverMsg = new ServerMessageImpl();
+ CoreMessage serverMsg = new CoreMessage();
serverMsg.setMessageID(500);
serverMsg.setAddress(new SimpleString("tttt"));
ActiveMQBuffer buffer = ActiveMQBuffers.dynamicBuffer(100);
- serverMsg.encodeHeadersAndProperties(buffer);
+ serverMsg.encodeHeadersAndProperties(buffer.byteBuf());
manager.largeMessageBegin(500);
@@ -619,6 +619,62 @@ public final class ReplicationTest extends ActiveMQTestBase {
static final class FakeJournal implements Journal {
@Override
+ public void appendAddRecord(long id,
+ byte recordType,
+ Persister persister,
+ Object record,
+ boolean sync) throws Exception {
+
+ }
+
+ @Override
+ public void appendAddRecord(long id,
+ byte recordType,
+ Persister persister,
+ Object record,
+ boolean sync,
+ IOCompletion completionCallback) throws Exception {
+
+ }
+
+ @Override
+ public void appendUpdateRecord(long id,
+ byte recordType,
+ Persister persister,
+ Object record,
+ boolean sync) throws Exception {
+
+ }
+
+ @Override
+ public void appendUpdateRecord(long id,
+ byte recordType,
+ Persister persister,
+ Object record,
+ boolean sync,
+ IOCompletion callback) throws Exception {
+
+ }
+
+ @Override
+ public void appendAddRecordTransactional(long txID,
+ long id,
+ byte recordType,
+ Persister persister,
+ Object record) throws Exception {
+
+ }
+
+ @Override
+ public void appendUpdateRecordTransactional(long txID,
+ long id,
+ byte recordType,
+ Persister persister,
+ Object record) throws Exception {
+
+ }
+
+ @Override
public void appendAddRecord(final long id,
final byte recordType,
final byte[] record,
@@ -756,11 +812,6 @@ public final class ReplicationTest extends ActiveMQTestBase {
}
@Override
- public void perfBlast(final int pages) {
-
- }
-
- @Override
public boolean isStarted() {
return false;
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/53887656/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/FakeStorageManager.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/FakeStorageManager.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/FakeStorageManager.java
index c3670c5..67cfe18 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/FakeStorageManager.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/FakeStorageManager.java
@@ -19,8 +19,8 @@ package org.apache.activemq.artemis.tests.integration.server;
import java.util.ArrayList;
import java.util.List;
+import org.apache.activemq.artemis.api.core.Message;
import org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager;
-import org.apache.activemq.artemis.core.server.ServerMessage;
public class FakeStorageManager extends NullStorageManager {
@@ -29,12 +29,12 @@ public class FakeStorageManager extends NullStorageManager {
List<Long> ackIds = new ArrayList<>();
@Override
- public void storeMessage(final ServerMessage message) throws Exception {
+ public void storeMessage(final Message message) throws Exception {
messageIds.add(message.getMessageID());
}
@Override
- public void storeMessageTransactional(final long txID, final ServerMessage message) throws Exception {
+ public void storeMessageTransactional(final long txID, final Message message) throws Exception {
messageIds.add(message.getMessageID());
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/53887656/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/PersistMultiThreadTest.java
----------------------------------------------------------------------
diff --git a/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/PersistMultiThreadTest.java b/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/PersistMultiThreadTest.java
index 0ee92e9..0c4dbf5 100644
--- a/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/PersistMultiThreadTest.java
+++ b/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/PersistMultiThreadTest.java
@@ -26,7 +26,9 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
+import org.apache.activemq.artemis.api.core.Message;
import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
import org.apache.activemq.artemis.core.paging.PagingManager;
import org.apache.activemq.artemis.core.paging.PagingStore;
import org.apache.activemq.artemis.core.paging.cursor.PageCursorProvider;
@@ -37,8 +39,6 @@ import org.apache.activemq.artemis.core.replication.ReplicationManager;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.JournalType;
import org.apache.activemq.artemis.core.server.RouteContextList;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.core.transaction.Transaction;
@@ -188,8 +188,9 @@ public class PersistMultiThreadTest extends ActiveMQTestBase {
}
private void storeMessage(long txID, long id) throws Exception {
- ServerMessage message = new ServerMessageImpl(id, 10 * 1024);
- message.setPagingStore(fakePagingStore);
+ Message message = new CoreMessage(id, 10 * 1024);
+ // TODO-now: fix this
+ message.setContext(fakePagingStore);
message.getBodyBuffer().writeBytes(new byte[104]);
message.putStringProperty("hello", "" + id);
@@ -248,6 +249,26 @@ public class PersistMultiThreadTest extends ActiveMQTestBase {
class FakePagingStore implements PagingStore {
@Override
+ public void durableDown(Message message, int durableCount) {
+
+ }
+
+ @Override
+ public void durableUp(Message message, int durableCount) {
+
+ }
+
+ @Override
+ public void nonDurableUp(Message message, int nonDurableCoun) {
+
+ }
+
+ @Override
+ public void nonDurableDown(Message message, int nonDurableCoun) {
+
+ }
+
+ @Override
public SimpleString getAddress() {
return null;
}
@@ -328,7 +349,7 @@ public class PersistMultiThreadTest extends ActiveMQTestBase {
}
@Override
- public boolean page(ServerMessage message,
+ public boolean page(Message message,
Transaction tx,
RouteContextList listCtx,
ReentrantReadWriteLock.ReadLock readLock) throws Exception {
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/53887656/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/paging/PageCursorStressTest.java
----------------------------------------------------------------------
diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/paging/PageCursorStressTest.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/paging/PageCursorStressTest.java
index d902d3c..61c8d30 100644
--- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/paging/PageCursorStressTest.java
+++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/paging/PageCursorStressTest.java
@@ -25,9 +25,12 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.api.core.RoutingType;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.filter.Filter;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
import org.apache.activemq.artemis.core.paging.cursor.PageCache;
import org.apache.activemq.artemis.core.paging.cursor.PageCursorProvider;
import org.apache.activemq.artemis.core.paging.cursor.PageSubscription;
@@ -39,10 +42,7 @@ import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContex
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.RoutingContext;
-import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.core.server.ServerMessage;
import org.apache.activemq.artemis.core.server.impl.RoutingContextImpl;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.core.transaction.Transaction;
import org.apache.activemq.artemis.core.transaction.impl.TransactionImpl;
@@ -147,7 +147,7 @@ public class PageCursorStressTest extends ActiveMQTestBase {
PageSubscription cursorEven = createNonPersistentCursor(new Filter() {
@Override
- public boolean match(ServerMessage message) {
+ public boolean match(Message message) {
Boolean property = message.getBooleanProperty("even");
if (property == null) {
return false;
@@ -166,7 +166,7 @@ public class PageCursorStressTest extends ActiveMQTestBase {
PageSubscription cursorOdd = createNonPersistentCursor(new Filter() {
@Override
- public boolean match(ServerMessage message) {
+ public boolean match(Message message) {
Boolean property = message.getBooleanProperty("even");
if (property == null) {
return false;
@@ -382,7 +382,7 @@ public class PageCursorStressTest extends ActiveMQTestBase {
ActiveMQBuffer buffer = RandomUtil.randomBuffer(messageSize, i + 1L);
- ServerMessage msg = new ServerMessageImpl(i, buffer.writerIndex());
+ Message msg = new CoreMessage(i, buffer.writerIndex());
msg.putIntProperty("key", i);
msg.getBodyBuffer().writeBytes(buffer, 0, buffer.writerIndex());
@@ -415,7 +415,7 @@ public class PageCursorStressTest extends ActiveMQTestBase {
ActiveMQBuffer buffer = RandomUtil.randomBuffer(messageSize, i + 1L);
- ServerMessage msg = new ServerMessageImpl(i, buffer.writerIndex());
+ Message msg = new CoreMessage(i, buffer.writerIndex());
msg.putIntProperty("key", i);
msg.getBodyBuffer().writeBytes(buffer, 0, buffer.writerIndex());
@@ -445,7 +445,7 @@ public class PageCursorStressTest extends ActiveMQTestBase {
ActiveMQBuffer buffer = RandomUtil.randomBuffer(messageSize, i + 1L);
- ServerMessage msg = new ServerMessageImpl(i, buffer.writerIndex());
+ Message msg = new CoreMessage(i, buffer.writerIndex());
msg.putIntProperty("key", i + 1);
msg.getBodyBuffer().writeBytes(buffer, 0, buffer.writerIndex());
@@ -530,7 +530,7 @@ public class PageCursorStressTest extends ActiveMQTestBase {
//System.out.println("Sending " + count);
ActiveMQBuffer buffer = RandomUtil.randomBuffer(messageSize, count);
- ServerMessage msg = new ServerMessageImpl(i, buffer.writerIndex());
+ Message msg = new CoreMessage(i, buffer.writerIndex());
msg.putIntProperty("key", count++);
msg.getBodyBuffer().writeBytes(buffer, 0, buffer.writerIndex());
@@ -666,7 +666,7 @@ public class PageCursorStressTest extends ActiveMQTestBase {
}
- private int tstProperty(ServerMessage msg) {
+ private int tstProperty(Message msg) {
return msg.getIntProperty("key").intValue();
}
@@ -747,7 +747,7 @@ public class PageCursorStressTest extends ActiveMQTestBase {
System.out.println("Paged " + i);
ActiveMQBuffer buffer = RandomUtil.randomBuffer(messageSize, i + 1L);
- ServerMessage msg = new ServerMessageImpl(i, buffer.writerIndex());
+ Message msg = new CoreMessage(i, buffer.writerIndex());
msg.putIntProperty("key", i);
// to be used on tests that are validating filters
msg.putBooleanProperty("even", i % 2 == 0);
@@ -850,7 +850,7 @@ public class PageCursorStressTest extends ActiveMQTestBase {
for (int i = start; i < start + NUM_MESSAGES; i++) {
ActiveMQBuffer buffer = RandomUtil.randomBuffer(messageSize, i + 1L);
- ServerMessage msg = new ServerMessageImpl(storage.generateID(), buffer.writerIndex());
+ Message msg = new CoreMessage(storage.generateID(), buffer.writerIndex());
msg.getBodyBuffer().writeBytes(buffer, 0, buffer.writerIndex());
msg.putIntProperty("key", i);
pageStore.page(msg, ctx.getTransaction(), ctx.getContextListing(ADDRESS), lock);
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/53887656/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueConcurrentTest.java
----------------------------------------------------------------------
diff --git a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueConcurrentTest.java b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueConcurrentTest.java
index 34ce7ac..6d73cfd 100644
--- a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueConcurrentTest.java
+++ b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueConcurrentTest.java
@@ -19,12 +19,12 @@ package org.apache.activemq.artemis.tests.timing.core.server.impl;
import java.util.ArrayList;
import java.util.List;
+import org.apache.activemq.artemis.api.core.Message;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.server.HandleStatus;
import org.apache.activemq.artemis.core.server.MessageReference;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.QueueConfig;
-import org.apache.activemq.artemis.core.server.ServerMessage;
import org.apache.activemq.artemis.core.server.impl.QueueImpl;
import org.apache.activemq.artemis.tests.unit.UnitTestLogger;
import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakeConsumer;
@@ -138,9 +138,9 @@ public class QueueConcurrentTest extends ActiveMQTestBase {
long start = System.currentTimeMillis();
while (System.currentTimeMillis() - start < testTime) {
- ServerMessage message = generateMessage(i);
+ Message message = generateMessage(i);
- MessageReference ref = message.createReference(queue);
+ MessageReference ref = MessageReference.Factory.createReference(message, queue);
queue.addTail(ref, false);
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/53887656/tests/unit-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/unit-tests/pom.xml b/tests/unit-tests/pom.xml
index 32ca63b..803bf39 100644
--- a/tests/unit-tests/pom.xml
+++ b/tests/unit-tests/pom.xml
@@ -54,6 +54,12 @@
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
+ <artifactId>artemis-amqp-protocol</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
<artifactId>artemis-jms-server</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/53887656/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestUnit.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestUnit.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestUnit.java
index d1536d4..39507aa 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestUnit.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestUnit.java
@@ -2426,7 +2426,7 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase {
}
@Test
- public void testTransactionChangesNotVisibleOutsideTX() throws Exception {
+ public void testTransactionChangesNotVisibleOutsideTXtestTransactionChangesNotVisibleOutsideTX() throws Exception {
setup(10, 10 * 1024, true);
createJournal();
startJournal();
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/53887656/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/message/impl/MessageImplTest.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/message/impl/MessageImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/message/impl/MessageImplTest.java
index 252b0eb..2e0ffac 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/message/impl/MessageImplTest.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/message/impl/MessageImplTest.java
@@ -24,8 +24,8 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
import org.apache.activemq.artemis.api.core.Message;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.client.impl.ClientMessageImpl;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendMessage;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.utils.RandomUtil;
import org.junit.Assert;
@@ -63,7 +63,7 @@ public class MessageImplTest extends ActiveMQTestBase {
final byte priority2 = RandomUtil.randomByte();
message.setAddress(destination);
- Assert.assertEquals(destination, message.getAddress());
+ Assert.assertEquals(destination, message.getAddressSimpleString());
message.setDurable(durable2);
Assert.assertEquals(durable2, message.isDurable());
@@ -232,10 +232,9 @@ public class MessageImplTest extends ActiveMQTestBase {
private void internalMessageCopy() throws Exception {
final long RUNS = 2;
- final ServerMessageImpl msg = new ServerMessageImpl(123, 18);
+ final CoreMessage msg = new CoreMessage(123, 18);
msg.setMessageID(RandomUtil.randomLong());
- msg.encodeMessageIDToBuffer();
msg.setAddress(new SimpleString("Batatantkashf aksjfh aksfjh askfdjh askjfh "));
final AtomicInteger errors = new AtomicInteger(0);
@@ -257,7 +256,7 @@ public class MessageImplTest extends ActiveMQTestBase {
for (int i = 0; i < RUNS; i++) {
try {
- ServerMessageImpl newMsg = (ServerMessageImpl) msg.copy();
+ Message newMsg = msg.copy();
} catch (Throwable e) {
e.printStackTrace();
errors.incrementAndGet();
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/53887656/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PageTest.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PageTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PageTest.java
index d6e0f72..37e33ed 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PageTest.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PageTest.java
@@ -17,23 +17,26 @@
package org.apache.activemq.artemis.tests.unit.core.paging.impl;
import java.nio.ByteBuffer;
-import java.util.ArrayList;
import java.util.List;
-import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import org.apache.activemq.artemis.api.core.Message;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.io.SequentialFile;
import org.apache.activemq.artemis.core.io.SequentialFileFactory;
import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
+import org.apache.activemq.artemis.core.message.impl.CoreMessagePersister;
import org.apache.activemq.artemis.core.paging.PagedMessage;
import org.apache.activemq.artemis.core.paging.impl.Page;
import org.apache.activemq.artemis.core.paging.impl.PagedMessageImpl;
import org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
+import org.apache.activemq.artemis.core.protocol.core.impl.CoreProtocolManagerFactory;
+import org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessagePersister;
+import org.apache.activemq.artemis.spi.core.protocol.MessagePersister;
import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
public class PageTest extends ActiveMQTestBase {
@@ -47,6 +50,12 @@ public class PageTest extends ActiveMQTestBase {
// Public --------------------------------------------------------
+ @Before
+ public void registerProtocols() {
+ MessagePersister.registerPersister(CoreProtocolManagerFactory.ID, CoreMessagePersister.getInstance());
+ MessagePersister.registerPersister((byte)2, AMQPMessagePersister.getInstance());
+ }
+
@Test
public void testPageWithNIO() throws Exception {
recreateDirectory(getTestDir());
@@ -64,6 +73,11 @@ public class PageTest extends ActiveMQTestBase {
testAdd(new FakeSequentialFileFactory(1, false), 10);
}
+ @Test
+ public void testAddCore() throws Exception {
+ testAdd(new NIOSequentialFileFactory(getTestDirfile(), 1), 1);
+ }
+
/**
* Validate if everything we add is recovered
*/
@@ -89,7 +103,7 @@ public class PageTest extends ActiveMQTestBase {
SimpleString simpleDestination = new SimpleString("Test");
- ArrayList<ActiveMQBuffer> buffers = addPageElements(simpleDestination, impl, numberOfElements);
+ addPageElements(simpleDestination, impl, numberOfElements);
impl.sync();
impl.close();
@@ -105,9 +119,7 @@ public class PageTest extends ActiveMQTestBase {
Assert.assertEquals(numberOfElements, impl.getNumberOfMessages());
for (int i = 0; i < msgs.size(); i++) {
- Assert.assertEquals(simpleDestination, msgs.get(i).getMessage().getAddress());
-
- ActiveMQTestBase.assertEqualsByteArrays(buffers.get(i).toByteBuffer().array(), msgs.get(i).getMessage().getBodyBuffer().toByteBuffer().array());
+ Assert.assertEquals(simpleDestination, msgs.get(i).getMessage().getAddressSimpleString());
}
impl.delete(null);
@@ -130,7 +142,7 @@ public class PageTest extends ActiveMQTestBase {
SimpleString simpleDestination = new SimpleString("Test");
- ArrayList<ActiveMQBuffer> buffers = addPageElements(simpleDestination, impl, numberOfElements);
+ addPageElements(simpleDestination, impl, numberOfElements);
impl.sync();
@@ -170,9 +182,7 @@ public class PageTest extends ActiveMQTestBase {
Assert.assertEquals(numberOfElements, impl.getNumberOfMessages());
for (int i = 0; i < msgs.size(); i++) {
- Assert.assertEquals(simpleDestination, msgs.get(i).getMessage().getAddress());
-
- ActiveMQTestBase.assertEqualsByteArrays(buffers.get(i).toByteBuffer().array(), msgs.get(i).getMessage().getBodyBuffer().toByteBuffer().array());
+ Assert.assertEquals(simpleDestination, msgs.get(i).getMessage().getAddressSimpleString());
}
impl.delete(null);
@@ -190,29 +200,25 @@ public class PageTest extends ActiveMQTestBase {
* @return
* @throws Exception
*/
- protected ArrayList<ActiveMQBuffer> addPageElements(final SimpleString simpleDestination,
+ protected void addPageElements(final SimpleString simpleDestination,
final Page page,
final int numberOfElements) throws Exception {
- ArrayList<ActiveMQBuffer> buffers = new ArrayList<>();
int initialNumberOfMessages = page.getNumberOfMessages();
for (int i = 0; i < numberOfElements; i++) {
- ServerMessage msg = new ServerMessageImpl(i, 100);
+ Message msg = new CoreMessage().initBuffer(100);
for (int j = 0; j < 10; j++) {
msg.getBodyBuffer().writeByte((byte) 'b');
}
- buffers.add(msg.getBodyBuffer());
-
msg.setAddress(simpleDestination);
page.write(new PagedMessageImpl(msg, new long[0]));
Assert.assertEquals(initialNumberOfMessages + i + 1, page.getNumberOfMessages());
}
- return buffers;
}
// Package protected ---------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/53887656/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingManagerImplTest.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingManagerImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingManagerImplTest.java
index 10b9a06..654fd89 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingManagerImplTest.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingManagerImplTest.java
@@ -22,7 +22,9 @@ import java.util.List;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
+import org.apache.activemq.artemis.api.core.Message;
import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
import org.apache.activemq.artemis.core.paging.PagedMessage;
import org.apache.activemq.artemis.core.paging.PagingStore;
import org.apache.activemq.artemis.core.paging.impl.Page;
@@ -30,9 +32,7 @@ import org.apache.activemq.artemis.core.paging.impl.PagingManagerImpl;
import org.apache.activemq.artemis.core.paging.impl.PagingStoreFactoryNIO;
import org.apache.activemq.artemis.core.persistence.StorageManager;
import org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager;
-import org.apache.activemq.artemis.core.server.ServerMessage;
import org.apache.activemq.artemis.core.server.impl.RoutingContextImpl;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
@@ -63,7 +63,7 @@ public class PagingManagerImplTest extends ActiveMQTestBase {
PagingStore store = managerImpl.getPageStore(new SimpleString("simple-test"));
- ServerMessage msg = createMessage(1L, new SimpleString("simple-test"), createRandomBuffer(10));
+ Message msg = createMessage(1L, new SimpleString("simple-test"), createRandomBuffer(10));
final RoutingContextImpl ctx = new RoutingContextImpl(null);
Assert.assertFalse(store.page(msg, ctx.getTransaction(), ctx.getContextListing(store.getStoreName()), lock));
@@ -82,7 +82,7 @@ public class PagingManagerImplTest extends ActiveMQTestBase {
Assert.assertEquals(1, msgs.size());
- ActiveMQTestBase.assertEqualsByteArrays(msg.getBodyBuffer().writerIndex(), msg.getBodyBuffer().toByteBuffer().array(), msgs.get(0).getMessage().getBodyBuffer().toByteBuffer().array());
+ ActiveMQTestBase.assertEqualsByteArrays(msg.getBodyBuffer().writerIndex(), msg.getBodyBuffer().toByteBuffer().array(), (msgs.get(0).getMessage()).getBodyBuffer().toByteBuffer().array());
Assert.assertTrue(store.isPaging());
@@ -104,10 +104,10 @@ public class PagingManagerImplTest extends ActiveMQTestBase {
pageDirDir.mkdirs();
}
- protected ServerMessage createMessage(final long messageId,
- final SimpleString destination,
- final ByteBuffer buffer) {
- ServerMessage msg = new ServerMessageImpl(messageId, 200);
+ protected Message createMessage(final long messageId,
+ final SimpleString destination,
+ final ByteBuffer buffer) {
+ Message msg = new CoreMessage(messageId, 200);
msg.setAddress(destination);