diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/InterceptorRegistryTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/InterceptorRegistryTests.java index e5c1e56f2d..ec188c1ea4 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/InterceptorRegistryTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/InterceptorRegistryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 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. @@ -23,7 +23,6 @@ import java.util.List; import org.junit.Before; import org.junit.Test; -import org.mockito.Mock; import org.mockito.Mockito; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/ResponseStatusExceptionResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/ResponseStatusExceptionResolverTests.java index 4731ce6fed..8c08804f14 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/ResponseStatusExceptionResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/ResponseStatusExceptionResolverTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2014 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.web.servlet.mvc.annotation; import static org.junit.Assert.*; @@ -7,14 +23,12 @@ import java.util.Locale; import org.junit.Before; import org.junit.Test; -import org.springframework.context.ApplicationContext; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.support.StaticMessageSource; import org.springframework.http.HttpStatus; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.context.support.StaticWebApplicationContext; import org.springframework.web.servlet.ModelAndView; /** @author Arjen Poutsma */ diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java index 35b2a79c17..0a7a90b839 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java @@ -34,7 +34,6 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.util.UriComponents; -import org.springframework.web.util.UriComponentsBuilder; import java.util.Arrays; import java.util.List; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java index a5acd05a69..17d13855c0 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 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,12 +22,11 @@ import java.util.Arrays; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; + import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.ui.Model; -import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.ControllerAdvice; -import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.SessionAttributes; import org.springframework.web.context.support.StaticWebApplicationContext; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java index 65cefe564f..18fa909f4d 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 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. @@ -41,7 +41,6 @@ import org.dom4j.io.SAXReader; import org.springframework.beans.propertyeditors.CustomCollectionEditor; import org.springframework.format.Formatter; import org.springframework.format.support.FormattingConversionService; -import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.tests.sample.beans.TestBean; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.BindingResult; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolverTests.java index 4911b5bb57..bec2e39d0d 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 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. @@ -27,6 +27,7 @@ import java.util.Set; import org.junit.After; import org.junit.Before; import org.junit.Test; + import org.springframework.http.MediaType; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; @@ -46,7 +47,6 @@ import org.springframework.web.servlet.ViewResolver; import static org.junit.Assert.*; import static org.mockito.BDDMockito.*; -import static org.mockito.Mockito.*; /** * @author Arjen Poutsma diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerConfigurerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerConfigurerTests.java index 759a2030d9..f926aac046 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerConfigurerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerConfigurerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 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,20 +16,11 @@ 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; -import freemarker.cache.ClassTemplateLoader; -import freemarker.cache.MultiTemplateLoader; -import freemarker.cache.TemplateLoader; -import freemarker.template.Configuration; -import freemarker.template.Template; -import freemarker.template.TemplateException; -import junit.framework.TestCase; +import org.junit.Test; import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.FileSystemResource; @@ -39,28 +30,30 @@ import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean; import org.springframework.ui.freemarker.FreeMarkerTemplateUtils; import org.springframework.ui.freemarker.SpringTemplateLoader; +import freemarker.template.Configuration; +import freemarker.template.Template; + +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.*; + /** * @author Juergen Hoeller * @since 14.03.2004 */ -public class FreeMarkerConfigurerTests extends TestCase { +public class FreeMarkerConfigurerTests { - public void testFreemarkerConfigurationFactoryBeanWithConfigLocation() throws TemplateException { + @Test(expected = IOException.class) + public void freemarkerConfigurationFactoryBeanWithConfigLocation() throws Exception { FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean(); fcfb.setConfigLocation(new FileSystemResource("myprops.properties")); Properties props = new Properties(); props.setProperty("myprop", "/mydir"); fcfb.setFreemarkerSettings(props); - try { - fcfb.afterPropertiesSet(); - fail("Should have thrown IOException"); - } - catch (IOException ex) { - // expected - } + fcfb.afterPropertiesSet(); } - public void testFreeMarkerConfigurationFactoryBeanWithResourceLoaderPath() throws Exception { + @Test + public void freeMarkerConfigurationFactoryBeanWithResourceLoaderPath() throws Exception { FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean(); fcfb.setTemplateLoaderPath("file:/mydir"); fcfb.afterPropertiesSet(); @@ -68,14 +61,16 @@ public class FreeMarkerConfigurerTests extends TestCase { assertTrue(cfg.getTemplateLoader() instanceof SpringTemplateLoader); } - public void testFreemarkerConfigurationFactoryBeanWithNonFileResourceLoaderPath() - throws IOException, TemplateException { + @Test + @SuppressWarnings("rawtypes") + public void freemarkerConfigurationFactoryBeanWithNonFileResourceLoaderPath() throws Exception { FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean(); fcfb.setTemplateLoaderPath("file:/mydir"); Properties settings = new Properties(); settings.setProperty("localized_lookup", "false"); fcfb.setFreemarkerSettings(settings); fcfb.setResourceLoader(new ResourceLoader() { + @Override public Resource getResource(String location) { if (!("file:/mydir".equals(location) || "file:/mydir/test".equals(location))) { @@ -83,6 +78,7 @@ public class FreeMarkerConfigurerTests extends TestCase { } return new ByteArrayResource("test".getBytes(), "test"); } + @Override public ClassLoader getClassLoader() { return getClass().getClassLoader();