Clean up generics warnings in spring-oxm tests

This commit is contained in:
Sam Brannen 2014-01-25 14:17:25 +01:00
parent 5e7811a45d
commit 31a74b0ff6
3 changed files with 16 additions and 11 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,17 +17,18 @@
package org.springframework.oxm.jibx;
import java.util.ArrayList;
import java.util.List;
public class Flights {
protected ArrayList flightList = new ArrayList();
protected List<FlightType> flightList = new ArrayList<FlightType>();
public void addFlight(FlightType flight) {
flightList.add(flight);
}
public FlightType getFlight(int index) {
return (FlightType) flightList.get(index);
return flightList.get(index);
}
public int sizeFlightList() {

View File

@ -25,6 +25,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.stream.XMLEventWriter;
@ -42,6 +43,7 @@ import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;
import com.thoughtworks.xstream.io.json.JsonHierarchicalStreamDriver;
import com.thoughtworks.xstream.io.json.JsonWriter;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@ -51,7 +53,6 @@ import org.w3c.dom.Element;
import org.w3c.dom.Text;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.springframework.util.xml.StaxUtils;
import static org.custommonkey.xmlunit.XMLAssert.*;
@ -266,7 +267,7 @@ public class XStreamMarshallerTests {
}
@Test
@SuppressWarnings("unchecked")
@SuppressWarnings({ "rawtypes", "unchecked" })
public void omitFields() throws Exception {
Map omittedFieldsMap = Collections.singletonMap(Flight.class, "flightNumber");
marshaller.setOmittedFields(omittedFieldsMap);
@ -276,13 +277,13 @@ public class XStreamMarshallerTests {
}
@Test
@SuppressWarnings("unchecked")
@SuppressWarnings({ "rawtypes", "unchecked" })
public void implicitCollections() throws Exception {
Flights flights = new Flights();
flights.getFlights().add(flight);
flights.getStrings().add("42");
Map<String, Class> aliases = new HashMap<String, Class>();
Map<String, Class<?>> aliases = new HashMap<String, Class<?>>();
aliases.put("flight", Flight.class);
aliases.put("flights", Flights.class);
marshaller.setAliases(aliases);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream;
import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.stream.XMLInputFactory;
@ -28,13 +29,15 @@ import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamSource;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.springframework.util.xml.StaxUtils;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.springframework.util.xml.StaxUtils;
import static org.junit.Assert.*;
/**
* @author Arjen Poutsma
@ -48,7 +51,7 @@ public class XStreamUnmarshallerTests {
@Before
public void creteUnmarshaller() throws Exception {
unmarshaller = new XStreamMarshaller();
Map<String, Class> aliases = new HashMap<String, Class>();
Map<String, Class<?>> aliases = new HashMap<String, Class<?>>();
aliases.put("flight", Flight.class);
unmarshaller.setAliases(aliases);
}