Clean up warnings and tests in spring-core
This commit is contained in:
parent
9ab4062317
commit
a3e7848a30
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2014 the original author or authors.
|
* Copyright 2002-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -364,7 +364,7 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
public Map<String, Object> getSystemEnvironment() {
|
public Map<String, Object> getSystemEnvironment() {
|
||||||
if (suppressGetenvAccess()) {
|
if (suppressGetenvAccess()) {
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
|
|
@ -408,7 +408,7 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
public Map<String, Object> getSystemProperties() {
|
public Map<String, Object> getSystemProperties() {
|
||||||
try {
|
try {
|
||||||
return (Map) System.getProperties();
|
return (Map) System.getProperties();
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,6 @@ public class ListenableFutureCallbackRegistry<T> {
|
||||||
* @param callback the failure callback to add
|
* @param callback the failure callback to add
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void addFailureCallback(FailureCallback callback) {
|
public void addFailureCallback(FailureCallback callback) {
|
||||||
Assert.notNull(callback, "'callback' must not be null");
|
Assert.notNull(callback, "'callback' must not be null");
|
||||||
synchronized (this.mutex) {
|
synchronized (this.mutex) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2014 the original author or authors.
|
* Copyright 2002-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -42,6 +42,7 @@ import static org.junit.Assert.*;
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public class BridgeMethodResolverTests {
|
public class BridgeMethodResolverTests {
|
||||||
|
|
||||||
private static TypeVariable<?> findTypeVariable(Class<?> clazz, String name) {
|
private static TypeVariable<?> findTypeVariable(Class<?> clazz, String name) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2012 the original author or authors.
|
* Copyright 2002-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -26,6 +26,7 @@ import static org.junit.Assert.*;
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
* @author Chris Shepperd
|
* @author Chris Shepperd
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public class ExceptionDepthComparatorTests {
|
public class ExceptionDepthComparatorTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ import static org.springframework.util.ReflectionUtils.*;
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
* @author Sam Brannen
|
* @author Sam Brannen
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
public class GenericTypeResolverTests {
|
public class GenericTypeResolverTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -160,7 +161,7 @@ public class GenericTypeResolverTests {
|
||||||
MethodParameter methodParameter = MethodParameter.forMethodOrConstructor(
|
MethodParameter methodParameter = MethodParameter.forMethodOrConstructor(
|
||||||
WithArrayBase.class.getDeclaredMethod("array", Object[].class), 0);
|
WithArrayBase.class.getDeclaredMethod("array", Object[].class), 0);
|
||||||
Class<?> resolved = GenericTypeResolver.resolveParameterType(methodParameter, WithArray.class);
|
Class<?> resolved = GenericTypeResolver.resolveParameterType(methodParameter, WithArray.class);
|
||||||
assertThat(resolved, equalTo((Class) Object[].class));
|
assertThat(resolved, equalTo((Class<?>) Object[].class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -168,7 +169,7 @@ public class GenericTypeResolverTests {
|
||||||
// SPR-11044
|
// SPR-11044
|
||||||
Class<?> resolved = GenericTypeResolver.resolveReturnType(
|
Class<?> resolved = GenericTypeResolver.resolveReturnType(
|
||||||
WithArrayBase.class.getDeclaredMethod("array", Object[].class), WithArray.class);
|
WithArrayBase.class.getDeclaredMethod("array", Object[].class), WithArray.class);
|
||||||
assertThat(resolved, equalTo((Class) Object[].class));
|
assertThat(resolved, equalTo((Class<?>) Object[].class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -214,7 +215,6 @@ public class GenericTypeResolverTests {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
public MyInterfaceType raw() {
|
public MyInterfaceType raw() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2014 the original author or authors.
|
* Copyright 2002-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -343,7 +343,7 @@ public class CollectionToCollectionConverterTests {
|
||||||
|
|
||||||
public List<String> strings;
|
public List<String> strings;
|
||||||
|
|
||||||
public List list = Collections.emptyList();
|
public List<?> list = Collections.emptyList();
|
||||||
|
|
||||||
public Collection<?> wildcardCollection = Collections.emptyList();
|
public Collection<?> wildcardCollection = Collections.emptyList();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2014 the original author or authors.
|
* Copyright 2002-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -278,6 +278,7 @@ public class MapToMapConverterTests {
|
||||||
|
|
||||||
public MultiValueMap<String, String> multiValueMapTarget;
|
public MultiValueMap<String, String> multiValueMapTarget;
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public Map notGenericMapSource;
|
public Map notGenericMapSource;
|
||||||
|
|
||||||
public EnumMap<MyEnum, Integer> enumMap;
|
public EnumMap<MyEnum, Integer> enumMap;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2012 the original author or authors.
|
* Copyright 2002-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -30,6 +30,7 @@ import org.springframework.util.ObjectUtils;
|
||||||
/**
|
/**
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
public class ToStringCreatorTests extends TestCase {
|
public class ToStringCreatorTests extends TestCase {
|
||||||
|
|
||||||
private SomeObject s1, s2, s3;
|
private SomeObject s1, s2, s3;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2007 the original author or authors.
|
* Copyright 2002-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -17,29 +17,27 @@ package org.springframework.core.type;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Ramnivas Laddad
|
* @author Ramnivas Laddad
|
||||||
*
|
* @author Sam Brannen
|
||||||
*/
|
*/
|
||||||
public class ClassloadingAssertions {
|
abstract class ClassloadingAssertions {
|
||||||
public static boolean isClassLoaded(String className) {
|
|
||||||
|
private static boolean isClassLoaded(String className) {
|
||||||
ClassLoader cl = ClassUtils.getDefaultClassLoader();
|
ClassLoader cl = ClassUtils.getDefaultClassLoader();
|
||||||
Method findLoadeClassMethod = ReflectionUtils.findMethod(cl.getClass(), "findLoadedClass", new Class[] { String.class });
|
Method findLoadeClassMethod = ReflectionUtils.findMethod(cl.getClass(), "findLoadedClass", new Class[] { String.class });
|
||||||
findLoadeClassMethod.setAccessible(true);
|
ReflectionUtils.makeAccessible(findLoadeClassMethod);
|
||||||
Class loadedClass = (Class)ReflectionUtils.invokeMethod(findLoadeClassMethod, cl, new Object[]{className});
|
Class<?> loadedClass = (Class<?>) ReflectionUtils.invokeMethod(findLoadeClassMethod, cl, new Object[] { className });
|
||||||
return loadedClass != null;
|
return loadedClass != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void assertClassLoaded(String className) {
|
public static void assertClassNotLoaded(String className) {
|
||||||
|
assertFalse("Class [" + className + "] should not have been loaded", isClassLoaded(className));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void assertClassNotLoaded(String className) {
|
|
||||||
TestCase.assertFalse("Class shouldn't have been loaded", isClassLoaded(className));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2013 the original author or authors.
|
* Copyright 2002-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -18,29 +18,35 @@ package org.springframework.util;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.springframework.tests.sample.objects.TestObject;
|
import org.springframework.tests.sample.objects.TestObject;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rob Harrop
|
* @author Rob Harrop
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
*/
|
*/
|
||||||
public class AutoPopulatingListTests extends TestCase {
|
public class AutoPopulatingListTests {
|
||||||
|
|
||||||
public void testWithClass() throws Exception {
|
@Test
|
||||||
|
public void withClass() throws Exception {
|
||||||
doTestWithClass(new AutoPopulatingList<Object>(TestObject.class));
|
doTestWithClass(new AutoPopulatingList<Object>(TestObject.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWithClassAndUserSuppliedBackingList() throws Exception {
|
@Test
|
||||||
|
public void withClassAndUserSuppliedBackingList() throws Exception {
|
||||||
doTestWithClass(new AutoPopulatingList<Object>(new LinkedList<Object>(), TestObject.class));
|
doTestWithClass(new AutoPopulatingList<Object>(new LinkedList<Object>(), TestObject.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWithElementFactory() throws Exception {
|
@Test
|
||||||
|
public void withElementFactory() throws Exception {
|
||||||
doTestWithElementFactory(new AutoPopulatingList<Object>(new MockElementFactory()));
|
doTestWithElementFactory(new AutoPopulatingList<Object>(new MockElementFactory()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWithElementFactoryAndUserSuppliedBackingList() throws Exception {
|
@Test
|
||||||
|
public void withElementFactoryAndUserSuppliedBackingList() throws Exception {
|
||||||
doTestWithElementFactory(new AutoPopulatingList<Object>(new LinkedList<Object>(), new MockElementFactory()));
|
doTestWithElementFactory(new AutoPopulatingList<Object>(new LinkedList<Object>(), new MockElementFactory()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,13 +82,14 @@ public class AutoPopulatingListTests extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSerialization() throws Exception {
|
@Test
|
||||||
|
public void serialization() throws Exception {
|
||||||
AutoPopulatingList<?> list = new AutoPopulatingList<Object>(TestObject.class);
|
AutoPopulatingList<?> list = new AutoPopulatingList<Object>(TestObject.class);
|
||||||
assertEquals(list, SerializationTestUtils.serializeAndDeserialize(list));
|
assertEquals(list, SerializationTestUtils.serializeAndDeserialize(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class MockElementFactory implements AutoPopulatingList.ElementFactory {
|
private static class MockElementFactory implements AutoPopulatingList.ElementFactory<Object> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object createElement(int index) {
|
public Object createElement(int index) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2013 the original author or authors.
|
* Copyright 2002-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -44,6 +44,7 @@ import static org.junit.Assert.*;
|
||||||
* @author Rob Harrop
|
* @author Rob Harrop
|
||||||
* @author Rick Evans
|
* @author Rick Evans
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
public class ClassUtilsTests {
|
public class ClassUtilsTests {
|
||||||
|
|
||||||
private ClassLoader classLoader = getClass().getClassLoader();
|
private ClassLoader classLoader = getClass().getClassLoader();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2012 the original author or authors.
|
* Copyright 2002-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -19,49 +19,62 @@ package org.springframework.util;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Alef Arendsen
|
* @author Alef Arendsen
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
|
* @author Sam Brannen
|
||||||
*/
|
*/
|
||||||
public class Log4jConfigurerTests extends TestCase {
|
public class Log4jConfigurerTests {
|
||||||
|
|
||||||
public void testInitLoggingWithClasspath() throws FileNotFoundException {
|
@Test
|
||||||
|
public void initLoggingWithClasspath() throws FileNotFoundException {
|
||||||
doTestInitLogging("classpath:org/springframework/util/testlog4j.properties", false);
|
doTestInitLogging("classpath:org/springframework/util/testlog4j.properties", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInitLoggingWithRelativeFilePath() throws FileNotFoundException {
|
@Test
|
||||||
|
public void initLoggingWithRelativeFilePath() throws FileNotFoundException {
|
||||||
doTestInitLogging("src/test/resources/org/springframework/util/testlog4j.properties", false);
|
doTestInitLogging("src/test/resources/org/springframework/util/testlog4j.properties", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInitLoggingWithAbsoluteFilePath() throws FileNotFoundException {
|
@Test
|
||||||
|
public void initLoggingWithAbsoluteFilePath() throws FileNotFoundException {
|
||||||
URL url = getClass().getResource("testlog4j.properties");
|
URL url = getClass().getResource("testlog4j.properties");
|
||||||
doTestInitLogging(url.toString(), false);
|
doTestInitLogging(url.toString(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInitLoggingWithClasspathAndRefreshInterval() throws FileNotFoundException {
|
@Test
|
||||||
|
public void initLoggingWithClasspathAndRefreshInterval() throws FileNotFoundException {
|
||||||
doTestInitLogging("classpath:org/springframework/util/testlog4j.properties", true);
|
doTestInitLogging("classpath:org/springframework/util/testlog4j.properties", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInitLoggingWithRelativeFilePathAndRefreshInterval() throws FileNotFoundException {
|
@Test
|
||||||
|
public void initLoggingWithRelativeFilePathAndRefreshInterval() throws FileNotFoundException {
|
||||||
doTestInitLogging("src/test/resources/org/springframework/util/testlog4j.properties", true);
|
doTestInitLogging("src/test/resources/org/springframework/util/testlog4j.properties", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* only works on Windows
|
@Test
|
||||||
public void testInitLoggingWithAbsoluteFilePathAndRefreshInterval() throws FileNotFoundException {
|
public void initLoggingWithAbsoluteFilePathAndRefreshInterval() throws FileNotFoundException {
|
||||||
URL url = getClass().getResource("testlog4j.properties");
|
URL url = getClass().getResource("testlog4j.properties");
|
||||||
doTestInitLogging(url.getFile(), true);
|
doTestInitLogging(url.getFile(), true);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
public void testInitLoggingWithFileUrlAndRefreshInterval() throws FileNotFoundException {
|
@Test
|
||||||
|
public void initLoggingWithFileUrlAndRefreshInterval() throws FileNotFoundException {
|
||||||
URL url = getClass().getResource("testlog4j.properties");
|
URL url = getClass().getResource("testlog4j.properties");
|
||||||
doTestInitLogging(url.toString(), true);
|
doTestInitLogging(url.toString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected = FileNotFoundException.class)
|
||||||
|
public void initLoggingWithRefreshIntervalAndFileNotFound() throws FileNotFoundException {
|
||||||
|
Log4jConfigurer.initLogging("test/org/springframework/util/bla.properties", 10);
|
||||||
|
}
|
||||||
|
|
||||||
private void doTestInitLogging(String location, boolean refreshInterval) throws FileNotFoundException {
|
private void doTestInitLogging(String location, boolean refreshInterval) throws FileNotFoundException {
|
||||||
if (refreshInterval) {
|
if (refreshInterval) {
|
||||||
Log4jConfigurer.initLogging(location, 10);
|
Log4jConfigurer.initLogging(location, 10);
|
||||||
|
|
@ -87,14 +100,5 @@ public class Log4jConfigurerTests extends TestCase {
|
||||||
assertTrue(MockLog4jAppender.closeCalled);
|
assertTrue(MockLog4jAppender.closeCalled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInitLoggingWithRefreshIntervalAndFileNotFound() throws FileNotFoundException {
|
|
||||||
try {
|
|
||||||
Log4jConfigurer.initLogging("test/org/springframework/util/bla.properties", 10);
|
|
||||||
fail("Exception should have been thrown, file does not exist!");
|
|
||||||
}
|
|
||||||
catch (FileNotFoundException ex) {
|
|
||||||
// OK
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2012 the original author or authors.
|
* Copyright 2002-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -27,36 +27,24 @@ import org.apache.log4j.spi.LoggingEvent;
|
||||||
*/
|
*/
|
||||||
public class MockLog4jAppender extends AppenderSkeleton {
|
public class MockLog4jAppender extends AppenderSkeleton {
|
||||||
|
|
||||||
public static final List loggingStrings = new ArrayList();
|
public static final List<String> loggingStrings = new ArrayList<String>();
|
||||||
|
|
||||||
public static boolean closeCalled = false;
|
public static boolean closeCalled = false;
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.apache.log4j.AppenderSkeleton#append(org.apache.log4j.spi.LoggingEvent)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void append(LoggingEvent evt) {
|
protected void append(LoggingEvent evt) {
|
||||||
//System.out.println("Adding " + evt.getMessage());
|
loggingStrings.add(evt.getMessage().toString());
|
||||||
loggingStrings.add(evt.getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.apache.log4j.Appender#close()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
closeCalled = true;
|
closeCalled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.apache.log4j.Appender#requiresLayout()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean requiresLayout() {
|
public boolean requiresLayout() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2014 the original author or authors.
|
* Copyright 2002-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -28,6 +28,7 @@ import static org.mockito.Mockito.*;
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
* @author Sebastien Deleuze
|
* @author Sebastien Deleuze
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public class ListenableFutureTaskTests {
|
public class ListenableFutureTaskTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2014 the original author or authors.
|
* Copyright 2002-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -29,10 +29,10 @@ import static org.junit.Assert.*;
|
||||||
import static org.mockito.Mockito.any;
|
import static org.mockito.Mockito.any;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mattias Severson
|
* @author Mattias Severson
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
public class SettableListenableFutureTests {
|
public class SettableListenableFutureTests {
|
||||||
|
|
||||||
private SettableListenableFuture<String> settableListenableFuture;
|
private SettableListenableFuture<String> settableListenableFuture;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2009 the original author or authors.
|
* Copyright 2002-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -13,26 +13,23 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.util.xml;
|
package org.springframework.util.xml;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import javax.xml.XMLConstants;
|
import javax.xml.XMLConstants;
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class SimpleNamespaceContextTests {
|
public class SimpleNamespaceContextTests {
|
||||||
|
|
||||||
private SimpleNamespaceContext context;
|
private final SimpleNamespaceContext context = new SimpleNamespaceContext() {{
|
||||||
|
bindNamespaceUri("prefix", "namespaceURI");
|
||||||
|
}};
|
||||||
|
|
||||||
@Before
|
|
||||||
public void createContext() throws Exception {
|
|
||||||
context = new SimpleNamespaceContext();
|
|
||||||
context.bindNamespaceUri("prefix", "namespaceURI");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getNamespaceURI() {
|
public void getNamespaceURI() {
|
||||||
|
|
@ -48,7 +45,6 @@ public class SimpleNamespaceContextTests {
|
||||||
context.getNamespaceURI(XMLConstants.XML_NS_PREFIX));
|
context.getNamespaceURI(XMLConstants.XML_NS_PREFIX));
|
||||||
assertEquals("Invalid namespaceURI for attribute prefix", XMLConstants.XMLNS_ATTRIBUTE_NS_URI,
|
assertEquals("Invalid namespaceURI for attribute prefix", XMLConstants.XMLNS_ATTRIBUTE_NS_URI,
|
||||||
context.getNamespaceURI(XMLConstants.XMLNS_ATTRIBUTE));
|
context.getNamespaceURI(XMLConstants.XMLNS_ATTRIBUTE));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -75,32 +71,32 @@ public class SimpleNamespaceContextTests {
|
||||||
public void multiplePrefixes() {
|
public void multiplePrefixes() {
|
||||||
context.bindNamespaceUri("prefix1", "namespace");
|
context.bindNamespaceUri("prefix1", "namespace");
|
||||||
context.bindNamespaceUri("prefix2", "namespace");
|
context.bindNamespaceUri("prefix2", "namespace");
|
||||||
Iterator iterator = context.getPrefixes("namespace");
|
Iterator<String> iterator = context.getPrefixes("namespace");
|
||||||
assertNotNull("getPrefixes returns null", iterator);
|
assertNotNull("getPrefixes returns null", iterator);
|
||||||
assertTrue("iterator is empty", iterator.hasNext());
|
assertTrue("iterator is empty", iterator.hasNext());
|
||||||
String result = (String) iterator.next();
|
String result = iterator.next();
|
||||||
assertTrue("Invalid prefix", result.equals("prefix1") || result.equals("prefix2"));
|
assertTrue("Invalid prefix", result.equals("prefix1") || result.equals("prefix2"));
|
||||||
assertTrue("iterator is empty", iterator.hasNext());
|
assertTrue("iterator is empty", iterator.hasNext());
|
||||||
result = (String) iterator.next();
|
result = iterator.next();
|
||||||
assertTrue("Invalid prefix", result.equals("prefix1") || result.equals("prefix2"));
|
assertTrue("Invalid prefix", result.equals("prefix1") || result.equals("prefix2"));
|
||||||
assertFalse("iterator contains more than two values", iterator.hasNext());
|
assertFalse("iterator contains more than two values", iterator.hasNext());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertPrefixes(String namespaceUri, String prefix) {
|
private void assertPrefixes(String namespaceUri, String prefix) {
|
||||||
Iterator iterator = context.getPrefixes(namespaceUri);
|
Iterator<String> iterator = context.getPrefixes(namespaceUri);
|
||||||
assertNotNull("getPrefixes returns null", iterator);
|
assertNotNull("getPrefixes returns null", iterator);
|
||||||
assertTrue("iterator is empty", iterator.hasNext());
|
assertTrue("iterator is empty", iterator.hasNext());
|
||||||
String result = (String) iterator.next();
|
String result = iterator.next();
|
||||||
assertEquals("Invalid prefix", prefix, result);
|
assertEquals("Invalid prefix", prefix, result);
|
||||||
assertFalse("iterator contains multiple values", iterator.hasNext());
|
assertFalse("iterator contains multiple values", iterator.hasNext());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getBoundPrefixes() throws Exception {
|
public void getBoundPrefixes() throws Exception {
|
||||||
Iterator iterator = context.getBoundPrefixes();
|
Iterator<String> iterator = context.getBoundPrefixes();
|
||||||
assertNotNull("getPrefixes returns null", iterator);
|
assertNotNull("getPrefixes returns null", iterator);
|
||||||
assertTrue("iterator is empty", iterator.hasNext());
|
assertTrue("iterator is empty", iterator.hasNext());
|
||||||
String result = (String) iterator.next();
|
String result = iterator.next();
|
||||||
assertEquals("Invalid prefix", "prefix", result);
|
assertEquals("Invalid prefix", "prefix", result);
|
||||||
assertFalse("iterator contains multiple values", iterator.hasNext());
|
assertFalse("iterator contains multiple values", iterator.hasNext());
|
||||||
}
|
}
|
||||||
|
|
@ -115,8 +111,6 @@ public class SimpleNamespaceContextTests {
|
||||||
public void removeBinding() throws Exception {
|
public void removeBinding() throws Exception {
|
||||||
context.removeBinding("prefix");
|
context.removeBinding("prefix");
|
||||||
assertNull("Invalid prefix for unbound namespace", context.getPrefix("prefix"));
|
assertNull("Invalid prefix for unbound namespace", context.getPrefix("prefix"));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue