Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc8a846

Browse files
committed
Update tests.
1 parent ae495a0 commit fc8a846

File tree

4 files changed

+18
-26
lines changed

4 files changed

+18
-26
lines changed

src/test/java/org/tinystruct/application/ActionHttpModeTests.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ public void setup() {
2626
public void shouldMatchHttpGetAndPostOnSamePath() throws ApplicationException {
2727
ActionRegistry registry = ActionRegistry.getInstance();
2828

29-
Action getAction = registry.getAction("hello", Action.Mode.HTTP_GET);
29+
Action getAction = registry.getAction("hello", org.tinystruct.system.annotation.Action.Mode.HTTP_GET);
3030
assertNotNull(getAction, "GET action should be resolved");
3131
assertEquals("GET", String.valueOf(getAction.execute()));
3232

33-
Action postAction = registry.getAction("hello", Action.Mode.HTTP_POST);
33+
Action postAction = registry.getAction("hello", org.tinystruct.system.annotation.Action.Mode.HTTP_POST);
3434
assertNotNull(postAction, "POST action should be resolved");
3535
assertEquals("POST", String.valueOf(postAction.execute()));
3636
}
@@ -56,14 +56,14 @@ public void shouldRespectModeFilterWhenProvided() throws ApplicationException {
5656
ActionRegistry registry = ActionRegistry.getInstance();
5757

5858
// With explicit mode filter
59-
Action a = registry.getAction("hello", Action.Mode.HTTP_GET);
59+
Action a = registry.getAction("hello", org.tinystruct.system.annotation.Action.Mode.HTTP_GET);
6060
assertNotNull(a);
61-
assertEquals(Action.Mode.HTTP_GET, a.getMode());
61+
assertEquals(org.tinystruct.system.annotation.Action.Mode.HTTP_GET, a.getMode());
6262

6363
// Mismatched filter returns best available action but not HTTP_PUT
64-
Action b = registry.getAction("hello", Action.Mode.HTTP_PUT);
64+
Action b = registry.getAction("hello", org.tinystruct.system.annotation.Action.Mode.HTTP_PUT);
6565
assertNotNull(b);
66-
assertNotEquals(Action.Mode.HTTP_PUT, b.getMode());
66+
assertNotEquals(org.tinystruct.system.annotation.Action.Mode.HTTP_PUT, b.getMode());
6767
}
6868

6969
private static class TestWebApp extends AbstractApplication {
@@ -72,17 +72,17 @@ public void init() {
7272
this.setTemplateRequired(false);
7373
}
7474

75-
@org.tinystruct.system.annotation.Action(value = "hello", description = "GET hello", mode = Action.Mode.HTTP_GET)
75+
@org.tinystruct.system.annotation.Action(value = "hello", description = "GET hello", mode = org.tinystruct.system.annotation.Action.Mode.HTTP_GET)
7676
public String helloGet() {
7777
return "GET";
7878
}
7979

80-
@org.tinystruct.system.annotation.Action(value = "hello", description = "POST hello", mode = Action.Mode.HTTP_POST)
80+
@org.tinystruct.system.annotation.Action(value = "hello", description = "POST hello", mode = org.tinystruct.system.annotation.Action.Mode.HTTP_POST)
8181
public String helloPost() {
8282
return "POST";
8383
}
8484

85-
@org.tinystruct.system.annotation.Action(value = "ping", description = "Ping", mode = Action.Mode.DEFAULT)
85+
@org.tinystruct.system.annotation.Action(value = "ping", description = "Ping", mode = org.tinystruct.system.annotation.Action.Mode.DEFAULT)
8686
public String ping() {
8787
return "pong";
8888
}

src/test/java/org/tinystruct/mcp/MCPClientServerIntegrationTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.tinystruct.system.Dispatcher;
2727
import org.tinystruct.system.HttpServer;
2828
import org.tinystruct.system.Settings;
29+
import org.tinystruct.system.annotation.Action;
2930

3031
import java.io.IOException;
3132
import java.net.Socket;
@@ -63,7 +64,7 @@ public static void setUp() throws Exception {
6364
serverContext.setAttribute("--server-port", "8001");
6465
ApplicationManager.install(new Dispatcher());
6566
ApplicationManager.install(new HttpServer());
66-
ApplicationManager.call("start", serverContext, org.tinystruct.application.Action.Mode.CLI);
67+
ApplicationManager.call("start", serverContext, Action.Mode.CLI);
6768

6869
// Keep the thread alive as long as the server is running
6970
while (!Thread.currentThread().isInterrupted()) {

src/test/java/org/tinystruct/system/ApplicationManagerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import org.junit.jupiter.api.Test;
44
import org.tinystruct.ApplicationContext;
55
import org.tinystruct.ApplicationException;
6-
import org.tinystruct.application.Action;
6+
import org.tinystruct.system.annotation.Action;
77

88
import java.time.Duration;
99
import java.time.Instant;

src/test/java/org/tinystruct/system/HttpServerHttpModeTest.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,13 @@
33
import org.junit.jupiter.api.*;
44
import org.tinystruct.AbstractApplication;
55
import org.tinystruct.ApplicationContext;
6-
import org.tinystruct.application.Action;
7-
import org.tinystruct.http.Method;
8-
import org.tinystruct.http.Response;
96
import org.tinystruct.net.URLRequest;
107
import org.tinystruct.net.URLResponse;
118
import org.tinystruct.net.handlers.HTTPHandler;
12-
import org.tinystruct.system.Dispatcher;
9+
import org.tinystruct.system.annotation.Action;
1310

14-
import java.io.BufferedReader;
15-
import java.io.InputStreamReader;
16-
import java.io.OutputStream;
17-
import java.net.HttpURLConnection;
1811
import java.net.Socket;
1912
import java.net.URI;
20-
import java.net.URL;
21-
import java.nio.charset.StandardCharsets;
2213

2314
import static org.junit.jupiter.api.Assertions.*;
2415

@@ -205,7 +196,7 @@ public void init() {
205196
this.setTemplateRequired(false);
206197
}
207198

208-
@org.tinystruct.system.annotation.Action(
199+
@Action(
209200
value = "api/users",
210201
description = "Get users",
211202
mode = Action.Mode.HTTP_GET
@@ -214,7 +205,7 @@ public String getUsers() {
214205
return "GET users";
215206
}
216207

217-
@org.tinystruct.system.annotation.Action(
208+
@Action(
218209
value = "api/users",
219210
description = "Create user",
220211
mode = Action.Mode.HTTP_POST
@@ -223,7 +214,7 @@ public String createUser() {
223214
return "POST users";
224215
}
225216

226-
@org.tinystruct.system.annotation.Action(
217+
@Action(
227218
value = "api/users",
228219
description = "Update user",
229220
mode = Action.Mode.HTTP_PUT
@@ -232,7 +223,7 @@ public String updateUser(String id) {
232223
return "PUT user " + (id != null ? id : "unknown");
233224
}
234225

235-
@org.tinystruct.system.annotation.Action(
226+
@Action(
236227
value = "api/users",
237228
description = "Delete user",
238229
mode = Action.Mode.HTTP_DELETE
@@ -241,7 +232,7 @@ public String deleteUser(String id) {
241232
return "DELETE user " + (id != null ? id : "unknown");
242233
}
243234

244-
@org.tinystruct.system.annotation.Action(
235+
@Action(
245236
value = "api/ping",
246237
description = "Ping endpoint",
247238
mode = Action.Mode.DEFAULT

0 commit comments

Comments
 (0)