提交 6a98b40e 编写于 作者: J Juergen Hoeller

Consistent use of LinkedHashMaps and independent getAttributeNames Enumeration...

Consistent use of LinkedHashMaps and independent getAttributeNames Enumeration in Servlet/Portlet mocks

Issue: SPR-10224
上级 94a88069
......@@ -30,6 +30,7 @@ import java.util.Date;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
......@@ -294,7 +295,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
public Enumeration<String> getAttributeNames() {
checkActive();
return Collections.enumeration(this.attributes.keySet());
return Collections.enumeration(new LinkedHashSet<String>(this.attributes.keySet()));
}
public String getCharacterEncoding() {
......
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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,6 +22,7 @@ import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
......@@ -50,6 +51,7 @@ public class MockHttpSession implements HttpSession {
public static final String SESSION_COOKIE_NAME = "JSESSION";
private static int nextId = 1;
private final String id;
......@@ -141,7 +143,7 @@ public class MockHttpSession implements HttpSession {
}
public Enumeration<String> getAttributeNames() {
return Collections.enumeration(this.attributes.keySet());
return Collections.enumeration(new LinkedHashSet<String>(this.attributes.keySet()));
}
public String[] getValueNames() {
......
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
......@@ -21,6 +21,7 @@ import java.io.UnsupportedEncodingException;
import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import javax.el.ELContext;
import javax.servlet.Servlet;
......@@ -249,7 +250,7 @@ public class MockPageContext extends PageContext {
}
public Enumeration<String> getAttributeNames() {
return Collections.enumeration(this.attributes.keySet());
return Collections.enumeration(new LinkedHashSet<String>(this.attributes.keySet()));
}
@SuppressWarnings("unchecked")
......
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
......@@ -29,7 +29,6 @@ import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import javax.activation.FileTypeMap;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
......@@ -434,7 +433,7 @@ public class MockServletContext implements ServletContext {
}
public Enumeration<String> getAttributeNames() {
return Collections.enumeration(this.attributes.keySet());
return Collections.enumeration(new LinkedHashSet<String>(this.attributes.keySet()));
}
public void setAttribute(String name, Object value) {
......
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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,7 +28,6 @@ import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
import javax.activation.FileTypeMap;
import javax.portlet.PortletContext;
import javax.portlet.PortletRequestDispatcher;
......@@ -210,7 +209,7 @@ public class MockPortletContext implements PortletContext {
}
public Enumeration<String> getAttributeNames() {
return new Vector<String>(this.attributes.keySet()).elements();
return Collections.enumeration(new LinkedHashSet<String>(this.attributes.keySet()));
}
public void setAttribute(String name, Object value) {
......
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
......@@ -21,13 +21,12 @@ import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
import javax.portlet.PortalContext;
import javax.portlet.PortletContext;
import javax.portlet.PortletMode;
......@@ -332,7 +331,7 @@ public class MockPortletRequest implements PortletRequest {
public Enumeration<String> getAttributeNames() {
checkActive();
return new Vector<String>(this.attributes.keySet()).elements();
return Collections.enumeration(new LinkedHashSet<String>(this.attributes.keySet()));
}
public void setParameters(Map<String, String[]> parameters) {
......
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
......@@ -18,10 +18,10 @@ package org.springframework.mock.web.portlet;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Vector;
import javax.portlet.PortletContext;
import javax.portlet.PortletSession;
import javax.servlet.http.HttpSessionBindingEvent;
......@@ -51,9 +51,9 @@ public class MockPortletSession implements PortletSession {
private final PortletContext portletContext;
private final Map<String, Object> portletAttributes = new HashMap<String, Object>();
private final Map<String, Object> portletAttributes = new LinkedHashMap<String, Object>();
private final Map<String, Object> applicationAttributes = new HashMap<String, Object>();
private final Map<String, Object> applicationAttributes = new LinkedHashMap<String, Object>();
private boolean invalid = false;
......@@ -92,15 +92,15 @@ public class MockPortletSession implements PortletSession {
}
public Enumeration<String> getAttributeNames() {
return new Vector<String>(this.portletAttributes.keySet()).elements();
return Collections.enumeration(new LinkedHashSet<String>(this.portletAttributes.keySet()));
}
public Enumeration<String> getAttributeNames(int scope) {
if (scope == PortletSession.PORTLET_SCOPE) {
return new Vector<String>(this.portletAttributes.keySet()).elements();
return Collections.enumeration(new LinkedHashSet<String>(this.portletAttributes.keySet()));
}
else if (scope == PortletSession.APPLICATION_SCOPE) {
return new Vector<String>(this.applicationAttributes.keySet()).elements();
return Collections.enumeration(new LinkedHashSet<String>(this.applicationAttributes.keySet()));
}
return null;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册