Skip to content

Commit d027e67

Browse files
committed
test: Introduce AdkWebServerUITest
This WORKS and will not yet actually reproduce the #302 problem. This because that is a packaging problem, which this kind of test cannot detect. It still seems valuable to have such a test here though anyway. A future follow-up contribution on this might add the missing test coverage for the actual packaging problem.
1 parent 417a8bc commit d027e67

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.adk.web;
18+
19+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
20+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl;
21+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
22+
23+
import org.junit.jupiter.api.Test;
24+
import org.springframework.beans.factory.annotation.Autowired;
25+
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
26+
import org.springframework.boot.test.context.SpringBootTest;
27+
import org.springframework.test.web.servlet.MockMvc;
28+
29+
/**
30+
* Integration tests for the {@link AdkWebServer} UI.
31+
*
32+
* @author <a href="http://www.vorburger.ch">Michael Vorburger.ch</a>, with Google Gemini Code
33+
* Assist in Agent mode
34+
*/
35+
@SpringBootTest
36+
@AutoConfigureMockMvc
37+
public class AdkWebServerUITest {
38+
39+
@Autowired private MockMvc mockMvc;
40+
41+
@Test
42+
public void root_shouldRedirectToDevUi() throws Exception {
43+
mockMvc
44+
.perform(get("/"))
45+
.andExpect(status().is3xxRedirection())
46+
.andExpect(redirectedUrl("/dev-ui"));
47+
}
48+
49+
@Test
50+
public void devUi_shouldReturnOk() throws Exception {
51+
mockMvc.perform(get("/dev-ui")).andExpect(status().isOk());
52+
}
53+
54+
@Test
55+
public void devUiWithSlash_shouldReturnOk() throws Exception {
56+
mockMvc.perform(get("/dev-ui/")).andExpect(status().isOk());
57+
}
58+
59+
@Test
60+
public void nonExistentUiPage_shouldReturnNotFound() throws Exception {
61+
mockMvc.perform(get("/non-existent-page")).andExpect(status().isNotFound());
62+
}
63+
}

0 commit comments

Comments
 (0)