@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"}, 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"); }
public void verifySchema() throws GovernanceException { SchemaManager schemaManager = new SchemaManager(governance); Schema[] schemas = schemaManager.getAllSchemas(); boolean resourceFound = false; for (Schema schema : schemas) { if (schema.getQName().getLocalPart().equals("SampleSchema.xsd")) { resourceFound = true; } } Assert.assertTrue(resourceFound); }
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); }
@Test( groups = {"wso2.greg.api"}, description = "Testing removeSchema API method", priority = 12) public void testRemoveSchema() throws GovernanceException { try { schemaManager.removeSchema(schemaObj.getId()); schemaArray = schemaManager.getAllSchemas(); for (Schema s : schemaArray) { assertFalse( s.getId().equalsIgnoreCase(schemaObj.getId()), "SchemaManager:removeSchema" + " API method having error"); } } catch (GovernanceException e) { throw new GovernanceException( "Error occurred while executing SchemaManager:removeSchema method" + e); } }
@Test( groups = {"wso2.greg.api"}, dependsOnMethods = {"testGetSchema"}, description = "Testing " + "updateSchema API method", priority = 5) public void testUpdateSchema() throws GovernanceException { String lcName = "ServiceLifeCycle"; try { schemaObj.attachLifecycle(lcName); schemaManager.updateSchema(schemaObj); Schema localSchema = schemaManager.getSchema(schemaObj.getId()); assertTrue( localSchema.getLifecycleName().equalsIgnoreCase(lcName), "Updated schema doesn't " + "have lifecycle Information.SchemaManager:updateSchema didn't work"); } catch (GovernanceException e) { throw new GovernanceException( "Error occurred while executing SchemaManager:updateSchema method" + e); } }
@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); } }
@Test( groups = {"wso2.greg.api"}, dependsOnMethods = {"testAddSchema"}, description = "Testing " + "getAllSchemas API method", priority = 3) public void testGetAllSchema() throws GovernanceException { try { schemaArray = schemaManager.getAllSchemas(); assertTrue( schemaArray.length > 0, "Error occurred while executing SchemaManager:" + "getAllSchemas method"); } catch (GovernanceException e) { throw new GovernanceException( "Error occurred while executing SchemaManager:getAllSchemas method" + e); } }
@Test( groups = {"wso2.greg.api"}, dependsOnMethods = {"testGetAllSchema"}, description = "Testing " + "getSchema API method", priority = 4) public void testGetSchema() throws GovernanceException { try { schemaObj = schemaManager.getSchema(schemaArray[0].getId()); assertTrue( schemaObj.getQName().getLocalPart().equalsIgnoreCase(schemaName), "SchemaManager:" + "getSchema API method not contain expected schema name"); } catch (GovernanceException e) { throw new GovernanceException( "Error occurred while executing SchemaManager:getSchema method" + e); } }
@Test( groups = {"wso2.greg.api"}, description = "Testing newSchema API method", priority = 1) public void testNewSchemaUrl() throws GovernanceException { try { cleanSchema(); schemaObj = schemaManager.newSchema( "http://svn.wso2.org/repos/wso2/carbon" + "/platform/trunk/platform-integration/system-test-framework/core/org.wso2." + "automation.platform.core/src/main/resources/artifacts/GREG/schema/calculator.xsd"); } catch (GovernanceException e) { throw new GovernanceException( "Error occurred while executing SchemaManager:newSchema with " + "URL method" + e); } }
@Test( groups = {"wso2.greg.api"}, description = "Testing getQName API method with schema object", priority = 7) public void testGetQName() throws Exception { boolean isSchemaFound = false; Schema[] schema = schemaManager.getAllSchemas(); try { for (Schema s : schema) { if (s.getQName().getLocalPart().equalsIgnoreCase(schemaName)) { isSchemaFound = true; } } assertTrue(isSchemaFound, "getQName method prompt error while executing with schema object"); } catch (Exception e) { throw new Exception("Error occurred while executing WsdlManager:getQName method" + e); } }
// https://wso2.org/jira/browse/REGISTRY-762 @Test( groups = {"wso2.greg.api"}, description = "Testing getUrl API method with schema object", priority = 8, enabled = false) public void testGetUrl() throws Exception { boolean isSchemaFound = false; Schema[] schema = schemaManager.getAllSchemas(); try { for (Schema s : schema) { if ((s.getUrl() != null)) { isSchemaFound = true; } } assertTrue(isSchemaFound, "getUrl method prompt error while executing with schema object"); } catch (Exception e) { throw new Exception("Error occurred while executing WsdlManager:getUrl method" + e); } }
@Test( groups = {"wso2.greg.api"}, description = "Testing getSchemaElement API method with schema object", priority = 9) public void testGetSchemaElement() throws Exception { boolean isSchemaFound = false; Schema[] schema = schemaManager.getAllSchemas(); try { for (Schema s : schema) { if (s.getQName().getLocalPart().equalsIgnoreCase(schemaName)) { OMElement omElement = s.getSchemaElement(); if (omElement.toString().contains("http://charitha.org/")) { isSchemaFound = true; } } } assertTrue( isSchemaFound, "getSchemaElement method prompt error while executing with schema object"); } catch (Exception e) { throw new Exception("Error occurred while executing getSchemaElement method" + e); } }
@Test( groups = {"wso2.greg.api"}, description = "Testing FindSchema", priority = 6) public void testFindService() throws GovernanceException { try { Schema[] schemaArray = schemaManager.findSchemas( new SchemaFilter() { public boolean matches(Schema schema) throws GovernanceException { String name = schema.getQName().getLocalPart(); assertTrue( name.contains(schemaName), "Error occurred while executing " + "findSchema API method"); return name.contains(schemaName); } }); assertTrue( schemaArray.length > 0, "Error occurred while executing findSchema API " + "method"); } catch (GovernanceException e) { throw new GovernanceException( "Error occurred while executing WsdlManager:findSchemas method" + e); } }
private void cleanSchema() throws GovernanceException { Schema[] schemas = schemaManager.getAllSchemas(); for (Schema s : schemas) { schemaManager.removeSchema(s.getId()); } }