use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class MessagingSubsystem30TestCase method testTransformers.
private void testTransformers(ModelTestControllerVersion controllerVersion, ModelVersion messagingVersion, ModelFixer fixer, ModelFixer legacyModelFixer) throws Exception {
//Boot up empty controllers with the resources needed for the ops coming from the xml to work
KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXmlResource("subsystem_3_0.xml");
builder.createLegacyKernelServicesBuilder(createAdditionalInitialization(), controllerVersion, messagingVersion).addMavenResourceURL(getMessagingGAV(controllerVersion)).addMavenResourceURL(getHornetQDependencies(controllerVersion)).configureReverseControllerCheck(createAdditionalInitialization(), fixer).dontPersistXml();
KernelServices mainServices = builder.build();
assertTrue(mainServices.isSuccessfulBoot());
assertTrue(mainServices.getLegacyServices(messagingVersion).isSuccessfulBoot());
checkSubsystemModelTransformation(mainServices, messagingVersion, legacyModelFixer);
}
use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class MessagingSubsystem30TestCase method doTestRejectExpressions_2_0_0_or_2_1_0.
/**
* Tests rejection of expressions in either 2.0.0 or 2.1.0 model.
*/
private void doTestRejectExpressions_2_0_0_or_2_1_0(KernelServicesBuilder builder, ModelVersion version) throws Exception {
KernelServices mainServices = builder.build();
assertTrue(mainServices.isSuccessfulBoot());
KernelServices legacyServices = mainServices.getLegacyServices(version);
assertNotNull(legacyServices);
assertTrue(legacyServices.isSuccessfulBoot());
//Use the real xml with expressions for testing all the attributes
PathAddress subsystemAddress = PathAddress.pathAddress(pathElement(SUBSYSTEM, MessagingExtension.SUBSYSTEM_NAME));
List<ModelNode> modelNodes = builder.parseXmlResource("subsystem_3_0_expressions.xml");
modelNodes.remove(0);
checkFailedTransformedBootOperations(mainServices, version, modelNodes, new FailedOperationTransformationConfig().addFailedAttribute(subsystemAddress.append(HORNETQ_SERVER_PATH), createChainedConfig(new AttributeDefinition[] {}, new AttributeDefinition[] { OVERRIDE_IN_VM_SECURITY })).addFailedAttribute(subsystemAddress.append(HORNETQ_SERVER_PATH).append(AddressSettingDefinition.PATH), createChainedConfig(new AttributeDefinition[] {}, new AttributeDefinition[] { AddressSettingDefinition.MAX_REDELIVERY_DELAY, AddressSettingDefinition.REDELIVERY_MULTIPLIER, AddressSettingDefinition.SLOW_CONSUMER_CHECK_PERIOD, AddressSettingDefinition.SLOW_CONSUMER_POLICY, AddressSettingDefinition.SLOW_CONSUMER_THRESHOLD })));
}
use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class MigrateTestCase method testMigrateOperation.
private void testMigrateOperation(boolean addLegacyEntries) throws Exception {
String subsystemXml = readResource("subsystem_migration.xml");
newSubsystemAdditionalInitialization additionalInitialization = new newSubsystemAdditionalInitialization();
KernelServices services = createKernelServicesBuilder(additionalInitialization).setSubsystemXml(subsystemXml).build();
ModelNode model = services.readWholeModel();
assertFalse(additionalInitialization.extensionAdded);
assertTrue(model.get(SUBSYSTEM, SUBSYSTEM_NAME).isDefined());
assertFalse(model.get(SUBSYSTEM, MESSAGING_ACTIVEMQ_SUBSYSTEM_NAME).isDefined());
ModelNode migrateOp = new ModelNode();
migrateOp.get(OP).set("migrate");
migrateOp.get("add-legacy-entries").set(addLegacyEntries);
migrateOp.get(OP_ADDR).add(SUBSYSTEM, SUBSYSTEM_NAME);
ModelNode response = services.executeOperation(migrateOp);
System.out.println("response = " + response);
checkOutcome(response);
ModelNode warnings = response.get(RESULT, "migration-warnings");
// 6 warnings about broadcast-group attributes that can not be migrated.
// 2 warnings about broadcast-group attributes not migrated because they have an expression.
// 5 warnings about discovery-group attributes that can not be migrated.
// 2 warnings about discovery-group attributes not migrated because they have an expression.
// 3 warnings about interceptors that can not be migrated (for remoting-interceptors, remoting-incoming-interceptors & remoting-outgoing-interceptors attributes)
// 1 warning about HA migration (attributes have expressions)
// 1 warning about cluster-connection forward-when-no-consumers attribute having an expression.
// 1 warning about use-nio being ignored for netty-throughput remote-connector resource.
int expectedNumberOfWarnings = 6 + 2 + 5 + 2 + 3 + 1 + 1 + 1;
// 1 warning if add-legacy-entries is true because an in-vm connector can not be used in a legacy-connection-factory
if (addLegacyEntries) {
expectedNumberOfWarnings += 1;
}
assertEquals(warnings.toString(), expectedNumberOfWarnings, warnings.asList().size());
model = services.readWholeModel();
assertTrue(additionalInitialization.extensionAdded);
assertFalse(model.get(SUBSYSTEM, SUBSYSTEM_NAME).isDefined());
assertTrue(model.get(SUBSYSTEM, MESSAGING_ACTIVEMQ_SUBSYSTEM_NAME).isDefined());
ModelNode newSubsystem = model.get(SUBSYSTEM, MESSAGING_ACTIVEMQ_SUBSYSTEM_NAME);
ModelNode newServer = newSubsystem.get("server", "default");
assertNotNull(newServer);
assertTrue(newServer.isDefined());
assertEquals("STRICT", newServer.get("cluster-connection", "cc2", "message-load-balancing-type").asString());
assertEquals("ON_DEMAND", newServer.get("cluster-connection", "cc3", "message-load-balancing-type").asString());
if (addLegacyEntries) {
// check that legacy entries were added to JMS resources
ModelNode jmsQueueLegacyEntries = newServer.get("jms-queue", "testQueue", "legacy-entries");
assertTrue(jmsQueueLegacyEntries.toJSONString(true), jmsQueueLegacyEntries.isDefined());
assertEquals(1, jmsQueueLegacyEntries.asList().size());
ModelNode jmsTopicLegacyEntries = newServer.get("jms-topic", "testTopic", "legacy-entries");
assertTrue(jmsTopicLegacyEntries.toJSONString(true), jmsQueueLegacyEntries.isDefined());
assertEquals(1, jmsTopicLegacyEntries.asList().size());
assertTrue(newServer.get("legacy-connection-factory", "RemoteConnectionFactory").isDefined());
} else {
// check that no legacy resource or entries were added to the new server
assertFalse(newServer.get("jms-queue", "testQueue", "legacy-entries").isDefined());
assertFalse(newServer.get("jms-topic", "testTopic", "legacy-entries").isDefined());
assertFalse(newServer.get("jms-topic", "testTopic", "legacy-entries").isDefined());
assertFalse(newServer.get("legacy-connection-factory", "RemoteConnectionFactory").isDefined());
}
}
use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class MigrateTestCase method testMigrateHA.
@Test
public void testMigrateHA() throws Exception {
String subsystemXml = readResource("subsystem_migration_ha.xml");
newSubsystemAdditionalInitialization additionalInitialization = new newSubsystemAdditionalInitialization();
KernelServices services = createKernelServicesBuilder(additionalInitialization).setSubsystemXml(subsystemXml).build();
ModelNode model = services.readWholeModel();
assertFalse(additionalInitialization.extensionAdded);
assertTrue(model.get(SUBSYSTEM, SUBSYSTEM_NAME).isDefined());
assertFalse(model.get(SUBSYSTEM, MESSAGING_ACTIVEMQ_SUBSYSTEM_NAME).isDefined());
ModelNode migrateOp = new ModelNode();
migrateOp.get(OP).set("migrate");
migrateOp.get(OP_ADDR).add(SUBSYSTEM, SUBSYSTEM_NAME);
ModelNode response = services.executeOperation(migrateOp);
System.out.println("response = " + response);
checkOutcome(response);
ModelNode warnings = response.get(RESULT, "migration-warnings");
// 1 warning about unmigrated-backup
// 1 warning about shared-store
// 3 warnings aboud discarded failback-delay attribute
assertEquals(warnings.toString(), 1 + 1 + 3, warnings.asList().size());
model = services.readWholeModel();
System.out.println("model = " + model);
assertFalse(model.get(SUBSYSTEM, MESSAGING_ACTIVEMQ_SUBSYSTEM_NAME, "server", "unmigrated-backup", "ha-policy").isDefined());
assertFalse(model.get(SUBSYSTEM, MESSAGING_ACTIVEMQ_SUBSYSTEM_NAME, "server", "unmigrated-shared-store", "ha-policy").isDefined());
ModelNode haPolicyForDefaultServer = model.get(SUBSYSTEM, MESSAGING_ACTIVEMQ_SUBSYSTEM_NAME, "server", "default", "ha-policy", "shared-store-master");
assertTrue(haPolicyForDefaultServer.isDefined());
assertFalse(haPolicyForDefaultServer.get("failback-delay").isDefined());
assertEquals(false, haPolicyForDefaultServer.get("failover-on-server-shutdown").asBoolean());
ModelNode haPolicyForSharedStoreMasterServer = model.get(SUBSYSTEM, MESSAGING_ACTIVEMQ_SUBSYSTEM_NAME, "server", "shared-store-master", "ha-policy", "shared-store-master");
assertTrue(haPolicyForSharedStoreMasterServer.isDefined());
assertFalse(haPolicyForSharedStoreMasterServer.get("failback-delay").isDefined());
assertEquals("${failover.on.shutdown:true}", haPolicyForSharedStoreMasterServer.get("failover-on-server-shutdown").asString());
ModelNode haPolicyForSharedStoreSlaveServer = model.get(SUBSYSTEM, MESSAGING_ACTIVEMQ_SUBSYSTEM_NAME, "server", "shared-store-slave", "ha-policy", "shared-store-slave");
assertTrue(haPolicyForSharedStoreSlaveServer.isDefined());
assertEquals("${allow.failback.1:false}", haPolicyForSharedStoreSlaveServer.get("allow-failback").asString());
assertFalse(haPolicyForSharedStoreSlaveServer.get("failback-delay").isDefined());
assertEquals("${failover.on.shutdown.1:true}", haPolicyForSharedStoreSlaveServer.get("failover-on-server-shutdown").asString());
ModelNode haPolicyForReplicationMasterServer = model.get(SUBSYSTEM, MESSAGING_ACTIVEMQ_SUBSYSTEM_NAME, "server", "replication-master", "ha-policy", "replication-master");
assertTrue(haPolicyForReplicationMasterServer.isDefined());
assertEquals("${check.for.live.server:true}", haPolicyForReplicationMasterServer.get("check-for-live-server").asString());
assertEquals("${replication.master.group.name:mygroup}", haPolicyForReplicationMasterServer.get("group-name").asString());
ModelNode haPolicyForReplicationSlaveServer = model.get(SUBSYSTEM, MESSAGING_ACTIVEMQ_SUBSYSTEM_NAME, "server", "replication-slave", "ha-policy", "replication-slave");
assertTrue(haPolicyForReplicationSlaveServer.isDefined());
assertEquals("${allow.failback.2:false}", haPolicyForReplicationSlaveServer.get("allow-failback").asString());
assertFalse(haPolicyForReplicationSlaveServer.get("failback-delay").isDefined());
assertEquals("${max.saved.replicated.journal.size:2}", haPolicyForReplicationSlaveServer.get("max-saved-replicated-journal-size").asString());
assertEquals("${replication.master.group.name:mygroup2}", haPolicyForReplicationSlaveServer.get("group-name").asString());
}
use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class SubsystemDescriptionsUnitTestCase method testSubsystemDescriptions.
@Test
public void testSubsystemDescriptions() throws Exception {
List<ModelNode> empty = Collections.emptyList();
KernelServices servicesA = createKernelServicesBuilder(AdditionalInitialization.ADMIN_ONLY_HC).setBootOperations(empty).build();
final ModelNode operation = createReadResourceDescriptionOperation();
final ModelNode result = servicesA.executeOperation(operation);
Assert.assertEquals(ModelDescriptionConstants.SUCCESS, result.get(ModelDescriptionConstants.OUTCOME).asString());
servicesA.shutdown();
}
Aggregations