9
9
*******************************************************************************/
10
10
package io .openliberty .mcp .internal .fat .tool ;
11
11
12
- import static com . ibm . websphere . simplicity . ShrinkHelper . DeployOptions . SERVER_ONLY ;
12
+ import java . util . List ;
13
13
14
- import org .jboss .shrinkwrap .api .ShrinkWrap ;
15
- import org .jboss .shrinkwrap .api .spec .WebArchive ;
16
- import org .json .JSONObject ;
17
14
import org .junit .AfterClass ;
18
15
import org .junit .BeforeClass ;
19
16
import org .junit .Test ;
20
17
import org .junit .runner .RunWith ;
21
- import org .skyscreamer .jsonassert .JSONAssert ;
22
-
23
- import com .ibm .websphere .simplicity .ShrinkHelper ;
24
18
25
19
import componenttest .annotation .Server ;
26
20
import componenttest .custom .junit .runner .FATRunner ;
27
21
import componenttest .topology .impl .LibertyServer ;
28
22
import componenttest .topology .utils .FATServletClient ;
29
23
import io .openliberty .mcp .internal .fat .noparamtool .NoParamTools ;
30
- import io .openliberty .mcp .internal .fat .utils .HttpTestUtils ;
31
24
32
25
@ RunWith (FATRunner .class )
33
26
public class NoParamNameTest extends FATServletClient {
@@ -36,40 +29,18 @@ public class NoParamNameTest extends FATServletClient {
36
29
37
30
@ BeforeClass
38
31
public static void setup () throws Exception {
39
- WebArchive war = ShrinkWrap .create (WebArchive .class , "toolTest.war" ).addPackage (NoParamTools .class .getPackage ());
40
-
41
- ShrinkHelper .exportDropinAppToServer (server , war , SERVER_ONLY );
42
-
43
- server .startServer ();
32
+ ExpectedAppFailureValidator .deployAppToAssertFailure (server , "ExpectedNoParamNameFailureTest" , NoParamTools .class .getPackage ());
44
33
}
45
34
46
35
@ AfterClass
47
36
public static void teardown () throws Exception {
48
- server .stopServer ();
37
+ server .stopServer (ExpectedAppFailureValidator . APP_START_FAILED_CODE );
49
38
}
50
39
51
40
@ Test
52
- public void testIllegalToolArgNameTool () throws Exception {
53
- String request = """
54
- {
55
- "jsonrpc": "2.0",
56
- "id": "2",
57
- "method": "tools/call",
58
- "params": {
59
- "name": "illegalToolArgNameTool",
60
- "arguments": {
61
- "input": "Hello"
62
- }
63
- }
64
- }
65
- """ ;
66
-
67
- String response = HttpTestUtils .callMCP (server , "/toolTest" , request );
68
- JSONObject jsonResponse = new JSONObject (response );
69
-
70
- String expectedResponseString = """
71
- Exception thrown
72
- """ ;
73
- JSONAssert .assertEquals (expectedResponseString , response , true );
41
+ public void testNoParamNameToolArg () throws Exception {
42
+ String expectedErrorHeader = "Illegal arguments found in MCP Tool:" ;
43
+ List <String > expectedErrorList = List .of ("io.openliberty.mcp.internal.fat.noparamtool.NoParamTools.illegalToolArgNameTool" );
44
+ ExpectedAppFailureValidator .findAndAssertExpectedErrorsInLogs ("Illegal Tool Arg: " , expectedErrorHeader , expectedErrorList , server );
74
45
}
75
46
}
0 commit comments