diff --git a/gradlew.bat b/gradlew.bat index e1b2af0e72..4fe0451ec5 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -12,7 +12,7 @@ if "%OS%"=="Windows_NT" setlocal set DEFAULT_JVM_OPTS= @rem ADDED BY HAND -- DO NOT ACCIDENTALLY DELETE WHEN UPGRADING GRADLE WRAPPER! -set GRADLE_OPTS=-XX:MaxPermSize=1024m -Xmx1024m %GRADLE_OPTS% +set GRADLE_OPTS=-XX:MaxPermSize=1024m -Xmx1024m -XX:MaxHeapSize=256m %GRADLE_OPTS% @rem END ADDED BY HAND set DIRNAME=%~dp0 diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java index 87b99b6afe..1f080734bc 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2012 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. @@ -25,11 +25,15 @@ import static org.springframework.beans.factory.support.BeanDefinitionBuilder.ge import static test.util.TestResourceUtils.qualifiedResource; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; +import java.util.prefs.AbstractPreferences; +import java.util.prefs.BackingStoreException; import java.util.prefs.Preferences; +import java.util.prefs.PreferencesFactory; import org.junit.Before; import org.junit.Test; @@ -52,19 +56,24 @@ import test.beans.TestBean; * Unit tests for various {@link PropertyResourceConfigurer} implementations including: * {@link PropertyPlaceholderConfigurer}, {@link PropertyOverrideConfigurer} and * {@link PreferencesPlaceholderConfigurer}. - * + * * @see PropertyPlaceholderConfigurerTests * @since 02.10.2003 * @author Juergen Hoeller * @author Chris Beams + * @author Phillip Webb */ public final class PropertyResourceConfigurerTests { + static { + System.setProperty("java.util.prefs.PreferencesFactory", MockPreferencesFactory.class.getName()); + } + private static final Class CLASS = PropertyResourceConfigurerTests.class; private static final Resource TEST_PROPS = qualifiedResource(CLASS, "test.properties"); private static final Resource XTEST_PROPS = qualifiedResource(CLASS, "xtest.properties"); // does not exist private static final Resource TEST_PROPS_XML = qualifiedResource(CLASS, "test.properties.xml"); - + private DefaultListableBeanFactory factory; @Before @@ -808,4 +817,87 @@ public final class PropertyResourceConfigurerTests { } } + /** + * {@link PreferencesFactory} to create {@link MockPreferences}. + */ + public static class MockPreferencesFactory implements PreferencesFactory { + + private Preferences systemRoot = new MockPreferences(); + + private Preferences userRoot = new MockPreferences(); + + public Preferences systemRoot() { + return systemRoot; + } + + public Preferences userRoot() { + return userRoot; + } + } + + /** + * Mock implementation of {@link Preferences} that behaves the same regardless of the + * underlying operating system and will never throw security exceptions. + */ + public static class MockPreferences extends AbstractPreferences { + + private static Map values = new HashMap(); + + private static Map children = new HashMap(); + + public MockPreferences() { + super(null, ""); + } + + protected MockPreferences(AbstractPreferences parent, String name) { + super(parent, name); + } + + @Override + protected void putSpi(String key, String value) { + values.put(key, value); + } + + @Override + protected String getSpi(String key) { + return values.get(key); + } + + @Override + protected void removeSpi(String key) { + values.remove(key); + } + + @Override + protected void removeNodeSpi() throws BackingStoreException { + } + + @Override + protected String[] keysSpi() throws BackingStoreException { + return values.keySet().toArray(new String[values.size()]); + } + + @Override + protected String[] childrenNamesSpi() throws BackingStoreException { + return children.keySet().toArray(new String[values.size()]); + } + + @Override + protected AbstractPreferences childSpi(String name) { + AbstractPreferences child = children.get(name); + if (child == null) { + child = new MockPreferences(this, name); + children.put(name, child); + } + return child; + } + + @Override + protected void syncSpi() throws BackingStoreException { + } + + @Override + protected void flushSpi() throws BackingStoreException { + } + } } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java index f85a4e011a..d54f13e2c6 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2012 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. @@ -321,6 +321,7 @@ public class FreeMarkerMacroTests { ClassPathResource resource = new ClassPathResource("test.ftl", getClass()); assertTrue(resource.exists()); String all = FileCopyUtils.copyToString(new InputStreamReader(resource.getInputStream())); + all = all.replace("\r\n", "\n"); String[] macros = StringUtils.delimitedListToStringArray(all, "\n\n"); for (String macro : macros) { if (macro.startsWith(name)) { diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java index c3196a6f58..a52273e370 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java @@ -156,7 +156,7 @@ public class MappingJackson2JsonViewTests { view.setPrettyPrint(true); view.render(model, request, response); - String result = response.getContentAsString(); + String result = response.getContentAsString().replace("\r\n", "\n"); assertTrue("Pretty printing not applied:\n" + result, result.startsWith("{\n \"foo\" : {\n ")); validateResult(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJacksonJsonViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJacksonJsonViewTests.java index 9caf042842..91415315ea 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJacksonJsonViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJacksonJsonViewTests.java @@ -149,7 +149,7 @@ public class MappingJacksonJsonViewTests { view.setPrettyPrint(true); view.render(model, request, response); - String result = response.getContentAsString(); + String result = response.getContentAsString().replace("\r\n", "\n"); assertTrue("Pretty printing not applied:\n" + result, result.startsWith("{\n \"foo\" : {\n ")); validateResult(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/velocity/VelocityRenderTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/velocity/VelocityRenderTests.java index a85524241a..d5ac5d9ada 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/velocity/VelocityRenderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/velocity/VelocityRenderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2012 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. @@ -53,7 +53,7 @@ public class VelocityRenderTests { private MockHttpServletRequest request; private MockHttpServletResponse response; - + @Rule public ExpectedException thrown = ExpectedException.none(); @@ -95,12 +95,12 @@ public class VelocityRenderTests { Map model = new HashMap(); model.put("command", new TestBean("juergen", 99)); view.render(model, request, response); - assertEquals("\nNAME\njuergen\n", response.getContentAsString()); + assertEquals("\nNAME\njuergen\n", response.getContentAsString().replace("\r\n", "\n")); } @Test - @Ignore // This works with Velocity 1.6.2 + @Ignore // This works with Velocity 1.6.2 public void testSimpleRenderWithError() throws Exception { thrown.expect(NestedServletException.class); @@ -111,10 +111,10 @@ public class VelocityRenderTests { } public void describeTo(Description description) { description.appendText("exception has cause of MethodInvocationException"); - + } - }); - + }); + VelocityConfigurer vc = new VelocityConfigurer(); vc.setPreferFileSystemAccess(false); vc.setVelocityPropertiesMap(Collections.singletonMap("runtime.references.strict", "true")); @@ -143,10 +143,10 @@ public class VelocityRenderTests { } public void describeTo(Description description) { description.appendText("exception has cause of IOException"); - + } - }); - + }); + VelocityConfigurer vc = new VelocityConfigurer(); vc.setPreferFileSystemAccess(false); vc.setVelocityPropertiesMap(Collections.singletonMap("runtime.references.strict", "true")); diff --git a/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java b/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java index 0750058583..8720f31bd8 100644 --- a/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java +++ b/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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. @@ -84,7 +84,7 @@ public class ScheduledAndTransactionalAnnotationIntegrationTests { ctx.register(Config.class, JdkProxyTxConfig.class, RepoConfigB.class); ctx.refresh(); - Thread.sleep(10); // allow @Scheduled method to be called several times + Thread.sleep(30); // allow @Scheduled method to be called several times MyRepositoryWithScheduledMethod repository = ctx.getBean(MyRepositoryWithScheduledMethod.class); CallCountingTransactionManager txManager = ctx.getBean(CallCountingTransactionManager.class); @@ -179,4 +179,5 @@ public class ScheduledAndTransactionalAnnotationIntegrationTests { return this.count.get(); } } -} \ No newline at end of file +} +