@Test( groups = {"wso2.greg.api"}, description = "Testing newSchema API method with inline schema content", priority = 10) public void testNewSchemaInlineContent() throws GovernanceException, IOException { String schemaFileLocation = ProductConstant.SYSTEM_TEST_RESOURCE_LOCATION + File.separator + "artifacts" + File.separator + "GREG" + File.separator + "schema" + File.separator + "calculator.xsd"; try { schemaObj = schemaManager.newSchema(FileManager.readFile(schemaFileLocation).getBytes()); schemaManager.addSchema(schemaObj); } catch (GovernanceException e) { throw new GovernanceException( "Exception thrown while executing newSchema API method with " + "inline wsdl content" + e.getMessage()); } schemaObj = schemaManager.getSchema(schemaObj.getId()); assertTrue( schemaObj.getQName().getNamespaceURI().contains("http://charitha.org/"), "Error" + " found in newSchema with inline schema content"); }
@Test( groups = {"wso2.greg.api"}, description = "Testing newSchema API method with inline schema " + "content with name value", priority = 11) public void testNewSchemaInlineContentWithName() throws GovernanceException, IOException { String schemaFileLocation = ProductConstant.SYSTEM_TEST_RESOURCE_LOCATION + File.separator + "artifacts" + File.separator + "GREG" + File.separator + "schema" + File.separator + "calculator.xsd"; try { schemaObj = schemaManager.newSchema( FileManager.readFile(schemaFileLocation).getBytes(), "SampleSchemaContentWithName.xsd"); schemaManager.addSchema(schemaObj); } catch (GovernanceException e) { throw new GovernanceException( "Exception thrown while executing newSchema API method with " + "inline wsdl content and name" + e.getMessage()); } schemaObj = schemaManager.getSchema(schemaObj.getId()); assertTrue( schemaObj.getQName().getLocalPart().equalsIgnoreCase("SampleSchemaContentWithName.xsd"), "Error found in newSchema with inline schema content and name"); }
@Test( groups = {"wso2.greg.api"}, dependsOnMethods = {"testNewSchemaUrl"}, description = "Testing " + "addSchema API method", priority = 2) public void testAddSchema() throws GovernanceException { try { schemaManager.addSchema(schemaObj); } catch (GovernanceException e) { throw new GovernanceException( "Error occurred while executing SchemaManager:addSchema method" + e); } }
private void addSchema() throws IOException, RegistryException { SchemaManager schemaManager = new SchemaManager(governance); String schemaFilePath = ProductConstant.getResourceLocations(ProductConstant.GREG_SERVER_NAME) + File.separator + "schema" + File.separator; Schema schema = schemaManager.newSchema( FileManager.readFile(schemaFilePath + "Person.xsd").getBytes(), "Person.xsd"); schemaManager.addSchema(schema); schema = schemaManager.getSchema(schema.getId()); Resource resource = governance.get(schema.getPath()); resource.addProperty("z", "30"); governance.put(schema.getPath(), resource); }