Package org.apache.commons.digester3

Examples of org.apache.commons.digester3.SimpleRegexMatcher


    @Test
    public void testSimpleRegexMatch()
    {

        SimpleRegexMatcher matcher = new SimpleRegexMatcher();

        // SimpleLog log = new SimpleLog("{testSimpleRegexMatch:SimpleRegexMatcher]");
        // log.setLevel(SimpleLog.LOG_LEVEL_TRACE);

        assertEquals( "Simple Regex Match '/alpha/beta/gamma' to '/alpha/beta/gamma' ", true,
                      matcher.match( "/alpha/beta/gamma", "/alpha/beta/gamma" ) );
        assertEquals( "Simple Regex Match '/alpha/beta/gamma' to '/alpha/beta/gamma/epsilon' ", false,
                      matcher.match( "/alpha/beta/gamma", "/alpha/beta/gamma/epsilon" ) );
        assertEquals( "Simple Regex Match '/alpha/beta/gamma' to '/alpha/*' ", true,
                      matcher.match( "/alpha/beta/gamma", "/alpha/*" ) );
        assertEquals( "Simple Regex Match '/alpha/beta/gamma' to '/alpha/*/gamma' ", true,
                      matcher.match( "/alpha/beta/gamma", "/alpha/*/gamma" ) );
        assertEquals( "Simple Regex Match '/alpha/beta/gamma' to '/alpha/*me' ", false,
                      matcher.match( "/alpha/beta/gamma", "/alpha/*me" ) );
        assertEquals( "Simple Regex Match '/alpha/beta/gamma' to '*/beta/gamma' ", true,
                      matcher.match( "/alpha/beta/gamma", "*/beta/gamma" ) );
        assertEquals( "Simple Regex Match '/alpha/beta/gamma' to '*/alpha/beta/gamma' ", true,
                      matcher.match( "/alpha/beta/gamma", "*/alpha/beta/gamma" ) );
        assertEquals( "Simple Regex Match '/alpha/beta/gamma' to '*/bet/gamma' ", false,
                      matcher.match( "/alpha/beta/gamma", "*/bet/gamma" ) );
        assertEquals( "Simple Regex Match '/alpha/beta/gamma' to 'alph?/beta/gamma' ", true,
                      matcher.match( "/alpha/beta/gamma", "/alph?/beta/gamma" ) );
        assertEquals( "Simple Regex Match '/alpha/beta/gamma' to '/?lpha/beta/gamma' ", true,
                      matcher.match( "/alpha/beta/gamma", "/?lpha/beta/gamma" ) );
        assertEquals( "Simple Regex Match '/alpha/beta/gamma' to '/alpha/?beta/gamma' ", false,
                      matcher.match( "/alpha/beta/gamma", "/alpha/?beta/gamma" ) );
        assertEquals( "Simple Regex Match '/alpha/beta/gamma' to '/alpha/?eta/*' ", true,
                      matcher.match( "/alpha/beta/gamma", "/alpha/?eta/*" ) );
        assertEquals( "Simple Regex Match '/alpha/beta/gamma' to '/alpha/?eta/*e' ", false,
                      matcher.match( "/alpha/beta/gamma", "/alpha/?eta/*e" ) );
        assertEquals( "Simple Regex Match '/alpha/beta/gamma' to '*/?et?/?amma' ", true,
                      matcher.match( "/alpha/beta/gamma", "*/?et?/?amma" ) );
        assertEquals( "Simple Regex Match '/alpha/beta/gamma/beta/epsilon/beta/gamma/epsilon' to "
                          + " '*/beta/gamma/?p*n' ", true,
                      matcher.match( "/alpha/beta/gamma/beta/epsilon/beta/gamma/epsilon", "*/beta/gamma/?p*n" ) );
        assertEquals( "Simple Regex Match '/alpha/beta/gamma/beta/epsilon/beta/gamma/epsilon' to "
            + " '*/beta/gamma/?p*no' ", false, matcher.match( "/alpha/beta/gamma", "*/beta/gamma/?p*no" ) );
    }
