Merge pull request #102

Closes gh-102
This commit is contained in:
Rossen Stoyanchev
2020-05-04 20:10:32 +01:00
23 changed files with 139 additions and 184 deletions

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2004-2020 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
*
* https://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.binding.collection;
import java.io.Serializable;
@@ -68,7 +83,7 @@ public abstract class AbstractCachingMapDecorator<K, V> implements Map<K, V>, Se
* @param size the initial cache size
*/
public AbstractCachingMapDecorator(boolean weak, int size) {
Map<K, Object> internalMap = weak ? new WeakHashMap<K, Object> (size) : new HashMap<>(size);
Map<K, Object> internalMap = weak ? new WeakHashMap<>(size) : new HashMap<>(size);
this.targetMap = Collections.synchronizedMap(internalMap);
this.synchronize = true;
this.weak = weak;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 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,7 +22,7 @@ public class StringToCharacter extends StringToObject {
}
protected Object toObject(String string, Class<?> targetClass) {
return new Character(string.charAt(0));
return string.charAt(0);
}
protected String toString(Object object) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 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.
@@ -46,7 +46,7 @@ public class ELExpressionParser implements ExpressionParser {
private ExpressionFactory expressionFactory;
private Map<Class<?>, ELContextFactory> contextFactories = new HashMap<Class<?>, ELContextFactory>();
private Map<Class<?>, ELContextFactory> contextFactories = new HashMap<>();
private ConversionService conversionService = new DefaultConversionService();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 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.
@@ -44,13 +44,13 @@ public class DefaultMessageContext implements StateManageableMessageContext {
private MessageSource messageSource;
@SuppressWarnings("serial")
private Map<Object, List<Message>> sourceMessages = new AbstractCachingMapDecorator<Object, List<Message>>(
new LinkedHashMap<Object, List<Message>>()) {
private Map<Object, List<Message>> sourceMessages =
new AbstractCachingMapDecorator<Object, List<Message>>(new LinkedHashMap<>()) {
protected List<Message> create(Object source) {
return new ArrayList<>();
}
};
protected List<Message> create(Object source) {
return new ArrayList<>();
}
};
/**
* Creates a new default message context. Defaults to a message source that simply resolves default text and cannot
@@ -130,7 +130,7 @@ public class DefaultMessageContext implements StateManageableMessageContext {
// implementing state manageable message context
public Serializable createMessagesMemento() {
return new LinkedHashMap<Object, List<Message>>(sourceMessages);
return new LinkedHashMap<>(sourceMessages);
}
@SuppressWarnings("unchecked")

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 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.
@@ -164,11 +164,7 @@ public class DefaultConversionServiceTests {
DefaultConversionService service = new DefaultConversionService();
service.addConverter("princy", new CustomTwoWayConverter());
ConversionExecutor executor = service.getConversionExecutor("princy", Principal.class, String.class);
assertEquals("name", executor.execute(new Principal() {
public String getName() {
return "name";
}
}));
assertEquals("name", executor.execute((Principal) () -> "name"));
}
@Test
@@ -197,16 +193,8 @@ public class DefaultConversionServiceTests {
DefaultConversionService service = new DefaultConversionService();
service.addConverter("princy", new CustomTwoWayConverter());
ConversionExecutor executor = service.getConversionExecutor("princy", Principal[].class, String[].class);
final Principal princy1 = new Principal() {
public String getName() {
return "princy1";
}
};
final Principal princy2 = new Principal() {
public String getName() {
return "princy2";
}
};
final Principal princy1 = () -> "princy1";
final Principal princy2 = () -> "princy2";
String[] p = (String[]) executor.execute(new Principal[] { princy1, princy2 });
assertEquals("princy1", p[0]);
assertEquals("princy2", p[1]);
@@ -567,11 +555,7 @@ public class DefaultConversionServiceTests {
private static class CustomConverter implements Converter {
public Object convertSourceToTargetClass(final Object source, Class<?> targetClass) throws Exception {
return new Principal() {
public String getName() {
return (String) source;
}
};
return (Principal) () -> (String) source;
}
public Class<?> getSourceClass() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2014 the original author or authors.
* Copyright 2004-2020 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.
@@ -82,7 +82,7 @@ public class FacesFlowBuilderServicesBeanDefinitionParser extends AbstractSingle
private boolean parseEnableManagedBeans(Element element, BeanDefinitionBuilder definitionBuilder) {
String enableManagedBeans = element.getAttribute(ENABLE_MANAGED_BEANS_ATTR);
if (StringUtils.hasText(enableManagedBeans)) {
return Boolean.valueOf(enableManagedBeans);
return Boolean.parseBoolean(enableManagedBeans);
} else {
return false;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 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.
@@ -52,7 +52,7 @@ public class SelectionTrackingActionListener implements ActionListener {
private final ActionListener delegate;
private final Map<Class<?>, Method> valueMethodCache = new ConcurrentHashMap<Class<?>, Method>(256);
private final Map<Class<?>, Method> valueMethodCache = new ConcurrentHashMap<>(256);
public SelectionTrackingActionListener(ActionListener delegate) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2015 the original author or authors.
* Copyright 2004-2020 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.
@@ -28,6 +28,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import javax.el.ELContext;
import javax.faces.application.FacesMessage;
import javax.faces.context.ExternalContext;
@@ -38,7 +39,6 @@ import javax.faces.context.PartialViewContextFactory;
import javax.faces.lifecycle.Lifecycle;
import org.springframework.binding.message.Message;
import org.springframework.binding.message.MessageCriteria;
import org.springframework.binding.message.MessageResolver;
import org.springframework.binding.message.Severity;
import org.springframework.context.MessageSource;
@@ -230,12 +230,9 @@ public class FlowFacesContext extends FacesContextWrapper {
*/
public List<FacesMessage> getMessageList(final String clientId) {
final FacesMessageSource source = new FacesMessageSource(clientId);
Message[] messages = this.context.getMessageContext().getMessagesByCriteria(new MessageCriteria() {
public boolean test(Message message) {
return ObjectUtils.nullSafeEquals(message.getSource(), source)
|| ObjectUtils.nullSafeEquals(message.getSource(), clientId);
}
});
Message[] messages = this.context.getMessageContext().getMessagesByCriteria(message ->
ObjectUtils.nullSafeEquals(message.getSource(), source)
|| ObjectUtils.nullSafeEquals(message.getSource(), clientId));
return asFacesMessages(messages);
}
@@ -338,8 +335,8 @@ public class FlowFacesContext extends FacesContextWrapper {
String detail = (String) ois.readObject();
int severityOrdinal = ois.readInt();
FacesMessage.Severity severity = FacesMessage.SEVERITY_INFO;
for (Iterator<?> iterator = FacesMessage.VALUES.iterator(); iterator.hasNext();) {
FacesMessage.Severity value = (FacesMessage.Severity) iterator.next();
for (Object o : FacesMessage.VALUES) {
FacesMessage.Severity value = (FacesMessage.Severity) o;
if (value.getOrdinal() == severityOrdinal) {
severity = value;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 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.
@@ -289,11 +289,7 @@ class FlowRegistryFactoryBean implements FactoryBean<FlowDefinitionRegistry>, Be
flowRegistry, flowBuilderServices);
FlowAssembler assembler = new FlowAssembler(builder, builderContext);
return assembler.assembleFlow();
} catch (IllegalArgumentException e) {
throw new FlowDefinitionConstructionException(builderInfo.getId(), e);
} catch (InstantiationException e) {
throw new FlowDefinitionConstructionException(builderInfo.getId(), e);
} catch (IllegalAccessException e) {
} catch (IllegalArgumentException | IllegalAccessException | InstantiationException e) {
throw new FlowDefinitionConstructionException(builderInfo.getId(), e);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2015 the original author or authors.
* Copyright 2004-2020 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,8 +16,6 @@
package org.springframework.webflow.conversation.impl;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -134,8 +132,7 @@ public class ConversationContainer implements Serializable {
* Remove identified conversation from this container.
*/
public synchronized void removeConversation(ConversationId id) {
for (Iterator<ContainedConversation> it = conversations.iterator(); it.hasNext();) {
ContainedConversation conversation = it.next();
for (ContainedConversation conversation : conversations) {
if (conversation.getId().equals(id)) {
conversations.remove(conversation);
break;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2008 the original author or authors.
* Copyright 2004-2020 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.
@@ -93,9 +93,7 @@ public class DefaultDocumentLoader implements DocumentLoader {
}
public Document loadDocument(Resource resource) throws IOException, ParserConfigurationException, SAXException {
InputStream is = null;
try {
is = resource.getInputStream();
try (InputStream is = resource.getInputStream()) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(isValidating());
factory.setNamespaceAware(true);
@@ -111,10 +109,6 @@ public class DefaultDocumentLoader implements DocumentLoader {
docBuilder.setErrorHandler(new SimpleSaxErrorHandler(logger));
docBuilder.setEntityResolver(getEntityResolver());
return docBuilder.parse(is);
} finally {
if (is != null) {
is.close();
}
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 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.
@@ -58,7 +58,7 @@ public class TransitionExecutingFlowExecutionExceptionHandler implements FlowExe
/**
* The exceptionType to targetStateResolver map.
*/
private Map<Class<? extends Throwable>, TargetStateResolver> exceptionTargetStateMappings = new HashMap<Class<? extends Throwable>, TargetStateResolver>();
private Map<Class<? extends Throwable>, TargetStateResolver> exceptionTargetStateMappings = new HashMap<>();
/**
* The list of actions to execute when this handler handles an exception.
@@ -190,4 +190,4 @@ public class TransitionExecutingFlowExecutionExceptionHandler implements FlowExe
public String toString() {
return new ToStringCreator(this).append("exceptionHandlingMappings", exceptionTargetStateMappings).toString();
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 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.
@@ -168,13 +168,10 @@ public class SerializedFlowExecutionSnapshot extends FlowExecutionSnapshot imple
*/
protected byte[] serialize(FlowExecution flowExecution) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
ObjectOutputStream oos = new ObjectOutputStream(baos);
try {
try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
oos.writeObject(flowExecution);
oos.flush();
return baos.toByteArray();
} finally {
oos.close();
}
}
@@ -189,11 +186,8 @@ public class SerializedFlowExecutionSnapshot extends FlowExecutionSnapshot imple
*/
protected FlowExecution deserialize(byte[] data, ClassLoader classLoader) throws IOException,
ClassNotFoundException {
ObjectInputStream ois = new ConfigurableObjectInputStream(new ByteArrayInputStream(data), classLoader);
try {
try (ObjectInputStream ois = new ConfigurableObjectInputStream(new ByteArrayInputStream(data), classLoader)) {
return (FlowExecution) ois.readObject();
} finally {
ois.close();
}
}
@@ -203,12 +197,9 @@ public class SerializedFlowExecutionSnapshot extends FlowExecutionSnapshot imple
*/
protected byte[] compress(byte[] dataToCompress) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
GZIPOutputStream gzipos = new GZIPOutputStream(baos);
try {
try (GZIPOutputStream gzipos = new GZIPOutputStream(baos)) {
gzipos.write(dataToCompress);
gzipos.flush();
} finally {
gzipos.close();
}
return baos.toByteArray();
}
@@ -231,7 +222,7 @@ public class SerializedFlowExecutionSnapshot extends FlowExecutionSnapshot imple
private static class ConfigurableObjectInputStream extends ObjectInputStream {
/* Temporary workaround for SPR-???? */
private static final HashMap<String, Class<?>> PRIMITIVE_CLASSES = new HashMap<String, Class<?>>(8, 1.0F);
private static final HashMap<String, Class<?>> PRIMITIVE_CLASSES = new HashMap<>(8, 1.0F);
static {
PRIMITIVE_CLASSES.put("boolean", boolean.class);
PRIMITIVE_CLASSES.put("byte", byte.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 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.
@@ -50,21 +50,11 @@ public class FlowVariablePropertyAccessor implements PropertyAccessor {
private static Map<String, FlowVariableAccessor> variables = new HashMap<>();
static {
variables.put("currentUser", new FlowVariableAccessor() {
public Object getVariable() {
return RequestContextHolder.getRequestContext().getExternalContext().getCurrentUser();
}
});
variables.put("flowRequestContext", new FlowVariableAccessor() {
public Object getVariable() {
return RequestContextHolder.getRequestContext();
}
});
variables.put("resourceBundle", new FlowVariableAccessor() {
public Object getVariable() {
return RequestContextHolder.getRequestContext().getActiveFlow().getApplicationContext();
}
});
variables.put("currentUser", () ->
RequestContextHolder.getRequestContext().getExternalContext().getCurrentUser());
variables.put("flowRequestContext", RequestContextHolder::getRequestContext);
variables.put("resourceBundle", () ->
RequestContextHolder.getRequestContext().getActiveFlow().getApplicationContext());
}
public Class<?>[] getSpecificTargetClasses() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2018 the original author or authors.
* Copyright 2004-2020 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.
@@ -547,8 +547,8 @@ public abstract class AbstractMvcView implements View {
if (!beanWrapper.isReadableProperty(propertyNames.get(0))) {
return false;
}
for (int i=0; i < propertyNames.size(); i++) {
if (!SourceVersion.isName(propertyNames.get(i))) {
for (String propertyName : propertyNames) {
if (!SourceVersion.isName(propertyName)) {
return false;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2015 the original author or authors.
* Copyright 2004-2020 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.
@@ -107,7 +107,7 @@ public class SecurityFlowExecutionListener implements FlowExecutionListener {
}
private AbstractAccessDecisionManager createManager(SecurityRule rule) {
List<AccessDecisionVoter<? extends Object>> voters = new ArrayList<AccessDecisionVoter<? extends Object>>();
List<AccessDecisionVoter<? extends Object>> voters = new ArrayList<>();
voters.add(new RoleVoter());
if (rule.getComparisonType() == SecurityRule.COMPARISON_ANY) {
return new AffirmativeBased(voters);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 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.
@@ -370,7 +370,7 @@ public class MockExternalContext implements ExternalContext {
* @param responseAllowed true or false
*/
public void setResponseAllowed(boolean responseAllowed) {
this.responseAllowed = Boolean.valueOf(responseAllowed);
this.responseAllowed = responseAllowed;
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2008 the original author or authors.
* Copyright 2004-2020 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.
@@ -63,9 +63,7 @@ public class WebFlowUpgrader {
Source source = new StreamSource(flowResource.getInputStream());
Result result = new StreamResult(output);
transform(source, result);
} catch (TransformerException e) {
e.printStackTrace();
} catch (IOException e) {
} catch (TransformerException | IOException e) {
e.printStackTrace();
}
return output.toString();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008-2012 the original author or authors.
* Copyright 2008-2020 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.
@@ -357,7 +357,7 @@ public class ValidationHelper {
private Method findValidationMethod(Object model, Object validator, String methodName, Class<?> context) {
Class<?> modelClass = AopUtils.getTargetClass(model);
List<Class<?>> modelSearchClasses = new ArrayList<Class<?>>();
List<Class<?>> modelSearchClasses = new ArrayList<>();
while (modelClass != null) {
modelSearchClasses.add(modelClass);
modelClass = modelClass.getSuperclass();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 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.
@@ -45,33 +45,33 @@ public class LocalAttributeMapTests {
attributeMap.put("integer", 12345);
attributeMap.put("boolean", true);
attributeMap.put("long", 12345L);
attributeMap.put("double", new Double(12345));
attributeMap.put("float", new Float(12345));
attributeMap.put("double", 12345d);
attributeMap.put("float", 12345f);
attributeMap.put("bigDecimal", new BigDecimal("12345.67"));
attributeMap.put("bean", new TestBean());
attributeMap.put("stringArray", new String[] { "1", "2", "3" });
attributeMap.put("collection", new LinkedList<>());
}
@Test
@Test
public void testGet() {
TestBean bean = (TestBean) attributeMap.get("bean");
assertNotNull(bean);
}
@Test
@Test
public void testGetNull() {
TestBean bean = (TestBean) attributeMap.get("bogus");
assertNull(bean);
}
@Test
@Test
public void testGetRequiredType() {
TestBean bean = attributeMap.get("bean", TestBean.class);
assertNotNull(bean);
}
@Test
@Test
public void testGetWrongType() {
try {
attributeMap.get("bean", String.class);
@@ -81,7 +81,7 @@ public class LocalAttributeMapTests {
}
}
@Test
@Test
public void testGetWithDefaultOption() {
TestBean d = new TestBean();
TestBean bean = (TestBean) attributeMap.get("bean", d);
@@ -89,20 +89,20 @@ public class LocalAttributeMapTests {
assertNotSame(bean, d);
}
@Test
@Test
public void testGetWithDefault() {
TestBean d = new TestBean();
TestBean bean = (TestBean) attributeMap.get("bogus", d);
assertSame(bean, d);
}
@Test
@Test
public void testGetRequired() {
TestBean bean = (TestBean) attributeMap.getRequired("bean");
assertNotNull(bean);
}
@Test
@Test
public void testGetRequiredNotPresent() {
try {
attributeMap.getRequired("bogus");
@@ -112,13 +112,13 @@ public class LocalAttributeMapTests {
}
}
@Test
@Test
public void testGetRequiredOfType() {
TestBean bean = attributeMap.getRequired("bean", TestBean.class);
assertNotNull(bean);
}
@Test
@Test
public void testGetRequiredWrongType() {
try {
attributeMap.getRequired("bean", String.class);
@@ -128,13 +128,13 @@ public class LocalAttributeMapTests {
}
}
@Test
@Test
public void testGetNumber() {
BigDecimal bd = attributeMap.getNumber("bigDecimal", BigDecimal.class);
assertEquals(new BigDecimal("12345.67"), bd);
}
@Test
@Test
public void testGetNumberWrongType() {
try {
attributeMap.getNumber("bigDecimal", Integer.class);
@@ -144,7 +144,7 @@ public class LocalAttributeMapTests {
}
}
@Test
@Test
public void testGetNumberWithDefaultOption() {
BigDecimal d = new BigDecimal("1");
BigDecimal bd = attributeMap.getNumber("bigDecimal", BigDecimal.class, d);
@@ -152,7 +152,7 @@ public class LocalAttributeMapTests {
assertNotSame(d, bd);
}
@Test
@Test
public void testGetNumberWithDefault() {
BigDecimal d = new BigDecimal("1");
BigDecimal bd = attributeMap.getNumber("bogus", BigDecimal.class, d);
@@ -160,13 +160,13 @@ public class LocalAttributeMapTests {
assertSame(d, bd);
}
@Test
@Test
public void testGetNumberRequired() {
BigDecimal bd = attributeMap.getRequiredNumber("bigDecimal", BigDecimal.class);
assertEquals(new BigDecimal("12345.67"), bd);
}
@Test
@Test
public void testGetNumberRequiredNotPresent() {
try {
attributeMap.getRequiredNumber("bogus", BigDecimal.class);
@@ -176,25 +176,25 @@ public class LocalAttributeMapTests {
}
}
@Test
@Test
public void testGetInteger() {
Integer i = attributeMap.getInteger("integer");
assertEquals(new Integer(12345), i);
}
@Test
@Test
public void testGetIntegerNull() {
Integer i = attributeMap.getInteger("bogus");
assertNull(i);
}
@Test
@Test
public void testGetIntegerRequired() {
Integer i = attributeMap.getRequiredInteger("integer");
assertEquals(new Integer(12345), i);
}
@Test
@Test
public void testGetIntegerRequiredNotPresent() {
try {
attributeMap.getRequiredInteger("bogus");
@@ -204,25 +204,25 @@ public class LocalAttributeMapTests {
}
}
@Test
@Test
public void testGetLong() {
Long i = attributeMap.getLong("long");
assertEquals(new Long(12345), i);
}
@Test
@Test
public void testGetLongNull() {
Long i = attributeMap.getLong("bogus");
assertNull(i);
}
@Test
@Test
public void testGetLongRequired() {
Long i = attributeMap.getRequiredLong("long");
assertEquals(new Long(12345), i);
}
@Test
@Test
public void testGetLongRequiredNotPresent() {
try {
attributeMap.getRequiredLong("bogus");
@@ -232,25 +232,25 @@ public class LocalAttributeMapTests {
}
}
@Test
@Test
public void testGetString() {
String i = attributeMap.getString("string");
assertEquals("A string", i);
}
@Test
@Test
public void testGetStringNull() {
String i = attributeMap.getString("bogus");
assertNull(i);
}
@Test
@Test
public void testGetStringRequired() {
String i = attributeMap.getRequiredString("string");
assertEquals("A string", i);
}
@Test
@Test
public void testGetStringRequiredNotPresent() {
try {
attributeMap.getRequiredString("bogus");
@@ -260,25 +260,25 @@ public class LocalAttributeMapTests {
}
}
@Test
@Test
public void testGetBoolean() {
Boolean i = attributeMap.getBoolean("boolean");
assertEquals(Boolean.TRUE, i);
}
@Test
@Test
public void testGetBooleanNull() {
Boolean i = attributeMap.getBoolean("bogus");
assertNull(i);
}
@Test
@Test
public void testGetBooleanRequired() {
Boolean i = attributeMap.getRequiredBoolean("boolean");
assertEquals(Boolean.TRUE, i);
}
@Test
@Test
public void testGetBooleanRequiredNotPresent() {
try {
attributeMap.getRequiredBoolean("bogus");
@@ -288,25 +288,25 @@ public class LocalAttributeMapTests {
}
}
@Test
@Test
public void testGetArray() {
String[] i = attributeMap.getArray("stringArray", String[].class);
assertEquals(3, i.length);
}
@Test
@Test
public void testGetArrayNull() {
String[] i = attributeMap.getArray("A bogus array", String[].class);
assertNull(i);
}
@Test
@Test
public void testGetArrayRequired() {
String[] i = attributeMap.getRequiredArray("stringArray", String[].class);
assertEquals(3, i.length);
}
@Test
@Test
public void testGetArrayRequiredNotPresent() {
try {
attributeMap.getRequiredArray("A bogus array", String[].class);
@@ -317,7 +317,7 @@ public class LocalAttributeMapTests {
}
@SuppressWarnings("unchecked")
@Test
@Test
public void testGetCollection() {
List<Object> i = attributeMap.getCollection("collection", List.class);
assertTrue(i instanceof LinkedList);
@@ -325,20 +325,20 @@ public class LocalAttributeMapTests {
}
@SuppressWarnings("unchecked")
@Test
@Test
public void testGetCollectionNull() {
List<Object> i = attributeMap.getCollection("bogus", List.class);
assertNull(i);
}
@SuppressWarnings("unchecked")
@Test
@Test
public void testGetCollectionRequired() {
List<Object> i = attributeMap.getRequiredCollection("collection", List.class);
assertEquals(0, i.size());
}
@Test
@Test
public void testGetCollectionRequiredNotPresent() {
try {
attributeMap.getRequiredCollection("A bogus collection");
@@ -348,13 +348,13 @@ public class LocalAttributeMapTests {
}
}
@Test
@Test
public void testGetMap() {
Map<String, Object> map = attributeMap.asMap();
assertEquals(10, map.size());
}
@Test
@Test
public void testUnion() {
LocalAttributeMap<Object> one = new LocalAttributeMap<>();
one.put("foo", "bar");
@@ -371,7 +371,7 @@ public class LocalAttributeMapTests {
assertEquals("boo", three.get("bar"));
}
@Test
@Test
public void testEquality() {
LocalAttributeMap<String> map = new LocalAttributeMap<>();
map.put("foo", "bar");
@@ -382,7 +382,7 @@ public class LocalAttributeMapTests {
assertEquals(map, map2);
}
@Test
@Test
public void testExtract() {
assertEquals("A string", attributeMap.extract("string"));
assertFalse(attributeMap.contains("string"));

View File

@@ -1,19 +1,14 @@
package org.springframework.webflow.expression.el;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import java.security.Principal;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.el.ELResolver;
import javax.el.PropertyNotWritableException;
import org.junit.jupiter.api.Test;
import org.springframework.binding.message.MessageContext;
import org.springframework.util.ClassUtils;
import org.springframework.webflow.context.ExternalContext;
@@ -27,6 +22,11 @@ import org.springframework.webflow.test.MockFlowExecutionContext;
import org.springframework.webflow.test.MockFlowExecutionKey;
import org.springframework.webflow.test.MockRequestContext;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
public class ImplicitFlowVariableELResolverTests extends FlowDependentELResolverTestCase {
private static final List<String> vars = new ArrayList<>();
@@ -261,9 +261,7 @@ public class ImplicitFlowVariableELResolverTests extends FlowDependentELResolver
@Test
public void testIsReadOnly_AllVars() {
RequestContextHolder.setRequestContext(new MockRequestContext());
Iterator<String> i = vars.iterator();
while (i.hasNext()) {
String var = i.next();
for (String var : vars) {
assertTrue(context.getELResolver().isReadOnly(context, null, var));
}
}
@@ -271,9 +269,7 @@ public class ImplicitFlowVariableELResolverTests extends FlowDependentELResolver
@Test
public void testSetValue_AllVars() {
RequestContextHolder.setRequestContext(new MockRequestContext());
Iterator<String> i = vars.iterator();
while (i.hasNext()) {
String var = i.next();
for (String var : vars) {
try {
context.getELResolver().setValue(context, null, var, new Object());
fail("setValue should not be allowed");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 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.
@@ -15,20 +15,19 @@
*/
package org.springframework.webflow.expression.spel;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.webflow.engine.ViewState;
import org.springframework.webflow.execution.RequestContext;
import org.springframework.webflow.execution.View;
import org.springframework.webflow.execution.ViewFactory;
import org.springframework.webflow.test.MockFlowSession;
import org.springframework.webflow.test.MockRequestContext;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
public class ScopeSearchingPropertyAccessorTests {
private ScopeSearchingPropertyAccessor accessor = new ScopeSearchingPropertyAccessor();
@@ -79,10 +78,8 @@ public class ScopeSearchingPropertyAccessorTests {
protected void initView(MockRequestContext requestContext) {
((MockFlowSession) requestContext.getFlowExecutionContext().getActiveSession()).setState(new ViewState(
requestContext.getRootFlow(), "view", new ViewFactory() {
public View getView(RequestContext context) {
throw new UnsupportedOperationException("Not implemented");
}
requestContext.getRootFlow(), "view", context -> {
throw new UnsupportedOperationException("Not implemented");
}));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 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.
@@ -37,7 +37,7 @@ public class TestBean {
}
public TestBean(long id, String name) {
this.entityId = new Long(id);
this.entityId = id;
this.name = name;
}