Author: veithen
Date: Fri Nov 6 22:12:01 2015
New Revision: 1713045
URL: http://svn.apache.org/viewvc?rev=1713045&view=rev
Log:
Use Java 5 features.
Modified:
webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestSuiteBuilder.java
webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/ParentLastURLClassLoader.java
webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/StAXImplementation.java
webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/TestGetEncodingFromDetection.java
webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/TestGetNamespaceContext.java
Modified:
webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestSuiteBuilder.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestSuiteBuilder.java?rev=1713045&r1=1713044&r2=1713045&view=diff
==============================================================================
---
webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestSuiteBuilder.java
(original)
+++
webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestSuiteBuilder.java
Fri Nov 6 22:12:01 2015
@@ -19,7 +19,6 @@
package org.apache.axiom.util.stax.dialect;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import javax.xml.stream.XMLStreamConstants;
@@ -30,15 +29,15 @@ import org.apache.axiom.ts.xml.StreamTyp
import org.apache.axiom.ts.xml.XMLSample;
public class DialectTestSuiteBuilder extends MatrixTestSuiteBuilder {
- private final List/*<StAXImplementation>*/ implementations = new
ArrayList();
+ private final List<StAXImplementation> implementations = new
ArrayList<StAXImplementation>();
public void addImplementation(StAXImplementation implementation) {
implementations.add(implementation);
}
protected void addTests() {
- for (Iterator it = implementations.iterator(); it.hasNext(); ) {
- addTests((StAXImplementation)it.next());
+ for (StAXImplementation impl : implementations) {
+ addTests(impl);
}
}
@@ -65,8 +64,8 @@ public class DialectTestSuiteBuilder ext
// because UTF-16BE or UTF-16LE may be interpreted as an indication
that
// there should be no BOM.
// Therefore we accept both results.
- addTest(new TestGetEncodingFromDetection(staxImpl, "UnicodeBig", new
String[] { "UTF-16", "UTF-16BE" } ));
- addTest(new TestGetEncodingFromDetection(staxImpl, "UnicodeLittle",
new String[] { "UTF-16", "UTF-16LE" }));
+ addTest(new TestGetEncodingFromDetection(staxImpl, "UnicodeBig",
"UTF-16", "UTF-16BE"));
+ addTest(new TestGetEncodingFromDetection(staxImpl, "UnicodeLittle",
"UTF-16", "UTF-16LE"));
// Here there is no doubt; if the encoding is UTF-16 without BOM, then
the
// parser should report the detected byte order.
addTest(new TestGetEncodingFromDetection(staxImpl,
"UnicodeBigUnmarked", "UTF-16BE"));
@@ -96,12 +95,11 @@ public class DialectTestSuiteBuilder ext
addTest(new TestGetNameIllegalStateException(staxImpl,
XMLStreamConstants.DTD, true));
addTest(new TestGetNameIllegalStateException(staxImpl,
XMLStreamConstants.CDATA, true));
addTest(new TestGetNamespaceContextImplicitNamespaces(staxImpl));
- for (Iterator it = Multiton.getInstances(XMLSample.class).iterator();
it.hasNext(); ) {
- XMLSample file = (XMLSample)it.next();
+ for (XMLSample sample : Multiton.getInstances(XMLSample.class)) {
// Some parsers have problems with external subsets; anyway the
test files with
// DTDs are not essential for this test.
- if (!file.hasExternalSubset()) {
- addTest(new TestGetNamespaceContext(staxImpl, file));
+ if (!sample.hasExternalSubset()) {
+ addTest(new TestGetNamespaceContext(staxImpl, sample));
}
}
addTest(new TestGetNamespacePrefixDefaultNamespace(staxImpl));
Modified:
webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/ParentLastURLClassLoader.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/ParentLastURLClassLoader.java?rev=1713045&r1=1713044&r2=1713045&view=diff
==============================================================================
---
webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/ParentLastURLClassLoader.java
(original)
+++
webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/ParentLastURLClassLoader.java
Fri Nov 6 22:12:01 2015
@@ -37,12 +37,12 @@ public class ParentLastURLClassLoader ex
return url;
}
- public Enumeration getResources(String name) throws IOException {
+ public Enumeration<URL> getResources(String name) throws IOException {
// Make sure that we return our own resources first. Otherwise, if an
API performs
// JDK 1.3 service discovery using getResources instead of
getResource, we would
// have a problem.
- Vector resources = new Vector();
- Enumeration e = findResources(name);
+ Vector<URL> resources = new Vector<URL>();
+ Enumeration<URL> e = findResources(name);
while (e.hasMoreElements()) {
resources.add(e.nextElement());
}
@@ -53,11 +53,11 @@ public class ParentLastURLClassLoader ex
return resources.elements();
}
- protected synchronized Class loadClass(String name, boolean resolve)
throws ClassNotFoundException {
+ protected synchronized Class<?> loadClass(String name, boolean resolve)
throws ClassNotFoundException {
if (name.startsWith("javax.")) {
return super.loadClass(name, resolve);
} else {
- Class c = findLoadedClass(name);
+ Class<?> c = findLoadedClass(name);
if (c == null) {
try {
c = findClass(name);
Modified:
webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/StAXImplementation.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/StAXImplementation.java?rev=1713045&r1=1713044&r2=1713045&view=diff
==============================================================================
---
webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/StAXImplementation.java
(original)
+++
webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/StAXImplementation.java
Fri Nov 6 22:12:01 2015
@@ -43,7 +43,7 @@ public final class StAXImplementation {
return name;
}
- private Object newFactory(Class type) {
+ private <T> T newFactory(Class<T> type) {
String className = props == null ? null :
props.getProperty(type.getName());
if (className == null) {
// We do the lookup ourselves instead of using the StAX API. This
allows
@@ -62,9 +62,9 @@ public final class StAXImplementation {
throw new FactoryConfigurationError(ex);
}
}
- Object factory;
+ T factory;
try {
- factory = classLoader.loadClass(className).newInstance();
+ factory =
classLoader.loadClass(className).asSubclass(type).newInstance();
} catch (Exception ex) {
throw new FactoryConfigurationError(ex);
}
@@ -80,7 +80,7 @@ public final class StAXImplementation {
}
public XMLInputFactory newXMLInputFactory() {
- return (XMLInputFactory)newFactory(XMLInputFactory.class);
+ return newFactory(XMLInputFactory.class);
}
public XMLInputFactory newNormalizedXMLInputFactory() {
@@ -92,7 +92,7 @@ public final class StAXImplementation {
}
public XMLOutputFactory newXMLOutputFactory() {
- return (XMLOutputFactory)newFactory(XMLOutputFactory.class);
+ return newFactory(XMLOutputFactory.class);
}
public XMLOutputFactory newNormalizedXMLOutputFactory() {
Modified:
webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/TestGetEncodingFromDetection.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/TestGetEncodingFromDetection.java?rev=1713045&r1=1713044&r2=1713045&view=diff
==============================================================================
---
webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/TestGetEncodingFromDetection.java
(original)
+++
webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/TestGetEncodingFromDetection.java
Fri Nov 6 22:12:01 2015
@@ -34,19 +34,15 @@ import javax.xml.stream.XMLStreamReader;
*/
public class TestGetEncodingFromDetection extends DialectTestCase {
private final String javaEncoding;
- private final Set xmlEncodings;
+ private final Set<String> xmlEncodings;
- public TestGetEncodingFromDetection(StAXImplementation staxImpl, String
javaEncoding, String[] xmlEncodings) {
+ public TestGetEncodingFromDetection(StAXImplementation staxImpl, String
javaEncoding, String... xmlEncodings) {
super(staxImpl);
this.javaEncoding = javaEncoding;
- this.xmlEncodings = new HashSet(Arrays.asList(xmlEncodings));
+ this.xmlEncodings = new HashSet<String>(Arrays.asList(xmlEncodings));
addTestParameter("javaEncoding", javaEncoding);
}
- public TestGetEncodingFromDetection(StAXImplementation staxImpl, String
javaEncoding, String xmlEncoding) {
- this(staxImpl, javaEncoding, new String[] { xmlEncoding });
- }
-
protected void runTest() throws Throwable {
XMLInputFactory factory = staxImpl.newNormalizedXMLInputFactory();
XMLStreamReader reader = factory.createXMLStreamReader(new
ByteArrayInputStream(
Modified:
webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/TestGetNamespaceContext.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/TestGetNamespaceContext.java?rev=1713045&r1=1713044&r2=1713045&view=diff
==============================================================================
---
webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/TestGetNamespaceContext.java
(original)
+++
webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/TestGetNamespaceContext.java
Fri Nov 6 22:12:01 2015
@@ -40,8 +40,8 @@ public class TestGetNamespaceContext ext
}
// Copy & paste from XMLStreamReaderComparator
- private Set toPrefixSet(Iterator it) {
- Set set = new HashSet();
+ private Set<String> toPrefixSet(Iterator<?> it) {
+ Set<String> set = new HashSet<String>();
while (it.hasNext()) {
String prefix = (String)it.next();
// TODO: Woodstox returns null instead of "" for the default
namespace.
@@ -55,8 +55,8 @@ public class TestGetNamespaceContext ext
protected void runTest() throws Throwable {
XMLInputFactory factory = staxImpl.newNormalizedXMLInputFactory();
InputStream in = testResource.getInputStream();
- Set/*<String>*/ prefixes = new HashSet();
- Set/*<String>*/ namespaceURIs = new HashSet();
+ Set<String> prefixes = new HashSet<String>();
+ Set<String> namespaceURIs = new HashSet<String>();
prefixes.add("");
try {
ScopedNamespaceContext refNc = new ScopedNamespaceContext();
@@ -82,14 +82,12 @@ public class TestGetNamespaceContext ext
}
if (depth > 0) {
NamespaceContext nc = reader.getNamespaceContext();
- for (Iterator it = prefixes.iterator(); it.hasNext(); ) {
- String prefix = (String)it.next();
+ for (String prefix : prefixes) {
String expectedUri = refNc.getNamespaceURI(prefix);
String actualUri = nc.getNamespaceURI(prefix);
assertEquals("Namespace URI for prefix '" + prefix +
"'", expectedUri, actualUri);
}
- for (Iterator it = namespaceURIs.iterator(); it.hasNext();
) {
- String namespaceURI = (String)it.next();
+ for (String namespaceURI : namespaceURIs) {
assertEquals(
"Prefix for namespace URI '" + namespaceURI +
"'",
refNc.getPrefix(namespaceURI),