From 31a74b0ff610f97d434c3c2195a3ed07c20d8661 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sat, 25 Jan 2014 14:17:25 +0100 Subject: [PATCH] Clean up generics warnings in spring-oxm tests --- .../java/org/springframework/oxm/jibx/Flights.java | 7 ++++--- .../oxm/xstream/XStreamMarshallerTests.java | 9 +++++---- .../oxm/xstream/XStreamUnmarshallerTests.java | 11 +++++++---- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/spring-oxm/src/test/java/org/springframework/oxm/jibx/Flights.java b/spring-oxm/src/test/java/org/springframework/oxm/jibx/Flights.java index 422f8d0035..f44e14c831 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/jibx/Flights.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/jibx/Flights.java @@ -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 flightList = new ArrayList(); 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() { diff --git a/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java index f08252db2c..2a34652284 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java @@ -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 aliases = new HashMap(); + Map> aliases = new HashMap>(); aliases.put("flight", Flight.class); aliases.put("flights", Flights.class); marshaller.setAliases(aliases); diff --git a/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamUnmarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamUnmarshallerTests.java index 8c9bcd51d7..762fe37953 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamUnmarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamUnmarshallerTests.java @@ -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 aliases = new HashMap(); + Map> aliases = new HashMap>(); aliases.put("flight", Flight.class); unmarshaller.setAliases(aliases); }