Java Code Examples for org.apache.commons.digester3.Digester#parse()

The following examples show how to use org.apache.commons.digester3.Digester#parse() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigReader.java    From formatter-maven-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Read from the <code>input</code> and return it's configuration settings as a {@link Map}.
 *
 * @param input
 *            the input
 * 
 * @return return {@link Map} with all the configurations read from the config file, or throws an exception if
 *         there's a problem reading the input, e.g.: invalid XML.
 * 
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 * @throws SAXException
 *             the SAX exception
 * @throws ConfigReadException
 *             the config read exception
 */
public Map<String, String> read(InputStream input) throws IOException, SAXException, ConfigReadException {
    Digester digester = new Digester();
    digester.addRuleSet(new RuleSet());

    Object result = digester.parse(input);
    if (result == null || !(result instanceof Profiles)) {
        throw new ConfigReadException("No profiles found in config file");
    }

    Profiles profiles = (Profiles) result;
    List<Map<String, String>> list = profiles.getProfiles();
    if (list.isEmpty()) {
        throw new ConfigReadException("No profile in config file of kind: " + Profiles.PROFILE_KIND);
    }

    return list.get(0);
}
 
Example 2
Source File: CheckStyleRules.java    From warnings-ng-plugin with MIT License 6 votes vote down vote up
/**
 * Initializes the rules.
 */
public void initialize() {
    String[] ruleFiles = {"annotation", "blocks", "coding", "design", "filters", "header",
            "imports", "javadoc", "metrics", "misc", "modifier", "naming", "regexp",
            "reporting", "sizes", "whitespace"};
    for (String ruleFile : ruleFiles) {
        try (InputStream inputStream = CheckStyleRules.class.getResourceAsStream("config_" + ruleFile + ".xml")) {
            Digester digester = createDigester();
            List<Rule> rules = new ArrayList<>();
            digester.push(rules);
            digester.parse(inputStream);
            for (Rule rule : rules) {
                if (StringUtils.isNotBlank(rule.getDescription())) {
                    rulesByName.put(rule.getName(), rule);
                }
            }
        }
        catch (ParserConfigurationException | IOException | SAXException exception) {
            log(exception);
        }
    }
}
 
Example 3
Source File: XmlFactoryConfiguration.java    From velocity-tools with Apache License 2.0 6 votes vote down vote up
/**
 * <p>Reads an XML document from an {@link URL}
 * and uses it to configure this {@link FactoryConfiguration}.</p>
 * 
 * @param url the URL to read from
 */
protected void readImpl(URL url) throws IOException
{
    // since beanutils 1.9.4, we need to relax access to the 'class' method
    BeanUtilsBean.getInstance().getPropertyUtils().removeBeanIntrospector(SuppressPropertiesBeanIntrospector.SUPPRESS_CLASS);

    Digester digester = new Digester();
    digester.setNamespaceAware(true);
    digester.setXIncludeAware(true);
    digester.setValidating(false);
    digester.setUseContextClassLoader(true);
    digester.push(this);
    digester.addRuleSet(getRuleSet());
    try
    {
        digester.parse(url);
    }
    catch (SAXException saxe)
    {
        throw new RuntimeException("There was an error while parsing the InputStream", saxe);
    }
    finally
    {
        BeanUtilsBean.getInstance().getPropertyUtils().resetBeanIntrospectors();
    }
}
 
