コード例 #1
0
  private void testTransformers(ModelTestControllerVersion controllerVersion) throws Exception {
    ModelVersion modelVersion = ModelVersion.create(1, 0, 0);
    KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization());

    builder
        .createLegacyKernelServicesBuilder(
            createAdditionalInitialization(), controllerVersion, modelVersion)
        .addMavenResourceURL("org.jboss.as:jboss-as-cmp:" + controllerVersion.getMavenGavVersion())
        .configureReverseControllerCheck(createAdditionalInitialization(), null);

    KernelServices mainServices = builder.build();
    Assert.assertTrue(mainServices.isSuccessfulBoot());
    Assert.assertTrue(mainServices.getLegacyServices(modelVersion).isSuccessfulBoot());

    ModelTestUtils.checkFailedTransformedBootOperations(
        mainServices,
        modelVersion,
        parse(getSubsystemXml()),
        new FailedOperationTransformationConfig()
            .addFailedAttribute(
                SUBSYSTEM_PATH.append(CmpSubsystemModel.UUID_KEY_GENERATOR_PATH),
                new FailedOperationTransformationConfig.NewAttributesConfig(
                    CMPSubsystemRootResourceDefinition.JNDI_NAME))
            .addFailedAttribute(
                SUBSYSTEM_PATH.append(CmpSubsystemModel.HILO_KEY_GENERATOR_PATH),
                new FailedOperationTransformationConfig.NewAttributesConfig(
                    CMPSubsystemRootResourceDefinition.JNDI_NAME)));
  }
コード例 #2
0
  private void testRejections(final ModelTestControllerVersion controller) throws Exception {
    final ModelVersion version = getModelVersion(controller).getVersion();
    final String[] dependencies = getDependencies(controller);

    // create builder for current subsystem version
    KernelServicesBuilder builder = this.createKernelServicesBuilder();

    // initialize the legacy services
    builder
        .createLegacyKernelServicesBuilder(createAdditionalInitialization(), controller, version)
        .addSingleChildFirstClass(LegacyControllerAdditionalInitialization.class)
        .addMavenResourceURL(dependencies)
        // TODO storing the model triggers the weirdness mentioned in
        // SubsystemTestDelegate.LegacyKernelServiceInitializerImpl.install()
        // which is strange since it should be loading it all from the current jboss modules
        // Also this works in several other tests
        .dontPersistXml();

    KernelServices services = builder.build();
    KernelServices legacyServices = services.getLegacyServices(version);
    Assert.assertNotNull(legacyServices);
    Assert.assertTrue("main services did not boot", services.isSuccessfulBoot());
    Assert.assertTrue(legacyServices.isSuccessfulBoot());

    // test failed operations involving backups
    List<ModelNode> xmlOps = builder.parseXmlResource("infinispan-transformer-reject.xml");
    ModelTestUtils.checkFailedTransformedBootOperations(
        services, version, xmlOps, createFailedOperationConfig(version));
  }
コード例 #3
0
  @Test
  public void testRejectTransformers71x() throws Exception {

    if (modelVersion.getMajor() > 1 || modelVersion.getMinor() > 3) {
      return;
    }

    KernelServicesBuilder builder =
        createKernelServicesBuilder(TestModelType.DOMAIN)
            .setModelInitializer(
                StandardServerGroupInitializers.XML_MODEL_INITIALIZER,
                StandardServerGroupInitializers.XML_MODEL_WRITE_SANITIZER)
            .createContentRepositoryContent("12345678901234567890")
            .createContentRepositoryContent("09876543210987654321");

    // Add legacy subsystems
    LegacyKernelServicesInitializer legacyInitializer =
        StandardServerGroupInitializers.addServerGroupInitializers(
                builder.createLegacyKernelServicesBuilder(modelVersion, testControllerVersion))
            // The reverse stuff is tested in the other test
            .skipReverseControllerCheck();
    // The 7.1.x descriptions are inaccurate so we can't validate the add ops against them
    legacyInitializer.setDontValidateOperations();

    KernelServices mainServices = builder.build();

    List<ModelNode> ops = builder.parseXmlResource("servergroup_1_3-with-expressions.xml");
    ModelTestUtils.checkFailedTransformedBootOperations(
        mainServices,
        modelVersion,
        ops,
        new FailedOperationTransformationConfig()
            .addFailedAttribute(
                PathAddress.pathAddress(PathElement.pathElement(SERVER_GROUP)),
                new FailedOperationTransformationConfig.RejectExpressionsConfig(
                        ServerGroupResourceDefinition.MANAGEMENT_SUBSYSTEM_ENDPOINT,
                        ServerGroupResourceDefinition.SOCKET_BINDING_PORT_OFFSET)
                    .setReadOnly(ServerGroupResourceDefinition.MANAGEMENT_SUBSYSTEM_ENDPOINT)));
  }
