From f7cd14b2d5aee8b3e792be4eca620c858fbe71d7 Mon Sep 17 00:00:00 2001 From: gkresic Date: Wed, 1 Mar 2023 20:23:02 +0100 Subject: [PATCH] Tests for Pippo restart --- .../pippo/weld/ControllerInterceptorTest.java | 6 +++ pippo-server-parent/pippo-jetty/pom.xml | 7 +++ .../java/ro/pippo/jetty/PippoCoreTest.java | 54 +++++++++++++++++++ pippo-server-parent/pippo-tomcat/pom.xml | 7 +++ .../java/ro/pippo/tomcat/PippoCoreTest.java | 54 +++++++++++++++++++ pippo-server-parent/pippo-undertow/pom.xml | 7 +++ .../java/ro/pippo/undertow/PippoCoreTest.java | 54 +++++++++++++++++++ 7 files changed, 189 insertions(+) create mode 100644 pippo-server-parent/pippo-jetty/src/test/java/ro/pippo/jetty/PippoCoreTest.java create mode 100644 pippo-server-parent/pippo-tomcat/src/test/java/ro/pippo/tomcat/PippoCoreTest.java create mode 100644 pippo-server-parent/pippo-undertow/src/test/java/ro/pippo/undertow/PippoCoreTest.java diff --git a/pippo-controller-parent/pippo-weld/src/test/java/ro/pippo/weld/ControllerInterceptorTest.java b/pippo-controller-parent/pippo-weld/src/test/java/ro/pippo/weld/ControllerInterceptorTest.java index d4e22cfb..41131306 100644 --- a/pippo-controller-parent/pippo-weld/src/test/java/ro/pippo/weld/ControllerInterceptorTest.java +++ b/pippo-controller-parent/pippo-weld/src/test/java/ro/pippo/weld/ControllerInterceptorTest.java @@ -51,6 +51,12 @@ public void testControllerWithInterceptor() { when().get("/").then().statusCode(200); } + /** Tests that server is working after restart */ + @Test + public void testControllerWithInterceptor2() { + when().get("/").then().statusCode(200); + } + @Inherited @InterceptorBinding @Retention(RUNTIME) diff --git a/pippo-server-parent/pippo-jetty/pom.xml b/pippo-server-parent/pippo-jetty/pom.xml index 54561428..21ba459e 100644 --- a/pippo-server-parent/pippo-jetty/pom.xml +++ b/pippo-server-parent/pippo-jetty/pom.xml @@ -54,6 +54,13 @@ metainf-services provided + + + ro.pippo + pippo-test + ${project.version} + test + diff --git a/pippo-server-parent/pippo-jetty/src/test/java/ro/pippo/jetty/PippoCoreTest.java b/pippo-server-parent/pippo-jetty/src/test/java/ro/pippo/jetty/PippoCoreTest.java new file mode 100644 index 00000000..35b0c2b2 --- /dev/null +++ b/pippo-server-parent/pippo-jetty/src/test/java/ro/pippo/jetty/PippoCoreTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2014-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package ro.pippo.jetty; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import ro.pippo.core.Application; +import ro.pippo.core.HttpConstants; +import ro.pippo.test.PippoExtension; +import ro.pippo.test.PippoTest; + +public class PippoCoreTest extends PippoTest { + + @RegisterExtension + public static PippoExtension pippoExtension = new PippoExtension(new Application() {{ + + GET("/", routeContext -> routeContext.status(HttpConstants.StatusCode.OK)); + + }}); + + /** Tests if Pippo initialized properly */ + @Test + public void testSimple() { + when() + .get("/") + .then() + .statusCode(HttpConstants.StatusCode.OK) + ; + } + + /** Tests if everything still works after Pippo stop/start cycle */ + @Test + public void testSimple2() { + when() + .get("/") + .then() + .statusCode(HttpConstants.StatusCode.OK) + ; + } + +} diff --git a/pippo-server-parent/pippo-tomcat/pom.xml b/pippo-server-parent/pippo-tomcat/pom.xml index df5debb0..47c39721 100644 --- a/pippo-server-parent/pippo-tomcat/pom.xml +++ b/pippo-server-parent/pippo-tomcat/pom.xml @@ -59,6 +59,13 @@ metainf-services provided + + + ro.pippo + pippo-test + ${project.version} + test + diff --git a/pippo-server-parent/pippo-tomcat/src/test/java/ro/pippo/tomcat/PippoCoreTest.java b/pippo-server-parent/pippo-tomcat/src/test/java/ro/pippo/tomcat/PippoCoreTest.java new file mode 100644 index 00000000..68aaf80f --- /dev/null +++ b/pippo-server-parent/pippo-tomcat/src/test/java/ro/pippo/tomcat/PippoCoreTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2014-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package ro.pippo.tomcat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import ro.pippo.core.Application; +import ro.pippo.core.HttpConstants; +import ro.pippo.test.PippoExtension; +import ro.pippo.test.PippoTest; + +public class PippoCoreTest extends PippoTest { + + @RegisterExtension + public static PippoExtension pippoExtension = new PippoExtension(new Application() {{ + + GET("/", routeContext -> routeContext.status(HttpConstants.StatusCode.OK)); + + }}); + + /** Tests if Pippo initialized properly */ + @Test + public void testSimple() { + when() + .get("/") + .then() + .statusCode(HttpConstants.StatusCode.OK) + ; + } + + /** Tests if everything still works after Pippo stop/start cycle */ + @Test + public void testSimple2() { + when() + .get("/") + .then() + .statusCode(HttpConstants.StatusCode.OK) + ; + } + +} diff --git a/pippo-server-parent/pippo-undertow/pom.xml b/pippo-server-parent/pippo-undertow/pom.xml index 2fda4f39..65f51ace 100644 --- a/pippo-server-parent/pippo-undertow/pom.xml +++ b/pippo-server-parent/pippo-undertow/pom.xml @@ -36,6 +36,13 @@ metainf-services provided + + + ro.pippo + pippo-test + ${project.version} + test + diff --git a/pippo-server-parent/pippo-undertow/src/test/java/ro/pippo/undertow/PippoCoreTest.java b/pippo-server-parent/pippo-undertow/src/test/java/ro/pippo/undertow/PippoCoreTest.java new file mode 100644 index 00000000..d1f34659 --- /dev/null +++ b/pippo-server-parent/pippo-undertow/src/test/java/ro/pippo/undertow/PippoCoreTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2014-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package ro.pippo.undertow; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import ro.pippo.core.Application; +import ro.pippo.core.HttpConstants; +import ro.pippo.test.PippoExtension; +import ro.pippo.test.PippoTest; + +public class PippoCoreTest extends PippoTest { + + @RegisterExtension + public static PippoExtension pippoExtension = new PippoExtension(new Application() {{ + + GET("/", routeContext -> routeContext.status(HttpConstants.StatusCode.OK)); + + }}); + + /** Tests if Pippo initialized properly */ + @Test + public void testSimple() { + when() + .get("/") + .then() + .statusCode(HttpConstants.StatusCode.OK) + ; + } + + /** Tests if everything still works after Pippo stop/start cycle */ + @Test + public void testSimple2() { + when() + .get("/") + .then() + .statusCode(HttpConstants.StatusCode.OK) + ; + } + +}