Fix 'is already an instance of type' warnings
This commit is contained in:
parent
36b5ba1871
commit
88f5dd6ce1
|
|
@ -15,7 +15,14 @@
|
|||
*/
|
||||
package org.springframework.aop.aspectj.annotation;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.lang.annotation.Retention;
|
||||
|
|
@ -39,9 +46,7 @@ import org.aspectj.lang.annotation.DeclareParents;
|
|||
import org.aspectj.lang.annotation.DeclarePrecedence;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.aop.Advisor;
|
||||
import org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory.SyntheticInstantiationAdvisor;
|
||||
import org.springframework.aop.framework.Advised;
|
||||
|
|
@ -52,14 +57,14 @@ import org.springframework.aop.support.AopUtils;
|
|||
import org.springframework.core.OrderComparator;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import test.aop.DefaultLockable;
|
||||
import test.aop.Lockable;
|
||||
import test.aop.PerTargetAspect;
|
||||
import test.aop.TwoAdviceAspect;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
/**
|
||||
* Abstract tests for AspectJAdvisorFactory.
|
||||
|
|
@ -385,7 +390,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
|||
CannotBeUnlocked.class
|
||||
),
|
||||
CannotBeUnlocked.class);
|
||||
assertTrue(proxy instanceof Lockable);
|
||||
assertThat(proxy, instanceOf(Lockable.class));
|
||||
Lockable lockable = proxy;
|
||||
assertTrue("Already locked", lockable.locked());
|
||||
lockable.lock();
|
||||
|
|
@ -442,7 +447,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
|||
Modifiable modifiable = (Modifiable) createProxy(target,
|
||||
advisors,
|
||||
ITestBean.class);
|
||||
assertTrue(modifiable instanceof Modifiable);
|
||||
assertThat(modifiable, instanceOf(Modifiable.class));
|
||||
Lockable lockable = (Lockable) modifiable;
|
||||
assertFalse(lockable.locked());
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,10 @@
|
|||
|
||||
package org.springframework.aop.support;
|
||||
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
|
@ -157,7 +159,7 @@ public final class DelegatingIntroductionInterceptorTests {
|
|||
//assertTrue(Arrays.binarySearch(pf.getProxiedInterfaces(), TimeStamped.class) != -1);
|
||||
TimeStamped ts = (TimeStamped) pf.getProxy();
|
||||
|
||||
assertTrue(ts instanceof TimeStamped);
|
||||
assertThat(ts, instanceOf(TimeStamped.class));
|
||||
// Shoulnd't proxy framework interfaces
|
||||
assertTrue(!(ts instanceof MethodInterceptor));
|
||||
assertTrue(!(ts instanceof IntroductionInterceptor));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -22,6 +22,7 @@ import java.util.Map;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
|
|
@ -59,7 +60,7 @@ public class BeanWrapperAutoGrowingTests {
|
|||
public void getPropertyValueAutoGrowArray() {
|
||||
assertNotNull(wrapper.getPropertyValue("array[0]"));
|
||||
assertEquals(1, bean.getArray().length);
|
||||
assertTrue(bean.getArray()[0] instanceof Bean);
|
||||
assertThat(bean.getArray()[0], instanceOf(Bean.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -72,11 +73,11 @@ public class BeanWrapperAutoGrowingTests {
|
|||
public void getPropertyValueAutoGrowArrayBySeveralElements() {
|
||||
assertNotNull(wrapper.getPropertyValue("array[4]"));
|
||||
assertEquals(5, bean.getArray().length);
|
||||
assertTrue(bean.getArray()[0] instanceof Bean);
|
||||
assertTrue(bean.getArray()[1] instanceof Bean);
|
||||
assertTrue(bean.getArray()[2] instanceof Bean);
|
||||
assertTrue(bean.getArray()[3] instanceof Bean);
|
||||
assertTrue(bean.getArray()[4] instanceof Bean);
|
||||
assertThat(bean.getArray()[0], instanceOf(Bean.class));
|
||||
assertThat(bean.getArray()[1], instanceOf(Bean.class));
|
||||
assertThat(bean.getArray()[2], instanceOf(Bean.class));
|
||||
assertThat(bean.getArray()[3], instanceOf(Bean.class));
|
||||
assertThat(bean.getArray()[4], instanceOf(Bean.class));
|
||||
assertNotNull(wrapper.getPropertyValue("array[0]"));
|
||||
assertNotNull(wrapper.getPropertyValue("array[1]"));
|
||||
assertNotNull(wrapper.getPropertyValue("array[2]"));
|
||||
|
|
@ -87,14 +88,14 @@ public class BeanWrapperAutoGrowingTests {
|
|||
public void getPropertyValueAutoGrowMultiDimensionalArray() {
|
||||
assertNotNull(wrapper.getPropertyValue("multiArray[0][0]"));
|
||||
assertEquals(1, bean.getMultiArray()[0].length);
|
||||
assertTrue(bean.getMultiArray()[0][0] instanceof Bean);
|
||||
assertThat(bean.getMultiArray()[0][0], instanceOf(Bean.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPropertyValueAutoGrowList() {
|
||||
assertNotNull(wrapper.getPropertyValue("list[0]"));
|
||||
assertEquals(1, bean.getList().size());
|
||||
assertTrue(bean.getList().get(0) instanceof Bean);
|
||||
assertThat(bean.getList().get(0), instanceOf(Bean.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -107,11 +108,11 @@ public class BeanWrapperAutoGrowingTests {
|
|||
public void getPropertyValueAutoGrowListBySeveralElements() {
|
||||
assertNotNull(wrapper.getPropertyValue("list[4]"));
|
||||
assertEquals(5, bean.getList().size());
|
||||
assertTrue(bean.getList().get(0) instanceof Bean);
|
||||
assertTrue(bean.getList().get(1) instanceof Bean);
|
||||
assertTrue(bean.getList().get(2) instanceof Bean);
|
||||
assertTrue(bean.getList().get(3) instanceof Bean);
|
||||
assertTrue(bean.getList().get(4) instanceof Bean);
|
||||
assertThat(bean.getList().get(0), instanceOf(Bean.class));
|
||||
assertThat(bean.getList().get(1), instanceOf(Bean.class));
|
||||
assertThat(bean.getList().get(2), instanceOf(Bean.class));
|
||||
assertThat(bean.getList().get(3), instanceOf(Bean.class));
|
||||
assertThat(bean.getList().get(4), instanceOf(Bean.class));
|
||||
assertNotNull(wrapper.getPropertyValue("list[0]"));
|
||||
assertNotNull(wrapper.getPropertyValue("list[1]"));
|
||||
assertNotNull(wrapper.getPropertyValue("list[2]"));
|
||||
|
|
@ -135,7 +136,7 @@ public class BeanWrapperAutoGrowingTests {
|
|||
public void getPropertyValueAutoGrowMultiDimensionalList() {
|
||||
assertNotNull(wrapper.getPropertyValue("multiList[0][0]"));
|
||||
assertEquals(1, bean.getMultiList().get(0).size());
|
||||
assertTrue(bean.getMultiList().get(0).get(0) instanceof Bean);
|
||||
assertThat(bean.getMultiList().get(0).get(0), instanceOf(Bean.class));
|
||||
}
|
||||
|
||||
@Test(expected=InvalidPropertyException.class)
|
||||
|
|
@ -146,13 +147,13 @@ public class BeanWrapperAutoGrowingTests {
|
|||
@Test
|
||||
public void setPropertyValueAutoGrowMap() {
|
||||
wrapper.setPropertyValue("map[A]", new Bean());
|
||||
assertTrue(bean.getMap().get("A") instanceof Bean);
|
||||
assertThat(bean.getMap().get("A"), instanceOf(Bean.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setNestedPropertyValueAutoGrowMap() {
|
||||
wrapper.setPropertyValue("map[A].nested", new Bean());
|
||||
assertTrue(bean.getMap().get("A").getNested() instanceof Bean);
|
||||
assertThat(bean.getMap().get("A").getNested(), instanceOf(Bean.class));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import org.springframework.core.convert.converter.GenericConverter;
|
|||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
|
|
@ -136,8 +137,8 @@ public class ConversionServiceFactoryBeanTests {
|
|||
|
||||
public ComplexConstructorArgument(Map<String, Class<?>> map) {
|
||||
assertTrue(!map.isEmpty());
|
||||
assertTrue(map.keySet().iterator().next() instanceof String);
|
||||
assertTrue(map.values().iterator().next() instanceof Class);
|
||||
assertThat(map.keySet().iterator().next(), instanceOf(String.class));
|
||||
assertThat(map.values().iterator().next(), instanceOf(Class.class));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@
|
|||
|
||||
package org.springframework.scheduling.timer;
|
||||
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
|
|
@ -84,7 +87,7 @@ public class TimerSupportTests extends TestCase {
|
|||
try {
|
||||
timerFactoryBean.setScheduledTimerTasks(tasks);
|
||||
timerFactoryBean.afterPropertiesSet();
|
||||
assertTrue(timerFactoryBean.getObject() instanceof Timer);
|
||||
assertThat(timerFactoryBean.getObject(), instanceOf(Timer.class));
|
||||
timerTask0.run();
|
||||
timerTask1.run();
|
||||
timerTask2.run();
|
||||
|
|
|
|||
|
|
@ -16,6 +16,16 @@
|
|||
|
||||
package org.springframework.web.servlet.mvc.annotation;
|
||||
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.beans.PropertyEditorSupport;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
|
@ -43,6 +53,7 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
|
|
@ -54,17 +65,12 @@ import javax.validation.constraints.NotNull;
|
|||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
|
||||
import org.springframework.aop.interceptor.SimpleTraceInterceptor;
|
||||
import org.springframework.aop.support.DefaultPointcutAdvisor;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.tests.sample.beans.DerivedTestBean;
|
||||
import org.springframework.tests.sample.beans.GenericBean;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.beans.PropertyEditorRegistrar;
|
||||
import org.springframework.beans.PropertyEditorRegistry;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
|
@ -96,6 +102,10 @@ import org.springframework.mock.web.test.MockServletConfig;
|
|||
import org.springframework.mock.web.test.MockServletContext;
|
||||
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.tests.sample.beans.DerivedTestBean;
|
||||
import org.springframework.tests.sample.beans.GenericBean;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.ui.ExtendedModelMap;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.ui.ModelMap;
|
||||
|
|
@ -140,8 +150,6 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|||
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
||||
import org.springframework.web.util.NestedServletException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
|
|
@ -3291,7 +3299,7 @@ public class ServletAnnotationControllerTests {
|
|||
|
||||
@RequestMapping("/integerSet")
|
||||
public void processCsv(@RequestParam("content") Set<Integer> content, HttpServletResponse response) throws IOException {
|
||||
assertTrue(content.iterator().next() instanceof Integer);
|
||||
assertThat(content.iterator().next(), instanceOf(Integer.class));
|
||||
response.getWriter().write(StringUtils.collectionToDelimitedString(content, "-"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -16,6 +16,9 @@
|
|||
|
||||
package org.springframework.web.servlet.tags;
|
||||
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
|
|
@ -49,7 +52,7 @@ public class UrlTagTests extends AbstractTagTests {
|
|||
}
|
||||
|
||||
public void testParamSupport() {
|
||||
assertTrue(tag instanceof ParamAware);
|
||||
assertThat(tag, instanceOf(ParamAware.class));
|
||||
}
|
||||
|
||||
public void testDoStartTag() throws JspException {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -16,6 +16,9 @@
|
|||
|
||||
package org.springframework.web.servlet.view.freemarker;
|
||||
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Properties;
|
||||
|
|
@ -98,7 +101,7 @@ public class FreeMarkerConfigurerTests extends TestCase {
|
|||
}
|
||||
});
|
||||
fcfb.afterPropertiesSet();
|
||||
assertTrue(fcfb.getObject() instanceof Configuration);
|
||||
assertThat(fcfb.getObject(), instanceOf(Configuration.class));
|
||||
Configuration fc = fcfb.getObject();
|
||||
Template ft = fc.getTemplate("test");
|
||||
assertEquals("test", FreeMarkerTemplateUtils.processTemplateIntoString(ft, new HashMap()));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -16,6 +16,9 @@
|
|||
|
||||
package org.springframework.web.servlet.view.velocity;
|
||||
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
|
|
@ -25,9 +28,9 @@ import java.util.Properties;
|
|||
import java.util.Vector;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.velocity.app.VelocityEngine;
|
||||
import org.apache.velocity.exception.VelocityException;
|
||||
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.core.io.DescriptiveResource;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
|
|
@ -68,7 +71,7 @@ public class VelocityConfigurerTests extends TestCase {
|
|||
map.put("myentry", value);
|
||||
vefb.setVelocityPropertiesMap(map);
|
||||
vefb.afterPropertiesSet();
|
||||
assertTrue(vefb.getObject() instanceof VelocityEngine);
|
||||
assertThat(vefb.getObject(), instanceOf(VelocityEngine.class));
|
||||
VelocityEngine ve = vefb.getObject();
|
||||
assertEquals("/mydir", ve.getProperty("myprop"));
|
||||
assertEquals(value, ve.getProperty("myentry"));
|
||||
|
|
@ -78,7 +81,7 @@ public class VelocityConfigurerTests extends TestCase {
|
|||
VelocityEngineFactoryBean vefb = new VelocityEngineFactoryBean();
|
||||
vefb.setResourceLoaderPath("file:/mydir");
|
||||
vefb.afterPropertiesSet();
|
||||
assertTrue(vefb.getObject() instanceof VelocityEngine);
|
||||
assertThat(vefb.getObject(), instanceOf(VelocityEngine.class));
|
||||
VelocityEngine ve = vefb.getObject();
|
||||
assertEquals(new File("/mydir").getAbsolutePath(), ve.getProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH));
|
||||
}
|
||||
|
|
@ -105,7 +108,7 @@ public class VelocityConfigurerTests extends TestCase {
|
|||
}
|
||||
});
|
||||
vefb.afterPropertiesSet();
|
||||
assertTrue(vefb.getObject() instanceof VelocityEngine);
|
||||
assertThat(vefb.getObject(), instanceOf(VelocityEngine.class));
|
||||
VelocityEngine ve = vefb.getObject();
|
||||
assertEquals("test", VelocityEngineUtils.mergeTemplateIntoString(ve, "test", new HashMap()));
|
||||
}
|
||||
|
|
@ -114,7 +117,7 @@ public class VelocityConfigurerTests extends TestCase {
|
|||
VelocityConfigurer vc = new VelocityConfigurer();
|
||||
vc.setResourceLoaderPath("file:/mydir");
|
||||
vc.afterPropertiesSet();
|
||||
assertTrue(vc.createVelocityEngine() instanceof VelocityEngine);
|
||||
assertThat(vc.createVelocityEngine(), instanceOf(VelocityEngine.class));
|
||||
VelocityEngine ve = vc.createVelocityEngine();
|
||||
assertEquals(new File("/mydir").getAbsolutePath(), ve.getProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH));
|
||||
}
|
||||
|
|
@ -123,7 +126,7 @@ public class VelocityConfigurerTests extends TestCase {
|
|||
VelocityConfigurer vc = new VelocityConfigurer();
|
||||
vc.setResourceLoaderPath("file:/mydir,file:/yourdir");
|
||||
vc.afterPropertiesSet();
|
||||
assertTrue(vc.createVelocityEngine() instanceof VelocityEngine);
|
||||
assertThat(vc.createVelocityEngine(), instanceOf(VelocityEngine.class));
|
||||
VelocityEngine ve = vc.createVelocityEngine();
|
||||
Vector paths = new Vector();
|
||||
paths.add(new File("/mydir").getAbsolutePath());
|
||||
|
|
@ -149,7 +152,7 @@ public class VelocityConfigurerTests extends TestCase {
|
|||
});
|
||||
vc.setPreferFileSystemAccess(false);
|
||||
vc.afterPropertiesSet();
|
||||
assertTrue(vc.createVelocityEngine() instanceof VelocityEngine);
|
||||
assertThat(vc.createVelocityEngine(), instanceOf(VelocityEngine.class));
|
||||
VelocityEngine ve = vc.createVelocityEngine();
|
||||
assertEquals("test", VelocityEngineUtils.mergeTemplateIntoString(ve, "test", new HashMap()));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue