Package org.apache.commons.digester3.plugins

Examples of org.apache.commons.digester3.plugins.PluginRules


        Object obj4 = new String( "replpush.obj4" );

        Object obj8 = new String( "obj8" );
        Object obj9 = new String( "obj9" );

        Digester d = new Digester();
        d.setStackAction( action );

        assertEquals( 0, action.events.size() );
        d.push( obj1 );
        d.push( obj2 );
        d.push( obj3 );
        d.push( obj4 );

        assertNotNull( d.peek( 0 ) );
        // for obj4, a copy should have been pushed
        assertNotSame( obj4, d.peek( 0 ) );
        assertEquals( obj4, d.peek( 0 ) );
        // for obj3, replacement only occurs on pop
        assertSame( obj3, d.peek( 1 ) );
        assertSame( obj2, d.peek( 2 ) );
        assertSame( obj1, d.peek( 3 ) );

        Object obj4a = d.pop();
        Object obj3a = d.pop();
        Object obj2a = d.pop();
        Object obj1a = d.pop();

        assertFalse( obj4 == obj4a );
        assertEquals( obj4, obj4a );
        assertFalse( obj3 == obj4a );
        assertEquals( obj3, obj3a );
        assertSame( obj2, obj2a );
        assertSame( obj1, obj1a );

        d.push( "stack1", obj8 );
        d.push( "stack1", obj9 );
        Object obj9a = d.pop( "stack1" );
        Object obj8a = d.pop( "stack1" );

        assertSame( obj8, obj8a );
        assertSame( obj9, obj9a );

        assertEquals( 12, action.events.size() );
View Full Code Here


     * {@inheritDoc}
     */
    @Override
    protected ObjectCreateRule createRule()
    {
        return new ObjectCreateRule( attributeName, type );
    }
View Full Code Here

    @Test
    public void testGetRoot()
        throws Exception
    {
        Digester digester = new Digester();
        digester.addRule( "root", new ObjectCreateRule( TestBean.class ) );

        String xml = "<root/>";
        InputSource in = new InputSource( new StringReader( xml ) );

        digester.parse( in );
View Full Code Here

    /** Test regex that matches everything */
    @Test
    public void testMatchAll()
    {
        // set up which should match every rule
        RegexRules rules = new RegexRules( new RegexMatcher()
        {
            @Override
            public boolean match( String pathPattern, String rulePattern )
            {
                return true;
View Full Code Here

    /** Test regex matcher that matches nothing */
    @Test
    public void testMatchNothing()
    {
        // set up which should match every rule
        RegexRules rules = new RegexRules( new RegexMatcher()
        {
            @Override
            public boolean match( String pathPattern, String rulePattern )
            {
                return false;
View Full Code Here

    /** Test a mixed regex - in other words, one that sometimes returns true and sometimes false */
    @Test
    public void testMatchMixed()
    {
        // set up which should match every rule
        RegexRules rules = new RegexRules( new RegexMatcher()
        {
            @Override
            public boolean match( String pathPattern, String rulePattern )
            {
                return ( rulePattern.equals( "/match/me" ) );
View Full Code Here

    /** 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;
View Full Code Here

    /** Test regex that matches everything */
    @Test
    public void testMatchAll()
    {
        // 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( "/a/b/b", new TestRule( "alpha" ) );
        rules.add( "/a/d", new TestRule( "beta" ) );
        rules.add( "/b", new TestRule( "gamma" ) );

        // now test a few patterns
        // check that all are return in the order which they were added
        List<Rule> matches = rules.match( "", "x/g/e", null, null );
        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( "", "/a", 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() );
    }
View Full Code Here

    /** Test regex matcher that matches nothing */
    @Test
    public void testMatchNothing()
    {
        // set up which should match every rule
        RegexRules rules = new RegexRules( new RegexMatcher()
        {
            @Override
            public boolean match( String pathPattern, String rulePattern )
            {
                return false;
            }
        } );

        rules.add( "/b/c/f", new TestRule( "alpha" ) );
        rules.add( "/c/f", new TestRule( "beta" ) );
        rules.add( "/b", new TestRule( "gamma" ) );

        // now test a few patterns
        // check that all are return in the order which they were added
        List<Rule> matches = rules.match( "", "/b/c", null, null );
        assertEquals( "Wrong number of rules returned (1)", 0, matches.size() );

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

    /** Test a mixed regex - in other words, one that sometimes returns true and sometimes false */
    @Test
    public void testMatchMixed()
    {
        // set up which should match every rule
        RegexRules rules = new RegexRules( new RegexMatcher()
        {
            @Override
            public boolean match( String pathPattern, String rulePattern )
            {
                return ( rulePattern.equals( "/match/me" ) );
            }
        } );

        rules.add( "/match", new TestRule( "alpha" ) );
        rules.add( "/match/me", new TestRule( "beta" ) );
        rules.add( "/match", new TestRule( "gamma" ) );

        // now test a few patterns
        // check that all are return in the order which they were added
        List<Rule> matches = rules.match( "", "/match", null, null );
        assertEquals( "Wrong number of rules returned (1)", 1, matches.size() );
        assertEquals( "Wrong Rule (1)", "beta", ( (TestRule) matches.get( 0 ) ).getIdentifier() );

        matches = rules.match( "", "/a/match", null, null );
        assertEquals( "Wrong Rule (2)", "beta", ( (TestRule) matches.get( 0 ) ).getIdentifier() );
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.digester3.plugins.PluginRules

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.