Package org.apache.commons.digester3

Examples of org.apache.commons.digester3.SetPropertiesRule


     */
    @Test
    public void testAttributes()
        throws SAXException, ParserConfigurationException, IOException
    {
        Digester digester = newLoader( new AbstractRulesModule()
        {

            @Override
            protected void configure()
            {
View Full Code Here


     */
    @Test
    public void testNamespaces()
        throws SAXException, ParserConfigurationException, IOException
    {
        Digester digester = newLoader( new AbstractRulesModule()
        {

            @Override
            protected void configure()
            {
View Full Code Here

     */
    @Test
    public void testNamespacedAttribute()
        throws SAXException, ParserConfigurationException, IOException
    {
        Digester digester = newLoader( new AbstractRulesModule()
        {

            @Override
            protected void configure()
            {
View Full Code Here

     */
    @Test
    public void testNonNamespacedAttribute()
        throws SAXException, ParserConfigurationException, IOException
    {
        Digester digester = newLoader( new AbstractRulesModule()
        {

            @Override
            protected void configure()
            {
View Full Code Here

     */
    @Test
    public void testImport()
        throws SAXException, ParserConfigurationException, IOException
    {
        Digester digester = newLoader( new AbstractRulesModule()
        {

            @Override
            protected void configure()
            {
View Full Code Here

    public void testEntityText()
        throws Exception
    {
        String TEST_XML2 = "<?xml version='1.0'?><root><alpha>&#65; &#65;</alpha></root>";

        Digester digester = newLoader( new AbstractRulesModule()
        {

            @Override
            protected void configure()
            {
View Full Code Here

     */
    @Test
    public void testBasic()
        throws SAXException, IOException
    {
        Digester digester = newLoader( new AbstractRulesModule()
        {

            @Override
            protected void configure()
            {
View Full Code Here

     */
    @Test
    public void testCallMethodOnly()
        throws Exception
    {
        Digester digester = newLoader( new AbstractRulesModule()
        {

            @Override
            protected void configure()
            {
View Full Code Here

     */
    @Test
    public void testSettingProperties()
        throws SAXException, IOException
    {
        Digester digester = newLoader( new AbstractRulesModule()
        {

            @Override
            protected void configure()
            {
                forPattern( "employee" ).createObject().ofType( Employee.class )
                    .then()
                    .callMethod( "setLastName" ).withParamTypes( "java.lang.String" );
                forPattern( "employee/lastName" ).callParam().ofIndex( 0 );
            }

        }).newDigester();

        // Parse our test input

        // an exception will be thrown if the method can't be found
        Employee employee = digester.parse( getInputStream( "Test5.xml" ) );
        assertEquals( "Failed to call Employee.setLastName", "Last Name", employee.getLastName() );

        digester = newLoader( new AbstractRulesModule()
        {

            @Override
            protected void configure()
            {
                forPattern( "employee" ).createObject().ofType( Employee.class )
                    .then()
                    .callMethod( "setAge" ).withParamTypes( int.class );
                forPattern( "employee/age" ).callParam();
            }

        }).newDigester();

        // Parse our test input
        // an exception will be thrown if the method can't be found
        employee = digester.parse( getInputStream( "Test5.xml" ) );
        assertEquals( "Failed to call Employee.setAge", 21, employee.getAge() );

        digester = newLoader( new AbstractRulesModule()
        {

            @Override
            protected void configure()
            {
                forPattern( "employee" ).createObject().ofType( Employee.class )
                    .then()
                    .callMethod( "setActive" ).withParamTypes( boolean.class );
                forPattern( "employee/active" ).callParam();
            }

        }).newDigester();

        // Parse our test input
        // an exception will be thrown if the method can't be found
        employee = digester.parse( getInputStream( "Test5.xml" ) );
        assertEquals( "Failed to call Employee.setActive", true, employee.isActive() );

        digester = newLoader( new AbstractRulesModule()
        {

            @Override
            protected void configure()
            {
View Full Code Here

     */
    @Test
    public void testParamsFromStack()
        throws SAXException, IOException
    {
        Digester digester = newLoader( new AbstractRulesModule()
        {

            @Override
            protected void configure()
            {
View Full Code Here

TOP

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

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.