/** * Compares two models to make sure that they are the same * * @param node1 the first model * @param node2 the second model * @param ignoreUndefined {@code true} if keys containing undefined nodes should be ignored */ protected void compare(ModelNode node1, ModelNode node2, boolean ignoreUndefined) { ModelTestUtils.compare(node1, node2, ignoreUndefined); }
/** * Compares two models to make sure that they are the same * * @param node1 the first model * @param node2 the second model */ protected void compare(ModelNode node1, ModelNode node2) { ModelTestUtils.compare(node1, node2); }
/** * Compares two models to make sure that they are the same * * @param node1 the first model * @param node2 the second model */ public static void compare(ModelNode node1, ModelNode node2) { compare(node1, node2, false); }
/** * Compares two models to make sure that they are the same * * @param node1 the first model * @param node2 the second model */ protected void compare(ModelNode node1, ModelNode node2) { ModelTestUtils.compare(node1, node2); }
/** * Compares two models to make sure that they are the same * * @param node1 the first model * @param node2 the second model */ protected void compare(ModelNode node1, ModelNode node2) { ModelTestUtils.compare(node1, node2); }
/** * Compares two models to make sure that they are the same * * @param node1 the first model * @param node2 the second model * @param ignoreUndefined {@code true} if keys containing undefined nodes should be ignored */ protected void compare(ModelNode node1, ModelNode node2, boolean ignoreUndefined) { ModelTestUtils.compare(node1, node2, ignoreUndefined); }
/** * Compares two models to make sure that they are the same * * @param node1 the first model * @param node2 the second model * @param ignoreUndefined {@code true} if keys containing undefined nodes should be ignored */ protected void compare(ModelNode node1, ModelNode node2, boolean ignoreUndefined) { ModelTestUtils.compare(node1, node2, ignoreUndefined); }
/** * Compares two models to make sure that they are the same * * @param node1 the first model * @param node2 the second model * @param ignoreUndefined {@code true} if keys containing undefined nodes should be ignored */ public static void compare(ModelNode node1, ModelNode node2, boolean ignoreUndefined) { compare(node1, node2, ignoreUndefined, false, new Stack<String>()); }
/** * Resolve two models and compare them to make sure that they have same content after expression resolution * * @param node1 the first model * @param node2 the second model */ public static void resolveAndCompareModels(ModelNode node1, ModelNode node2) { compare(resolve(node1), resolve(node2), false, true, new Stack<String>()); }
ModelTestUtils.compare(legacyModel, transformed, true);
ModelTestUtils.compare(legacyModel, transformed, true);
ModelTestUtils.compare(legacySubsystem, transformed, true);
ModelTestUtils.compare(legacySubsystem, transformed, true);
compare(child1, child2, ignoreUndefined, ignoreType, stack); stack.pop(); } else if (!ignoreUndefined) { compare(list1.get(i), list2.get(i), ignoreUndefined, ignoreType, stack); stack.pop(); Assert.assertEquals(prop1 + "\n" + prop2, prop1.getName(), prop2.getName()); stack.push(prop1.getName() + "/"); compare(prop1.getValue(), prop2.getValue(), ignoreUndefined, ignoreType, stack); stack.pop();
private KernelServices bootCurrentVersionWithLegacyBootOperations(List<ModelNode> bootOperations, KernelServices mainServices) throws Exception { //Clone the boot operations to avoid any pollution installing them in the main controller List<ModelNode> clonedBootOperations = new ArrayList<ModelNode>(); for (ModelNode op : bootOperations) { ModelNode cloned = reverseCheckOperationFixer.fixOperation(op.clone()); if (cloned!=null){ clonedBootOperations.add(cloned); } } KernelServices reverseServices = createKernelServicesBuilder(reverseCheckConfig) .setBootOperations(clonedBootOperations) .build(); final Throwable bootError = reverseServices.getBootError(); if (bootError != null) { if (bootError instanceof Exception) { throw (Exception) bootError; } throw new Exception(bootError); } Assert.assertTrue(reverseServices.isSuccessfulBoot()); ModelNode reverseSubsystem = reverseServices.readWholeModel().get(SUBSYSTEM, getMainSubsystemName()); if (reverseCheckModelFixer != null) { reverseSubsystem = reverseCheckModelFixer.fixModel(reverseSubsystem); } ModelTestUtils.compare(mainServices.readWholeModel().get(SUBSYSTEM, getMainSubsystemName()), reverseSubsystem); return reverseServices; }
private KernelServices bootCurrentVersionWithLegacyBootOperations(List<ModelNode> bootOperations, KernelServices mainServices) throws Exception { //Clone the boot operations to avoid any pollution installing them in the main controller List<ModelNode> clonedBootOperations = new ArrayList<ModelNode>(); for (ModelNode op : bootOperations) { ModelNode cloned = reverseCheckOperationFixer.fixOperation(op.clone()); if (cloned!=null){ clonedBootOperations.add(cloned); } } KernelServices reverseServices = createKernelServicesBuilder(reverseCheckConfig) .setBootOperations(clonedBootOperations) .build(); final Throwable bootError = reverseServices.getBootError(); if (bootError != null) { if (bootError instanceof Exception) { throw (Exception) bootError; } throw new Exception(bootError); } Assert.assertTrue(reverseServices.isSuccessfulBoot()); ModelNode reverseSubsystem = reverseServices.readWholeModel().get(SUBSYSTEM, getMainSubsystemName()); if (reverseCheckModelFixer != null) { reverseSubsystem = reverseCheckModelFixer.fixModel(reverseSubsystem); } ModelTestUtils.compare(mainServices.readWholeModel().get(SUBSYSTEM, getMainSubsystemName()), reverseSubsystem); return reverseServices; }
private KernelServices bootCurrentVersionWithLegacyBootOperations(List<ModelNode> bootOperations, KernelServices mainServices) throws Exception { //Clone the boot operations to avoid any pollution installing them in the main controller List<ModelNode> clonedBootOperations = new ArrayList<ModelNode>(); for (ModelNode op : bootOperations) { ModelNode cloned = reverseCheckOperationFixer.fixOperation(op.clone()); if (cloned!=null){ clonedBootOperations.add(cloned); } } KernelServices reverseServices = createKernelServicesBuilder(reverseCheckConfig) .setBootOperations(clonedBootOperations) .build(); if (reverseServices.getBootError() != null) { Throwable t = reverseServices.getBootError(); if (t instanceof Exception) { throw (Exception)t; } throw new Exception(t); } Assert.assertTrue(reverseServices.isSuccessfulBoot()); ModelNode reverseSubsystem = reverseServices.readWholeModel().get(SUBSYSTEM, getMainSubsystemName()); if (reverseCheckModelFixer != null) { reverseCheckModelFixer.fixModel(reverseSubsystem); } ModelTestUtils.compare(mainServices.readWholeModel().get(SUBSYSTEM, getMainSubsystemName()), reverseSubsystem); return reverseServices; }
/** * Checks that the transformed model is the same as the model built up in the legacy subsystem controller via the transformed operations, * and that the transformed model is valid according to the resource definition in the legacy subsystem controller. * * @param kernelServices the main kernel services * @param modelVersion the model version of the targetted legacy subsystem * @param legacyModelFixer use to touch up the model read from the legacy controller, use sparingly when the legacy model is just wrong. May be {@code null} * @return the whole model of the legacy controller */ ModelNode checkSubsystemModelTransformation(KernelServices kernelServices, ModelVersion modelVersion, ModelFixer legacyModelFixer) throws IOException { KernelServices legacy = kernelServices.getLegacyServices(modelVersion); ModelNode legacyModel = legacy.readWholeModel(); ModelNode legacySubsystem = legacyModel.require(SUBSYSTEM); legacySubsystem = legacySubsystem.require(mainSubsystemName); if (legacyModelFixer != null) { legacySubsystem = legacyModelFixer.fixModel(legacySubsystem); } //1) Check that the transformed model is the same as the whole model read from the legacy controller. //The transformed model is done via the resource transformers //The model in the legacy controller is built up via transformed operations ModelNode transformed = kernelServices.readTransformedModel(modelVersion).get(SUBSYSTEM, mainSubsystemName); ModelTestUtils.compare(legacySubsystem, transformed, true); //2) Check that the transformed model is valid according to the resource definition in the legacy subsystem controller ResourceDefinition rd = TransformerRegistry.loadSubsystemDefinitionFromFile(this.getClass(), mainSubsystemName, modelVersion); Assert.assertNotNull("Could not load legacy dmr for subsystem '" + mainSubsystemName + "' version: '" + modelVersion + "' please add it", rd); ManagementResourceRegistration rr = ManagementResourceRegistration.Factory.create(rd); ModelTestUtils.checkModelAgainstDefinition(transformed, rr); return legacyModel; }
private KernelServices bootCurrentVersionWithLegacyBootOperations(List<ModelNode> bootOperations, ModelInitializer modelInitializer, ModelWriteSanitizer modelWriteSanitizer, List<String> contentRepositoryHashes, KernelServices mainServices) throws Exception { KernelServicesBuilder reverseServicesBuilder = createKernelServicesBuilder(TestModelType.DOMAIN) .setBootOperations(bootOperations) .setModelInitializer(modelInitializer, modelWriteSanitizer); for (String hash : contentRepositoryHashes) { reverseServicesBuilder.createContentRepositoryContent(hash); } KernelServices reverseServices = reverseServicesBuilder.build(); if (reverseServices.getBootError() != null) { Throwable t = reverseServices.getBootError(); if (t instanceof Exception) { throw (Exception)t; } throw new Exception(t); } Assert.assertTrue(reverseServices.getBootError() == null ? "error" : reverseServices.getBootError().getMessage(), reverseServices.isSuccessfulBoot()); ModelNode mainModel = mainServices.readWholeModel(); if (reverseCheckMainModelFixer != null) { mainModel = reverseCheckMainModelFixer.fixModel(mainModel); } ModelNode reverseModel = reverseServices.readWholeModel(); if (reverseCheckLegacyModelFixer != null) { reverseModel = reverseCheckLegacyModelFixer.fixModel(reverseModel); } ModelTestUtils.compare(mainModel, reverseModel); return reverseServices; }
private KernelServices bootCurrentVersionWithLegacyBootOperations(List<ModelNode> bootOperations, ModelInitializer modelInitializer, ModelWriteSanitizer modelWriteSanitizer, List<String> contentRepositoryHashes, KernelServices mainServices) throws Exception { KernelServicesBuilder reverseServicesBuilder = createKernelServicesBuilder(TestModelType.DOMAIN) .setBootOperations(bootOperations) .setModelInitializer(modelInitializer, modelWriteSanitizer); for (String hash : contentRepositoryHashes) { reverseServicesBuilder.createContentRepositoryContent(hash); } KernelServices reverseServices = reverseServicesBuilder.build(); if (reverseServices.getBootError() != null) { Throwable t = reverseServices.getBootError(); if (t instanceof Exception) { throw (Exception)t; } throw new Exception(t); } Assert.assertTrue(reverseServices.getBootError() == null ? "error" : reverseServices.getBootError().getMessage(), reverseServices.isSuccessfulBoot()); ModelNode mainModel = mainServices.readWholeModel(); if (reverseCheckMainModelFixer != null) { mainModel = reverseCheckMainModelFixer.fixModel(mainModel); } ModelNode reverseModel = reverseServices.readWholeModel(); if (reverseCheckLegacyModelFixer != null) { reverseModel = reverseCheckLegacyModelFixer.fixModel(reverseModel); } ModelTestUtils.compare(mainModel, reverseModel); return reverseServices; }