提交 6c14eaad 编写于 作者: P Phillip Webb 提交者: Chris Beams

Fix [cast] compiler warnings

上级 b0986049
......@@ -700,7 +700,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
// 1 primitive arg, and one candidate...
for (int i = 0; i < this.argumentTypes.length; i++) {
if (isUnbound(i) && this.argumentTypes[i].isPrimitive()) {
bindParameterName(i, (String) varNames.get(0));
bindParameterName(i, varNames.get(0));
break;
}
}
......
......@@ -77,7 +77,7 @@ public class AspectJAwareAdvisorAutoProxyCreator extends AbstractAdvisorAutoProx
// sort it
List<PartiallyComparableAdvisorHolder> sorted =
(List<PartiallyComparableAdvisorHolder>) PartialOrder.sort(partiallyComparableAdvisors);
PartialOrder.sort(partiallyComparableAdvisors);
if (sorted == null) {
// TODO: work harder to give a better error message here.
throw new IllegalArgumentException("Advice precedence circularity error");
......
......@@ -386,7 +386,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
),
CannotBeUnlocked.class);
assertTrue(proxy instanceof Lockable);
Lockable lockable = (Lockable) proxy;
Lockable lockable = proxy;
assertTrue("Already locked", lockable.locked());
lockable.lock();
assertTrue("Real target ignores locking", lockable.locked());
......
......@@ -114,7 +114,7 @@ public abstract aspect AbstractMethodMockingControl percflow(mockStaticsTestMeth
if (responseType == CallResponse.return_) {
return call.returnValue(lastSig, args);
} else if(responseType == CallResponse.throw_) {
return (RuntimeException)call.throwException(lastSig, args);
return call.throwException(lastSig, args);
} else if(responseType == CallResponse.nothing) {
// do nothing
}
......
......@@ -495,7 +495,7 @@ class PropertyDescriptorUtils {
// copy all attributes (emulating behavior of private FeatureDescriptor#addTable)
Enumeration<String> keys = source.attributeNames();
while (keys.hasMoreElements()) {
String key = (String)keys.nextElement();
String key = keys.nextElement();
target.setValue(key, source.getValue(key));
}
......
......@@ -197,7 +197,7 @@ public class CustomEditorConfigurer implements BeanFactoryPostProcessor, BeanCla
else if (value instanceof String) {
Class editorClass = ClassUtils.forName((String) value, this.beanClassLoader);
Assert.isAssignable(PropertyEditor.class, editorClass);
beanFactory.registerCustomEditor(requiredType, (Class<? extends PropertyEditor>) editorClass);
beanFactory.registerCustomEditor(requiredType, editorClass);
}
else {
throw new IllegalArgumentException("Mapped value [" + value + "] for custom editor key [" +
......
......@@ -995,15 +995,15 @@ public final class BeanWrapperTests {
bw.setPropertyValues(pvs);
assertEquals(tb5, bean.getArray()[0]);
assertEquals(tb4, bean.getArray()[1]);
assertEquals(tb3, ((TestBean) bean.getList().get(0)));
assertEquals(tb2, ((TestBean) bean.getList().get(1)));
assertEquals(tb0, ((TestBean) bean.getList().get(2)));
assertEquals(null, ((TestBean) bean.getList().get(3)));
assertEquals(tb1, ((TestBean) bean.getList().get(4)));
assertEquals(tb1, ((TestBean) bean.getMap().get("key1")));
assertEquals(tb0, ((TestBean) bean.getMap().get("key2")));
assertEquals(tb4, ((TestBean) bean.getMap().get("key5")));
assertEquals(tb5, ((TestBean) bean.getMap().get("key9")));
assertEquals(tb3, (bean.getList().get(0)));
assertEquals(tb2, (bean.getList().get(1)));
assertEquals(tb0, (bean.getList().get(2)));
assertEquals(null, (bean.getList().get(3)));
assertEquals(tb1, (bean.getList().get(4)));
assertEquals(tb1, (bean.getMap().get("key1")));
assertEquals(tb0, (bean.getMap().get("key2")));
assertEquals(tb4, (bean.getMap().get("key5")));
assertEquals(tb5, (bean.getMap().get("key9")));
assertEquals(tb5, bw.getPropertyValue("array[0]"));
assertEquals(tb4, bw.getPropertyValue("array[1]"));
assertEquals(tb3, bw.getPropertyValue("list[0]"));
......
......@@ -497,7 +497,7 @@ public class DefaultListableBeanFactoryTests {
int count = (new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p, PREFIX);
assertTrue("2 beans registered, not " + count, count == 2);
TestBean kerry = (TestBean) lbf.getBean("kerry", TestBean.class);
TestBean kerry = lbf.getBean("kerry", TestBean.class);
assertTrue("Kerry name is Kerry", "Kerry".equals(kerry.getName()));
ITestBean spouse = kerry.getSpouse();
assertTrue("Kerry spouse is non null", spouse != null);
......@@ -516,7 +516,7 @@ public class DefaultListableBeanFactoryTests {
assertTrue("1 beans registered, not " + count, count == 1);
assertEquals(1, lbf.getBeanDefinitionCount());
TestBean tb = (TestBean) lbf.getBean("tb", TestBean.class);
TestBean tb = lbf.getBean("tb", TestBean.class);
assertEquals("my.value", tb.getSomeMap().get("my.key"));
}
......
......@@ -113,7 +113,7 @@ public class ObjectFactoryCreatingFactoryBeanTests {
factory.setTargetBeanName(targetBeanName);
factory.setBeanFactory(beanFactory);
factory.afterPropertiesSet();
ObjectFactory<?> objectFactory = (ObjectFactory<?>) factory.getObject();
ObjectFactory<?> objectFactory = factory.getObject();
Object actualSingleton = objectFactory.getObject();
assertSame(expectedSingleton, actualSingleton);
......
......@@ -42,7 +42,7 @@ public final class PropertiesFactoryBeanTests {
PropertiesFactoryBean pfb = new PropertiesFactoryBean();
pfb.setLocation(TEST_PROPS);
pfb.afterPropertiesSet();
Properties props = (Properties) pfb.getObject();
Properties props = pfb.getObject();
assertEquals("99", props.getProperty("tb.array[0].age"));
}
......@@ -51,7 +51,7 @@ public final class PropertiesFactoryBeanTests {
PropertiesFactoryBean pfb = new PropertiesFactoryBean();
pfb.setLocation(TEST_PROPS_XML);
pfb.afterPropertiesSet();
Properties props = (Properties) pfb.getObject();
Properties props = pfb.getObject();
assertEquals("99", props.getProperty("tb.array[0].age"));
}
......@@ -62,7 +62,7 @@ public final class PropertiesFactoryBeanTests {
localProps.setProperty("key2", "value2");
pfb.setProperties(localProps);
pfb.afterPropertiesSet();
Properties props = (Properties) pfb.getObject();
Properties props = pfb.getObject();
assertEquals("value2", props.getProperty("key2"));
}
......@@ -75,7 +75,7 @@ public final class PropertiesFactoryBeanTests {
localProps.setProperty("tb.array[0].age", "0");
pfb.setProperties(localProps);
pfb.afterPropertiesSet();
Properties props = (Properties) pfb.getObject();
Properties props = pfb.getObject();
assertEquals("99", props.getProperty("tb.array[0].age"));
assertEquals("value2", props.getProperty("key2"));
}
......@@ -100,7 +100,7 @@ public final class PropertiesFactoryBeanTests {
pfb.setPropertiesArray(new Properties[] {props1, props2, props3});
pfb.afterPropertiesSet();
Properties props = (Properties) pfb.getObject();
Properties props = pfb.getObject();
assertEquals("99", props.getProperty("tb.array[0].age"));
assertEquals("value2", props.getProperty("key2"));
assertEquals("framework", props.getProperty("spring"));
......@@ -119,7 +119,7 @@ public final class PropertiesFactoryBeanTests {
pfb.setProperties(localProps);
pfb.setLocalOverride(true);
pfb.afterPropertiesSet();
Properties props = (Properties) pfb.getObject();
Properties props = pfb.getObject();
assertEquals("0", props.getProperty("tb.array[0].age"));
assertEquals("value2", props.getProperty("key2"));
}
......@@ -133,10 +133,10 @@ public final class PropertiesFactoryBeanTests {
localProps.setProperty("key2", "value2");
pfb.setProperties(localProps);
pfb.afterPropertiesSet();
Properties props = (Properties) pfb.getObject();
Properties props = pfb.getObject();
assertEquals("99", props.getProperty("tb.array[0].age"));
assertEquals("value2", props.getProperty("key2"));
Properties newProps = (Properties) pfb.getObject();
Properties newProps = pfb.getObject();
assertTrue(props != newProps);
assertEquals("99", newProps.getProperty("tb.array[0].age"));
assertEquals("value2", newProps.getProperty("key2"));
......
......@@ -33,7 +33,7 @@ public class ManagedListTests extends TestCase {
ManagedList child = new ManagedList();
child.add("three");
child.setMergeEnabled(true);
List mergedList = (List) child.merge(parent);
List mergedList = child.merge(parent);
assertEquals("merge() obviously did not work.", 3, mergedList.size());
}
......@@ -72,7 +72,7 @@ public class ManagedListTests extends TestCase {
parent.add("two");
ManagedList child = new ManagedList();
child.setMergeEnabled(true);
List mergedList = (List) child.merge(parent);
List mergedList = child.merge(parent);
assertEquals("merge() obviously did not work.", 2, mergedList.size());
}
......@@ -84,7 +84,7 @@ public class ManagedListTests extends TestCase {
ManagedList child = new ManagedList();
child.add("one");
child.setMergeEnabled(true);
List mergedList = (List) child.merge(parent);
List mergedList = child.merge(parent);
assertEquals("merge() obviously did not work.", 3, mergedList.size());
}
......
......@@ -33,7 +33,7 @@ public class ManagedSetTests extends TestCase {
ManagedSet child = new ManagedSet();
child.add("three");
child.setMergeEnabled(true);
Set mergedSet = (Set) child.merge(parent);
Set mergedSet = child.merge(parent);
assertEquals("merge() obviously did not work.", 3, mergedSet.size());
}
......@@ -72,7 +72,7 @@ public class ManagedSetTests extends TestCase {
parent.add("two");
ManagedSet child = new ManagedSet();
child.setMergeEnabled(true);
Set mergedSet = (Set) child.merge(parent);
Set mergedSet = child.merge(parent);
assertEquals("merge() obviously did not work.", 2, mergedSet.size());
}
......@@ -84,7 +84,7 @@ public class ManagedSetTests extends TestCase {
ManagedSet child = new ManagedSet();
child.add("one");
child.setMergeEnabled(true);
Set mergedSet = (Set) child.merge(parent);
Set mergedSet = child.merge(parent);
assertEquals("merge() obviously did not work.", 2, mergedSet.size());
}
......
......@@ -118,7 +118,7 @@ public class QuartzSupportTests {
}
mijdfb.setTargetMethod("doSomething");
mijdfb.afterPropertiesSet();
JobDetail jobDetail1 = (JobDetail) mijdfb.getObject();
JobDetail jobDetail1 = mijdfb.getObject();
SimpleTriggerBean trigger1 = new SimpleTriggerBean();
trigger1.setBeanName("myTrigger1");
......@@ -210,7 +210,7 @@ public class QuartzSupportTests {
mijdfb.setTargetObject(task1);
mijdfb.setTargetMethod("doSomething");
mijdfb.afterPropertiesSet();
JobDetail jobDetail1 = (JobDetail) mijdfb.getObject();
JobDetail jobDetail1 = mijdfb.getObject();
SimpleTriggerBean trigger1 = new SimpleTriggerBean();
trigger1.setBeanName("myTrigger1");
......@@ -304,7 +304,7 @@ public class QuartzSupportTests {
mijdfb.setTargetObject(task1);
mijdfb.setTargetMethod("doSomething");
mijdfb.afterPropertiesSet();
JobDetail jobDetail1 = (JobDetail) mijdfb.getObject();
JobDetail jobDetail1 = mijdfb.getObject();
SimpleTriggerBean trigger1 = new SimpleTriggerBean();
trigger1.setBeanName("myTrigger1");
......@@ -446,7 +446,7 @@ public class QuartzSupportTests {
mijdfb.setTargetObject(task1);
mijdfb.setTargetMethod("doWait");
mijdfb.afterPropertiesSet();
JobDetail jobDetail1 = (JobDetail) mijdfb.getObject();
JobDetail jobDetail1 = mijdfb.getObject();
SimpleTriggerBean trigger0 = new SimpleTriggerBean();
trigger0.setBeanName("myTrigger1");
......@@ -532,7 +532,7 @@ public class QuartzSupportTests {
mijdfb.setTargetObject(task1);
mijdfb.setTargetMethod("doSomething");
mijdfb.afterPropertiesSet();
JobDetail jobDetail1 = (JobDetail) mijdfb.getObject();
JobDetail jobDetail1 = mijdfb.getObject();
SimpleTrigger trigger1 = new SimpleTrigger();
trigger1.setName("myTrigger1");
......@@ -618,7 +618,7 @@ public class QuartzSupportTests {
try {
schedulerFactoryBean.afterPropertiesSet();
schedulerFactoryBean.start();
Scheduler returnedScheduler = (Scheduler) schedulerFactoryBean.getObject();
Scheduler returnedScheduler = schedulerFactoryBean.getObject();
assertEquals(tb, returnedScheduler.getContext().get("testBean"));
assertEquals(ac, returnedScheduler.getContext().get("appCtx"));
}
......@@ -659,7 +659,7 @@ public class QuartzSupportTests {
mijdfb.setTargetMethod("doSomething");
mijdfb.setJobListenerNames(names);
mijdfb.afterPropertiesSet();
JobDetail jobDetail = (JobDetail) mijdfb.getObject();
JobDetail jobDetail = mijdfb.getObject();
List result = Arrays.asList(jobDetail.getJobListenerNames());
assertEquals(Arrays.asList(names), result);
}
......
......@@ -93,7 +93,7 @@ class WebSphereClassLoaderAdapter {
public ClassLoader getThrowawayClassLoader() {
try {
ClassLoader loader = (ClassLoader) cloneConstructor.newInstance(getClassLoader());
ClassLoader loader = cloneConstructor.newInstance(getClassLoader());
// clear out the transformers (copied as well)
List<?> list = (List<?>) transformerList.get(loader);
list.clear();
......
......@@ -186,7 +186,7 @@ public abstract class AbstractErrors implements Errors, Serializable {
public FieldError getFieldError(String field) {
List<FieldError> fieldErrors = getFieldErrors(field);
return (!fieldErrors.isEmpty() ? (FieldError) fieldErrors.get(0) : null);
return (!fieldErrors.isEmpty() ? fieldErrors.get(0) : null);
}
......
......@@ -137,7 +137,7 @@ public final class AfterReturningAdviceBindingTests {
@Test
public void testReturningBeanArray() {
this.testBeanTarget.setSpouse(new TestBean());
ITestBean[] spouses = (ITestBean[]) this.testBeanTarget.getSpouses();
ITestBean[] spouses = this.testBeanTarget.getSpouses();
mockCollaborator.testBeanArrayArg(spouses);
replay(mockCollaborator);
testBeanProxy.getSpouses();
......
......@@ -94,7 +94,7 @@ public abstract class AbstractApplicationContextTests extends AbstractListableBe
}
public void testGrandparentTypedDefinitionFound() throws Exception {
TestBean dad = (TestBean) applicationContext.getBean("father", TestBean.class);
TestBean dad = applicationContext.getBean("father", TestBean.class);
assertTrue("Dad has correct name", dad.getName().equals("Albert"));
}
......
......@@ -145,14 +145,14 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
ModelMBeanOperationInfo get = info.getOperation("getName");
assertNotNull("get operation should not be null", get);
assertEquals("get operation should have visibility of four",
(Integer) get.getDescriptor().getFieldValue("visibility"),
get.getDescriptor().getFieldValue("visibility"),
new Integer(4));
assertEquals("get operation should have role \"getter\"", "getter", get.getDescriptor().getFieldValue("role"));
ModelMBeanOperationInfo set = info.getOperation("setName");
assertNotNull("set operation should not be null", set);
assertEquals("set operation should have visibility of four",
(Integer) set.getDescriptor().getFieldValue("visibility"),
set.getDescriptor().getFieldValue("visibility"),
new Integer(4));
assertEquals("set operation should have role \"setter\"", "setter", set.getDescriptor().getFieldValue("role"));
}
......
......@@ -62,7 +62,7 @@ public class MBeanServerConnectionFactoryBeanTests extends AbstractMBeanServerTe
bean.afterPropertiesSet();
try {
MBeanServerConnection connection = (MBeanServerConnection) bean.getObject();
MBeanServerConnection connection = bean.getObject();
assertNotNull("Connection should not be null", connection);
// perform simple MBean count test
......@@ -100,7 +100,7 @@ public class MBeanServerConnectionFactoryBeanTests extends AbstractMBeanServerTe
bean.setConnectOnStartup(false);
bean.afterPropertiesSet();
MBeanServerConnection connection = (MBeanServerConnection) bean.getObject();
MBeanServerConnection connection = bean.getObject();
assertTrue(AopUtils.isAopProxy(connection));
JMXConnectorServer connector = null;
......@@ -122,7 +122,7 @@ public class MBeanServerConnectionFactoryBeanTests extends AbstractMBeanServerTe
bean.setConnectOnStartup(false);
bean.afterPropertiesSet();
MBeanServerConnection connection = (MBeanServerConnection) bean.getObject();
MBeanServerConnection connection = bean.getObject();
assertTrue(AopUtils.isAopProxy(connection));
bean.destroy();
}
......
......@@ -52,7 +52,7 @@ public class ScheduledTasksBeanDefinitionParserTests {
public void setup() {
this.context = new ClassPathXmlApplicationContext(
"scheduledTasksContext.xml", ScheduledTasksBeanDefinitionParserTests.class);
this.registrar = (ScheduledTaskRegistrar) this.context.getBeansOfType(
this.registrar = this.context.getBeansOfType(
ScheduledTaskRegistrar.class).values().iterator().next();
this.testBean = this.context.getBean("testBean");
}
......
......@@ -39,7 +39,7 @@ public class TimerSupportTests extends TestCase {
mittfb.setTargetObject(task1);
mittfb.setTargetMethod("doSomething");
mittfb.afterPropertiesSet();
final TimerTask timerTask1 = (TimerTask) mittfb.getObject();
final TimerTask timerTask1 = mittfb.getObject();
final TestRunnable timerTask2 = new TestRunnable();
......
......@@ -322,7 +322,7 @@ public abstract class GenericCollectionTypeResolver {
Type resolvedType = type;
if (type instanceof TypeVariable && typeVariableMap != null) {
Type mappedType = typeVariableMap.get((TypeVariable) type);
Type mappedType = typeVariableMap.get(type);
if (mappedType != null) {
resolvedType = mappedType;
}
......@@ -383,7 +383,7 @@ public abstract class GenericCollectionTypeResolver {
}
Type paramType = paramTypes[typeIndex];
if (paramType instanceof TypeVariable && typeVariableMap != null) {
Type mappedType = typeVariableMap.get((TypeVariable) paramType);
Type mappedType = typeVariableMap.get(paramType);
if (mappedType != null) {
paramType = mappedType;
}
......
......@@ -106,7 +106,7 @@ public class AnnotationAttributes extends LinkedHashMap<String, Object> {
@SuppressWarnings("unchecked")
public <T> Class<? extends T> getClass(String attributeName) {
return (Class<T>)doGet(attributeName, Class.class);
return doGet(attributeName, Class.class);
}
public Class<?>[] getClassArray(String attributeName) {
......
......@@ -71,8 +71,8 @@ public class CollectionToCollectionConverterTests {
@SuppressWarnings("unchecked")
List<String> result = (List<String>) conversionService.convert(list, sourceType, targetType);
assertFalse(list.equals(result));
assertEquals((Integer) 9, result.get(0));
assertEquals((Integer) 37, result.get(1));
assertEquals(9, result.get(0));
assertEquals(37, result.get(1));
}
public ArrayList<Integer> scalarListTarget;
......
......@@ -298,7 +298,7 @@ public class DefaultConversionTests {
@Test
public void testSpr7766() throws Exception {
ConverterRegistry registry = ((ConverterRegistry) conversionService);
ConverterRegistry registry = (conversionService);
registry.addConverter(new ColorConverter());
List<Color> colors = (List<Color>) conversionService.convert(new String[] { "ffffff", "#000000" }, TypeDescriptor.valueOf(String[].class), new TypeDescriptor(new MethodParameter(getClass().getMethod("handlerMethod", List.class), 0)));
assertEquals(2, colors.size());
......
......@@ -147,7 +147,7 @@ public class AnnotationMetadataTests {
assertThat(specialAttrs.getString("clazz"), is(String.class.getName()));
AnnotationAttributes nestedAnno = specialAttrs.getAnnotation("nestedAnno");
assertArrayEquals(new String[]{String.class.getName()}, (String[])nestedAnno.getStringArray("classArray"));
assertArrayEquals(new String[]{String.class.getName()}, nestedAnno.getStringArray("classArray"));
assertArrayEquals(new String[]{String.class.getName()}, nestedAnno.getStringArray("classArray"));
AnnotationAttributes[] nestedAnnoArray = specialAttrs.getAnnotationArray("nestedAnnoArray");
......
......@@ -1312,7 +1312,7 @@ public class EvaluationTests extends ExpressionTestCase {
e = parser.parseExpression("#wibble=#wibble+#wibble");
String s = e.getValue(ctx,String.class);
assertEquals("hello worldhello world",s);
assertEquals("hello worldhello world",(String)ctx.lookupVariable("wibble"));
assertEquals("hello worldhello world",ctx.lookupVariable("wibble"));
ctx.setVariable("wobble", 3);
e = parser.parseExpression("#wobble++");
......
......@@ -457,7 +457,7 @@ public class ParsingTests {
*/
public void parseCheck(String expression, String expectedStringFormOfAST) {
try {
SpelExpression e = (SpelExpression) parser.parseRaw(expression);
SpelExpression e = parser.parseRaw(expression);
if (e != null && !e.toStringAST().equals(expectedStringFormOfAST)) {
SpelUtilities.printAbstractSyntaxTree(System.err, e);
}
......
......@@ -70,7 +70,7 @@ public class BeanFactoryDataSourceLookup implements DataSourceLookup, BeanFactor
public DataSource getDataSource(String dataSourceName) throws DataSourceLookupFailureException {
Assert.state(this.beanFactory != null, "BeanFactory is required");
try {
return (DataSource) this.beanFactory.getBean(dataSourceName, DataSource.class);
return this.beanFactory.getBean(dataSourceName, DataSource.class);
}
catch (BeansException ex) {
throw new DataSourceLookupFailureException(
......
......@@ -953,7 +953,7 @@ public class SqlQueryTests extends AbstractJdbcTests {
public List findCustomers(List ids) {
Map params = new HashMap();
params.put("ids", ids);
return (List) executeByNamedParam(params);
return executeByNamedParam(params);
}
}
......@@ -1026,7 +1026,7 @@ public class SqlQueryTests extends AbstractJdbcTests {
public List findCustomers(Integer id) {
Map params = new HashMap();
params.put("id1", id);
return (List) executeByNamedParam(params);
return executeByNamedParam(params);
}
}
......@@ -1067,7 +1067,7 @@ public class SqlQueryTests extends AbstractJdbcTests {
public List findCustomers(Integer id1) {
Map params = new HashMap();
params.put("id1", id1);
return (List) executeByNamedParam(params);
return executeByNamedParam(params);
}
}
......
......@@ -198,7 +198,7 @@ public class SQLErrorCodesFactoryTests extends TestCase {
TestSQLErrorCodesFactory sf = new TestSQLErrorCodesFactory();
assertEquals(1, sf.getErrorCodes("Oracle").getCustomTranslations().length);
CustomSQLErrorCodesTranslation translation =
(CustomSQLErrorCodesTranslation) sf.getErrorCodes("Oracle").getCustomTranslations()[0];
sf.getErrorCodes("Oracle").getCustomTranslations()[0];
assertEquals(CustomErrorCodeException.class, translation.getExceptionClass());
assertEquals(1, translation.getErrorCodes().length);
}
......
......@@ -73,7 +73,7 @@ public class BeanFactoryDestinationResolver implements DestinationResolver, Bean
Assert.state(this.beanFactory != null, "BeanFactory is required");
try {
return (Destination) this.beanFactory.getBean(destinationName, Destination.class);
return this.beanFactory.getBean(destinationName, Destination.class);
}
catch (BeansException ex) {
throw new DestinationResolutionException(
......
......@@ -208,7 +208,7 @@ public abstract class HibernateAccessor implements InitializingBean, BeanFactory
if (this.beanFactory == null) {
throw new IllegalStateException("Cannot get entity interceptor via bean name if no bean factory set");
}
return (Interceptor) this.beanFactory.getBean((String) this.entityInterceptor, Interceptor.class);
return this.beanFactory.getBean((String) this.entityInterceptor, Interceptor.class);
}
return (Interceptor) this.entityInterceptor;
}
......
......@@ -228,8 +228,8 @@ public class OpenEntityManagerInViewTests extends TestCase {
replay(manager, factory);
final EntityManagerFactory factory2 = (EntityManagerFactory) createMock(EntityManagerFactory.class);
final EntityManager manager2 = (EntityManager) createMock(EntityManager.class);
final EntityManagerFactory factory2 = createMock(EntityManagerFactory.class);
final EntityManager manager2 = createMock(EntityManager.class);
expect(factory2.createEntityManager()).andReturn(manager2);
expect(manager2.isOpen()).andReturn(true);
......@@ -292,8 +292,8 @@ public class OpenEntityManagerInViewTests extends TestCase {
replay(manager, factory);
final EntityManagerFactory factory2 = (EntityManagerFactory) createMock(EntityManagerFactory.class);
final EntityManager manager2 = (EntityManager) createMock(EntityManager.class);
final EntityManagerFactory factory2 = createMock(EntityManagerFactory.class);
final EntityManager manager2 = createMock(EntityManager.class);
expect(factory2.createEntityManager()).andReturn(manager2);
expect(manager2.isOpen()).andReturn(true);
......
......@@ -256,7 +256,7 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT
public void testPublicPersistenceUnitSetterWithOverriding() {
EntityManagerFactory mockEmf2 =
(EntityManagerFactory) MockControl.createControl(EntityManagerFactory.class).getMock();
MockControl.createControl(EntityManagerFactory.class).getMock();
GenericApplicationContext gac = new GenericApplicationContext();
gac.getDefaultListableBeanFactory().registerSingleton("entityManagerFactory", mockEmf);
......@@ -274,7 +274,7 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT
public void testPublicPersistenceUnitSetterWithUnitIdentifiedThroughBeanName() {
EntityManagerFactory mockEmf2 =
(EntityManagerFactory) MockControl.createControl(EntityManagerFactory.class).getMock();
MockControl.createControl(EntityManagerFactory.class).getMock();
GenericApplicationContext gac = new GenericApplicationContext();
gac.getDefaultListableBeanFactory().registerSingleton("entityManagerFactory", mockEmf);
......@@ -329,7 +329,7 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT
@Ignore
public void ignoreTestPersistenceUnitsFromJndi() {
mockEmf.createEntityManager();
Object mockEm = (EntityManager) MockControl.createControl(EntityManager.class).getMock();
Object mockEm = MockControl.createControl(EntityManager.class).getMock();
emfMc.setReturnValue(mockEm, 1);
emfMc.replay();
......@@ -428,9 +428,9 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT
}
public void testPersistenceContextsFromJndi() {
Object mockEm = (EntityManager) MockControl.createControl(EntityManager.class).getMock();
Object mockEm2 = (EntityManager) MockControl.createControl(EntityManager.class).getMock();
Object mockEm3 = (EntityManager) MockControl.createControl(EntityManager.class).getMock();
Object mockEm = MockControl.createControl(EntityManager.class).getMock();
Object mockEm2 = MockControl.createControl(EntityManager.class).getMock();
Object mockEm3 = MockControl.createControl(EntityManager.class).getMock();
Map<String, String> persistenceContexts = new HashMap<String, String>();
persistenceContexts.put("", "pc1");
......@@ -467,9 +467,9 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT
}
public void testPersistenceContextsFromJndiWithDefaultUnit() {
Object mockEm = (EntityManager) MockControl.createControl(EntityManager.class).getMock();
Object mockEm2 = (EntityManager) MockControl.createControl(EntityManager.class).getMock();
Object mockEm3 = (EntityManager) MockControl.createControl(EntityManager.class).getMock();
Object mockEm = MockControl.createControl(EntityManager.class).getMock();
Object mockEm2 = MockControl.createControl(EntityManager.class).getMock();
Object mockEm3 = MockControl.createControl(EntityManager.class).getMock();
Map<String, String> persistenceContexts = new HashMap<String, String>();
persistenceContexts.put("System", "pc1");
......@@ -507,8 +507,8 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT
}
public void testSinglePersistenceContextFromJndi() {
Object mockEm = (EntityManager) MockControl.createControl(EntityManager.class).getMock();
Object mockEm2 = (EntityManager) MockControl.createControl(EntityManager.class).getMock();
Object mockEm = MockControl.createControl(EntityManager.class).getMock();
Object mockEm2 = MockControl.createControl(EntityManager.class).getMock();
Map<String, String> persistenceContexts = new HashMap<String, String>();
persistenceContexts.put("System", "pc1");
......
......@@ -61,7 +61,7 @@ public class SharedEntityManagerFactoryTests {
assertTrue(EntityManager.class.isAssignableFrom(proxyFactoryBean.getObjectType()));
assertTrue(proxyFactoryBean.isSingleton());
EntityManager proxy = (EntityManager) proxyFactoryBean.getObject();
EntityManager proxy = proxyFactoryBean.getObject();
assertSame(proxy, proxyFactoryBean.getObject());
assertFalse(proxy.contains(o));
......
......@@ -66,7 +66,7 @@ public class CastorUnmarshallerTests extends AbstractUnmarshallerTests {
protected void testFlight(Object o) {
Flight flight = (Flight) o;
assertNotNull("Flight is null", flight);
assertEquals("Number is invalid", 42L, (long) flight.getNumber());
assertEquals("Number is invalid", 42L, flight.getNumber());
}
@Override
......@@ -104,10 +104,10 @@ public class CastorUnmarshallerTests extends AbstractUnmarshallerTests {
assertEquals("Invalid amount of items", 2, order.getOrderItemCount());
OrderItem item = order.getOrderItem(0);
assertEquals("Invalid items", "1", item.getId());
assertEquals("Invalid items", 15, (int)item.getQuantity());
assertEquals("Invalid items", 15, item.getQuantity());
item = order.getOrderItem(1);
assertEquals("Invalid items", "3", item.getId());
assertEquals("Invalid items", 20, (int)item.getQuantity());
assertEquals("Invalid items", 20, item.getQuantity());
}
@Test
......
......@@ -127,7 +127,7 @@ public class DelegatingActionProxy extends Action {
protected Action getDelegateAction(ActionMapping mapping) throws BeansException {
WebApplicationContext wac = getWebApplicationContext(getServlet(), mapping.getModuleConfig());
String beanName = determineActionBeanName(mapping);
return (Action) wac.getBean(beanName, Action.class);
return wac.getBean(beanName, Action.class);
}
/**
......
......@@ -177,7 +177,7 @@ public class DelegatingRequestProcessor extends RequestProcessor {
if (!getWebApplicationContext().containsBean(beanName)) {
return null;
}
return (Action) getWebApplicationContext().getBean(beanName, Action.class);
return getWebApplicationContext().getBean(beanName, Action.class);
}
/**
......
......@@ -126,7 +126,7 @@ public class DelegatingTilesRequestProcessor extends TilesRequestProcessor {
if (!getWebApplicationContext().containsBean(beanName)) {
return null;
}
return (Action) getWebApplicationContext().getBean(beanName, Action.class);
return getWebApplicationContext().getBean(beanName, Action.class);
}
/**
......
......@@ -59,7 +59,7 @@ public class FlashAttributeResultMatchers {
return new ResultMatcher() {
@SuppressWarnings("unchecked")
public void match(MvcResult result) throws Exception {
assertEquals("Flash attribute", value, (T) result.getFlashMap().get(name));
assertEquals("Flash attribute", value, result.getFlashMap().get(name));
}
};
}
......
......@@ -269,7 +269,7 @@ public class MockPortletRequest implements PortletRequest {
public String getProperty(String key) {
Assert.notNull(key, "Property key must not be null");
List<String> list = this.properties.get(key);
return (list != null && list.size() > 0 ? (String) list.get(0) : null);
return (list != null && list.size() > 0 ? list.get(0) : null);
}
public Enumeration<String> getProperties(String key) {
......
......@@ -699,7 +699,7 @@ public class CciTemplateTests {
replay(connectionFactory, connection, interaction);
CciTemplate ct = new CciTemplate(connectionFactory);
Record tmpOutputRecord = (Record) ct.execute(interactionSpec,
Record tmpOutputRecord = ct.execute(interactionSpec,
inputOutputRecord);
assertNull(tmpOutputRecord);
......
......@@ -129,7 +129,7 @@ public class MappingJackson2HttpMessageConverter extends AbstractHttpMessageConv
@Override
public boolean canRead(Class<?> clazz, MediaType mediaType) {
return canRead((Type) clazz, null, mediaType);
return canRead(clazz, null, mediaType);
}
public boolean canRead(Type type, Class<?> contextClass, MediaType mediaType) {
......
......@@ -127,7 +127,7 @@ public class MappingJacksonHttpMessageConverter extends AbstractHttpMessageConve
@Override
public boolean canRead(Class<?> clazz, MediaType mediaType) {
return canRead((Type) clazz, null, mediaType);
return canRead(clazz, null, mediaType);
}
public boolean canRead(Type type, Class<?> contextClass, MediaType mediaType) {
......
......@@ -48,7 +48,7 @@ public class UnsatisfiedServletRequestParameterException extends ServletRequestB
public UnsatisfiedServletRequestParameterException(String[] paramConditions, Map actualParams) {
super("");
this.paramConditions = paramConditions;
this.actualParams = (Map<String, String[]>) actualParams;
this.actualParams = actualParams;
}
......
......@@ -55,7 +55,7 @@ public class HttpRequestHandlerServlet extends HttpServlet {
@Override
public void init() throws ServletException {
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
this.target = (HttpRequestHandler) wac.getBean(getServletName(), HttpRequestHandler.class);
this.target = wac.getBean(getServletName(), HttpRequestHandler.class);
}
......@@ -68,7 +68,7 @@ public class HttpRequestHandlerServlet extends HttpServlet {
this.target.handleRequest(request, response);
}
catch (HttpRequestMethodNotSupportedException ex) {
String[] supportedMethods = ((HttpRequestMethodNotSupportedException) ex).getSupportedMethods();
String[] supportedMethods = ex.getSupportedMethods();
if (supportedMethods != null) {
response.setHeader("Allow", StringUtils.arrayToDelimitedString(supportedMethods, ", "));
}
......
......@@ -126,7 +126,7 @@ public abstract class HtmlUtils {
char character = input.charAt(i);
if (characterEntityReferences.isMappedToReference(character)) {
escaped.append(HtmlCharacterEntityReferences.HEX_REFERENCE_START);
escaped.append(Integer.toString((int) character, 16));
escaped.append(Integer.toString(character, 16));
escaped.append(HtmlCharacterEntityReferences.REFERENCE_END);
}
else {
......
......@@ -76,7 +76,7 @@ public class Jaxb2RootElementHttpMessageConverterTest {
public void readXmlRootElement() throws Exception {
byte[] body = "<rootElement><type s=\"Hello World\"/></rootElement>".getBytes("UTF-8");
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body);
RootElement result = (RootElement) converter.read((Class) RootElement.class, inputMessage);
RootElement result = (RootElement) converter.read(RootElement.class, inputMessage);
assertEquals("Invalid result", "Hello World", result.type.s);
}
......@@ -85,7 +85,7 @@ public class Jaxb2RootElementHttpMessageConverterTest {
public void readXmlRootElementSubclass() throws Exception {
byte[] body = "<rootElement><type s=\"Hello World\"/></rootElement>".getBytes("UTF-8");
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body);
RootElementSubclass result = (RootElementSubclass) converter.read((Class) RootElementSubclass.class, inputMessage);
RootElementSubclass result = (RootElementSubclass) converter.read(RootElementSubclass.class, inputMessage);
assertEquals("Invalid result", "Hello World", result.type.s);
}
......@@ -94,7 +94,7 @@ public class Jaxb2RootElementHttpMessageConverterTest {
public void readXmlType() throws Exception {
byte[] body = "<foo s=\"Hello World\"/>".getBytes("UTF-8");
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body);
Type result = (Type) converter.read((Class) Type.class, inputMessage);
Type result = (Type) converter.read(Type.class, inputMessage);
assertEquals("Invalid result", "Hello World", result.s);
}
......
......@@ -94,7 +94,7 @@ public abstract class AbstractApplicationContextTests extends AbstractListableBe
}
public void testGrandparentTypedDefinitionFound() throws Exception {
TestBean dad = (TestBean) applicationContext.getBean("father", TestBean.class);
TestBean dad = applicationContext.getBean("father", TestBean.class);
assertTrue("Dad has correct name", dad.getName().equals("Albert"));
}
......
......@@ -132,7 +132,7 @@ public abstract class AbstractMessageConverterMethodArgumentResolver implements
logger.debug("Reading [" + targetType + "] as \"" +
contentType + "\" using [" + converter + "]");
}
return (T) genericConverter.read(targetType, contextClass, inputMessage);
return genericConverter.read(targetType, contextClass, inputMessage);
}
}
if (targetClass != null) {
......
......@@ -86,7 +86,7 @@ public class CheckboxTag extends AbstractSingleCheckedElementTag {
if (value == null) {
throw new IllegalArgumentException("Attribute 'value' is required when binding to non-boolean values");
}
Object resolvedValue = (value instanceof String ? evaluate("value", (String) value) : value);
Object resolvedValue = (value instanceof String ? evaluate("value", value) : value);
renderFromValue(resolvedValue, tagWriter);
}
}
......
......@@ -72,7 +72,7 @@ public class BeanNameViewResolver extends WebApplicationObjectSupport implements
// Allow for ViewResolver chaining.
return null;
}
return (View) context.getBean(viewName, View.class);
return context.getBean(viewName, View.class);
}
}
......@@ -106,7 +106,7 @@ public class XmlViewResolver extends AbstractCachingViewResolver
protected View loadView(String viewName, Locale locale) throws BeansException {
BeanFactory factory = initFactory();
try {
return (View) factory.getBean(viewName, View.class);
return factory.getBean(viewName, View.class);
}
catch (NoSuchBeanDefinitionException ex) {
// to allow for ViewResolver chaining
......
......@@ -100,7 +100,7 @@ public abstract class AbstractApplicationContextTests extends AbstractListableBe
}
public void testGrandparentTypedDefinitionFound() throws Exception {
TestBean dad = (TestBean) applicationContext.getBean("father", TestBean.class);
TestBean dad = applicationContext.getBean("father", TestBean.class);
assertTrue("Dad has correct name", dad.getName().equals("Albert"));
}
......
......@@ -338,7 +338,7 @@ public class ServletAnnotationControllerTests {
MockHttpServletResponse response = new MockHttpServletResponse();
servlet.service(request, response);
assertEquals("Invalid response status", HttpServletResponse.SC_METHOD_NOT_ALLOWED, response.getStatus());
String allowHeader = (String) response.getHeader("Allow");
String allowHeader = response.getHeader("Allow");
assertNotNull("No Allow header", allowHeader);
Set<String> allowedMethods = new HashSet<String>();
allowedMethods.addAll(Arrays.asList(StringUtils.delimitedListToStringArray(allowHeader, ", ")));
......
......@@ -292,7 +292,7 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl
MockHttpServletResponse response = new MockHttpServletResponse();
getServlet().service(request, response);
assertEquals("Invalid response status", HttpServletResponse.SC_METHOD_NOT_ALLOWED, response.getStatus());
String allowHeader = (String) response.getHeader("Allow");
String allowHeader = response.getHeader("Allow");
assertNotNull("No Allow header", allowHeader);
Set<String> allowedMethods = new HashSet<String>();
allowedMethods.addAll(Arrays.asList(StringUtils.delimitedListToStringArray(allowHeader, ", ")));
......
......@@ -267,7 +267,7 @@ public class RadioButtonTagTests extends AbstractFormTagTests {
}
public String getAsText() {
return "F" + (Float) getValue();
return "F" + getValue();
}
}
......
......@@ -242,7 +242,7 @@ public class SelectTagTests extends AbstractFormTagTests {
if (value==null) {
return null;
}
return ((Country) value).getName();
return value.getName();
}
});
getPageContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "testBean", bindingResult);
......@@ -295,7 +295,7 @@ public class SelectTagTests extends AbstractFormTagTests {
if (value==null) {
return "";
}
return ((Country) value).getName();
return value.getName();
}
});
getPageContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "testBean", bindingResult);
......
......@@ -297,7 +297,7 @@ public class BaseViewTests extends TestCase {
private void checkContainsAll(Map expected, Map<String, Object> actual) {
Set<String> keys = expected.keySet();
for (Iterator<String> iter = keys.iterator(); iter.hasNext();) {
String key = (String) iter.next();
String key = iter.next();
//System.out.println("Checking model key " + key);
assertTrue("Value for model key '" + key + "' must match", actual.get(key) == expected.get(key));
}
......
......@@ -84,7 +84,7 @@ public class InternalResourceViewTests extends TestCase {
Set<String> keys = model.keySet();
for (Iterator<String> it = keys.iterator(); it.hasNext();) {
String key = (String) it.next();
String key = it.next();
assertEquals(model.get(key), request.getAttribute(key));
}
......@@ -129,7 +129,7 @@ public class InternalResourceViewTests extends TestCase {
Set<String> keys = model.keySet();
for (Iterator<String> it = keys.iterator(); it.hasNext();) {
String key = (String) it.next();
String key = it.next();
assertEquals(model.get(key), request.getAttribute(key));
}
......@@ -153,7 +153,7 @@ public class InternalResourceViewTests extends TestCase {
expectLastCall().andReturn(null);
Set<String> keys = model.keySet();
for (Iterator<String> iter = keys.iterator(); iter.hasNext();) {
String key = (String) iter.next();
String key = iter.next();
request.setAttribute(key, model.get(key));
expectLastCall().times(1);
}
......@@ -186,7 +186,7 @@ public class InternalResourceViewTests extends TestCase {
expectLastCall().andReturn(null);
Set<String> keys = model.keySet();
for (Iterator<String> iter = keys.iterator(); iter.hasNext();) {
String key = (String) iter.next();
String key = iter.next();
request.setAttribute(key, model.get(key));
expectLastCall().times(1);
}
......@@ -220,7 +220,7 @@ public class InternalResourceViewTests extends TestCase {
expectLastCall().andReturn(null);
Set<String> keys = model.keySet();
for (Iterator<String> iter = keys.iterator(); iter.hasNext();) {
String key = (String) iter.next();
String key = iter.next();
request.setAttribute(key, model.get(key));
expectLastCall().times(1);
}
......
......@@ -73,7 +73,7 @@ public class FreeMarkerConfigurerTests extends TestCase {
FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean();
fcfb.setTemplateLoaderPath("file:/mydir");
fcfb.afterPropertiesSet();
Configuration cfg = (Configuration) fcfb.getObject();
Configuration cfg = fcfb.getObject();
assertTrue(cfg.getTemplateLoader() instanceof SpringTemplateLoader);
}
......@@ -97,7 +97,7 @@ public class FreeMarkerConfigurerTests extends TestCase {
});
fcfb.afterPropertiesSet();
assertTrue(fcfb.getObject() instanceof Configuration);
Configuration fc = (Configuration) fcfb.getObject();
Configuration fc = fcfb.getObject();
Template ft = fc.getTemplate("test");
assertEquals("test", FreeMarkerTemplateUtils.processTemplateIntoString(ft, new HashMap()));
}
......
......@@ -69,7 +69,7 @@ public class VelocityConfigurerTests extends TestCase {
vefb.setVelocityPropertiesMap(map);
vefb.afterPropertiesSet();
assertTrue(vefb.getObject() instanceof VelocityEngine);
VelocityEngine ve = (VelocityEngine) vefb.getObject();
VelocityEngine ve = vefb.getObject();
assertEquals("/mydir", ve.getProperty("myprop"));
assertEquals(value, ve.getProperty("myentry"));
}
......@@ -79,7 +79,7 @@ public class VelocityConfigurerTests extends TestCase {
vefb.setResourceLoaderPath("file:/mydir");
vefb.afterPropertiesSet();
assertTrue(vefb.getObject() instanceof VelocityEngine);
VelocityEngine ve = (VelocityEngine) vefb.getObject();
VelocityEngine ve = vefb.getObject();
assertEquals(new File("/mydir").getAbsolutePath(), ve.getProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH));
}
......@@ -104,7 +104,7 @@ public class VelocityConfigurerTests extends TestCase {
});
vefb.afterPropertiesSet();
assertTrue(vefb.getObject() instanceof VelocityEngine);
VelocityEngine ve = (VelocityEngine) vefb.getObject();
VelocityEngine ve = vefb.getObject();
assertEquals("test", VelocityEngineUtils.mergeTemplateIntoString(ve, "test", new HashMap()));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册