JAVA-21440 Minor cleanup (#14084)

This commit is contained in:
Dhawal Kapil 2023-05-21 15:33:22 +05:30 committed by GitHub
parent 3b73517b00
commit 9d63cfe4a6
2 changed files with 9 additions and 21 deletions

View File

@ -6,9 +6,6 @@ import io.jooby.Jooby;
import io.jooby.ServerOptions; import io.jooby.ServerOptions;
import io.jooby.Session; import io.jooby.Session;
import io.jooby.SessionStore; import io.jooby.SessionStore;
import io.jooby.redis.RedisModule;
import io.jooby.redis.RedisSessionStore;
import io.lettuce.core.RedisClient;
public class App extends Jooby { public class App extends Jooby {
{ {
@ -16,7 +13,6 @@ public class App extends Jooby {
.setSecurePort(8433)); .setSecurePort(8433));
} }
{ {
get("/", ctx -> "Hello World!"); get("/", ctx -> "Hello World!");
} }
@ -31,17 +27,11 @@ public class App extends Jooby {
} }
{ {
onStarting(() -> { onStarting(() -> System.out.println("starting app"));
System.out.println("starting app");
});
onStop(() -> { onStop(() -> System.out.println("stopping app"));
System.out.println("stopping app");
});
onStarted(() -> { onStarted(() -> System.out.println("app started"));
System.out.println("app started");
});
} }
{ {
@ -63,13 +53,12 @@ public class App extends Jooby {
post("/submitForm", ctx -> { post("/submitForm", ctx -> {
Employee employee = ctx.path(Employee.class); Employee employee = ctx.path(Employee.class);
// TODO // ...
return "employee data saved successfully"; return "employee data saved successfully";
}); });
} }
{ {
decorator(next -> ctx -> { decorator(next -> ctx -> {
System.out.println("first"); System.out.println("first");
@ -82,9 +71,7 @@ public class App extends Jooby {
return next.apply(ctx); return next.apply(ctx);
}); });
get("/handler", ctx -> { get("/handler", ctx -> "third");
return "third";
});
} }
{ {
@ -104,7 +91,8 @@ public class App extends Jooby {
get("/signedSession", ctx -> { get("/signedSession", ctx -> {
Session session = ctx.session(); Session session = ctx.session();
session.put("token", "value"); session.put("token", "value");
return session.get("token").value(); return session.get("token")
.value();
}); });
} }

View File

@ -12,12 +12,12 @@ import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
@JoobyTest(value = App.class, port = 8080) @JoobyTest(value = App.class, port = 8080)
public class AppLiveTest { class AppLiveTest {
static OkHttpClient client = new OkHttpClient(); static OkHttpClient client = new OkHttpClient();
@Test @Test
public void given_defaultUrl_expect_fixedString() { void given_defaultUrl_expect_fixedString() {
Request request = new Request.Builder().url("http://localhost:8080") Request request = new Request.Builder().url("http://localhost:8080")
.build(); .build();
try (Response response = client.newCall(request) try (Response response = client.newCall(request)