1   /*
2    * Copyright 2005 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.springframework.oxm.jaxb;
17  
18  import org.springframework.oxm.AbstractUnmarshallerTestCase;
19  import org.springframework.oxm.Unmarshaller;
20  import org.springframework.oxm.jaxb1.FlightType;
21  import org.springframework.oxm.jaxb1.Flights;
22  
23  public class Jaxb1UnmarshallerTest extends AbstractUnmarshallerTestCase {
24  
25      protected Unmarshaller createUnmarshaller() throws Exception {
26          Jaxb1Marshaller marshaller = new Jaxb1Marshaller();
27          marshaller.setContextPath("org.springframework.oxm.jaxb1");
28          marshaller.setValidating(true);
29          marshaller.afterPropertiesSet();
30          return marshaller;
31      }
32  
33      protected void testFlights(Object o) {
34          Flights flights = (Flights) o;
35          assertNotNull("Flights is null", flights);
36          assertEquals("Invalid amount of flight elements", 1, flights.getFlight().size());
37          testFlight(flights.getFlight().get(0));
38      }
39  
40      protected void testFlight(Object o) {
41          FlightType flight = (FlightType) o;
42          assertNotNull("Flight is null", flight);
43          assertEquals("Number is invalid", 42L, flight.getNumber());
44      }
45  
46  }