Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
(cherry picked from commit b541fc9)
  • Loading branch information
jhoeller committed Mar 6, 2015
1 parent f01a030 commit 7ed7f98
Show file tree
Hide file tree
Showing 14 changed files with 90 additions and 94 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 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.
Expand Down Expand Up @@ -219,8 +219,7 @@ protected void processProperties(ConfigurableListableBeanFactory beanFactoryToPr
throws BeansException {

StringValueResolver valueResolver = new PlaceholderResolvingStringValueResolver(props);

this.doProcessProperties(beanFactoryToProcess, valueResolver);
doProcessProperties(beanFactoryToProcess, valueResolver);
}

/**
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 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.
Expand Down Expand Up @@ -279,7 +279,7 @@ public BeanDefinitionBuilder setDependencyCheck(int dependencyCheck) {
*/
public BeanDefinitionBuilder addDependsOn(String beanName) {
if (this.beanDefinition.getDependsOn() == null) {
this.beanDefinition.setDependsOn(new String[] {beanName});
this.beanDefinition.setDependsOn(beanName);
}
else {
String[] added = ObjectUtils.addObjectToArray(this.beanDefinition.getDependsOn(), beanName);
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 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.
Expand Down Expand Up @@ -28,16 +28,16 @@
* Indicates the 'role' hint for a given bean.
*
* <p>May be used on any class directly or indirectly annotated with
* {@link org.springframework.stereotype.Component} or on methods annotated with
* {@link Bean}.
* {@link org.springframework.stereotype.Component} or on methods
* annotated with {@link Bean}.
*
* <p>If this annotation is not present on a Component or Bean definition, the
* default value of {@link BeanDefinition#ROLE_APPLICATION} will apply.
* <p>If this annotation is not present on a Component or Bean definition,
* the default value of {@link BeanDefinition#ROLE_APPLICATION} will apply.
*
* <p>If Role is present on a {@link Configuration @Configuration} class, this
* indicates the role of the configuration class bean definition and does not
* cascade to all @{@code Bean} methods defined within. This behavior is
* different than that of the @{@link Lazy} annotation, for example.
* <p>If Role is present on a {@link Configuration @Configuration} class,
* this indicates the role of the configuration class bean definition and
* does not cascade to all @{@code Bean} methods defined within. This behavior
* is different than that of the @{@link Lazy} annotation, for example.
*
* @author Chris Beams
* @since 3.1
Expand Down
Expand Up @@ -152,7 +152,7 @@ public void setBasenames(String... basenames) {
* Set the default charset to use for parsing resource bundle files.
* <p>Default is none, using the {@code java.util.ResourceBundle}
* default encoding: ISO-8859-1.
* and more flexibility in setting of an encoding per file.
* @since 3.1.3
*/
public void setDefaultEncoding(String defaultEncoding) {
this.defaultEncoding = defaultEncoding;
Expand All @@ -167,6 +167,7 @@ public void setDefaultEncoding(String defaultEncoding) {
* {@code java.util.ResourceBundle}. However, this is often not desirable
* in an application server environment, where the system Locale is not relevant
* to the application at all: Set this flag to "false" in such a scenario.
* @since 3.1.3
*/
public void setFallbackToSystemLocale(boolean fallbackToSystemLocale) {
this.fallbackToSystemLocale = fallbackToSystemLocale;
Expand All @@ -188,6 +189,7 @@ public void setFallbackToSystemLocale(boolean fallbackToSystemLocale) {
* Consider {@link ReloadableResourceBundleMessageSource} in combination
* with resource bundle files in a non-classpath location.
* </ul>
* @since 3.1.3
*/
public void setCacheSeconds(int cacheSeconds) {
this.cacheMillis = (cacheSeconds * 1000);
Expand Down Expand Up @@ -304,7 +306,7 @@ protected ResourceBundle getResourceBundle(String basename, Locale locale) {
* @param locale the Locale to look for
* @return the corresponding ResourceBundle
* @throws MissingResourceException if no matching bundle could be found
* @see java.util.ResourceBundle#getBundle(String, java.util.Locale, ClassLoader)
* @see java.util.ResourceBundle#getBundle(String, Locale, ClassLoader)
* @see #getBundleClassLoader()
*/
protected ResourceBundle doGetBundle(String basename, Locale locale) throws MissingResourceException {
Expand Down
Expand Up @@ -44,7 +44,7 @@ public class ProxyAsyncConfiguration extends AbstractAsyncConfiguration {
public AsyncAnnotationBeanPostProcessor asyncAdvisor() {
Assert.notNull(this.enableAsync, "@EnableAsync annotation metadata was not injected");
AsyncAnnotationBeanPostProcessor bpp = new AsyncAnnotationBeanPostProcessor();
Class<? extends Annotation> customAsyncAnnotation = enableAsync.getClass("annotation");
Class<? extends Annotation> customAsyncAnnotation = this.enableAsync.getClass("annotation");
if (customAsyncAnnotation != AnnotationUtils.getDefaultValue(EnableAsync.class, "annotation")) {
bpp.setAsyncAnnotationType(customAsyncAnnotation);
}
Expand Down
@@ -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.
Expand Down Expand Up @@ -335,9 +335,10 @@ public static <E> Iterator<E> toIterator(Enumeration<E> enumeration) {
}

/**
* Adapt a {@code Map<K, List<V>>} to an {@code MultiValueMap<K,V>}.
* @param map the map
* Adapt a {@code Map<K, List<V>>} to an {@code MultiValueMap<K, V>}.
* @param map the original map
* @return the multi-value map
* @since 3.1
*/
public static <K, V> MultiValueMap<K, V> toMultiValueMap(Map<K, List<V>> map) {
return new MultiValueMapAdapter<K, V>(map);
Expand All @@ -348,8 +349,9 @@ public static <K, V> MultiValueMap<K, V> toMultiValueMap(Map<K, List<V>> map) {
* Return an unmodifiable view of the specified multi-value map.
* @param map the map for which an unmodifiable view is to be returned.
* @return an unmodifiable view of the specified multi-value map.
* @since 3.1
*/
public static <K,V> MultiValueMap<K,V> unmodifiableMultiValueMap(MultiValueMap<? extends K, ? extends V> map) {
public static <K, V> MultiValueMap<K, V> unmodifiableMultiValueMap(MultiValueMap<? extends K, ? extends V> map) {
Assert.notNull(map, "'map' must not be null");
Map<K, List<V>> result = new LinkedHashMap<K, List<V>>(map.size());
for (Map.Entry<? extends K, ? extends List<? extends V>> entry : map.entrySet()) {
Expand All @@ -366,7 +368,7 @@ public static <K,V> MultiValueMap<K,V> unmodifiableMultiValueMap(MultiValueMap<?
*/
private static class EnumerationIterator<E> implements Iterator<E> {

private Enumeration<E> enumeration;
private final Enumeration<E> enumeration;

public EnumerationIterator(Enumeration<E> enumeration) {
this.enumeration = enumeration;
Expand Down Expand Up @@ -476,8 +478,8 @@ public List<V> remove(Object key) {
}

@Override
public void putAll(Map<? extends K, ? extends List<V>> m) {
this.map.putAll(m);
public void putAll(Map<? extends K, ? extends List<V>> map) {
this.map.putAll(map);
}

@Override
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 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.
Expand Down Expand Up @@ -35,6 +35,7 @@ public class ByteBufferConverterTests {

private GenericConversionService conversionService;


@Before
public void setup() {
this.conversionService = new GenericConversionService();
Expand All @@ -43,6 +44,7 @@ public void setup() {
this.conversionService.addConverter(new OtherTypeToByteArrayConverter());
}


@Test
public void byteArrayToByteBuffer() throws Exception {
byte[] bytes = new byte[] { 1, 2, 3 };
Expand Down Expand Up @@ -78,6 +80,7 @@ public void otherTypeToByteBuffer() throws Exception {
assertThat(bytes, equalTo(convert.array()));
}


private static class OtherType {

private byte[] bytes;
Expand All @@ -88,17 +91,17 @@ public OtherType(byte[] bytes) {

}

private static class ByteArrayToOtherTypeConverter implements
Converter<byte[], OtherType> {

private static class ByteArrayToOtherTypeConverter implements Converter<byte[], OtherType> {

@Override
public OtherType convert(byte[] source) {
return new OtherType(source);
}
}

private static class OtherTypeToByteArrayConverter implements
Converter<OtherType, byte[]> {

private static class OtherTypeToByteArrayConverter implements Converter<OtherType, byte[]> {

@Override
public byte[] convert(OtherType source) {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 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.
Expand Down Expand Up @@ -34,7 +34,6 @@
*/
public enum TestGroup {


/**
* Tests that take a considerable amount of time to run. Any test lasting longer than
* 500ms should be considered a candidate in order to avoid making the overall test
Expand Down Expand Up @@ -68,6 +67,7 @@ public enum TestGroup {
*/
CUSTOM_COMPILATION;


/**
* Parse the specified comma separated string of groups.
* @param value the comma separated string of groups
Expand Down Expand Up @@ -102,4 +102,5 @@ private static Set<TestGroup> parseGroups(String value) {
}
return groups;
}

}
Expand Up @@ -29,7 +29,7 @@
* a default {@link JmsListenerEndpointRegistry}.
*
* <p>This configuration class is automatically imported when using the @{@link EnableJms}
* annotation. See {@link EnableJms} Javadoc for complete usage.
* annotation. See the {@link EnableJms} javadocs for complete usage details.
*
* @author Stephane Nicoll
* @since 4.1
Expand Down
@@ -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.
Expand Down Expand Up @@ -55,55 +55,56 @@ public class CastorMarshallerTests extends AbstractMarshallerTests {
/**
* Represents the expected result that doesn't contain the xml declaration.
*/
private static final String DOCUMENT_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<tns:flights xmlns:tns=\"http://samples.springframework.org/flight\">"
+ "<tns:flight><tns:number>42</tns:number></tns:flight></tns:flights>";
private static final String DOCUMENT_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<tns:flights xmlns:tns=\"http://samples.springframework.org/flight\">" +
"<tns:flight><tns:number>42</tns:number></tns:flight></tns:flights>";

/**
* Represents the expected result that doesn't contain the xml namespaces.
*/
private static final String SUPPRESSED_NAMESPACE_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><flights><flight><number>42</number></flight></flights>";
private static final String SUPPRESSED_NAMESPACE_EXPECTED_STRING =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><flights><flight><number>42</number></flight></flights>";

/**
* Represents the expected result with modified root element name.
*/
private static final String ROOT_ELEMENT_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<tns:canceledFlights xmlns:tns=\"http://samples.springframework.org/flight\">"
+ "<tns:flight><tns:number>42</tns:number></tns:flight></tns:canceledFlights>";
private static final String ROOT_ELEMENT_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<tns:canceledFlights xmlns:tns=\"http://samples.springframework.org/flight\">" +
"<tns:flight><tns:number>42</tns:number></tns:flight></tns:canceledFlights>";

/**
* Represents the expected result with 'xsi:type' attribute.
*/
private static final String XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<objects><castor-object xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ " xmlns:java=\"http://java.sun.com\""
+ " xsi:type=\"java:org.springframework.oxm.castor.CastorObject\">"
+ "<name>test</name><value>8</value></castor-object></objects>";
private static final String XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<objects><castor-object xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
" xmlns:java=\"http://java.sun.com\"" +
" xsi:type=\"java:org.springframework.oxm.castor.CastorObject\">" +
"<name>test</name><value>8</value></castor-object></objects>";

/**
* Represents the expected result with suppressed 'xsi:type' attribute.
*/
private static final String SUPPRESSED_XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<objects><castor-object><name>test</name><value>8</value></castor-object></objects>";
private static final String SUPPRESSED_XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<objects><castor-object><name>test</name><value>8</value></castor-object></objects>";

/**
* Represents the expected result with 'xsi:type' attribute for root element.
*/
private static final String ROOT_WITH_XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<objects xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ " xmlns:java=\"http://java.sun.com\""
+ " xsi:type=\"java:java.util.Arrays$ArrayList\">"
+ "<castor-object xsi:type=\"java:org.springframework.oxm.castor.CastorObject\">"
+ "<name>test</name><value>8</value></castor-object></objects>";
private static final String ROOT_WITH_XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<objects xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
" xmlns:java=\"http://java.sun.com\"" +
" xsi:type=\"java:java.util.Arrays$ArrayList\">" +
"<castor-object xsi:type=\"java:org.springframework.oxm.castor.CastorObject\">" +
"<name>test</name><value>8</value></castor-object></objects>";

/**
* Represents the expected result without 'xsi:type' attribute for root element.
*/
private static final String ROOT_WITHOUT_XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<objects><castor-object xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ " xmlns:java=\"http://java.sun.com\""
+ " xsi:type=\"java:org.springframework.oxm.castor.CastorObject\">"
+ "<name>test</name><value>8</value></castor-object></objects>";
private static final String ROOT_WITHOUT_XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<objects><castor-object xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
" xmlns:java=\"http://java.sun.com\"" +
" xsi:type=\"java:org.springframework.oxm.castor.CastorObject\">" +
"<name>test</name><value>8</value></castor-object></objects>";


@Override
Expand Down Expand Up @@ -277,9 +278,9 @@ private String marshalFlights() throws Exception {
}

/**
* Asserts the values of xpath expression evaluation is exactly the same as expected value. </p> The xpath may contain
* the xml namespace prefixes, since namespaces from flight example are being registered.
*
* Asserts the values of xpath expression evaluation is exactly the same as expected value.
* <p>The xpath may contain the xml namespace prefixes, since namespaces from flight example
* are being registered.
* @param msg the error message that will be used in case of test failure
* @param expected the expected value
* @param xpath the xpath to evaluate
Expand All @@ -302,13 +303,12 @@ private void assertXpathEvaluatesTo(String msg, String expected, String xpath, S

/**
* Creates a instance of {@link CastorObject} for testing.
*
* @return a instance of {@link CastorObject}
*/
private CastorObject createCastorObject() {
CastorObject castorObject = new CastorObject();
castorObject.setName("test");
castorObject.setValue(8);
return castorObject;
}

}

0 comments on commit 7ed7f98

Please sign in to comment.