Package freenet.crypt

Examples of freenet.crypt.MultiHashInputStream$Digester


     */
    @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 );

        Object root = digester.getRoot();
        assertNotNull( "root object not retrieved", root );
        assertTrue( "root object not a TestRule instance", ( root instanceof TestBean ) );
    }
View Full Code Here


        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

        throws Exception
    {
        // * tests that custom rules can be declared on a
        // separate class by explicitly declaring the rule class.

        Digester digester = new Digester();
        PluginRules rc = new PluginRules();
        digester.setRules( rc );

        PluginDeclarationRule pdr = new PluginDeclarationRule();
        digester.addRule( "root/plugin", pdr );

        PluginCreateRule pcr = new PluginCreateRule( Widget.class );
        digester.addRule( "root/widget", pcr );
        digester.addSetNext( "root/widget", "addChild" );

        Container root = new Container();
        digester.push( root );

        try
        {
            digester.parse( Utils.getInputStream( this, "test5a.xml" ) );
        }
        catch ( Exception e )
        {
            throw e;
        }
View Full Code Here

    {
        // * tests that custom rules can be declared on a
        // separate class by explicitly declaring the rule class.
        // and explicitly declaring the rule method name.

        Digester digester = new Digester();
        PluginRules rc = new PluginRules();
        digester.setRules( rc );

        PluginDeclarationRule pdr = new PluginDeclarationRule();
        digester.addRule( "root/plugin", pdr );

        PluginCreateRule pcr = new PluginCreateRule( Widget.class );
        digester.addRule( "root/widget", pcr );
        digester.addSetNext( "root/widget", "addChild" );

        Container root = new Container();
        digester.push( root );

        try
        {
            digester.parse( Utils.getInputStream( this, "test5b.xml" ) );
        }
        catch ( Exception e )
        {
            throw e;
        }
View Full Code Here

    {
        // * tests that custom rules can be declared on a
        // separate class with name {plugin-class}RuleInfo,
        // and they are automatically detected and loaded.

        Digester digester = new Digester();
        PluginRules rc = new PluginRules();
        digester.setRules( rc );

        PluginDeclarationRule pdr = new PluginDeclarationRule();
        digester.addRule( "root/plugin", pdr );

        PluginCreateRule pcr = new PluginCreateRule( Widget.class );
        digester.addRule( "root/widget", pcr );
        digester.addSetNext( "root/widget", "addChild" );

        Container root = new Container();
        digester.push( root );

        try
        {
            digester.parse( Utils.getInputStream( this, "test5c.xml" ) );
        }
        catch ( Exception e )
        {
            throw e;
        }
View Full Code Here

    {
        // this method tests the Delegate functionality by capturing all
        // data below the specified pattern, and printing it to stdout.
        // I can't for the moment think how to turn this into a unit test,
        // so this test is disabled.
        Digester digester = new Digester();
        PluginRules rc = new PluginRules();
        digester.setRules( rc );

        DumperRule dr = new DumperRule();
        digester.addRule( "root", dr );

        try
        {
            digester.parse( Utils.getInputStream( this, "test1.xml" ) );
        }
        catch ( Exception e )
        {
            throw e;
        }
View Full Code Here

     */
    @Before
    public void setUp()
    {

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

    }
View Full Code Here

            "<?xml version='1.0'?>\n" + "<box id='root'>\n" + "  <subBox id='box1'/>\n" + "  <ignoreme/>\n"
                + "  <subBox id='box2'/> <subBox id='box3'/>\n" + "</box>";

        LocationTracker locnTracker = new LocationTracker();

        Digester digester = newLoader( new AbstractRulesModule()
        {

            @Override
            protected void configure()
            {
                forPattern( "box" ).createObject().ofType( Box.class )
                    .then()
                    .setProperties();
                forPattern( "box/subBox" ).createObject().ofType( Box.class )
                    .then()
                    .setProperties()
                    .then()
                    .setNext( "addChild" );
            }

        })
        .setStackAction( locnTracker )
        .newDigester();

        Box root = digester.parse( new StringReader( TEST_XML ) );
        assertNotNull( root );
        List<Box> children = root.getChildren();
        assertEquals( 3, children.size() );
        Box box1 = children.get( 0 );
        Box box2 = children.get( 1 );
View Full Code Here

    @Test
    public void testDigesterResolveRelative()
        throws Exception
    {
        Digester digester = new Digester();
        digester.setValidating( true );
        digester.parse( new File( "src/test/resources/org/apache/commons/digester3/document-with-relative-dtd.xml" ) );
    }
View Full Code Here

        // now for the tests
        String xml = "<?xml version='1.0' ?><root><element/></root>";

        // test default - which is to propagate the exception
        Digester digester = new Digester();
        digester.addFactoryCreate( "root", new ThrowExceptionCreateRule(), ignoreCreateExceptions );
        try
        {

            digester.parse( new StringReader( xml ) );
            if ( !ignoreCreateExceptions )
            {
                fail( "Exception should be propagated from create rule" );
            }
View Full Code Here

TOP

Related Classes of freenet.crypt.MultiHashInputStream$Digester

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.