Package freenet.crypt

Examples of freenet.crypt.MultiHashInputStream$Digester


    assertThat( identityAssertionProvider.getParams().get("name"), is( "user.name" ) );
  }

  @Test
  public void testParseServiceParamsInAmbariFormat() throws IOException, SAXException {
    Digester digester = loader.newDigester();
    String name = "org/apache/hadoop/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" ) );
View Full Code Here


    private static final Logger logger = LoggerFactory.getLogger(XmlChangeSetReader.class);

    private Digester digester;

    XmlChangeSetReader() {
        digester = new Digester();

        digester.setValidating(false);

        digester.addObjectCreate("mongoChangeLog", ChangeSetList.class);
        digester.addObjectCreate("mongoChangeLog/changeSet", ChangeSet.class);
View Full Code Here

    public List<Resource> getFiles(Resource file) {
        List<Resource> files = new ArrayList<Resource>();

        try {
            Digester digester = new Digester();

            digester.setValidating(false);

            digester.addObjectCreate("changeFiles", ChangeFileSet.class);
            digester.addObjectCreate("changeFiles/file", ChangeFile.class);
            digester.addSetProperties("changeFiles/file");
            digester.addSetNext("changeFiles/file", "add");

            logger.info("Parsing XML Fileset file {}", file.getFilename());
            ChangeFileSet changeFileSet = (ChangeFileSet) digester.parse(file.getInputStream());
            if (changeFileSet != null) {
                logger.info("Num of changefiles found " + changeFileSet.getChangeFiles().size());
                for (ChangeFile changeFile : changeFileSet.getChangeFiles()) {
                    files.add(file.createRelative(changeFile.getPath()));
                }
View Full Code Here

    public void testDefaultPlugins2()
        throws Exception
    {
        // * tests that when there is no default plugin, it is an error
        // not to have one of plugin-class or plugin-id specified
        Digester digester = new Digester();
        PluginRules rc = new PluginRules();
        digester.setRules( rc );

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

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

        Log oldLog = digester.getLogger();
        try
        {
            digester.setLogger( new NoOpLog() );
            digester.parse( Utils.getInputStream( this, "test2.xml" ) );
            fail("Expected SAXParseException");
        }
        catch ( SAXParseException e )
        {
            assertEquals( PluginInvalidInputException.class, e.getException().getClass() );
        }
        finally
        {
            digester.setLogger( oldLog );
        }

    }
View Full Code Here

    public void testDefaultPlugins3()
        throws Exception
    {
        // * tests that the default plugin must implement or extend the
        // plugin base class.
        Digester digester = new Digester();
        PluginRules rc = new PluginRules();
        digester.setRules( rc );

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

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

        Log oldLog = digester.getLogger();
        try
        {
            digester.setLogger( new NoOpLog() );
            digester.parse( Utils.getInputStream( this, "test2.xml" ) );
            fail("Expected SAXParseException");
        }
        catch ( SAXParseException e )
        {
            assertEquals( PluginConfigurationException.class, e.getException().getClass() );
        }
        finally
        {
            digester.setLogger( oldLog );
        }
    }
View Full Code Here

     */
    @Before
    public void setUp()
    {

        digester = new Digester();

    }
View Full Code Here

     * Test rule addition - this boils down to making sure that digester is set properly on rule addition.
     */
    @Test
    public void testAddRule()
    {
        Digester digester = new Digester();
        TestRule rule = new TestRule( "Test" );
        digester.addRule( "/root", rule );

        assertEquals( "Digester is not properly on rule addition.", digester, rule.getDigester() );

    }
View Full Code Here

    @Test
    public void testSetNext()
        throws SAXException, IOException
    {
        Digester digester = new Digester();
        digester.setRules( new ExtendedBaseRules() );
        digester.setValidating( false );

        digester.addObjectCreate( "!*/b", BetaBean.class );
        digester.addObjectCreate( "!*/a", AlphaBean.class );
        digester.addObjectCreate( "root", ArrayList.class );
        digester.addSetProperties( "!*" );
        digester.addSetNext( "!*/b/?", "setChild" );
        digester.addSetNext( "!*/a/?", "setChild" );
        digester.addSetNext( "!root/?", "add" );
        ArrayList<?> root = digester.parse( getInputStream( "Test4.xml" ) );

        assertEquals( "Wrong array size", 2, root.size() );
        AlphaBean one = (AlphaBean) root.get( 0 );
        assertTrue( one.getChild() instanceof BetaBean );
        BetaBean two = (BetaBean) one.getChild();
View Full Code Here

    @Test
    public void testSetTop()
        throws SAXException, IOException
    {
        Digester digester = new Digester();
        digester.setRules( new ExtendedBaseRules() );
        digester.setValidating( false );

        digester.addObjectCreate( "!*/b", BetaBean.class );
        digester.addObjectCreate( "!*/a", AlphaBean.class );
        digester.addObjectCreate( "root", ArrayList.class );
        digester.addSetProperties( "!*" );
        digester.addSetTop( "!*/b/?", "setParent" );
        digester.addSetTop( "!*/a/?", "setParent" );
        digester.addSetRoot( "!*/a", "add" );
        digester.addSetRoot( "!*/b", "add" );
        ArrayList<?> root = digester.parse( getInputStream( "Test4.xml" ) );

        assertEquals( "Wrong array size", 5, root.size() );

        // note that the array is in popped order (rather than pushed)

View Full Code Here

        ConvertUtils.register( dateConverter, Date.class );

        final URL rules = getClass().getResource( "atom-rules.xml" );
        final URL input = getClass().getResource( "atom-content.xml" );

        Digester digester = newLoader( new FromXmlRulesModule()
        {

            @Override
            protected void loadRules()
            {
                loadXMLRules( rules );
            }

        } )
        .setNamespaceAware( true )
        .newDigester();
        Feed feed = digester.parse( input.openStream() );
        assertNotNull( feed );
    }
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.