Javadoc refinements, exception fine-tuning, general polishing

Issue: SPR-13034
This commit is contained in:
Juergen Hoeller
2015-07-15 15:42:17 +02:00
parent 2577ac300b
commit d183bbb667
13 changed files with 193 additions and 169 deletions

View File

@@ -31,14 +31,15 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.servlet.RequestDispatcher;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import org.hamcrest.Matchers;
import org.joda.time.LocalDate;
import org.junit.Before;
import org.junit.Test;
@@ -56,6 +57,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;
import org.springframework.format.annotation.NumberFormat;
import org.springframework.format.support.FormattingConversionServiceFactoryBean;
import org.springframework.http.CacheControl;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter;
@@ -75,7 +77,6 @@ import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
import org.springframework.web.accept.ContentNegotiationManager;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.http.CacheControl;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.request.ServletWebRequest;
@@ -141,11 +142,6 @@ import org.springframework.web.servlet.view.velocity.VelocityConfigurer;
import org.springframework.web.servlet.view.velocity.VelocityViewResolver;
import org.springframework.web.util.UrlPathHelper;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
@@ -807,7 +803,7 @@ public class MvcNamespaceTests {
assertEquals("render", scriptTemplateConfigurer.getRenderFunction());
assertEquals(StandardCharsets.ISO_8859_1, scriptTemplateConfigurer.getCharset());
assertEquals("classpath:", scriptTemplateConfigurer.getResourceLoaderPath());
assertFalse(scriptTemplateConfigurer.isShareEngine());
assertFalse(scriptTemplateConfigurer.isSharedEngine());
String[] scripts = { "org/springframework/web/servlet/view/script/nashorn/render.js" };
accessor = new DirectFieldAccessor(scriptTemplateConfigurer);
assertArrayEquals(scripts, (String[]) accessor.getPropertyValue("scripts"));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 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.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.servlet.view.script;
import org.junit.Assert;

View File

@@ -28,19 +28,18 @@ import javax.script.Invocable;
import javax.script.ScriptEngine;
import org.hamcrest.Matchers;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.*;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import org.junit.Before;
import org.junit.Test;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.context.ApplicationContextException;
import org.springframework.context.support.StaticApplicationContext;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.mockito.BDDMockito.*;
import static org.mockito.Mockito.mock;
/**
* Unit tests for {@link ScriptTemplateView}.
*
@@ -149,11 +148,12 @@ public class ScriptTemplateViewTests {
public void nonInvocableScriptEngine() throws Exception {
try {
this.view.setEngine(mock(ScriptEngine.class));
} catch(IllegalArgumentException ex) {
fail("Should have thrown IllegalArgumentException");
}
catch (IllegalArgumentException ex) {
assertThat(ex.getMessage(), containsString("instance"));
return;
}
fail();
}
@Test
@@ -161,11 +161,11 @@ public class ScriptTemplateViewTests {
this.view.setEngine(mock(InvocableScriptEngine.class));
try {
this.view.setApplicationContext(this.applicationContext);
} catch(IllegalStateException ex) {
assertThat(ex.getMessage(), containsString("renderFunction"));
return;
fail("Should have thrown IllegalArgumentException");
}
catch (IllegalArgumentException ex) {
assertThat(ex.getMessage(), containsString("renderFunction"));
}
fail();
}
@Test
@@ -175,11 +175,11 @@ public class ScriptTemplateViewTests {
this.view.setRenderFunction("render");
try {
this.view.setApplicationContext(this.applicationContext);
} catch(IllegalStateException ex) {
assertThat(ex.getMessage(), containsString("engine or engineName"));
return;
fail("Should have thrown IllegalArgumentException");
}
catch (IllegalArgumentException ex) {
assertThat(ex.getMessage(), containsString("'engine' or 'engineName'"));
}
fail();
}
@Test
@@ -189,7 +189,9 @@ public class ScriptTemplateViewTests {
this.view.setSharedEngine(false);
try {
this.view.setApplicationContext(this.applicationContext);
} catch(IllegalStateException ex) {
fail("Should have thrown IllegalArgumentException");
}
catch (IllegalArgumentException ex) {
assertThat(ex.getMessage(), containsString("sharedEngine"));
return;
}