Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dk131072
spring-framework
提交
3b9833c5
S
spring-framework
项目概览
dk131072
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3b9833c5
编写于
8月 16, 2012
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update MockHttpSession across the test suite
上级
80596256
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
109 addition
and
43 deletion
+109
-43
spring-orm/src/test/java/org/springframework/mock/web/MockHttpSession.java
...st/java/org/springframework/mock/web/MockHttpSession.java
+22
-6
spring-test/src/main/java/org/springframework/mock/web/MockHttpSession.java
...in/java/org/springframework/mock/web/MockHttpSession.java
+7
-2
spring-web/src/test/java/org/springframework/mock/web/MockHttpSession.java
...st/java/org/springframework/mock/web/MockHttpSession.java
+26
-11
spring-webmvc-portlet/src/test/java/org/springframework/mock/web/MockHttpSession.java
...st/java/org/springframework/mock/web/MockHttpSession.java
+28
-13
spring-webmvc/src/test/java/org/springframework/mock/web/MockHttpSession.java
...st/java/org/springframework/mock/web/MockHttpSession.java
+26
-11
未找到文件。
spring-orm/src/test/java/org/springframework/mock/web/MockHttpSession.java
浏览文件 @
3b9833c5
/*
* Copyright 2002-201
1
the original author or authors.
* Copyright 2002-201
2
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.
...
...
@@ -17,12 +17,12 @@
package
org.springframework.mock.web
;
import
java.io.Serializable
;
import
java.util.Collections
;
import
java.util.Enumeration
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.Vector
;
import
javax.servlet.ServletContext
;
import
javax.servlet.http.HttpSession
;
import
javax.servlet.http.HttpSessionBindingEvent
;
...
...
@@ -36,14 +36,20 @@ import org.springframework.util.Assert;
*
* <p>Compatible with Servlet 2.5 as well as Servlet 3.0.
*
* <p>Used for testing the web framework; also useful for testing application
* controllers.
*
* @author Juergen Hoeller
* @author Rod Johnson
* @author Mark Fisher
* @author Sam Brannen
* @since 1.0.2
*/
@SuppressWarnings
(
"deprecation"
)
public
class
MockHttpSession
implements
HttpSession
{
public
static
final
String
SESSION_COOKIE_NAME
=
"JSESSION"
;
private
static
int
nextId
=
1
;
private
final
String
id
;
...
...
@@ -64,9 +70,9 @@ public class MockHttpSession implements HttpSession {
/**
* Create a new MockHttpSession with a default {@link
org.springframework.mock.web.
MockServletContext}.
*
* @see
org.springframework.mock.web.
MockServletContext
* Create a new MockHttpSession with a default {@link MockServletContext}.
*
* @see MockServletContext
*/
public
MockHttpSession
()
{
this
(
null
);
...
...
@@ -135,7 +141,7 @@ public class MockHttpSession implements HttpSession {
}
public
Enumeration
<
String
>
getAttributeNames
()
{
return
new
Vector
<
String
>(
this
.
attributes
.
keySet
()).
elements
(
);
return
Collections
.
enumeration
(
this
.
attributes
.
keySet
()
);
}
public
String
[]
getValueNames
()
{
...
...
@@ -186,7 +192,17 @@ public class MockHttpSession implements HttpSession {
}
}
/**
* Invalidates this session then unbinds any objects bound to it.
*
* @throws IllegalStateException if this method is called on an already invalidated session
*/
public
void
invalidate
()
{
if
(
this
.
invalid
)
{
throw
new
IllegalStateException
(
"The session has already been invalidated"
);
}
// else
this
.
invalid
=
true
;
clearAttributes
();
}
...
...
spring-test/src/main/java/org/springframework/mock/web/MockHttpSession.java
浏览文件 @
3b9833c5
...
...
@@ -17,12 +17,12 @@
package
org.springframework.mock.web
;
import
java.io.Serializable
;
import
java.util.Collections
;
import
java.util.Enumeration
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.Vector
;
import
javax.servlet.ServletContext
;
import
javax.servlet.http.HttpSession
;
import
javax.servlet.http.HttpSessionBindingEvent
;
...
...
@@ -36,6 +36,9 @@ import org.springframework.util.Assert;
*
* <p>Compatible with Servlet 2.5 as well as Servlet 3.0.
*
* <p>Used for testing the web framework; also useful for testing application
* controllers.
*
* @author Juergen Hoeller
* @author Rod Johnson
* @author Mark Fisher
...
...
@@ -45,6 +48,8 @@ import org.springframework.util.Assert;
@SuppressWarnings
(
"deprecation"
)
public
class
MockHttpSession
implements
HttpSession
{
public
static
final
String
SESSION_COOKIE_NAME
=
"JSESSION"
;
private
static
int
nextId
=
1
;
private
final
String
id
;
...
...
@@ -136,7 +141,7 @@ public class MockHttpSession implements HttpSession {
}
public
Enumeration
<
String
>
getAttributeNames
()
{
return
new
Vector
<
String
>(
this
.
attributes
.
keySet
()).
elements
(
);
return
Collections
.
enumeration
(
this
.
attributes
.
keySet
()
);
}
public
String
[]
getValueNames
()
{
...
...
spring-web/src/test/java/org/springframework/mock/web/MockHttpSession.java
浏览文件 @
3b9833c5
/*
* Copyright 2002-20
09
the original author or authors.
* Copyright 2002-20
12
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.
...
...
@@ -33,23 +33,25 @@ import org.springframework.util.Assert;
/**
* Mock implementation of the {@link javax.servlet.http.HttpSession} interface.
* Supports the Servlet 2.4 API level.
*
* <p>Used for testing the web framework; also useful for testing
* application controllers.
* <p>Compatible with Servlet 2.5 as well as Servlet 3.0.
*
* <p>Used for testing the web framework; also useful for testing application
* controllers.
*
* @author Juergen Hoeller
* @author Rod Johnson
* @author Mark Fisher
* @author Sam Brannen
* @since 1.0.2
*/
@SuppressWarnings
(
"deprecation"
)
public
class
MockHttpSession
implements
HttpSession
{
public
static
final
String
SESSION_COOKIE_NAME
=
"JSESSION"
;
private
static
int
nextId
=
1
;
private
final
String
id
;
private
final
long
creationTime
=
System
.
currentTimeMillis
();
...
...
@@ -69,6 +71,7 @@ public class MockHttpSession implements HttpSession {
/**
* Create a new MockHttpSession with a default {@link MockServletContext}.
*
* @see MockServletContext
*/
public
MockHttpSession
()
{
...
...
@@ -77,6 +80,7 @@ public class MockHttpSession implements HttpSession {
/**
* Create a new MockHttpSession.
*
* @param servletContext the ServletContext that the session runs in
*/
public
MockHttpSession
(
ServletContext
servletContext
)
{
...
...
@@ -85,6 +89,7 @@ public class MockHttpSession implements HttpSession {
/**
* Create a new MockHttpSession.
*
* @param servletContext the ServletContext that the session runs in
* @param id a unique identifier for this session
*/
...
...
@@ -93,7 +98,6 @@ public class MockHttpSession implements HttpSession {
this
.
id
=
(
id
!=
null
?
id
:
Integer
.
toString
(
nextId
++));
}
public
long
getCreationTime
()
{
return
this
.
creationTime
;
}
...
...
@@ -188,7 +192,17 @@ public class MockHttpSession implements HttpSession {
}
}
/**
* Invalidates this session then unbinds any objects bound to it.
*
* @throws IllegalStateException if this method is called on an already invalidated session
*/
public
void
invalidate
()
{
if
(
this
.
invalid
)
{
throw
new
IllegalStateException
(
"The session has already been invalidated"
);
}
// else
this
.
invalid
=
true
;
clearAttributes
();
}
...
...
@@ -205,10 +219,10 @@ public class MockHttpSession implements HttpSession {
return
this
.
isNew
;
}
/**
* Serialize the attributes of this session into an object that can
* be turned into a byte array with standard Java serialization.
* Serialize the attributes of this session into an object that can be
* turned into a byte array with standard Java serialization.
*
* @return a representation of this session's serialized state
*/
public
Serializable
serializeState
()
{
...
...
@@ -233,8 +247,9 @@ public class MockHttpSession implements HttpSession {
}
/**
* Deserialize the attributes of this session from a state object
* created by {@link #serializeState()}.
* Deserialize the attributes of this session from a state object created by
* {@link #serializeState()}.
*
* @param state a representation of this session's serialized state
*/
@SuppressWarnings
(
"unchecked"
)
...
...
spring-webmvc-portlet/src/test/java/org/springframework/mock/web/MockHttpSession.java
浏览文件 @
3b9833c5
/*
* Copyright 2002-20
09
the original author or authors.
* Copyright 2002-20
12
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.
...
...
@@ -33,23 +33,25 @@ import org.springframework.util.Assert;
/**
* Mock implementation of the {@link javax.servlet.http.HttpSession} interface.
* Supports the Servlet 2.4 API level.
*
* <p>Used for testing the web framework; also useful for testing
* application controllers.
* <p>Compatible with Servlet 2.5 as well as Servlet 3.0.
*
* <p>Used for testing the web framework; also useful for testing application
* controllers.
*
* @author Juergen Hoeller
* @author Rod Johnson
* @author Mark Fisher
* @author Sam Brannen
* @since 1.0.2
*/
@SuppressWarnings
(
"deprecation"
)
public
class
MockHttpSession
implements
HttpSession
{
public
static
final
String
SESSION_COOKIE_NAME
=
"JSESSION"
;
private
static
int
nextId
=
1
;
private
final
String
id
;
private
final
long
creationTime
=
System
.
currentTimeMillis
();
...
...
@@ -68,8 +70,9 @@ public class MockHttpSession implements HttpSession {
/**
* Create a new MockHttpSession with a default {@link org.springframework.mock.web.MockServletContext}.
* @see org.springframework.mock.web.MockServletContext
* Create a new MockHttpSession with a default {@link MockServletContext}.
*
* @see MockServletContext
*/
public
MockHttpSession
()
{
this
(
null
);
...
...
@@ -77,6 +80,7 @@ public class MockHttpSession implements HttpSession {
/**
* Create a new MockHttpSession.
*
* @param servletContext the ServletContext that the session runs in
*/
public
MockHttpSession
(
ServletContext
servletContext
)
{
...
...
@@ -85,6 +89,7 @@ public class MockHttpSession implements HttpSession {
/**
* Create a new MockHttpSession.
*
* @param servletContext the ServletContext that the session runs in
* @param id a unique identifier for this session
*/
...
...
@@ -93,7 +98,6 @@ public class MockHttpSession implements HttpSession {
this
.
id
=
(
id
!=
null
?
id
:
Integer
.
toString
(
nextId
++));
}
public
long
getCreationTime
()
{
return
this
.
creationTime
;
}
...
...
@@ -188,7 +192,17 @@ public class MockHttpSession implements HttpSession {
}
}
/**
* Invalidates this session then unbinds any objects bound to it.
*
* @throws IllegalStateException if this method is called on an already invalidated session
*/
public
void
invalidate
()
{
if
(
this
.
invalid
)
{
throw
new
IllegalStateException
(
"The session has already been invalidated"
);
}
// else
this
.
invalid
=
true
;
clearAttributes
();
}
...
...
@@ -205,10 +219,10 @@ public class MockHttpSession implements HttpSession {
return
this
.
isNew
;
}
/**
* Serialize the attributes of this session into an object that can
* be turned into a byte array with standard Java serialization.
* Serialize the attributes of this session into an object that can be
* turned into a byte array with standard Java serialization.
*
* @return a representation of this session's serialized state
*/
public
Serializable
serializeState
()
{
...
...
@@ -233,8 +247,9 @@ public class MockHttpSession implements HttpSession {
}
/**
* Deserialize the attributes of this session from a state object
* created by {@link #serializeState()}.
* Deserialize the attributes of this session from a state object created by
* {@link #serializeState()}.
*
* @param state a representation of this session's serialized state
*/
@SuppressWarnings
(
"unchecked"
)
...
...
spring-webmvc/src/test/java/org/springframework/mock/web/MockHttpSession.java
浏览文件 @
3b9833c5
/*
* Copyright 2002-20
09
the original author or authors.
* Copyright 2002-20
12
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.
...
...
@@ -33,23 +33,25 @@ import org.springframework.util.Assert;
/**
* Mock implementation of the {@link javax.servlet.http.HttpSession} interface.
* Supports the Servlet 2.4 API level.
*
* <p>Used for testing the web framework; also useful for testing
* application controllers.
* <p>Compatible with Servlet 2.5 as well as Servlet 3.0.
*
* <p>Used for testing the web framework; also useful for testing application
* controllers.
*
* @author Juergen Hoeller
* @author Rod Johnson
* @author Mark Fisher
* @author Sam Brannen
* @since 1.0.2
*/
@SuppressWarnings
(
"deprecation"
)
public
class
MockHttpSession
implements
HttpSession
{
public
static
final
String
SESSION_COOKIE_NAME
=
"JSESSION"
;
private
static
int
nextId
=
1
;
private
final
String
id
;
private
final
long
creationTime
=
System
.
currentTimeMillis
();
...
...
@@ -69,6 +71,7 @@ public class MockHttpSession implements HttpSession {
/**
* Create a new MockHttpSession with a default {@link MockServletContext}.
*
* @see MockServletContext
*/
public
MockHttpSession
()
{
...
...
@@ -77,6 +80,7 @@ public class MockHttpSession implements HttpSession {
/**
* Create a new MockHttpSession.
*
* @param servletContext the ServletContext that the session runs in
*/
public
MockHttpSession
(
ServletContext
servletContext
)
{
...
...
@@ -85,6 +89,7 @@ public class MockHttpSession implements HttpSession {
/**
* Create a new MockHttpSession.
*
* @param servletContext the ServletContext that the session runs in
* @param id a unique identifier for this session
*/
...
...
@@ -93,7 +98,6 @@ public class MockHttpSession implements HttpSession {
this
.
id
=
(
id
!=
null
?
id
:
Integer
.
toString
(
nextId
++));
}
public
long
getCreationTime
()
{
return
this
.
creationTime
;
}
...
...
@@ -188,7 +192,17 @@ public class MockHttpSession implements HttpSession {
}
}
/**
* Invalidates this session then unbinds any objects bound to it.
*
* @throws IllegalStateException if this method is called on an already invalidated session
*/
public
void
invalidate
()
{
if
(
this
.
invalid
)
{
throw
new
IllegalStateException
(
"The session has already been invalidated"
);
}
// else
this
.
invalid
=
true
;
clearAttributes
();
}
...
...
@@ -205,10 +219,10 @@ public class MockHttpSession implements HttpSession {
return
this
.
isNew
;
}
/**
* Serialize the attributes of this session into an object that can
* be turned into a byte array with standard Java serialization.
* Serialize the attributes of this session into an object that can be
* turned into a byte array with standard Java serialization.
*
* @return a representation of this session's serialized state
*/
public
Serializable
serializeState
()
{
...
...
@@ -233,8 +247,9 @@ public class MockHttpSession implements HttpSession {
}
/**
* Deserialize the attributes of this session from a state object
* created by {@link #serializeState()}.
* Deserialize the attributes of this session from a state object created by
* {@link #serializeState()}.
*
* @param state a representation of this session's serialized state
*/
@SuppressWarnings
(
"unchecked"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录