View Full Code Here


        // Configure the digester as required
        digester.addObjectCreate( "root", SimpleTestBean.class );
        digester.addSetProperties( "root" );

        // Parse our test input.
        SimpleTestBean root = digester.parse( input );

        assertNotNull( "Digester returned no object", root );

        assertEquals( "${attr1}", root.getAlpha() );
        assertEquals( "var{attr2}", root.getBeta() );
    }
View Full Code Here

        digester.setSubstitutor( new VariableSubstitutor( expander ) );
        digester.addObjectCreate( "root", SimpleTestBean.class );
        digester.addSetProperties( "root" );

        // Parse our test input.
        SimpleTestBean root = digester.parse( input );

        assertNotNull( "Digester returned no object", root );

        assertEquals( "${attr1}", root.getAlpha() );
        assertEquals( "var{attr2}", root.getBeta() );
    }
View Full Code Here

        digester.parse( input );

        assertEquals( 2, this.simpleTestBeans.size() );

        {
            SimpleTestBean bean = this.simpleTestBeans.get( 0 );
            assertEquals( "source1.attr1", bean.getAlpha() );
            assertEquals( "source2.attr1", bean.getBeta() );
        }

        {
            SimpleTestBean bean = this.simpleTestBeans.get( 1 );
            assertEquals( "source1.attr2", bean.getAlpha() );
            assertEquals( "source2.attr2", bean.getBeta() );
        }
    }
View Full Code Here

        digester.addObjectCreate( "root", SimpleTestBean.class );
        digester.addCallMethod( "root", "setAlpha", 0 );

        // Parse our test input.
        SimpleTestBean root = digester.parse( input );

        assertNotNull( "Digester returned no object", root );

        assertEquals( "Twas brillig and the slithy toves" + " did gyre and gimble in the wabe", root.getAlpha() );
    }
View Full Code Here

        simpleTestBeans.clear();
        digester.push( this );
        digester.parse( input );

        assertEquals( 1, simpleTestBeans.size() );
        SimpleTestBean bean = simpleTestBeans.get( 0 );
        assertEquals( "prop.value", bean.getAlpha() );
    }
View Full Code Here

        simpleTestBeans.clear();
        digester.push( this );
        digester.parse( input );

        assertEquals( 1, simpleTestBeans.size() );
        SimpleTestBean bean = simpleTestBeans.get( 0 );
        assertEquals( "substituted-prop.value1", bean.getAlpha() );
    }
View Full Code Here

        catch ( IllegalArgumentException e )
        {
            // OK
        }

        Substitutor a = new SubstitutorStub( "XYZ", "", "a", "", "abc" );

        try
        {
            new CompoundSubstitutor( a, null );
            fail();
View Full Code Here

    }

    @Test
    public void testChaining()
    {
        Substitutor a = new SubstitutorStub( "XYZ", "", "a", "", "abc" );
        Substitutor b = new SubstitutorStub( "STU", "", "b", "", "bcd" );

        Substitutor test = new CompoundSubstitutor( a, b );

        AttributesImpl attribFixture = new AttributesImpl( attrib );
        attribFixture.addAttribute( "", "a", ":a", "", "abc" );
        attribFixture.addAttribute( "", "b", ":b", "", "bcd" );

        assertTrue( areEqual( test.substitute( attrib ), attribFixture ) );
        assertEquals( test.substitute( bodyText ), "STU" );
    }
View Full Code Here

        assertEquals( "Unsubstituted body text", "Do you feel luck punk?", tsr.body );
        assertEquals( "Unsubstituted number of attributes", 2, tsr.attributes.getLength() );
        assertEquals( "Unsubstituted forname attribute value", "Dirty", tsr.attributes.getValue( "forname" ) );
        assertEquals( "Unsubstituted surname attribute value", "Harry", tsr.attributes.getValue( "surname" ) );

        digester.setSubstitutor( new Substitutor()
        {
            @Override
            public Attributes substitute( Attributes attributes )
            {
                AttributesImpl results = new AttributesImpl();
View Full Code Here

TOP

Related Classes of org.apache.commons.digester3.SimpleRegexMatcher

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.