SCIMConfigProcessor { public SCIMConfig buildConfigFromInputStream(InputStream inStream) throws CharonException { try { StAXOMBuilder omBuilder = new StAXOMBuilder(inStream); OMElement rootElement = omBuilder.getDocumentElement(); if (inStream != null) { inStream.close(); } return buildConfigFromRootElement(rootElement); } catch (XMLStreamException e) { throw new CharonException("Error in building the configuration file: " + SCIMConfigConstants.PROVISIONING_CONFIG_NAME); } catch (IOException e) { throw new CharonException("Error in closing the input stream."); } }  SCIMConfig buildConfigFromFile(String filePath); SCIMConfig buildConfigFromInputStream(InputStream inStream); SCIMConfig buildConfigFromRootElement(OMElement rootElement);  }
@Test public void testBuildingSampleConfig1() throws CharonException, IOException { SCIMConfigProcessor scimConfigProcessor = new SCIMConfigProcessor(); InputStream inStream = this.getClass().getClassLoader().getResource( "provisioning-config-sample1.xml").openStream(); SCIMConfig scimConfig = scimConfigProcessor.buildConfigFromInputStream(inStream); Assert.assertEquals("carbon.super", scimConfig.getSCIMConsumer("carbon.super").getId()); Assert.assertEquals("node2", scimConfig.getProvidersMap().get("node2").getId()); Assert.assertEquals("https: scimConfig.getProvidersMap().get("node2").getProperty( SCIMConfigConstants.ELEMENT_NAME_USER_ENDPOINT)); Assert.assertEquals(true, Boolean.parseBoolean(scimConfig.getSCIMConsumer( "carbon.super").getPropertiesMap().get( SCIMConfigConstants.ELEMENT_NAME_APPLIED_TO_SCIM_OPERATIONS))); Assert.assertEquals("https: scimConfig.getConsumerProcessed("carbon.super"). getScimProviders().get("node2").getProperty( SCIMConfigConstants.ELEMENT_NAME_USER_ENDPOINT)); if (inStream != null) { inStream.close(); } }
@Test public void testBuildingSampleConfig2() throws IOException, CharonException { SCIMConfigProcessor scimConfigProcessor = new SCIMConfigProcessor(); InputStream inStream = this.getClass().getClassLoader().getResource( "provisioning-config-sample2.xml").openStream(); SCIMConfig scimConfig = scimConfigProcessor.buildConfigFromInputStream(inStream); Assert.assertNotNull(scimConfig.getProvidersMap().get("wso2")); Assert.assertNotNull(scimConfig.getProvidersMap().get("google")); Assert.assertNotNull(scimConfig.getProvidersMap().get("salesforce")); Assert.assertNotNull(scimConfig.getConsumersMap().get("example.com")); Assert.assertNotNull(scimConfig.getConsumersMap().get("admin@carbon.super")); SCIMConsumer exampleConsumer = scimConfig.getConsumerProcessed("example.com"); Assert.assertNotNull(exampleConsumer.getScimProviders().get("wso2")); Assert.assertNotNull(exampleConsumer.getScimProviders().get("google")); Assert.assertNotNull(exampleConsumer.getScimProviders().get("salesforce")); Assert.assertEquals("adminabc", scimConfig.getProvidersMap().get("salesforce").getProperty( SCIMConfigConstants.ELEMENT_NAME_USERNAME)); Assert.assertEquals("adminabc", scimConfig.getProvidersMap().get("salesforce").getProperty( SCIMConfigConstants.ELEMENT_NAME_PASSWORD)); Assert.assertEquals("https: scimConfig.getProvidersMap().get("salesforce").getProperty( SCIMConfigConstants.ELEMENT_NAME_USER_ENDPOINT)); Assert.assertEquals("admin1", scimConfig.getConsumerProcessed( "example.com").getScimProviders().get("salesforce").getProperty( SCIMConfigConstants.ELEMENT_NAME_USERNAME)); Assert.assertEquals("admin1", scimConfig.getConsumerProcessed( "example.com").getScimProviders().get("salesforce").getProperty( SCIMConfigConstants.ELEMENT_NAME_PASSWORD)); Assert.assertEquals("https: scimConfig.getConsumerProcessed("example.com").getScimProviders(). get("salesforce").getProperty(SCIMConfigConstants.ELEMENT_NAME_USER_ENDPOINT)); Assert.assertNull(scimConfig.getConsumerProcessed("admin@carbon.super").getScimProviders().get("wso2")); Assert.assertNotNull(scimConfig.getConsumerProcessed("admin@carbon.super").getScimProviders().get("google")); Assert.assertNotNull(scimConfig.getConsumerProcessed("admin@carbon.super").getScimProviders().get("salesforce")); }
@Test public void testBuildingSampleConfig3() throws IOException, CharonException { SCIMConfigProcessor scimConfigProcessor = new SCIMConfigProcessor(); InputStream inStream = this.getClass().getClassLoader().getResource( "provisioning-config-sample3.xml").openStream(); SCIMConfig scimConfig = scimConfigProcessor.buildConfigFromInputStream(inStream); }
@Test public void testBuildingSampleConfig4() throws IOException, CharonException { SCIMConfigProcessor scimConfigProcessor = new SCIMConfigProcessor(); InputStream inStream = this.getClass().getClassLoader().getResource( "provisioning-config-sample4.xml").openStream(); SCIMConfig scimConfig = scimConfigProcessor.buildConfigFromInputStream(inStream); }
@Test public void testBuildingSampleConfig5() throws IOException, CharonException { SCIMConfigProcessor scimConfigProcessor = new SCIMConfigProcessor(); InputStream inStream = this.getClass().getClassLoader().getResource( "provisioning-config-sample5.xml").openStream(); SCIMConfig scimConfig = scimConfigProcessor.buildConfigFromInputStream(inStream); Assert.assertFalse(scimConfig.isDumbMode()); Assert.assertEquals("org.wso2.charon.core.provisioning.SampleProvisioningHandler", scimConfig.getProvisioningHandler()); }