001/* $Id: EmployeeTestCase.java 1127412 2011-05-25 07:29:59Z simonetripodi $ 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one or more 004 * contributor license agreements. See the NOTICE file distributed with 005 * this work for additional information regarding copyright ownership. 006 * The ASF licenses this file to You under the Apache License, Version 2.0 007 * (the "License"); you may not use this file except in compliance with 008 * the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.commons.digester3.annotations.employee; 019 020import java.util.Collection; 021import java.util.Stack; 022 023import org.apache.commons.digester3.annotations.AbstractAnnotatedPojoTestCase; 024import org.apache.commons.digester3.annotations.FromAnnotationsRuleModule; 025import org.apache.commons.digester3.binder.RulesModule; 026import org.junit.Test; 027 028/** 029 * @since 2.1 030 */ 031public final class EmployeeTestCase 032 extends AbstractAnnotatedPojoTestCase 033{ 034 035 @Test 036 public void testEmployee() 037 throws Exception 038 { 039 Employee employee = new Employee(); 040 employee.setFirstName( "First Name" ); 041 employee.setLastName( "Last Name" ); 042 043 Address address = new Address(); 044 address.setCity( "Home City" ); 045 address.setState( "HS" ); 046 address.setStreet( "Home Street" ); 047 address.setType( "home" ); 048 address.setZipCode( "HmZip" ); 049 address.setEmployee( employee ); 050 051 address = new Address(); 052 address.setCity( "Office City" ); 053 address.setState( "OS" ); 054 address.setStreet( "Office Street" ); 055 address.setType( "office" ); 056 address.setZipCode( "OfZip" ); 057 address.setEmployee( employee ); 058 059 this.verifyExpectedEqualsToParsed( employee ); 060 } 061 062 @Override 063 protected Collection<RulesModule> getAuxModules() 064 { 065 Collection<RulesModule> modules = new Stack<RulesModule>(); 066 modules.add( new FromAnnotationsRuleModule() 067 { 068 069 @Override 070 protected void configureRules() 071 { 072 bindRulesFrom( Address.class ); 073 } 074 075 }); 076 return modules; 077 } 078 079}