View Javadoc

1   /* $Id: EmployeeTestCase.java 1127412 2011-05-25 07:29:59Z simonetripodi $
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one or more
4    * contributor license agreements.  See the NOTICE file distributed with
5    * this work for additional information regarding copyright ownership.
6    * The ASF licenses this file to You under the Apache License, Version 2.0
7    * (the "License"); you may not use this file except in compliance with
8    * the License.  You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.commons.digester3.annotations.employee;
19  
20  import java.util.Collection;
21  import java.util.Stack;
22  
23  import org.apache.commons.digester3.annotations.AbstractAnnotatedPojoTestCase;
24  import org.apache.commons.digester3.annotations.FromAnnotationsRuleModule;
25  import org.apache.commons.digester3.binder.RulesModule;
26  import org.junit.Test;
27  
28  /**
29   * @since 2.1
30   */
31  public final class EmployeeTestCase
32      extends AbstractAnnotatedPojoTestCase
33  {
34  
35      @Test
36      public void testEmployee()
37          throws Exception
38      {
39          Employee employee = new Employee();
40          employee.setFirstName( "First Name" );
41          employee.setLastName( "Last Name" );
42  
43          Address address = new Address();
44          address.setCity( "Home City" );
45          address.setState( "HS" );
46          address.setStreet( "Home Street" );
47          address.setType( "home" );
48          address.setZipCode( "HmZip" );
49          address.setEmployee( employee );
50  
51          address = new Address();
52          address.setCity( "Office City" );
53          address.setState( "OS" );
54          address.setStreet( "Office Street" );
55          address.setType( "office" );
56          address.setZipCode( "OfZip" );
57          address.setEmployee( employee );
58  
59          this.verifyExpectedEqualsToParsed( employee );
60      }
61  
62      @Override
63      protected Collection<RulesModule> getAuxModules()
64      {
65          Collection<RulesModule> modules = new Stack<RulesModule>();
66          modules.add( new FromAnnotationsRuleModule()
67          {
68  
69              @Override
70              protected void configureRules()
71              {
72                  bindRulesFrom( Address.class );
73              }
74  
75          });
76          return modules;
77      }
78  
79  }