質問編集履歴

1

ソースコードの修正

2016/03/07 06:55

投稿

skyhy
skyhy

スコア12

test CHANGED
File without changes
test CHANGED
@@ -4,13 +4,11 @@
4
4
 
5
5
 
6
6
 
7
- JSPで指定したファイルのアップロードを行う機能のテストケースを作成したいのですが、以下のように書いた所、「java.lang.AssertionError: No ModelAndView found」エラーになってしいます。
7
+ JSPで指定したファイルのアップロードを行う機能のテストケースを作成したいのですが、以下のように書いた所、「java.lang.AssertionError: Status expected:<200> but was:<400>」エラーになます。
8
8
 
9
9
 
10
10
 
11
- Viewが無いと言われるので、
12
-
13
- 「this.mockMvc.perform(fileUpload("upload").file(file))...」
11
+ 「this.mockMvc.perform(fileUpload("/testview").file(file)...」
14
12
 
15
13
  の書き方が悪いのだとは思うのですが、どこが問題なのか、どう書けば良いのか分かりません。
16
14
 
@@ -18,9 +16,9 @@
18
16
 
19
17
  Postの場合だと、
20
18
 
21
- 「this.mockMvc.perform(post("/hoge").session(this.mockHttpSession).param("search", "検索"))」
19
+ 「this.mockMvc.perform(post("/testview").session(this.mockHttpSession).param("search", "検索"))」
22
20
 
23
- 、VeiwやModel取得できるのですが。。。
21
+ 期待した結果るのですが。
24
22
 
25
23
 
26
24
 
@@ -102,7 +100,11 @@
102
100
 
103
101
  this.mockMvc.perform(
104
102
 
105
- fileUpload("upload").file(file))
103
+ fileUpload("/testview").file(file)
104
+
105
+ .param("upload", "Upload(CSV)"))
106
+
107
+ .andExpect(status().isOk())
106
108
 
107
109
  .andExpect(view().name("testView")) // 遷移先View名の判定。
108
110