Fix Windows-related build issues
- Increase max heap size in gradle wrapper. - Use MockProperties implementation to protect against security exceptions. - Replace windows CRLF with LF in various tests. - Increase Thread.sleep times to account for lack of precision on Windows. Issue: SPR-9717
This commit is contained in:
committed by
Chris Beams
parent
94bb036269
commit
8e7622bb8a
2
gradlew.bat
vendored
2
gradlew.bat
vendored
@@ -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
|
||||
|
||||
@@ -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<String, String> values = new HashMap<String, String>();
|
||||
|
||||
private static Map<String, AbstractPreferences> children = new HashMap<String, AbstractPreferences>();
|
||||
|
||||
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 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<String,Object> model = new HashMap<String,Object>();
|
||||
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.<String,Object>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.<String,Object>singletonMap("runtime.references.strict", "true"));
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user