Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dk131072
spring-framework
提交
26271fc3
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,发现更多精彩内容 >>
提交
26271fc3
编写于
1月 13, 2014
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
18653611
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
64 addition
and
38 deletion
+64
-38
spring-context/src/main/java/org/springframework/scripting/bsh/BshScriptFactory.java
...a/org/springframework/scripting/bsh/BshScriptFactory.java
+1
-0
spring-context/src/test/java/org/springframework/scripting/groovy/GroovyAspectIntegrationTests.java
...mework/scripting/groovy/GroovyAspectIntegrationTests.java
+38
-25
spring-context/src/test/java/org/springframework/scripting/groovy/GroovyAspectTests.java
...g/springframework/scripting/groovy/GroovyAspectTests.java
+24
-10
spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java
...st/web/servlet/request/MockHttpServletRequestBuilder.java
+1
-3
未找到文件。
spring-context/src/main/java/org/springframework/scripting/bsh/BshScriptFactory.java
浏览文件 @
26271fc3
...
@@ -86,6 +86,7 @@ public class BshScriptFactory implements ScriptFactory, BeanClassLoaderAware {
...
@@ -86,6 +86,7 @@ public class BshScriptFactory implements ScriptFactory, BeanClassLoaderAware {
this
.
scriptInterfaces
=
scriptInterfaces
;
this
.
scriptInterfaces
=
scriptInterfaces
;
}
}
@Override
@Override
public
void
setBeanClassLoader
(
ClassLoader
classLoader
)
{
public
void
setBeanClassLoader
(
ClassLoader
classLoader
)
{
this
.
beanClassLoader
=
classLoader
;
this
.
beanClassLoader
=
classLoader
;
...
...
spring-context/src/test/java/org/springframework/scripting/groovy/GroovyAspectIntegrationTests.java
浏览文件 @
26271fc3
package
org.springframework.scripting.groovy
;
/*
* 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.
* You may obtain a copy of the License at
*
* http://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.
*/
import
static
org
.
junit
.
Assert
.
assertEquals
;
package
org.springframework.scripting.groovy
;
import
static
org
.
junit
.
Assert
.
fail
;
import
org.junit.After
;
import
org.junit.After
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.context.support.GenericXmlApplicationContext
;
import
org.springframework.context.support.GenericXmlApplicationContext
;
import
static
org
.
junit
.
Assert
.*;
/**
/**
* @author Dave Syer
* @author Dave Syer
*/
*/
...
@@ -14,18 +30,9 @@ public class GroovyAspectIntegrationTests {
...
@@ -14,18 +30,9 @@ public class GroovyAspectIntegrationTests {
private
GenericXmlApplicationContext
context
;
private
GenericXmlApplicationContext
context
;
@After
public
void
close
()
{
if
(
context
!=
null
)
{
context
.
close
();
}
}
@Test
@Test
public
void
testJavaBean
()
{
public
void
testJavaBean
()
{
context
=
new
GenericXmlApplicationContext
(
getClass
(),
getClass
().
getSimpleName
()+
"-java-context.xml"
);
context
=
new
GenericXmlApplicationContext
(
getClass
(),
getClass
().
getSimpleName
()+
"-java-context.xml"
);
TestService
bean
=
context
.
getBean
(
"javaBean"
,
TestService
.
class
);
TestService
bean
=
context
.
getBean
(
"javaBean"
,
TestService
.
class
);
LogUserAdvice
logAdvice
=
context
.
getBean
(
LogUserAdvice
.
class
);
LogUserAdvice
logAdvice
=
context
.
getBean
(
LogUserAdvice
.
class
);
...
@@ -33,8 +40,9 @@ public class GroovyAspectIntegrationTests {
...
@@ -33,8 +40,9 @@ public class GroovyAspectIntegrationTests {
try
{
try
{
bean
.
sayHello
();
bean
.
sayHello
();
fail
(
"Expected exception"
);
fail
(
"Expected exception"
);
}
catch
(
RuntimeException
e
)
{
}
assertEquals
(
"TestServiceImpl"
,
e
.
getMessage
());
catch
(
RuntimeException
ex
)
{
assertEquals
(
"TestServiceImpl"
,
ex
.
getMessage
());
}
}
assertEquals
(
1
,
logAdvice
.
getCountThrows
());
assertEquals
(
1
,
logAdvice
.
getCountThrows
());
...
@@ -43,7 +51,6 @@ public class GroovyAspectIntegrationTests {
...
@@ -43,7 +51,6 @@ public class GroovyAspectIntegrationTests {
@Test
@Test
public
void
testGroovyBeanInterface
()
{
public
void
testGroovyBeanInterface
()
{
context
=
new
GenericXmlApplicationContext
(
getClass
(),
getClass
().
getSimpleName
()+
"-groovy-interface-context.xml"
);
context
=
new
GenericXmlApplicationContext
(
getClass
(),
getClass
().
getSimpleName
()+
"-groovy-interface-context.xml"
);
TestService
bean
=
context
.
getBean
(
"groovyBean"
,
TestService
.
class
);
TestService
bean
=
context
.
getBean
(
"groovyBean"
,
TestService
.
class
);
LogUserAdvice
logAdvice
=
context
.
getBean
(
LogUserAdvice
.
class
);
LogUserAdvice
logAdvice
=
context
.
getBean
(
LogUserAdvice
.
class
);
...
@@ -51,8 +58,9 @@ public class GroovyAspectIntegrationTests {
...
@@ -51,8 +58,9 @@ public class GroovyAspectIntegrationTests {
try
{
try
{
bean
.
sayHello
();
bean
.
sayHello
();
fail
(
"Expected exception"
);
fail
(
"Expected exception"
);
}
catch
(
RuntimeException
e
)
{
}
assertEquals
(
"GroovyServiceImpl"
,
e
.
getMessage
());
catch
(
RuntimeException
ex
)
{
assertEquals
(
"GroovyServiceImpl"
,
ex
.
getMessage
());
}
}
assertEquals
(
1
,
logAdvice
.
getCountThrows
());
assertEquals
(
1
,
logAdvice
.
getCountThrows
());
}
}
...
@@ -60,9 +68,7 @@ public class GroovyAspectIntegrationTests {
...
@@ -60,9 +68,7 @@ public class GroovyAspectIntegrationTests {
@Test
@Test
public
void
testGroovyBeanDynamic
()
{
public
void
testGroovyBeanDynamic
()
{
context
=
new
GenericXmlApplicationContext
(
getClass
(),
getClass
().
getSimpleName
()+
"-groovy-dynamic-context.xml"
);
context
=
new
GenericXmlApplicationContext
(
getClass
(),
getClass
().
getSimpleName
()+
"-groovy-dynamic-context.xml"
);
TestService
bean
=
context
.
getBean
(
"groovyBean"
,
TestService
.
class
);
TestService
bean
=
context
.
getBean
(
"groovyBean"
,
TestService
.
class
);
LogUserAdvice
logAdvice
=
context
.
getBean
(
LogUserAdvice
.
class
);
LogUserAdvice
logAdvice
=
context
.
getBean
(
LogUserAdvice
.
class
);
...
@@ -70,8 +76,9 @@ public class GroovyAspectIntegrationTests {
...
@@ -70,8 +76,9 @@ public class GroovyAspectIntegrationTests {
try
{
try
{
bean
.
sayHello
();
bean
.
sayHello
();
fail
(
"Expected exception"
);
fail
(
"Expected exception"
);
}
catch
(
RuntimeException
e
)
{
}
assertEquals
(
"GroovyServiceImpl"
,
e
.
getMessage
());
catch
(
RuntimeException
ex
)
{
assertEquals
(
"GroovyServiceImpl"
,
ex
.
getMessage
());
}
}
// No proxy here because the pointcut only applies to the concrete class, not the interface
// No proxy here because the pointcut only applies to the concrete class, not the interface
assertEquals
(
0
,
logAdvice
.
getCountThrows
());
assertEquals
(
0
,
logAdvice
.
getCountThrows
());
...
@@ -80,9 +87,7 @@ public class GroovyAspectIntegrationTests {
...
@@ -80,9 +87,7 @@ public class GroovyAspectIntegrationTests {
@Test
@Test
public
void
testGroovyBeanProxyTargetClass
()
{
public
void
testGroovyBeanProxyTargetClass
()
{
context
=
new
GenericXmlApplicationContext
(
getClass
(),
getClass
().
getSimpleName
()+
"-groovy-proxy-target-class-context.xml"
);
context
=
new
GenericXmlApplicationContext
(
getClass
(),
getClass
().
getSimpleName
()+
"-groovy-proxy-target-class-context.xml"
);
TestService
bean
=
context
.
getBean
(
"groovyBean"
,
TestService
.
class
);
TestService
bean
=
context
.
getBean
(
"groovyBean"
,
TestService
.
class
);
LogUserAdvice
logAdvice
=
context
.
getBean
(
LogUserAdvice
.
class
);
LogUserAdvice
logAdvice
=
context
.
getBean
(
LogUserAdvice
.
class
);
...
@@ -90,11 +95,19 @@ public class GroovyAspectIntegrationTests {
...
@@ -90,11 +95,19 @@ public class GroovyAspectIntegrationTests {
try
{
try
{
bean
.
sayHello
();
bean
.
sayHello
();
fail
(
"Expected exception"
);
fail
(
"Expected exception"
);
}
catch
(
TestException
e
)
{
}
assertEquals
(
"GroovyServiceImpl"
,
e
.
getMessage
());
catch
(
TestException
ex
)
{
assertEquals
(
"GroovyServiceImpl"
,
ex
.
getMessage
());
}
}
assertEquals
(
1
,
logAdvice
.
getCountBefore
());
assertEquals
(
1
,
logAdvice
.
getCountBefore
());
assertEquals
(
1
,
logAdvice
.
getCountThrows
());
assertEquals
(
1
,
logAdvice
.
getCountThrows
());
}
}
@After
public
void
close
()
{
if
(
context
!=
null
)
{
context
.
close
();
}
}
}
}
spring-context/src/test/java/org/springframework/scripting/groovy/GroovyAspectTests.java
浏览文件 @
26271fc3
package
org.springframework.scripting.groovy
;
/*
* 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.
* You may obtain a copy of the License at
*
* http://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.
*/
import
static
org
.
junit
.
Assert
.
assertEquals
;
package
org.springframework.scripting.groovy
;
import
static
org
.
junit
.
Assert
.
fail
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.aop.Advisor
;
import
org.springframework.aop.Advisor
;
import
org.springframework.aop.aspectj.AspectJExpressionPointcut
;
import
org.springframework.aop.aspectj.AspectJExpressionPointcut
;
import
org.springframework.aop.framework.ProxyFactory
;
import
org.springframework.aop.framework.ProxyFactory
;
import
org.springframework.aop.support.DefaultPointcutAdvisor
;
import
org.springframework.aop.support.DefaultPointcutAdvisor
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.scripting.groovy.GroovyScriptFactory
;
import
org.springframework.scripting.support.ResourceScriptSource
;
import
org.springframework.scripting.support.ResourceScriptSource
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ClassUtils
;
import
static
org
.
junit
.
Assert
.*;
/**
/**
* @author Dave Syer
* @author Dave Syer
*/
*/
...
@@ -20,7 +35,6 @@ public class GroovyAspectTests {
...
@@ -20,7 +35,6 @@ public class GroovyAspectTests {
@Test
@Test
public
void
testManualGroovyBeanWithUnconditionalPointcut
()
throws
Exception
{
public
void
testManualGroovyBeanWithUnconditionalPointcut
()
throws
Exception
{
LogUserAdvice
logAdvice
=
new
LogUserAdvice
();
LogUserAdvice
logAdvice
=
new
LogUserAdvice
();
GroovyScriptFactory
scriptFactory
=
new
GroovyScriptFactory
(
"GroovyServiceImpl.grv"
);
GroovyScriptFactory
scriptFactory
=
new
GroovyScriptFactory
(
"GroovyServiceImpl.grv"
);
...
@@ -28,7 +42,6 @@ public class GroovyAspectTests {
...
@@ -28,7 +42,6 @@ public class GroovyAspectTests {
new
ClassPathResource
(
"GroovyServiceImpl.grv"
,
getClass
())));
new
ClassPathResource
(
"GroovyServiceImpl.grv"
,
getClass
())));
testAdvice
(
new
DefaultPointcutAdvisor
(
logAdvice
),
logAdvice
,
target
,
"GroovyServiceImpl"
);
testAdvice
(
new
DefaultPointcutAdvisor
(
logAdvice
),
logAdvice
,
target
,
"GroovyServiceImpl"
);
}
}
@Test
@Test
...
@@ -46,7 +59,6 @@ public class GroovyAspectTests {
...
@@ -46,7 +59,6 @@ public class GroovyAspectTests {
@Test
@Test
public
void
testManualGroovyBeanWithDynamicPointcut
()
throws
Exception
{
public
void
testManualGroovyBeanWithDynamicPointcut
()
throws
Exception
{
LogUserAdvice
logAdvice
=
new
LogUserAdvice
();
LogUserAdvice
logAdvice
=
new
LogUserAdvice
();
GroovyScriptFactory
scriptFactory
=
new
GroovyScriptFactory
(
"GroovyServiceImpl.grv"
);
GroovyScriptFactory
scriptFactory
=
new
GroovyScriptFactory
(
"GroovyServiceImpl.grv"
);
...
@@ -61,7 +73,6 @@ public class GroovyAspectTests {
...
@@ -61,7 +73,6 @@ public class GroovyAspectTests {
@Test
@Test
public
void
testManualGroovyBeanWithDynamicPointcutProxyTargetClass
()
throws
Exception
{
public
void
testManualGroovyBeanWithDynamicPointcutProxyTargetClass
()
throws
Exception
{
LogUserAdvice
logAdvice
=
new
LogUserAdvice
();
LogUserAdvice
logAdvice
=
new
LogUserAdvice
();
GroovyScriptFactory
scriptFactory
=
new
GroovyScriptFactory
(
"GroovyServiceImpl.grv"
);
GroovyScriptFactory
scriptFactory
=
new
GroovyScriptFactory
(
"GroovyServiceImpl.grv"
);
...
@@ -76,6 +87,7 @@ public class GroovyAspectTests {
...
@@ -76,6 +87,7 @@ public class GroovyAspectTests {
private
void
testAdvice
(
Advisor
advisor
,
LogUserAdvice
logAdvice
,
TestService
target
,
String
message
)
private
void
testAdvice
(
Advisor
advisor
,
LogUserAdvice
logAdvice
,
TestService
target
,
String
message
)
throws
Exception
{
throws
Exception
{
testAdvice
(
advisor
,
logAdvice
,
target
,
message
,
false
);
testAdvice
(
advisor
,
logAdvice
,
target
,
message
,
false
);
}
}
...
@@ -93,9 +105,11 @@ public class GroovyAspectTests {
...
@@ -93,9 +105,11 @@ public class GroovyAspectTests {
try
{
try
{
bean
.
sayHello
();
bean
.
sayHello
();
fail
(
"Expected exception"
);
fail
(
"Expected exception"
);
}
catch
(
TestException
e
)
{
}
assertEquals
(
message
,
e
.
getMessage
());
catch
(
TestException
ex
)
{
assertEquals
(
message
,
ex
.
getMessage
());
}
}
assertEquals
(
1
,
logAdvice
.
getCountThrows
());
assertEquals
(
1
,
logAdvice
.
getCountThrows
());
}
}
}
}
spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java
浏览文件 @
26271fc3
...
@@ -367,8 +367,7 @@ public class MockHttpServletRequestBuilder implements RequestBuilder, Mergeable
...
@@ -367,8 +367,7 @@ public class MockHttpServletRequestBuilder implements RequestBuilder, Mergeable
* requestURI and using any remaining part. If specified here, the pathInfo
* requestURI and using any remaining part. If specified here, the pathInfo
* must start with a "/".
* must start with a "/".
* <p>If specified, the pathInfo will be used as is.
* <p>If specified, the pathInfo will be used as is.
* @see <a
* @see <a href="http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html#getPathInfo%28%29">HttpServletRequest.getServletPath()</a>
* href="http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html#getPathInfo%28%29">HttpServletRequest.getServletPath()</a>
*/
*/
public
MockHttpServletRequestBuilder
pathInfo
(
String
pathInfo
)
{
public
MockHttpServletRequestBuilder
pathInfo
(
String
pathInfo
)
{
if
(
StringUtils
.
hasText
(
pathInfo
))
{
if
(
StringUtils
.
hasText
(
pathInfo
))
{
...
@@ -464,7 +463,6 @@ public class MockHttpServletRequestBuilder implements RequestBuilder, Mergeable
...
@@ -464,7 +463,6 @@ public class MockHttpServletRequestBuilder implements RequestBuilder, Mergeable
this
.
principal
=
parentBuilder
.
principal
;
this
.
principal
=
parentBuilder
.
principal
;
}
}
for
(
String
attributeName
:
parentBuilder
.
attributes
.
keySet
())
{
for
(
String
attributeName
:
parentBuilder
.
attributes
.
keySet
())
{
if
(!
this
.
attributes
.
containsKey
(
attributeName
))
{
if
(!
this
.
attributes
.
containsKey
(
attributeName
))
{
this
.
attributes
.
put
(
attributeName
,
parentBuilder
.
attributes
.
get
(
attributeName
));
this
.
attributes
.
put
(
attributeName
,
parentBuilder
.
attributes
.
get
(
attributeName
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录