use of com.evolveum.midpoint.prism.schema.SchemaRegistry in project midpoint by Evolveum.
the class ConsistencyTest method test000Integrity.
/**
* Test integrity of the test setup.
*/
@Test
public void test000Integrity() throws Exception {
final String TEST_NAME = "test000Integrity";
TestUtil.displayTestTile(this, TEST_NAME);
assertNotNull(modelWeb);
assertNotNull(modelService);
assertNotNull(repositoryService);
assertTrue(isSystemInitialized());
assertNotNull(taskManager);
assertNotNull(prismContext);
SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry();
assertNotNull(schemaRegistry);
// This is defined in extra schema. So this effectively checks whether
// the extra schema was loaded
PrismPropertyDefinition shipStateDefinition = schemaRegistry.findPropertyDefinitionByElementName(MY_SHIP_STATE);
assertNotNull("No my:shipState definition", shipStateDefinition);
assertEquals("Wrong maxOccurs in my:shipState definition", 1, shipStateDefinition.getMaxOccurs());
assertNoRepoCache();
OperationResult result = new OperationResult(ConsistencyTest.class.getName() + "." + TEST_NAME);
// Check if OpenDJ resource was imported correctly
PrismObject<ResourceType> openDjResource = repositoryService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, result);
display("Imported OpenDJ resource (repository)", openDjResource);
AssertJUnit.assertEquals(RESOURCE_OPENDJ_OID, openDjResource.getOid());
assertNoRepoCache();
String ldapConnectorOid = openDjResource.asObjectable().getConnectorRef().getOid();
PrismObject<ConnectorType> ldapConnector = repositoryService.getObject(ConnectorType.class, ldapConnectorOid, null, result);
display("LDAP Connector: ", ldapConnector);
}
use of com.evolveum.midpoint.prism.schema.SchemaRegistry in project midpoint by Evolveum.
the class TestPrismContext method testPrefixMapper.
@Test
public void testPrefixMapper() throws SchemaException, SAXException, IOException {
System.out.println("===[ testPrefixMapper ]===");
// WHEN
PrismContextImpl prismContext = constructInitializedPrismContext();
// THEN
assertNotNull("No prism context", prismContext);
SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry();
assertNotNull("No schema registry in context", schemaRegistry);
DynamicNamespacePrefixMapper prefixMapper = schemaRegistry.getNamespacePrefixMapper();
System.out.println("Prefix mapper:");
System.out.println(DebugUtil.dump(prefixMapper));
assertEquals("Wrong foo prefix", "", prefixMapper.getPrefix(NS_FOO));
assertEquals("Wrong xsd prefix", DOMUtil.NS_W3C_XML_SCHEMA_PREFIX, prefixMapper.getPrefix(XMLConstants.W3C_XML_SCHEMA_NS_URI));
}
use of com.evolveum.midpoint.prism.schema.SchemaRegistry in project midpoint by Evolveum.
the class TestPrismContext method testExtensionSchema.
@Test
public void testExtensionSchema() throws SchemaException, SAXException, IOException {
System.out.println("===[ testExtensionSchema ]===");
// GIVEN
PrismContext prismContext = constructInitializedPrismContext();
assertNotNull("No prism context", prismContext);
SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry();
assertNotNull("No schema registry in context", schemaRegistry);
PrismPropertyDefinition ignoredTypeDef = schemaRegistry.findPropertyDefinitionByElementName(EXTENSION_IGNORED_TYPE_ELEMENT);
PrismAsserts.assertDefinition(ignoredTypeDef, EXTENSION_IGNORED_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1);
assertTrue("Element " + EXTENSION_IGNORED_TYPE_ELEMENT + " is NOT ignored", ignoredTypeDef.isIgnored());
PrismPropertyDefinition stringTypeDef = schemaRegistry.findPropertyDefinitionByElementName(EXTENSION_STRING_TYPE_ELEMENT);
PrismAsserts.assertDefinition(stringTypeDef, EXTENSION_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1);
assertFalse("Element " + EXTENSION_STRING_TYPE_ELEMENT + " is ignored", stringTypeDef.isIgnored());
PrismPropertyDefinition singleStringTypeDef = schemaRegistry.findPropertyDefinitionByElementName(EXTENSION_SINGLE_STRING_TYPE_ELEMENT);
PrismAsserts.assertDefinition(singleStringTypeDef, EXTENSION_SINGLE_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, 1);
assertFalse("Element " + EXTENSION_SINGLE_STRING_TYPE_ELEMENT + " is ignored", singleStringTypeDef.isIgnored());
PrismPropertyDefinition intTypeDef = schemaRegistry.findPropertyDefinitionByElementName(EXTENSION_INT_TYPE_ELEMENT);
PrismAsserts.assertDefinition(intTypeDef, EXTENSION_INT_TYPE_ELEMENT, DOMUtil.XSD_INT, 0, -1);
assertFalse("Element " + EXTENSION_INT_TYPE_ELEMENT + " is ignored", intTypeDef.isIgnored());
PrismContainerDefinition meleeContextDefinition = schemaRegistry.findContainerDefinitionByElementName(EXTENSION_MELEE_CONTEXT_ELEMENT);
PrismAsserts.assertDefinition(meleeContextDefinition, EXTENSION_MELEE_CONTEXT_ELEMENT, EXTENSION_MELEE_CONTEXT_TYPE_QNAME, 0, 1);
assertTrue("Melee context container is NOT marked as runtime", meleeContextDefinition.isRuntimeSchema());
PrismReferenceDefinition opponentRefDef = meleeContextDefinition.findReferenceDefinition(EXTENSION_MELEE_CONTEXT_OPPONENT_REF_ELEMENT);
assertTrue("opponentRef definition is NOT composite", opponentRefDef.isComposite());
}
use of com.evolveum.midpoint.prism.schema.SchemaRegistry in project midpoint by Evolveum.
the class TestSchemaRegistry method testCommonSchema.
@Test
public void testCommonSchema() throws SchemaException, SAXException, IOException {
MidPointPrismContextFactory factory = getContextFactory();
PrismContext context = factory.createInitializedPrismContext();
SchemaRegistry schemaRegistry = context.getSchemaRegistry();
PrismSchema commonSchema = schemaRegistry.findSchemaByNamespace(SchemaConstants.NS_C);
assertNotNull("No parsed common schema", commonSchema);
System.out.println("Parsed common schema:");
System.out.println(commonSchema.debugDump());
// TODO
}
use of com.evolveum.midpoint.prism.schema.SchemaRegistry in project midpoint by Evolveum.
the class TestSchemaRegistry method testUserType.
@Test
public void testUserType() throws Exception {
MidPointPrismContextFactory factory = getContextFactory();
PrismContext context = factory.createInitializedPrismContext();
SchemaRegistry schemaRegistry = context.getSchemaRegistry();
PrismObjectDefinition<UserType> userDefinition = schemaRegistry.findObjectDefinitionByCompileTimeClass(UserType.class);
assertNotNull("No user definition", userDefinition);
System.out.println("testUserType:");
System.out.println(userDefinition.debugDump());
assertFalse("User definition is marked as runtime", userDefinition.isRuntimeSchema());
PrismPropertyDefinition<PolyString> nameDef = userDefinition.findPropertyDefinition(ObjectType.F_NAME);
assertNotNull("No name definition", nameDef);
PrismContainerDefinition extensionDef = userDefinition.findContainerDefinition(UserType.F_EXTENSION);
assertNotNull("No 'extension' definition", extensionDef);
assertTrue("Extension definition is NOT marked as runtime", extensionDef.isRuntimeSchema());
PrismPropertyDefinition<PolyString> givenNameDef = userDefinition.findPropertyDefinition(UserType.F_GIVEN_NAME);
assertNotNull("No givenName definition", givenNameDef);
PrismPropertyDefinition<String> preferredLanguageDef = userDefinition.findPropertyDefinition(UserType.F_PREFERRED_LANGUAGE);
assertNotNull("No preferredLanguage definition", preferredLanguageDef);
PrismReferenceValue preferredLanguageValueEnumerationRef = preferredLanguageDef.getValueEnumerationRef();
assertNotNull("No valueEnumerationRef in preferredLanguage definition", preferredLanguageValueEnumerationRef);
assertEquals("Wrong OID in valueEnumerationRef in preferredLanguage definition", SystemObjectsType.LOOKUP_LANGUAGES.value(), preferredLanguageValueEnumerationRef.getOid());
assertEquals("Wrong type in valueEnumerationRef in preferredLanguage definition", LookupTableType.COMPLEX_TYPE, preferredLanguageValueEnumerationRef.getTargetType());
// Just make sure this does not end with NPE or stack overflow
PrismObjectDefinition<UserType> shallowClone = userDefinition.clone();
PrismObjectDefinition<UserType> deepClone = userDefinition.deepClone(false);
PrismObjectDefinition<UserType> ultraDeepClone = userDefinition.deepClone(true);
}
Aggregations