/** * Test if a schema directory can be loaded to the schema registry. This contains definition of * user extension, therefore check if it is applied to the user definition. */ @Test public void testUserExtensionSchemaLoad() throws SAXException, IOException, SchemaException { System.out.println("===[ testUserExtensionSchemaLoad ]==="); PrismContext context = constructPrismContext(); SchemaRegistryImpl reg = (SchemaRegistryImpl) context.getSchemaRegistry(); reg.registerPrismSchemasFromDirectory(EXTRA_SCHEMA_DIR); context.initialize(); System.out.println("Initialized registry"); System.out.println(reg.debugDump()); // Try midpoint schemas by parsing a XML file PrismSchema schema = reg.getPrismSchema(NS_FOO); System.out.println("Parsed foo schema:"); System.out.println(schema.debugDump()); // TODO: assert user schema = reg.getPrismSchema(NS_USER_EXT); System.out.println("Parsed user ext schema:"); System.out.println(schema.debugDump()); ComplexTypeDefinition userExtComplexType = schema.findComplexTypeDefinition(USER_EXTENSION_TYPE_QNAME); assertEquals("Extension type ref does not match", USER_TYPE_QNAME, userExtComplexType.getExtensionForType()); }
/** * Test if a schema directory can be loaded to the schema registry. This contains definition of * user extension, therefore check if it is applied to the user definition. */ @Test public void testTypeOverride() throws SAXException, IOException, SchemaException { System.out.println("===[ testTypeOverride ]==="); PrismContext context = constructPrismContext(); SchemaRegistryImpl reg = (SchemaRegistryImpl) context.getSchemaRegistry(); reg.registerPrismSchemasFromDirectory(EXTRA_SCHEMA_DIR); context.initialize(); PrismSchema schema = reg.getPrismSchema(NS_ROOT); System.out.println("Parsed root schema:"); System.out.println(schema.debugDump()); PrismContainerDefinition rootContDef = schema.findContainerDefinitionByElementName(new QName(NS_ROOT,"root")); assertNotNull("Not <root> definition", rootContDef); PrismContainerDefinition extensionContDef = rootContDef.findContainerDefinition(new ItemName(NS_FOO, "extension")); assertNotNull("Not <extension> definition", extensionContDef); assertEquals("Wrong <extension> type", new QName(NS_ROOT, "MyExtensionType"), extensionContDef.getTypeName()); }