Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
745aeda5
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
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,体验更适合开发者的 AI 搜索 >>
提交
745aeda5
编写于
9月 18, 2018
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix typos in testing sections of Reference Manual
上级
c634b2fa
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
15 addition
and
15 deletion
+15
-15
src/docs/asciidoc/testing-webtestclient.adoc
src/docs/asciidoc/testing-webtestclient.adoc
+1
-1
src/docs/asciidoc/testing.adoc
src/docs/asciidoc/testing.adoc
+14
-14
未找到文件。
src/docs/asciidoc/testing-webtestclient.adoc
浏览文件 @
745aeda5
...
...
@@ -44,7 +44,7 @@ on the builder to customize the default WebFlux Java configuration.
[[webtestclient-fn-config]]
=== Bind to Router Function
The follo
iw
ng example shows how to set up a server from a
The follo
wi
ng example shows how to set up a server from a
<<web-reactive.adoc#webflux-fn,RouterFunction>>:
====
...
...
src/docs/asciidoc/testing.adoc
浏览文件 @
745aeda5
...
...
@@ -190,7 +190,7 @@ Framework>> instead.
[[
integration
-
testing
]]
==
Integration
Testing
This
section
covers
(
most
of
the
rest
of
this
chapter
)
covers
integration
testing
for
This
section
(
most
of
the
rest
of
this
chapter
)
covers
integration
testing
for
Spring
applications
.
It
includes
the
following
topics
:
*
<<
integration
-
testing
-
overview
>>
...
...
@@ -466,7 +466,7 @@ file:
// class body...
}
----
<1> Referring to a XML file.
<1> Referring to a
n
XML file.
====
The following example shows a `@ContextConfiguration` annotation that refers to a class:
...
...
@@ -1291,7 +1291,7 @@ configuration class:
<1> Specify the configuration class.
====
The following example shows how to use the `@SpringJUnitConfig` annotation to specify
a
The following example shows how to use the `@SpringJUnitConfig` annotation to specify
the location of a configuration file:
====
...
...
@@ -1532,7 +1532,7 @@ configuration of individual JUnit 4 based test classes, as follows:
----
====
If we writ tests that use JUnit Jupiter, we can reduce code duplication even further,
If we writ
e
tests that use JUnit Jupiter, we can reduce code duplication even further,
since annotations in JUnit 5 can also be used as meta-annotations.
Consider the following example:
...
...
@@ -2373,7 +2373,7 @@ configuration file and the superclass's configuration file:
====
Similarly, in the next example, which uses annotated classes, the
`ApplicationContext` for `ExtendedTest`
are
loaded from the `BaseConfig` and
`ApplicationContext` for `ExtendedTest`
is
loaded from the `BaseConfig` and
`ExtendedConfig` classes, in that order. Beans defined in `ExtendedConfig` can, therefore,
override (that is, replace) those defined in `BaseConfig`.
The following example shows how one class can extend another and use both its own
...
...
@@ -2401,7 +2401,7 @@ configuration class and the superclass's configuration class:
====
In
the
next
example
,
which
uses
context
initializers
,
the
`
ApplicationContext
`
for
`
ExtendedTest
`
are
initialized
by
using
`
BaseInitializer
`
and
`
ExtendedTest
`
is
initialized
by
using
`
BaseInitializer
`
and
`
ExtendedInitializer
`.
Note
,
however
,
that
the
order
in
which
the
initializers
are
invoked
depends
on
whether
they
implement
Spring
's `Ordered` interface or are annotated
with Spring'
s
`@
Order
`
annotation
or
the
standard
`@
Priority
`
annotation
.
...
...
@@ -2809,7 +2809,7 @@ is loaded by using the specified resource protocol. Resource location wildcards
`**/*.
properties
`)
are
not
permitted
:
Each
location
must
evaluate
to
exactly
one
`.
properties
`
or
`.
xml
`
resource
.
The
folowing
example
uses
a
test
properties
file
:
The
fol
l
owing
example
uses
a
test
properties
file
:
====
[
source
,
java
,
indent
=
0
]
...
...
@@ -3549,7 +3549,7 @@ request-scoped and session-scoped beans by following these steps:
`WebApplicationContext` (with dependency injection).
. Perform assertions against the mocks.
The nex
x
t code snippet shows the XML configuration for a login use case. Note
The next code snippet shows the XML configuration for a login use case. Note
that the `userService` bean has a dependency on a request-scoped `loginAction` bean.
Also, the `LoginAction` is instantiated by using <<core.adoc#expressions,SpEL expressions>> that
retrieve the username and password from the current HTTP request. In our test, we
...
...
@@ -4232,7 +4232,7 @@ of individual attributes in {api-spring-framework}/test/context/jdbc/Sql.html[`@
[[testcontext-executing-sql-declaratively-tx]]
*Transaction management for `@Sql`*
By default, the `SqlScriptsTestExecutionListener` infer the desired transaction
By default, the `SqlScriptsTestExecutionListener` infer
s
the desired transaction
semantics for scripts configured by using `@Sql`. Specifically, SQL scripts are run
without a transaction, within an existing Spring-managed transaction (for example, a
transaction managed by the `TransactionalTestExecutionListener` for a test annotated with
...
...
@@ -4453,7 +4453,7 @@ of `AbstractJUnit4SpringContextTests` that adds some convenience functionality f
access. This class expects a `javax.sql.DataSource` bean and a `PlatformTransactionManager`
bean to be defined in the `ApplicationContext`. When you extend
`AbstractTransactionalJUnit4SpringContextTests`, you can access a `protected` `jdbcTemplate`
instance variable that you can use
d
to run SQL statements to query the database. You can use such
instance variable that you can use to run SQL statements to query the database. You can use such
queries to confirm database state both before and after running
database-related application code, and Spring ensures that such queries run in the scope of
the same transaction as the application code. When used in conjunction with an ORM tool,
...
...
@@ -4702,7 +4702,7 @@ of `AbstractTestNGSpringContextTests` that adds some convenience functionality f
access. This class expects a `javax.sql.DataSource` bean and a `PlatformTransactionManager`
bean to be defined in the `ApplicationContext`. When you extend
`AbstractTransactionalTestNGSpringContextTests`, you can access a `protected` `jdbcTemplate`
instance variable that you can use
d
to execute SQL statements to query the database. You can use such
instance variable that you can use to execute SQL statements to query the database. You can use such
queries to confirm database state both before and after running
database-related application code, and Spring ensures that such queries run in the scope of
the same transaction as the application code. When used in conjunction with an ORM tool,
...
...
@@ -4749,7 +4749,7 @@ integration tests, see <<spring-mvc-test-vs-end-to-end-integration-tests>>.
[[spring-mvc-test-server]]
==== Server-Side Tests
You can write a plain unit test for a Spring MVC controller b
t
using JUnit or TestNG.
You can write a plain unit test for a Spring MVC controller b
y
using JUnit or TestNG.
To do so, instantiate the controller, inject it with mocked or stubbed dependencies, and call
its methods (passing `MockHttpServletRequest`, `MockHttpServletResponse`, and others, as necessary).
However, when writing such a unit test, much remains untested: for example, request
...
...
@@ -5022,7 +5022,7 @@ You can specify query parameters in URI template style, as the following example
----
====
You can also add Servlet request parameters that represent either query o
f
form parameters,
You can also add Servlet request parameters that represent either query o
r
form parameters,
as the following example shows:
====
...
...
@@ -5232,7 +5232,7 @@ with an actual client and server running.
The easiest way to think about this is by starting with a blank `MockHttpServletRequest`.
Whatever you add to it is what the request becomes. Things that may catch you by surprise
are that there is no context path by default; no `jsessionid` cookie; no forwarding, error,
or async dispatches; and
m
, therefore, no actual JSP rendering. Instead, "`forwarded`" and
or async dispatches; and, therefore, no actual JSP rendering. Instead, "`forwarded`" and
"`redirected`" URLs are saved in the `MockHttpServletResponse` and can be asserted with
expectations.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录