gt:         if (messagingVersion.equals(MessagingExtension.VERSION_1_0_0)) {
context: /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2010, Red Hat, Inc., and individual contributors
   * as indicated by the @author tags. See the copyright.txt file in the
   * distribution for a full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
   * the License, or (at your option) any later version.
   *
   * This software is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this software; if not, write to the Free
   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
   */
  
  package org.wildfly.extension.messaging.activemq;
  
  import static org.jboss.as.controller.PathElement.pathElement;
  import static org.jboss.as.model.test.ModelTestControllerVersion.EAP_7_0_0;
  import static org.jboss.as.model.test.ModelTestControllerVersion.EAP_7_1_0;
  import static org.junit.Assert.assertTrue;
  import static org.wildfly.extension.messaging.activemq.CommonAttributes.DEFAULT;
  import static org.wildfly.extension.messaging.activemq.CommonAttributes.SERVER;
  import static org.wildfly.extension.messaging.activemq.CommonAttributes.SUBSYSTEM;
  import static org.wildfly.extension.messaging.activemq.MessagingDependencies.getActiveMQDependencies;
  import static org.wildfly.extension.messaging.activemq.MessagingDependencies.getJGroupsDependencies;
  import static org.wildfly.extension.messaging.activemq.MessagingDependencies.getMessagingActiveMQGAV;
  import static org.wildfly.extension.messaging.activemq.MessagingExtension.ADDRESS_SETTING_PATH;
  import static org.wildfly.extension.messaging.activemq.MessagingExtension.BRIDGE_PATH;
  import static org.wildfly.extension.messaging.activemq.MessagingExtension.CLUSTER_CONNECTION_PATH;
  import static org.wildfly.extension.messaging.activemq.MessagingExtension.CONNECTION_FACTORY_PATH;
  import static org.wildfly.extension.messaging.activemq.MessagingExtension.EXTERNAL_JMS_QUEUE_PATH;
  import static org.wildfly.extension.messaging.activemq.MessagingExtension.EXTERNAL_JMS_TOPIC_PATH;
  import static org.wildfly.extension.messaging.activemq.MessagingExtension.POOLED_CONNECTION_FACTORY_PATH;
  import static org.wildfly.extension.messaging.activemq.MessagingExtension.REPLICATION_COLOCATED_PATH;
  import static org.wildfly.extension.messaging.activemq.MessagingExtension.REPLICATION_MASTER_PATH;
  import static org.wildfly.extension.messaging.activemq.MessagingExtension.SERVER_PATH;
  import static org.wildfly.extension.messaging.activemq.MessagingExtension.SUBSYSTEM_PATH;
  
  import java.io.IOException;
  import java.util.List;
  import java.util.Properties;
  
  import org.jboss.as.controller.ModelVersion;
  import org.jboss.as.controller.PathAddress;
  import org.jboss.as.controller.security.CredentialReference;
  import org.jboss.as.model.test.FailedOperationTransformationConfig;
  import org.jboss.as.model.test.ModelTestControllerVersion;
  import org.jboss.as.model.test.ModelTestUtils;
  import org.jboss.as.subsystem.test.AbstractSubsystemBaseTest;
  import org.jboss.as.subsystem.test.AdditionalInitialization;
  import org.jboss.as.subsystem.test.KernelServices;
  import org.jboss.as.subsystem.test.KernelServicesBuilder;
  import org.jboss.dmr.ModelNode;
  import org.junit.Assert;
  import org.junit.Test;
  import org.wildfly.clustering.jgroups.spi.JGroupsDefaultRequirement;
  import org.wildfly.clustering.spi.ClusteringDefaultRequirement;
  import org.wildfly.clustering.spi.ClusteringRequirement;
  import org.wildfly.extension.messaging.activemq.ha.HAAttributes;
  import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes;
  
  /**
   *  * @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2012 Red Hat inc
   */
  public class MessagingActiveMQSubsystem_7_0_TestCase extends AbstractSubsystemBaseTest {
  
      public MessagingActiveMQSubsystem_7_0_TestCase() {
          super(MessagingExtension.SUBSYSTEM_NAME, new MessagingExtension());
      }
  
      @Override
      protected String getSubsystemXml() throws IOException {
          return readResource("subsystem_7_0.xml");
      }
  
      @Override
      protected String getSubsystemXsdPath() throws IOException {
          return "schema/wildfly-messaging-activemq_7_0.xsd";
      }
  
      @Override
      protected Properties getResolvedProperties() {
          Properties properties = new Properties();
          properties.put("messaging.cluster.user.name", "myClusterUser");
          properties.put("messaging.cluster.user.password", "myClusterPassword");
          return properties;
      }
  
      @Override
      protected KernelServices standardSubsystemTest(String configId, boolean compareXml) throws Exception {
          return super.standardSubsystemTest(configId, false);
      }
  
      @Test
      public void testJournalAttributes() throws Exception {
          KernelServices kernelServices = standardSubsystemTest(null, false);
          ModelNode rootModel = kernelServices.readWholeModel();
          ModelNode serverModel = rootModel.require(SUBSYSTEM).require(MessagingExtension.SUBSYSTEM_NAME).require(SERVER)
                  .require(DEFAULT);
  
          Assert.assertEquals(1357, serverModel.get(ServerDefinition.JOURNAL_BUFFER_TIMEOUT.getName()).resolve().asInt());
          Assert.assertEquals(102400, serverModel.get(ServerDefinition.JOURNAL_FILE_SIZE.getName()).resolve().asInt());
          Assert.assertEquals(2, serverModel.get(ServerDefinition.JOURNAL_MIN_FILES.getName()).resolve().asInt());
          Assert.assertEquals(5, serverModel.get(ServerDefinition.JOURNAL_POOL_FILES.getName()).resolve().asInt());
          Assert.assertEquals(7, serverModel.get(ServerDefinition.JOURNAL_FILE_OPEN_TIMEOUT.getName()).resolve().asInt());
      }
  
      /////////////////////////////////////////
      //  Tests for HA Policy Configuration  //
      /////////////////////////////////////////
  
      @Test
      public void testHAPolicyConfiguration() throws Exception {
          standardSubsystemTest("subsystem_7_0_ha-policy.xml");
      }
  
      ///////////////////////
      // Transformers test //
      ///////////////////////
      @Test
      public void testTransformersWildfly16() throws Exception {
          testTransformers(ModelTestControllerVersion.MASTER, MessagingExtension.VERSION_6_0_0);
      }
  
      @Test
      public void testTransformersEAP_7_2_0() throws Exception {
          testTransformers(ModelTestControllerVersion.EAP_7_2_0, MessagingExtension.VERSION_4_0_0);
      }
  
      @Test
      public void testTransformersEAP_7_1_0() throws Exception {
          testTransformers(EAP_7_1_0, MessagingExtension.VERSION_2_0_0);
      }
  
      @Test
      public void testTransformersEAP_7_0_0() throws Exception {
          testTransformers(EAP_7_0_0, MessagingExtension.VERSION_1_0_0);
      }
  
      @Test
      public void testRejectingTransformersEAP_7_2_0() throws Exception {
          testRejectingTransformers(ModelTestControllerVersion.EAP_7_2_0, MessagingExtension.VERSION_4_0_0);
      }
  
      @Test
      public void testRejectingTransformersEAP_7_1_0() throws Exception {
          testRejectingTransformers(EAP_7_1_0, MessagingExtension.VERSION_2_0_0);
      }
  
      @Test
      public void testRejectingTransformersEAP_7_0_0() throws Exception {
          testRejectingTransformers(EAP_7_0_0, MessagingExtension.VERSION_1_0_0);
      }
  
      private void testTransformers(ModelTestControllerVersion controllerVersion, ModelVersion messagingVersion) 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_7_0_transform.xml");
          builder.createLegacyKernelServicesBuilder(createAdditionalInitialization(), controllerVersion, messagingVersion)
                  .addMavenResourceURL(getMessagingActiveMQGAV(controllerVersion))
                  .addMavenResourceURL(getActiveMQDependencies(controllerVersion))
                  .addMavenResourceURL(getJGroupsDependencies(controllerVersion))
                  .skipReverseControllerCheck()
                  .dontPersistXml();
  
          KernelServices mainServices = builder.build();
          assertTrue(mainServices.isSuccessfulBoot());
          assertTrue(mainServices.getLegacyServices(messagingVersion).isSuccessfulBoot());
  
          checkSubsystemModelTransformation(mainServices, messagingVersion);
          mainServices.shutdown();
      }
  
      private void testRejectingTransformers(ModelTestControllerVersion controllerVersion, ModelVersion messagingVersion) throws Exception {
          //Boot up empty controllers with the resources needed for the ops coming from the xml to work
          KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization());
          builder.createLegacyKernelServicesBuilder(createAdditionalInitialization(), controllerVersion, messagingVersion)
                  .addMavenResourceURL(getMessagingActiveMQGAV(controllerVersion))
                  .addMavenResourceURL(getActiveMQDependencies(controllerVersion))
                  .addMavenResourceURL(getJGroupsDependencies(controllerVersion))
                  .skipReverseControllerCheck()
                  .dontPersistXml();
  
          KernelServices mainServices = builder.build();
          assertTrue(mainServices.isSuccessfulBoot());
          assertTrue(mainServices.getLegacyServices(messagingVersion).isSuccessfulBoot());
  
          List<ModelNode> ops = builder.parseXmlResource("subsystem_7_0_reject_transform.xml");
          System.out.println("ops = " + ops);
          PathAddress subsystemAddress = PathAddress.pathAddress(SUBSYSTEM_PATH);
  
          FailedOperationTransformationConfig config = new FailedOperationTransformationConfig();
  