コード例 #4
0
  @Test
  public void testLegacyFilters() throws Exception {
    final KernelServices kernelServices = boot();
    final String fileHandlerName = "test-file-handler";

    // add new file logger so we can track logged messages
    final File logFile = createLogFile();
    final ModelNode handlerAddress = createFileHandlerAddress(fileHandlerName).toModelNode();
    addFileHandler(
        kernelServices, null, fileHandlerName, org.jboss.logmanager.Level.TRACE, logFile, true);
    // Write legacy filters
    for (Map.Entry<String, ModelNode> entry : FilterConversionTestCase.MAP.entrySet()) {
      // Validate the write-attribute operation
      ModelNode op =
          SubsystemOperations.createWriteAttributeOperation(
              handlerAddress, CommonAttributes.FILTER, entry.getValue());
      executeOperation(kernelServices, op);
      // Read the current value
      op =
          SubsystemOperations.createReadAttributeOperation(
              handlerAddress, CommonAttributes.FILTER_SPEC);
      String filterSpecResult =
          SubsystemOperations.readResultAsString(executeOperation(kernelServices, op));
      assertEquals(entry.getKey(), filterSpecResult);

      // Validate an add operation
      final ModelNode tempHandlerAddress = createConsoleHandlerAddress("temp").toModelNode();
      op = SubsystemOperations.createAddOperation(tempHandlerAddress);
      op.get(CommonAttributes.FILTER.getName()).set(entry.getValue());
      executeOperation(kernelServices, op);
      // Read the current value
      op =
          SubsystemOperations.createReadAttributeOperation(
              tempHandlerAddress, CommonAttributes.FILTER_SPEC);
      filterSpecResult =
          SubsystemOperations.readResultAsString(executeOperation(kernelServices, op));
      assertEquals(entry.getKey(), filterSpecResult);
      // Remove the temp handler
      op = SubsystemOperations.createRemoveOperation(tempHandlerAddress, true);
      executeOperation(kernelServices, op);

      // Add to a logger
      final ModelNode loggerAddress = createLoggerAddress("test-logger").toModelNode();
      op = SubsystemOperations.createAddOperation(loggerAddress);
      op.get(CommonAttributes.FILTER.getName()).set(entry.getValue());
      executeOperation(kernelServices, op);
      // Read the current value
      op =
          SubsystemOperations.createReadAttributeOperation(
              loggerAddress, CommonAttributes.FILTER_SPEC);
      filterSpecResult =
          SubsystemOperations.readResultAsString(executeOperation(kernelServices, op));
      assertEquals(entry.getKey(), filterSpecResult);

      // Remove the attribute
      op =
          SubsystemOperations.createUndefineAttributeOperation(
              loggerAddress, CommonAttributes.FILTER_SPEC);
      executeOperation(kernelServices, op);
      op = SubsystemOperations.createReadAttributeOperation(loggerAddress, CommonAttributes.FILTER);
      // Filter and filter spec should be undefined
      assertEquals(
          "Filter was not undefined",
          SubsystemOperations.UNDEFINED,
          SubsystemOperations.readResult(executeOperation(kernelServices, op)));
      op =
          SubsystemOperations.createReadAttributeOperation(
              loggerAddress, CommonAttributes.FILTER_SPEC);
      assertEquals(
          "Filter was not undefined",
          SubsystemOperations.UNDEFINED,
          SubsystemOperations.readResult(executeOperation(kernelServices, op)));

      // Test writing the attribute to the logger
      op =
          SubsystemOperations.createWriteAttributeOperation(
              loggerAddress, CommonAttributes.FILTER, entry.getValue());
      executeOperation(kernelServices, op);
      // Read the current value
      op =
          SubsystemOperations.createReadAttributeOperation(
              loggerAddress, CommonAttributes.FILTER_SPEC);
      filterSpecResult =
          SubsystemOperations.readResultAsString(executeOperation(kernelServices, op));
      assertEquals(entry.getKey(), filterSpecResult);

      // Remove the logger
      op = SubsystemOperations.createRemoveOperation(loggerAddress, true);
      executeOperation(kernelServices, op);
    }

    // Write new filters
    for (Map.Entry<String, ModelNode> entry : FilterConversionTestCase.MAP.entrySet()) {
      // Write to a handler
      ModelNode op =
          SubsystemOperations.createWriteAttributeOperation(
              handlerAddress, CommonAttributes.FILTER_SPEC, entry.getKey());
      executeOperation(kernelServices, op);
      // Read the current value
      op =
          SubsystemOperations.createReadAttributeOperation(handlerAddress, CommonAttributes.FILTER);
      ModelNode filterResult = SubsystemOperations.readResult(executeOperation(kernelServices, op));
      ModelTestUtils.compare(entry.getValue(), filterResult);

      // Validate an add operation
      final ModelNode tempHandlerAddress = createConsoleHandlerAddress("temp").toModelNode();
      op = SubsystemOperations.createAddOperation(tempHandlerAddress);
      op.get(CommonAttributes.FILTER_SPEC.getName()).set(entry.getKey());
      executeOperation(kernelServices, op);
      // Read the current value
      op =
          SubsystemOperations.createReadAttributeOperation(
              tempHandlerAddress, CommonAttributes.FILTER);
      filterResult = SubsystemOperations.readResult(executeOperation(kernelServices, op));
      ModelTestUtils.compare(entry.getValue(), filterResult);
      // Remove the temp handler
      op = SubsystemOperations.createRemoveOperation(tempHandlerAddress, true);
      executeOperation(kernelServices, op);

      // Add to a logger
      final ModelNode loggerAddress = createLoggerAddress("test-logger").toModelNode();
      op = SubsystemOperations.createAddOperation(loggerAddress);
      op.get(CommonAttributes.FILTER_SPEC.getName()).set(entry.getKey());
      executeOperation(kernelServices, op);
      // Read the current value
      op = SubsystemOperations.createReadAttributeOperation(loggerAddress, CommonAttributes.FILTER);
      filterResult = SubsystemOperations.readResult(executeOperation(kernelServices, op));
      ModelTestUtils.compare(entry.getValue(), filterResult);

      // Test writing the attribute to the logger
      op =
          SubsystemOperations.createWriteAttributeOperation(
              loggerAddress, CommonAttributes.FILTER_SPEC, entry.getKey());
      executeOperation(kernelServices, op);
      // Read the current value
      op = SubsystemOperations.createReadAttributeOperation(loggerAddress, CommonAttributes.FILTER);
      filterResult = SubsystemOperations.readResult(executeOperation(kernelServices, op));
      ModelTestUtils.compare(entry.getValue(), filterResult);

      // Remove the logger
      op = SubsystemOperations.createRemoveOperation(loggerAddress, true);
      executeOperation(kernelServices, op);
    }
    removeFileHandler(kernelServices, null, fileHandlerName, true);
  }