You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2013/10/30 21:21:46 UTC
svn commit: r1537278 -
/commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/locale/LocaleBeanificationTestCase.java
Author: oheger
Date: Wed Oct 30 20:21:46 2013
New Revision: 1537278
URL: http://svn.apache.org/r1537278
Log:
Fixed raw types warnings in test class.
Modified:
commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/locale/LocaleBeanificationTestCase.java
Modified: commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/locale/LocaleBeanificationTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/locale/LocaleBeanificationTestCase.java?rev=1537278&r1=1537277&r2=1537278&view=diff
==============================================================================
--- commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/locale/LocaleBeanificationTestCase.java (original)
+++ commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/locale/LocaleBeanificationTestCase.java Wed Oct 30 20:21:46 2013
@@ -17,24 +17,23 @@
package org.apache.commons.beanutils.locale;
-import java.lang.ref.WeakReference;
import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
import java.util.Locale;
import java.util.Map;
import java.util.WeakHashMap;
-import junit.framework.TestCase;
import junit.framework.Test;
+import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.apache.commons.logging.LogFactory;
-
import org.apache.commons.beanutils.BeanUtilsTestCase;
import org.apache.commons.beanutils.ContextClassLoaderLocal;
-import org.apache.commons.beanutils.PrimitiveBean;
-import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.ConversionException;
+import org.apache.commons.beanutils.ConvertUtils;
+import org.apache.commons.beanutils.PrimitiveBean;
import org.apache.commons.beanutils.locale.converters.LongLocaleConverter;
+import org.apache.commons.logging.LogFactory;
/**
* <p>
@@ -144,11 +143,11 @@ public class LocaleBeanificationTestCase
// many thanks to Juozas Baliuka for suggesting this methodology
TestClassLoader loader = new TestClassLoader();
- ReferenceQueue<?> queue = new ReferenceQueue<Object>();
- WeakReference loaderReference = new WeakReference(loader, queue);
+ ReferenceQueue<Object> queue = new ReferenceQueue<Object>();
+ WeakReference<ClassLoader> loaderReference = new WeakReference<ClassLoader>(loader, queue);
Integer test = new Integer(1);
- WeakReference testReference = new WeakReference(test, queue);
+ WeakReference<Integer> testReference = new WeakReference<Integer>(test, queue);
//Map map = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.HARD, true);
Map<TestClassLoader, Integer> map = new WeakHashMap<TestClassLoader, Integer>();
map.put(loader, test);
@@ -224,8 +223,8 @@ public class LocaleBeanificationTestCase
thread.start();
thread.join();
- WeakReference beanUtilsReference = new WeakReference(thread.beanUtils);
- WeakReference convertUtilsReference = new WeakReference(thread.convertUtils);
+ WeakReference<LocaleBeanUtilsBean> beanUtilsReference = new WeakReference<LocaleBeanUtilsBean>(thread.beanUtils);
+ WeakReference<LocaleConvertUtilsBean> convertUtilsReference = new WeakReference<LocaleConvertUtilsBean>(thread.convertUtils);
assertNotNull("Weak reference released early (1)", loaderReference.get());
assertNotNull("Weak reference released early (2)", beanUtilsReference.get());
@@ -314,9 +313,9 @@ public class LocaleBeanificationTestCase
class CCLLTesterThread extends Thread {
private final Signal signal;
- private final ContextClassLoaderLocal ccll;
+ private final ContextClassLoaderLocal<Integer> ccll;
- CCLLTesterThread(Signal signal, ContextClassLoaderLocal ccll) {
+ CCLLTesterThread(Signal signal, ContextClassLoaderLocal<Integer> ccll) {
this.signal = signal;
this.ccll = ccll;
}
@@ -334,8 +333,8 @@ public class LocaleBeanificationTestCase
}
}
- ContextClassLoaderLocal ccll = new ContextClassLoaderLocal();
- ccll.set(new Integer(1776));
+ ContextClassLoaderLocal<Integer> ccll = new ContextClassLoaderLocal<Integer>();
+ ccll.set(1776);
assertEquals("Start thread sets value", new Integer(1776), ccll.get());
Signal signal = new Signal();
@@ -369,11 +368,11 @@ public class LocaleBeanificationTestCase
try {
signal.setSignal(3);
LocaleConvertUtils.register(new LocaleConverter() {
- public Object convert(Class type, Object value) {
- return new Integer(9);
+ public <T> T convert(Class<T> type, Object value) {
+ return ConvertUtils.primitiveToWrapper(type).cast(9);
}
- public Object convert(Class type, Object value, String pattern) {
- return new Integer(9);
+ public <T> T convert(Class<T> type, Object value, String pattern) {
+ return ConvertUtils.primitiveToWrapper(type).cast(9);
}
}, Integer.TYPE, Locale.getDefault());
LocaleBeanUtils.setProperty(bean, "int", "1");
@@ -394,11 +393,11 @@ public class LocaleBeanificationTestCase
assertEquals("Wrong property value (1)", 1, bean.getInt());
LocaleConvertUtils.register(new LocaleConverter() {
- public Object convert(Class type, Object value) {
- return new Integer(5);
+ public <T> T convert(Class<T> type, Object value) {
+ return ConvertUtils.primitiveToWrapper(type).cast(5);
}
- public Object convert(Class type, Object value, String pattern) {
- return new Integer(5);
+ public <T> T convert(Class<T> type, Object value, String pattern) {
+ return ConvertUtils.primitiveToWrapper(type).cast(5);
}
}, Integer.TYPE, Locale.getDefault());
LocaleBeanUtils.setProperty(bean, "int", "1");
@@ -467,7 +466,7 @@ public class LocaleBeanificationTestCase
/** Tests whether the unset method works*/
public void testContextClassLoaderUnset() throws Exception {
LocaleBeanUtilsBean beanOne = new LocaleBeanUtilsBean();
- ContextClassLoaderLocal ccll = new ContextClassLoaderLocal();
+ ContextClassLoaderLocal<LocaleBeanUtilsBean> ccll = new ContextClassLoaderLocal<LocaleBeanUtilsBean>();
ccll.set(beanOne);
assertEquals("Start thread gets right instance", beanOne, ccll.get());
ccll.unset();