Example 4
Source File: MapParser.java    From tankbattle with MIT License 6 votes vote down vote up
public static XmlMap getMapFromXml(String name) {
    try {

        DigesterLoader loader = DigesterLoader.newLoader(new FromAnnotationsRuleModule() {
            @Override
            protected void configureRules() {
                bindRulesFrom(XmlMap.class);
            }

        });

        Digester digester = loader.newDigester();
        return digester.parse(new FileInputStream(new File(System.getProperty("user" +
                ".home") + File
                .separator +
                ".tankBattle" + File.separator + "custom" + File.separator + name + ".xml")));

    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 5
Source File: TopologyRulesModuleTest.java    From knox with Apache License 2.0 6 votes vote down vote up
@Test
public void testParseTopologyWithApplication() throws IOException, SAXException {
  Digester digester = loader.newDigester();
  String name = "topology-with-application.xml";
  URL url = TestUtils.getResourceUrl( TopologyRulesModuleTest.class, name );
  assertThat( "Failed to find URL for resource " + name, url, notNullValue() );
  File file = new File( url.getFile() );
  TopologyBuilder topologyBuilder = digester.parse( url );
  Topology topology = topologyBuilder.build();
  assertThat( "Failed to parse resource " + name, topology, notNullValue() );
  topology.setTimestamp( file.lastModified() );

  Application app = topology.getApplications().iterator().next();
  assertThat( "Failed to find application", app, notNullValue() );
  assertThat( app.getName(), is("test-app-name") );
  assertThat( app.getUrl(), is("test-app-path") );
  assertThat( app.getUrls().get( 0 ), is("test-app-path") );
  assertThat( app.getParams().get( "test-param-name" ), is( "test-param-value" ) );
}
 
Example 6
Source File: FindBugsParser.java    From analysis-model with MIT License 6 votes vote down vote up
/**
 * Pre-parses a file for some information not available from the FindBugs parser. Creates a mapping of FindBugs
 * warnings to messages. A bug is represented by its unique hash code. Also obtains original categories for bug
 * types.
 *
 * @param file
 *         the FindBugs XML file
 *
 * @return the map of warning messages
 * @throws SAXException
 *         if the file contains no valid XML
 * @throws IOException
 *         signals that an I/O exception has occurred.
 */
@VisibleForTesting
List<XmlBugInstance> preParse(final Reader file) throws SAXException, IOException {
    Digester digester = new SecureDigester(FindBugsParser.class);

    String rootXPath = "BugCollection/BugInstance";
    digester.addObjectCreate(rootXPath, XmlBugInstance.class);
    digester.addSetProperties(rootXPath);

    String fileXPath = rootXPath + "/LongMessage";
    digester.addCallMethod(fileXPath, "setMessage", 0);

    digester.addSetNext(rootXPath, "add", Object.class.getName());
    ArrayList<XmlBugInstance> bugs = new ArrayList<>();
    digester.push(bugs);
    digester.parse(file);

    return bugs;
}
 
Example 7
Source File: GoPluginBundleDescriptorParser.java    From gocd with Apache License 2.0 5 votes vote down vote up
static GoPluginBundleDescriptor parseXML(InputStream pluginXML,
                                         String pluginJarFileLocation,
                                         File pluginBundleLocation,
                                         boolean isBundledPlugin) throws IOException, SAXException {
    Digester digester = initDigester();

    GoPluginBundleDescriptorParser parserForThisXML = new GoPluginBundleDescriptorParser(pluginJarFileLocation, pluginBundleLocation, isBundledPlugin);
    digester.push(parserForThisXML);

    digester.addCallMethod("gocd-bundle", "createBundle", 1);
    digester.addCallParam("gocd-bundle", 0, "version");

    digester.addCallMethod("gocd-bundle/plugins/plugin", "createPlugin", 1);
    digester.addCallParam("gocd-bundle/plugins/plugin", 0, "id");

    digester.addCallMethod("gocd-bundle/plugins/plugin/about", "createAbout", 4);
    digester.addCallParam("gocd-bundle/plugins/plugin/about/name", 0);
    digester.addCallParam("gocd-bundle/plugins/plugin/about/version", 1);
    digester.addCallParam("gocd-bundle/plugins/plugin/about/target-go-version", 2);
    digester.addCallParam("gocd-bundle/plugins/plugin/about/description", 3);

    digester.addCallMethod("gocd-bundle/plugins/plugin/about/vendor", "createVendor", 2);
    digester.addCallParam("gocd-bundle/plugins/plugin/about/vendor/name", 0);
    digester.addCallParam("gocd-bundle/plugins/plugin/about/vendor/url", 1);

    digester.addCallMethod("gocd-bundle/plugins/plugin/about/target-os/value", "addTargetOS", 1);
    digester.addCallParam("gocd-bundle/plugins/plugin/about/target-os/value", 0);

    digester.addCallMethod("gocd-bundle/plugins/plugin/extensions/extension", "addExtension", 1);
    digester.addCallParam("gocd-bundle/plugins/plugin/extensions/extension", 0, "class");

    digester.parse(pluginXML);

    return parserForThisXML.descriptor;
}
 
Example 8
Source File: PluginFile.java    From lutece-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Load plugin data from the XML file using Jakarta Commons Digester
 * 
 * @param strFilename
 *            The XML plugin filename
 * @throws fr.paris.lutece.portal.service.init.LuteceInitException
 *             If a problem occured during the loading
 */
public void load( String strFilename ) throws LuteceInitException
{
    // Configure Digester from XML ruleset
    DigesterLoader digesterLoader = DigesterLoader.newLoader( new FromXmlRulesModule( )
    {
        @Override
        protected void loadRules( )
        {
            loadXMLRules( getClass( ).getResource( FILE_RULES ) );
        }
    } );

    Digester digester = digesterLoader.newDigester( );

    // Allow variables in plugin files
    MultiVariableExpander expander = new MultiVariableExpander( );
    expander.addSource( "$", ( (Map) AppPropertiesService.getPropertiesAsMap( ) ) );

    Substitutor substitutor = new VariableSubstitutor( expander );
    digester.setSubstitutor( substitutor );

    // Push empty List onto Digester's Stack
    digester.push( this );
    digester.setValidating( false );

    try
    {
        InputStream input = new FileInputStream( strFilename );
        digester.parse( input );
    }
    catch( IOException | IllegalArgumentException | SAXException e )
    {
        throw new LuteceInitException( "Error loading plugin file : " + strFilename, e );
    }
}
 
Example 9
Source File: UiDependencyTool.java    From velocity-tools with Apache License 2.0 5 votes vote down vote up
/**
 * Reads group info out of the specified file and into this instance.
 * If the file cannot be found and required is true, then this will throw
 * an IllegalArgumentException.  Otherwise, it will simply do nothing. Any
 * checked exceptions during the actual reading of the file are caught and
 * wrapped as {@link RuntimeException}s.
 * @param file file
 * @param required whether this file is required
 */
protected void read(String file, boolean required) {
    getLog().debug("UiDependencyTool: Reading file from {}", file);
    URL url = toURL(file);
    if (url == null) {
        String msg = "UiDependencyTool: Could not read file from '"+file+"'";
        if (required) {
            getLog().error(msg);
            throw new IllegalArgumentException(msg);
        } else {
            getLog().debug(msg);
        }
    } else {
        Digester digester = createDigester();
        try
        {
            digester.parse(url.openStream());
        }
        catch (SAXException saxe)
        {
            getLog().error("UiDependencyTool: Failed to parse '{}'", file, saxe);
            throw new RuntimeException("While parsing the InputStream", saxe);
        }
        catch (IOException ioe)
        {
            getLog().error("UiDependencyTool: Failed to read '{}'", file, ioe);
            throw new RuntimeException("While handling the InputStream", ioe);
        }
    }
}
 
Example 10
Source File: TopologyRulesModuleTest.java    From knox with Apache License 2.0 5 votes vote down vote up
@Test
public void testParseServiceParamsInAmbariFormat() throws IOException, SAXException {
  Digester digester = loader.newDigester();
  String name = "org/apache/knox/gateway/topology/xml/service-param-topology-ambari-format.conf";
  URL url = ClassLoader.getSystemResource( name );
  assertThat( "Failed to find URL for resource " + name, url, notNullValue() );
  File file = new File( url.getFile() );
  TopologyBuilder topologyBuilder = digester.parse( url );
  Topology topology = topologyBuilder.build();
  assertThat( "Failed to parse resource " + name, topology, notNullValue() );
  topology.setTimestamp( file.lastModified() );

  assertThat( topology.getName(), is( "test-topology-name" ) );
  assertThat( topology.getTimestamp(), is( file.lastModified() ) );

  assertThat( topology.getProviders().size(), is( 1 ) );
  Provider provider = topology.getProviders().iterator().next();
  assertThat( provider, notNullValue() );
  assertThat( provider.getRole(), is( "test-provider-role" ) );
  assertThat( provider.getName(), is( "test-provider-name" ) );
  assertThat( provider.isEnabled(), is( true ) );
  assertThat( provider.getParams(), hasEntry( is( "test-provider-param-name-1" ), is( "test-provider-param-value-1" ) ) );
  assertThat( provider.getParams(), hasEntry( is( "test-provider-param-name-2" ), is( "test-provider-param-value-2" ) ) );

  assertThat( topology.getServices().size(), is( 1 ) );
  Service service = topology.getServices().iterator().next();
  assertThat( service, notNullValue() );
  assertThat( service.getRole(), is( "test-service-role" ) );
  assertThat( service.getUrls().size(), is( 2 ) );
  assertThat( service.getUrls(), hasItem( "test-service-scheme://test-service-host1:42/test-service-path" ) );
  assertThat( service.getUrls(), hasItem( "test-service-scheme://test-service-host2:42/test-service-path" ) );
  assertThat( service.getName(), is( "test-service-name" ) );
  assertThat( service.getParams(), hasEntry( is( "test-service-param-name-1" ), is( "test-service-param-value-1" ) ) );
  assertThat( service.getParams(), hasEntry( is( "test-service-param-name-2" ), is( "test-service-param-value-2" ) ) );
}
 
Example 11
Source File: TopologyRulesModuleTest.java    From knox with Apache License 2.0 5 votes vote down vote up
@Test
public void testParseServiceParamsInKnoxFormat() throws IOException, SAXException {
  Digester digester = loader.newDigester();
  String name = "org/apache/knox/gateway/topology/xml/service-param-topology-knox-format.xml";
  URL url = ClassLoader.getSystemResource( name );
  assertThat( "Failed to find URL for resource " + name, url, notNullValue() );
  File file = new File( url.getFile() );
  TopologyBuilder topologyBuilder = digester.parse( url );
  Topology topology = topologyBuilder.build();
  assertThat( "Failed to parse resource " + name, topology, notNullValue() );
  topology.setTimestamp( file.lastModified() );

  assertThat( topology.getName(), is( "test-topology-name" ) );
  assertThat( topology.getTimestamp(), is( file.lastModified() ) );
  assertThat( topology.getServices().size(), is( 1 ) );

  Provider provider = topology.getProviders().iterator().next();
  assertThat( provider, notNullValue() );
  assertThat( provider.getRole(), is( "test-provider-role" ) );
  assertThat( provider.getName(), is( "test-provider-name" ) );
  assertThat( provider.getParams(), hasEntry( is( "test-provider-param-name-1" ), is( "test-provider-param-value-1" ) ) );
  assertThat( provider.getParams(), hasEntry( is( "test-provider-param-name-2" ), is( "test-provider-param-value-2" ) ) );

  Service service = topology.getServices().iterator().next();
  assertThat( service, notNullValue() );
  assertThat( service.getRole(), is( "test-service-role" ) );
  assertThat( service.getUrls().size(), is( 2 ) );
  assertThat( service.getUrls(), hasItem( "test-service-scheme://test-service-host1:42/test-service-path" ) );
  assertThat( service.getUrls(), hasItem( "test-service-scheme://test-service-host2:42/test-service-path" ) );
  assertThat( service.getName(), is( "test-service-name" ) );
  assertThat( service.getParams(), hasEntry( is( "test-service-param-name-1" ), is( "test-service-param-value-1" ) ) );
  assertThat( service.getParams(), hasEntry( is( "test-service-param-name-2" ), is( "test-service-param-value-2" ) ) );
  assertThat( service.getVersion(), is( new Version(1,0,0)));
}
 
Example 12
Source File: XmlGatewayDescriptorImporter.java    From knox with Apache License 2.0 5 votes vote down vote up
@Override
public GatewayDescriptor load( Reader reader ) throws IOException {
  Digester digester = loader.newDigester( new ExtendedBaseRules() );
  digester.setValidating( false );
  try {
    return digester.parse( reader );
  } catch( SAXException e ) {
    throw new IOException( e );
  }
}
 
Example 13
Source File: GoPluginDescriptorParser.java    From gocd with Apache License 2.0 5 votes vote down vote up
static GoPluginBundleDescriptor parseXML(InputStream pluginXML,
                                         String pluginJarFileLocation,
                                         File pluginBundleLocation,
                                         boolean isBundledPlugin) throws IOException, SAXException {
    Digester digester = initDigester();
    GoPluginDescriptorParser parserForThisXML = new GoPluginDescriptorParser(pluginJarFileLocation, pluginBundleLocation, isBundledPlugin);
    digester.push(parserForThisXML);

    digester.addCallMethod("go-plugin", "createPlugin", 2);
    digester.addCallParam("go-plugin", 0, "id");
    digester.addCallParam("go-plugin", 1, "version");

    digester.addCallMethod("go-plugin/about", "createAbout", 4);
    digester.addCallParam("go-plugin/about/name", 0);
    digester.addCallParam("go-plugin/about/version", 1);
    digester.addCallParam("go-plugin/about/target-go-version", 2);
    digester.addCallParam("go-plugin/about/description", 3);

    digester.addCallMethod("go-plugin/about/vendor", "createVendor", 2);
    digester.addCallParam("go-plugin/about/vendor/name", 0);
    digester.addCallParam("go-plugin/about/vendor/url", 1);

    digester.addCallMethod("go-plugin/about/target-os/value", "addTargetOS", 1);
    digester.addCallParam("go-plugin/about/target-os/value", 0);

    digester.parse(pluginXML);

    return parserForThisXML.descriptor;
}
 
Example 14
Source File: CheckStyleParser.java    From analysis-model with MIT License 5 votes vote down vote up
@Override
public Report parse(final ReaderFactory readerFactory) throws ParsingException {
    Digester digester = new SecureDigester(CheckStyleParser.class);

    String rootXPath = "checkstyle";
    digester.addObjectCreate(rootXPath, CheckStyle.class);
    digester.addSetProperties(rootXPath);

    String fileXPath = "checkstyle/file";
    digester.addObjectCreate(fileXPath, File.class);
    digester.addSetProperties(fileXPath);
    digester.addSetNext(fileXPath, "addFile", File.class.getName());

    String bugXPath = "checkstyle/file/error";
    digester.addObjectCreate(bugXPath, Error.class);
    digester.addSetProperties(bugXPath);
    digester.addSetNext(bugXPath, "addError", Error.class.getName());

    try (Reader reader = readerFactory.create()) {
        CheckStyle checkStyle = digester.parse(reader);
        if (checkStyle == null) {
            throw new ParsingException("Input stream is not a Checkstyle file.");
        }

        return convert(checkStyle);
    }
    catch (IOException | SAXException exception) {
        throw new ParsingException(exception);
    }
}
 
Example 15
Source File: TopologyRulesModuleTest.java    From knox with Apache License 2.0 4 votes vote down vote up
@Test
public void testParseSimpleTopologyXmlInKnoxFormat() throws IOException, SAXException, URISyntaxException {
  Digester digester = loader.newDigester();
  String name = "org/apache/knox/gateway/topology/xml/simple-topology-knox-format.xml";
  URL url = ClassLoader.getSystemResource( name );
  assertThat( "Failed to find URL for resource " + name, url, notNullValue() );
  File file = new File( url.getFile() );
  TopologyBuilder topologyBuilder = digester.parse( url );
  Topology topology = topologyBuilder.build();
  assertThat( "Failed to parse resource " + name, topology, notNullValue() );
  topology.setTimestamp( file.lastModified() );

  assertThat( topology.getName(), is( "topology" ) );
  assertThat( topology.getTimestamp(), is( file.lastModified() ) );
  assertThat( topology.getServices().size(), is( 3 ) );

  Service comp = topology.getServices().iterator().next();
  assertThat( comp, notNullValue() );
  assertThat( comp.getRole(), is("WEBHDFS") );
  assertThat( comp.getVersion().toString(), is( "2.4.0" ) );
  assertThat( comp.getUrls().size(), is( 2 ) );
  assertThat( comp.getUrls(), hasItem( "http://host1:80/webhdfs" ) );
  assertThat( comp.getUrls(), hasItem( "http://host2:80/webhdfs" ) );

  Provider provider = topology.getProviders().iterator().next();
  assertThat( provider, notNullValue() );
  assertThat( provider.isEnabled(), is(true) );
  assertThat( provider.getRole(), is( "authentication" ) );
  assertThat( provider.getParams().size(), is(5));

  Service service = topology.getService("WEBHDFS", "webhdfs", new Version(2,4,0));
  assertEquals(comp, service);

  comp = topology.getService("RESOURCEMANAGER", null, new Version("2.5.0"));
  assertThat( comp, notNullValue() );
  assertThat( comp.getRole(), is("RESOURCEMANAGER") );
  assertThat( comp.getVersion().toString(), is("2.5.0") );
  assertThat(comp.getUrl(), is("http://host1:8088/ws") );

  comp = topology.getService("HIVE", "hive", null);
  assertThat( comp, notNullValue() );
  assertThat( comp.getRole(), is("HIVE") );
  assertThat( comp.getName(), is("hive") );
  assertThat( comp.getUrl(), is("http://host2:10001/cliservice" ) );
}
 
Example 16
Source File: TopologyRulesModuleTest.java    From knox with Apache License 2.0 4 votes vote down vote up
@Test
public void testParseSimpleTopologyXmlInHadoopFormat() throws IOException, SAXException, URISyntaxException {
  Digester digester = loader.newDigester();
  String name = "org/apache/knox/gateway/topology/xml/simple-topology-ambari-format.conf";
  URL url = ClassLoader.getSystemResource( name );
  assertThat( "Failed to find URL for resource " + name, url, notNullValue() );
  File file = new File( url.getFile() );
  TopologyBuilder topologyBuilder = digester.parse( url );
  Topology topology = topologyBuilder.build();
  assertThat( "Failed to parse resource " + name, topology, notNullValue() );
  topology.setTimestamp( file.lastModified() );

  assertThat( topology.getName(), is( "topology2" ) );
  assertThat( topology.getTimestamp(), is( file.lastModified() ) );
  assertThat( topology.getServices().size(), is( 4 ) );
  assertThat( topology.getProviders().size(), is( 2 ) );

  Service webhdfsService = topology.getService( "WEBHDFS", null, null);
  assertThat( webhdfsService, notNullValue() );
  assertThat( webhdfsService.getRole(), is( "WEBHDFS" ) );
  assertThat( webhdfsService.getName(), nullValue() );
  assertThat( webhdfsService.getUrls().size(), is( 2 ) );
  assertThat( webhdfsService.getUrls(), hasItem( "http://host1:50070/webhdfs" ) );
  assertThat( webhdfsService.getUrls(), hasItem( "http://host2:50070/webhdfs" ) );

  Service webhcatService = topology.getService( "WEBHCAT", null, null);
  assertThat( webhcatService, notNullValue() );
  assertThat( webhcatService.getRole(), is( "WEBHCAT" ) );
  assertThat( webhcatService.getName(), nullValue() );
  assertThat( webhcatService.getUrls().size(), is( 1 ) );
  assertThat( webhcatService.getUrls(), hasItem( "http://host:50111/templeton" ) );

  Service oozieService = topology.getService( "OOZIE", null, null);
  assertThat( oozieService, notNullValue() );
  assertThat( oozieService.getRole(), is( "OOZIE" ) );
  assertThat( oozieService.getName(), nullValue() );
  assertThat( webhcatService.getUrls().size(), is( 1 ) );
  assertThat( oozieService.getUrls(), hasItem( "http://host:11000/oozie" ) );

  Service hiveService = topology.getService( "HIVE", null, null);
  assertThat( hiveService, notNullValue() );
  assertThat( hiveService.getRole(), is( "HIVE" ) );
  assertThat( hiveService.getName(), nullValue() );
  assertThat( webhcatService.getUrls().size(), is( 1 ) );
  assertThat( hiveService.getUrls(), hasItem( "http://host:10000" ) );

  Provider authenticationProvider = topology.getProvider( "authentication", "ShiroProvider" );
  assertThat( authenticationProvider, notNullValue() );
  assertThat( authenticationProvider.isEnabled(), is( true ) );
  assertThat( authenticationProvider.getRole(), is( "authentication" ) );
  assertThat( authenticationProvider.getName(), is( "ShiroProvider" ) );
  assertThat( authenticationProvider.getParams().size(), is( 5 ) );
  assertThat( authenticationProvider.getParams().get("main.ldapRealm.contextFactory.url"), is( "ldap://localhost:33389" ) );

  Provider identityAssertionProvider = topology.getProvider( "identity-assertion", "Default" );
  assertThat( identityAssertionProvider, notNullValue() );
  assertThat( identityAssertionProvider.isEnabled(), is( false ) );
  assertThat( identityAssertionProvider.getRole(), is( "identity-assertion" ) );
  assertThat( identityAssertionProvider.getName(), is( "Default" ) );
  assertThat( identityAssertionProvider.getParams().size(), is( 2 ) );
  assertThat( identityAssertionProvider.getParams().get("name"), is( "user.name" ) );
}
 
Example 17
Source File: AnyClassLF.java    From formatter-maven-plugin with Apache License 2.0 votes vote down vote up
public Map<String, String> read(InputStream input) throws IOException,				SAXException, ConfigReadException {			Digester digester = new Digester();			digester.addRuleSet(new RuleSet());			Object result = digester.parse(input);			if (result == null && !(result instanceof Profiles)) {				throw new ConfigReadException("No profiles found in config file");			}			Profiles profiles = (Profiles) result;			List<Map<String, String>> list = profiles.getProfiles();			if (list.size() == 0) {				throw new ConfigReadException("No profile in config file of kind: "						+ Profiles.PROFILE_KIND);			}			return list.stream()					.filter(profile -> (profile != null && profile.size() != 0))					.findAny().get();		} 
Example 18
Source File: AnyClassCR.java    From formatter-maven-plugin with Apache License 2.0 votes vote down vote up
public Map<String, String> read(InputStream input) throws IOException,				SAXException, ConfigReadException {			Digester digester = new Digester();			digester.addRuleSet(new RuleSet());			Object result = digester.parse(input);			if (result == null && !(result instanceof Profiles)) {				throw new ConfigReadException("No profiles found in config file");			}			Profiles profiles = (Profiles) result;			List<Map<String, String>> list = profiles.getProfiles();			if (list.size() == 0) {				throw new ConfigReadException("No profile in config file of kind: "						+ Profiles.PROFILE_KIND);			}			return list.stream()					.filter(profile -> (profile != null && profile.size() != 0))					.findAny().get();		} 
Example 19
Source File: AnyClassCRLF.java    From formatter-maven-plugin with Apache License 2.0 votes vote down vote up
public Map<String, String> read(InputStream input) throws IOException,				SAXException, ConfigReadException {			Digester digester = new Digester();			digester.addRuleSet(new RuleSet());			Object result = digester.parse(input);			if (result == null && !(result instanceof Profiles)) {				throw new ConfigReadException("No profiles found in config file");			}			Profiles profiles = (Profiles) result;			List<Map<String, String>> list = profiles.getProfiles();			if (list.size() == 0) {				throw new ConfigReadException("No profile in config file of kind: "						+ Profiles.PROFILE_KIND);			}			return list.stream()					.filter(profile -> (profile != null && profile.size() != 0))					.findAny().get();		} 
Example 20
Source File: AnyClass.java    From formatter-maven-plugin with Apache License 2.0 votes vote down vote up
public Map<String, String> read(InputStream input) throws IOException,				SAXException, ConfigReadException {			Digester digester = new Digester();			digester.addRuleSet(new RuleSet());			Object result = digester.parse(input);			if (result == null && !(result instanceof Profiles)) {				throw new ConfigReadException("No profiles found in config file");			}			Profiles profiles = (Profiles) result;			List<Map<String, String>> list = profiles.getProfiles();			if (list.size() == 0) {				throw new ConfigReadException("No profile in config file of kind: "						+ Profiles.PROFILE_KIND);			}			return list.stream()					.filter(profile -> (profile != null && profile.size() != 0))					.findAny().get();		}