001package org.apache.commons.digester3.xmlrules; 002 003import static org.apache.commons.digester3.binder.DigesterLoader.newLoader; 004import static org.junit.Assert.assertEquals; 005 006import org.apache.commons.digester3.Employee; 007import org.junit.Test; 008 009/* 010 * Licensed to the Apache Software Foundation (ASF) under one 011 * or more contributor license agreements. See the NOTICE file 012 * distributed with this work for additional information 013 * regarding copyright ownership. The ASF licenses this file 014 * to you under the Apache License, Version 2.0 (the 015 * "License"); you may not use this file except in compliance 016 * with the License. You may obtain a copy of the License at 017 * 018 * http://www.apache.org/licenses/LICENSE-2.0 019 * 020 * Unless required by applicable law or agreed to in writing, 021 * software distributed under the License is distributed on an 022 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 023 * KIND, either express or implied. See the License for the 024 * specific language governing permissions and limitations 025 * under the License. 026 */ 027 028public final class BeanPropertySetterRuleTestCase 029{ 030 031 @Test 032 public void extractPropertyNameFromAttribute() throws Exception 033 { 034 Employee expected = new Employee( "John", "Doe" ); 035 036 Employee actual = newLoader( new FromXmlRulesModule() 037 { 038 039 @Override 040 protected void loadRules() 041 { 042 loadXMLRules( getClass().getResource( "extractPropertyNameFromAttribute-rules.xml" ) ); 043 } 044 045 } ) 046 .newDigester() 047 .parse( getClass().getResource( "../extractPropertyNameFromAttribute.xml" ) ); 048 049 assertEquals( expected.getFirstName(), actual.getFirstName() ); 050 assertEquals( expected.getLastName(), actual.getLastName() ); 051 } 052 053}