-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WFCORE-7091] Adapt the test framework to use an stability level when…
… it is preparing the legacy controllers Jira issue: https://issues.redhat.com/browse/WFCORE-7091
- Loading branch information
Showing
13 changed files
with
265 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,58 +14,89 @@ | |
import org.jboss.as.core.model.bridge.impl.LegacyControllerKernelServicesProxy; | ||
import org.jboss.as.core.model.test.LegacyModelInitializerEntry; | ||
import org.jboss.as.model.test.ModelTestOperationValidatorFilter; | ||
import org.jboss.as.version.Stability; | ||
import org.jboss.dmr.ModelNode; | ||
|
||
/** | ||
* | ||
* @author <a href="[email protected]">Kabir Khan</a> | ||
*/ | ||
public class ScopedKernelServicesBootstrap { | ||
Stability stability; | ||
ClassLoader legacyChildFirstClassLoader; | ||
ClassLoaderObjectConverter objectConverter; | ||
|
||
public ScopedKernelServicesBootstrap(ClassLoader legacyChildFirstClassLoader) { | ||
public ScopedKernelServicesBootstrap(ClassLoader legacyChildFirstClassLoader, Stability stability) { | ||
this.legacyChildFirstClassLoader = legacyChildFirstClassLoader; | ||
this.objectConverter = new ClassLoaderObjectConverterImpl(this.getClass().getClassLoader(), legacyChildFirstClassLoader); | ||
this.stability = stability; | ||
} | ||
|
||
|
||
public LegacyControllerKernelServicesProxy createKernelServices(List<ModelNode> bootOperations, ModelTestOperationValidatorFilter validateOpsFilter, ModelVersion legacyModelVersion, List<LegacyModelInitializerEntry> modelInitializerEntries) throws Exception { | ||
|
||
Object childClassLoaderKernelServices = createChildClassLoaderKernelServices(bootOperations, validateOpsFilter, legacyModelVersion, modelInitializerEntries); | ||
return new LegacyControllerKernelServicesProxy(legacyChildFirstClassLoader, childClassLoaderKernelServices, objectConverter); | ||
} | ||
|
||
private Object createChildClassLoaderKernelServices(List<ModelNode> bootOperations, ModelTestOperationValidatorFilter validateOpsFilter, ModelVersion legacyModelVersion, List<LegacyModelInitializerEntry> modelInitializerEntries){ | ||
private Object createChildClassLoaderKernelServices(List<ModelNode> bootOperations, ModelTestOperationValidatorFilter validateOpsFilter, ModelVersion legacyModelVersion, List<LegacyModelInitializerEntry> modelInitializerEntries) { | ||
try { | ||
Class<?> clazz = legacyChildFirstClassLoader.loadClass(ChildFirstClassLoaderKernelServicesFactory.class.getName()); | ||
List<Object> convertedBootOps = getConvertedBootOps(bootOperations); | ||
List<Object> convertedModelInitializerEntries = convertModelInitializer(modelInitializerEntries); | ||
|
||
Method m = clazz.getMethod("create", | ||
List.class, | ||
legacyChildFirstClassLoader.loadClass(ModelTestOperationValidatorFilter.class.getName()), | ||
legacyChildFirstClassLoader.loadClass(ModelVersion.class.getName()), | ||
List.class); | ||
|
||
List<Object> convertedBootOps = new ArrayList<Object>(); | ||
for (int i = 0 ; i < bootOperations.size() ; i++) { | ||
ModelNode node = bootOperations.get(i); | ||
if (node != null) { | ||
convertedBootOps.add(objectConverter.convertModelNodeToChildCl(node)); | ||
} | ||
} | ||
Object convertedValidationFilter = objectConverter.convertValidateOperationsFilterToChildCl(validateOpsFilter); | ||
Object convertedLegacyModelVersion = objectConverter.convertModelVersionToChildCl(legacyModelVersion); | ||
|
||
List<Object> convertedModelInitializerEntries = null; | ||
if (modelInitializerEntries != null) { | ||
convertedModelInitializerEntries = new ArrayList<Object>(); | ||
for (LegacyModelInitializerEntry entry : modelInitializerEntries) { | ||
convertedModelInitializerEntries.add(objectConverter.convertLegacyModelInitializerEntryToChildCl(entry)); | ||
} | ||
} | ||
if (!Stability.DEFAULT.equals(stability)) { | ||
Method m = clazz.getMethod("create", | ||
List.class, | ||
legacyChildFirstClassLoader.loadClass(ModelTestOperationValidatorFilter.class.getName()), | ||
legacyChildFirstClassLoader.loadClass(ModelVersion.class.getName()), | ||
List.class, | ||
String.class); | ||
|
||
return m.invoke(null, convertedBootOps, objectConverter.convertValidateOperationsFilterToChildCl(validateOpsFilter), objectConverter.convertModelVersionToChildCl(legacyModelVersion), convertedModelInitializerEntries); | ||
return m.invoke(null, | ||
convertedBootOps, | ||
convertedValidationFilter, | ||
convertedLegacyModelVersion, | ||
convertedModelInitializerEntries, | ||
stability.toString()); | ||
} else { | ||
Method m = clazz.getMethod("create", | ||
List.class, | ||
legacyChildFirstClassLoader.loadClass(ModelTestOperationValidatorFilter.class.getName()), | ||
legacyChildFirstClassLoader.loadClass(ModelVersion.class.getName()), | ||
List.class); | ||
|
||
return m.invoke(null, | ||
convertedBootOps, | ||
convertedValidationFilter, | ||
convertedLegacyModelVersion, | ||
convertedModelInitializerEntries); | ||
} | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
private List<Object> convertModelInitializer(List<LegacyModelInitializerEntry> modelInitializerEntries) { | ||
List<Object> converted = null; | ||
if (modelInitializerEntries != null) { | ||
converted = new ArrayList<>(); | ||
for (LegacyModelInitializerEntry entry : modelInitializerEntries) { | ||
converted.add(objectConverter.convertLegacyModelInitializerEntryToChildCl(entry)); | ||
} | ||
} | ||
return converted; | ||
} | ||
|
||
private List<Object> getConvertedBootOps(List<ModelNode> bootOperations) { | ||
List<Object> converted = new ArrayList<>(); | ||
for (ModelNode node : bootOperations) { | ||
if (node != null) { | ||
converted.add(objectConverter.convertModelNodeToChildCl(node)); | ||
} | ||
} | ||
return converted; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.