Package org.apache.commons.digester3

Examples of org.apache.commons.digester3.NodeCreateRule$NodeBuilder


    /** Test rules and clear methods */
    @Test
    public void testClear()
    {
        // set up which should match every rule
        RegexRules rules = new RegexRules( new RegexMatcher()
        {
            @Override
            public boolean match( String pathPattern, String rulePattern )
            {
                return true;
            }
        } );

        rules.add( "/abba", new TestRule( "alpha" ) );
        rules.add( "/ad/ma", new TestRule( "beta" ) );
        rules.add( "/gamma", new TestRule( "gamma" ) );

        // check that rules returns all rules in the order which they were added
        List<Rule> matches = rules.rules();
        assertEquals( "Wrong number of rules returned (1)", 3, matches.size() );
        assertEquals( "Rule Out Of Order (1)", "alpha", ( (TestRule) matches.get( 0 ) ).getIdentifier() );
        assertEquals( "Rule Out Of Order (2)", "beta", ( (TestRule) matches.get( 1 ) ).getIdentifier() );
        assertEquals( "Rule Out Of Order (3)", "gamma", ( (TestRule) matches.get( 2 ) ).getIdentifier() );

        matches = rules.match( "", "/eggs", null, null );
        assertEquals( "Wrong number of rules returned (2)", 3, matches.size() );
        assertEquals( "Rule Out Of Order (4)", "alpha", ( (TestRule) matches.get( 0 ) ).getIdentifier() );
        assertEquals( "Rule Out Of Order (5)", "beta", ( (TestRule) matches.get( 1 ) ).getIdentifier() );
        assertEquals( "Rule Out Of Order (6)", "gamma", ( (TestRule) matches.get( 2 ) ).getIdentifier() );

        rules.clear();
        matches = rules.rules();
        assertEquals( "Wrong number of rules returned (3)", 0, matches.size() );

        matches = rules.match( "", "/eggs", null, null );
        assertEquals( "Wrong number of rules returned (4)", 0, matches.size() );
    }
View Full Code Here


     *
     * @param digester the Digester instance reference.
     */
    public void addRules( final Digester digester )
    {
        RuleSet ruleSet = createRuleSet();
        ruleSet.addRuleInstances( digester );
    }
View Full Code Here

    public void testRuleSet1()
        throws SAXException, IOException
    {

        // Configure the digester as required
        RuleSet rs = new TestRuleSet();
        digester.addRuleSet( rs );

        // Parse our test input.
        Employee employee = digester.parse( getInputStream( "Test1.xml" ) );
View Full Code Here

        throws SAXException, IOException
    {

        // Configure the digester as required
        digester.setNamespaceAware( true );
        RuleSet rs = new TestRuleSet( null, "http://commons.apache.org/digester/Foo" );
        digester.addRuleSet( rs );

        // Parse our test input.
        Employee employee = digester.parse( getInputStream( "Test2.xml" ) );
View Full Code Here

        throws SAXException, IOException
    {

        // Configure the digester as required
        digester.setNamespaceAware( true );
        RuleSet rs = new TestRuleSet( null, "http://commons.apache.org/digester/Foo" );
        digester.addRuleSet( rs );

        // Parse our test input.
        Employee employee = digester.parse( getInputStream( "Test3.xml" ) );
View Full Code Here

     *
     * @return a new {@link Digester} instance
     */
    public Digester newDigester()
    {
        return this.newDigester( new RulesBase() );
    }
View Full Code Here

     * @param parser the user defined {@code SAXParser}
     * @return a new {@link Digester} instance
     */
    public Digester newDigester( SAXParser parser )
    {
        return newDigester( parser, new RulesBase() );
    }
View Full Code Here

     * @param reader The user defined {@code XMLReader}
     * @return a new {@link Digester} instance
     */
    public Digester newDigester( XMLReader reader )
    {
        return this.newDigester( reader, new RulesBase() );
    }
View Full Code Here

    @Before
    public void setUp()
    {

        digester = new Digester();
        digester.setRules( new RulesBase() );

    }
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    protected SetNestedPropertiesRule createRule()
    {
        SetNestedPropertiesRule rule = new SetNestedPropertiesRule( elementNames );
        rule.setTrimData( trimData );
        rule.setAllowUnknownChildElements( allowUnknownChildElements );
        return rule;
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.digester3.NodeCreateRule$NodeBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.