NO-JIRA no need to validate MAX_INT on XmlImportExportTest

This is only double testing.

Instead of parameterizing with or without forceNextValue(MAX_INT)
I'm just always forcing it. No point on duplicating the test just for this.
This commit is contained in:
Clebert Suconic 2024-10-10 16:27:59 -04:00
parent 6186805b69
commit c58210cc29
1 changed files with 47 additions and 61 deletions

View File

@ -32,8 +32,6 @@ import javax.jms.TextMessage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumSet;
import java.util.UUID;
@ -60,15 +58,12 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.jms.server.JMSServerManager;
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
import org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedTestExtension;
import org.apache.activemq.artemis.tests.extensions.parameterized.Parameters;
import org.apache.activemq.artemis.tests.unit.util.InVMContext;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.tests.util.RandomUtil;
import org.apache.activemq.artemis.tests.util.Wait;
import org.apache.activemq.artemis.utils.UUIDGenerator;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.invoke.MethodHandles;
@ -76,20 +71,11 @@ import java.lang.invoke.MethodHandles;
/**
* A test of the XML export/import functionality
*/
@ExtendWith(ParameterizedTestExtension.class)
public class XmlImportExportTest extends ActiveMQTestBase {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private boolean forceLongs;
@Parameters(name = "forceLongs={0}")
public static Collection getParameters() {
return Arrays.asList(new Object[][]{{true}, {false}});
}
public XmlImportExportTest(boolean forceLongs) {
this.forceLongs = forceLongs;
public XmlImportExportTest() {
}
@ -101,15 +87,15 @@ public class XmlImportExportTest extends ActiveMQTestBase {
private ClientSessionFactory factory;
private InVMContext namingContext;
protected void checkForLongs() {
if (forceLongs) {
JournalStorageManager manager = (JournalStorageManager) server.getStorageManager();
BatchingIDGenerator idGenerator = (BatchingIDGenerator) manager.getIDGenerator();
idGenerator.forceNextID((Integer.MAX_VALUE) + 1L);
}
// this is to force nextID > Integer.MAX_VALUE.
// just to make it more challenging if there's any encoding using integer internally by mistake.
protected void forceLong() {
JournalStorageManager manager = (JournalStorageManager) server.getStorageManager();
BatchingIDGenerator idGenerator = (BatchingIDGenerator) manager.getIDGenerator();
idGenerator.forceNextID((Integer.MAX_VALUE) + 1L);
}
@TestTemplate
@Test
public void testMessageProperties() throws Exception {
ClientSession session = basicSetUp();
@ -159,7 +145,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
clearDataRecreateServerDirs();
server.start();
checkForLongs();
forceLong();
locator = createInVMNonHALocator();
factory = createSessionFactory(locator);
session = factory.createSession(false, true, true);
@ -217,11 +203,11 @@ public class XmlImportExportTest extends ActiveMQTestBase {
jmsServer.start();
locator = createInVMNonHALocator();
factory = createSessionFactory(locator);
checkForLongs();
forceLong();
return addClientSession(factory.createSession(false, true, true));
}
@TestTemplate
@Test
public void testMessageTypes() throws Exception {
ClientSession session = basicSetUp();
@ -258,7 +244,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
clearDataRecreateServerDirs();
server.start();
checkForLongs();
forceLong();
locator = createInVMNonHALocator();
factory = createSessionFactory(locator);
session = factory.createSession(false, true, true);
@ -287,7 +273,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
assertEquals(Message.DEFAULT_TYPE, msg.getType());
}
@TestTemplate
@Test
public void testTextMessage() throws Exception {
StringBuilder data = new StringBuilder();
for (int i = 0; i < 2608; i++) {
@ -316,7 +302,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
clearDataRecreateServerDirs();
server.start();
checkForLongs();
forceLong();
locator = createInVMNonHALocator();
factory = createSessionFactory(locator);
session = factory.createSession(false, true, true);
@ -334,7 +320,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
assertEquals(data.toString(), msg.getBodyBuffer().readString());
}
@TestTemplate
@Test
public void testBytesMessage() throws Exception {
StringBuilder data = new StringBuilder();
for (int i = 0; i < 2610; i++) {
@ -363,7 +349,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
clearDataRecreateServerDirs();
server.start();
checkForLongs();
forceLong();
locator = createInVMNonHALocator();
factory = createSessionFactory(locator);
session = factory.createSession(false, true, true);
@ -383,7 +369,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
assertEquals(data.toString().getBytes().length, result.length);
}
@TestTemplate
@Test
public void testMessageAttributes() throws Exception {
ClientSession session = basicSetUp();
@ -412,7 +398,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
clearDataRecreateServerDirs();
server.start();
checkForLongs();
forceLong();
locator = createInVMNonHALocator();
factory = createSessionFactory(locator);
session = factory.createSession(false, true, true);
@ -432,7 +418,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
assertNotNull(msg.getUserID());
}
@TestTemplate
@Test
public void testBindingAttributes() throws Exception {
ClientSession session = basicSetUp();
@ -452,7 +438,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
clearDataRecreateServerDirs();
server.start();
checkForLongs();
forceLong();
locator = createInVMNonHALocator();
factory = createSessionFactory(locator);
session = factory.createSession(false, true, true);
@ -475,7 +461,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
assertTrue(queueQuery.isDurable());
}
@TestTemplate
@Test
public void testLargeMessage() throws Exception {
server = createServer(true);
server.start();
@ -519,7 +505,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
clearDataRecreateServerDirs();
server.start();
checkForLongs();
forceLong();
locator = createInVMNonHALocator();
factory = createSessionFactory(locator);
session = factory.createSession(false, true, true);
@ -549,7 +535,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
session.commit();
}
@TestTemplate
@Test
public void testLargeMessagesNoTmpFiles() throws Exception {
server = createServer(true);
server.start();
@ -594,7 +580,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
clearDataRecreateServerDirs();
server.start();
checkForLongs();
forceLong();
locator = createInVMNonHALocator();
factory = createSessionFactory(locator);
session = factory.createSession(false, true, true);
@ -637,7 +623,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
}
}
@TestTemplate
@Test
public void testLargeJmsTextMessage() throws Exception {
basicSetUp();
ConnectionFactory cf = ActiveMQJMSClient.createConnectionFactory("vm://0", "test");
@ -667,7 +653,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
clearDataRecreateServerDirs();
server.start();
checkForLongs();
forceLong();
locator = createInVMNonHALocator();
factory = createSessionFactory(locator);
ClientSession session = factory.createSession(false, true, true);
@ -690,7 +676,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
c.close();
}
@TestTemplate
@Test
public void testPartialQueue() throws Exception {
ClientSession session = basicSetUp();
@ -722,7 +708,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
clearDataRecreateServerDirs();
server.start();
checkForLongs();
forceLong();
locator = createInVMNonHALocator();
factory = createSessionFactory(locator);
session = factory.createSession(false, true, true);
@ -743,7 +729,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
assertNotNull(msg);
}
@TestTemplate
@Test
public void testPagedMessageWithMissingBinding() throws Exception {
final String MY_ADDRESS = "myAddress";
final String MY_QUEUE = "myQueue";
@ -790,7 +776,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
clearDataRecreateServerDirs();
server.start();
checkForLongs();
forceLong();
locator = createInVMNonHALocator();
factory = locator.createSessionFactory();
session = factory.createSession(false, true, true);
@ -816,7 +802,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
server.stop();
}
@TestTemplate
@Test
public void testPaging() throws Exception {
final String MY_ADDRESS = "myAddress";
final String MY_QUEUE = "myQueue";
@ -859,7 +845,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
clearDataRecreateServerDirs();
server.start();
checkForLongs();
forceLong();
locator = createInVMNonHALocator();
factory = createSessionFactory(locator);
session = factory.createSession(false, true, true);
@ -881,7 +867,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
}
}
@TestTemplate
@Test
public void testPagedLargeMessage() throws Exception {
final String MY_ADDRESS = "myAddress";
final String MY_QUEUE = "myQueue";
@ -939,7 +925,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
clearDataRecreateServerDirs();
server.start();
checkForLongs();
forceLong();
locator = createInVMNonHALocator();
factory = locator.createSessionFactory();
session = factory.createSession(false, true, true);
@ -975,7 +961,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
server.stop();
}
@TestTemplate
@Test
public void testTransactional() throws Exception {
ClientSession session = basicSetUp();
@ -999,7 +985,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
clearDataRecreateServerDirs();
server.start();
checkForLongs();
forceLong();
locator = createInVMNonHALocator();
factory = createSessionFactory(locator);
session = factory.createSession(false, false, true);
@ -1017,7 +1003,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
assertNotNull(msg);
}
@TestTemplate
@Test
public void testBody() throws Exception {
final String QUEUE_NAME = "A1";
server = createServer(true);
@ -1047,7 +1033,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
clearDataRecreateServerDirs();
server.start();
checkForLongs();
forceLong();
locator = createInVMNonHALocator();
factory = locator.createSessionFactory();
session = factory.createSession(false, false, true);
@ -1070,7 +1056,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
server.stop();
}
@TestTemplate
@Test
public void testBody2() throws Exception {
final String QUEUE_NAME = "A1";
server = createServer(true);
@ -1105,7 +1091,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
clearDataRecreateServerDirs();
server.start();
checkForLongs();
forceLong();
locator = createInVMNonHALocator();
factory = locator.createSessionFactory();
session = factory.createSession(false, false, true);
@ -1131,7 +1117,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
server.stop();
}
@TestTemplate
@Test
public void testRoutingTypes() throws Exception {
SimpleString myAddress = SimpleString.of("myAddress");
ClientSession session = basicSetUp();
@ -1155,7 +1141,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
clearDataRecreateServerDirs();
server.start();
checkForLongs();
forceLong();
locator = createInVMNonHALocator();
factory = locator.createSessionFactory();
session = factory.createSession(false, false, true);
@ -1171,7 +1157,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
assertTrue(server.getAddressInfo(myAddress).getRoutingTypes().contains(RoutingType.MULTICAST));
}
@TestTemplate
@Test
public void testEmptyRoutingTypes() throws Exception {
SimpleString myAddress = SimpleString.of("myAddress");
ClientSession session = basicSetUp();
@ -1192,7 +1178,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
clearDataRecreateServerDirs();
server.start();
checkForLongs();
forceLong();
locator = createInVMNonHALocator();
factory = locator.createSessionFactory();
session = factory.createSession(false, false, true);
@ -1207,7 +1193,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
assertEquals(0, server.getAddressInfo(myAddress).getRoutingTypes().size());
}
@TestTemplate
@Test
public void testImportWrongRoutingType() throws Exception {
SimpleString myAddress = SimpleString.of("myAddress");
SimpleString myQueue = SimpleString.of("myQueue");
@ -1256,7 +1242,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
clearDataRecreateServerDirs();
server.start();
checkForLongs();
forceLong();
locator = createInVMNonHALocator();
factory = locator.createSessionFactory();
session = factory.createSession(false, false, true);