Fix 'is already an instance of type' warnings
This commit is contained in:
@@ -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()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user