From 0a2bed2a8b1eabbc774caaf595acd20bbddd9c60 Mon Sep 17 00:00:00 2001 From: Ivo Studensky Date: Fri, 1 Mar 2024 15:27:59 +0100 Subject: [PATCH] [WFLY-18509] tasks-jsf Quickstart Common Enhancements CY2023Q3 --- .github/workflows/quickstart_tasks-jsf_ci.yml | 14 ++ tasks-jsf/README-source.adoc | 57 ++----- tasks-jsf/charts/helm.yaml | 6 + tasks-jsf/pom.xml | 146 ++++++++++------- .../quickstarts/tasksJsf/BasicRuntimeIT.java | 57 +++++++ .../tasksJsf/DefaultDeployment.java | 70 -------- .../tasksJsf/FacesContextStub.java | 150 ------------------ .../as/quickstarts/tasksJsf/ResourcesIT.java | 79 --------- .../as/quickstarts/tasksJsf/TaskDaoIT.java | 133 ---------------- .../as/quickstarts/tasksJsf/TaskDaoStub.java | 54 ------- .../quickstarts/tasksJsf/TaskListBeanIT.java | 69 -------- .../as/quickstarts/tasksJsf/Testing.java | 46 ------ .../as/quickstarts/tasksJsf/UserDaoIT.java | 90 ----------- .../resources/META-INF/test-persistence.xml | 36 ----- tasks-jsf/src/test/resources/arquillian.xml | 36 ----- tasks-jsf/src/test/resources/test-ds.xml | 38 ----- tasks-jsf/src/test/webapp/WEB-INF/beans.xml | 27 ---- 17 files changed, 185 insertions(+), 923 deletions(-) create mode 100644 .github/workflows/quickstart_tasks-jsf_ci.yml create mode 100644 tasks-jsf/charts/helm.yaml create mode 100644 tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/BasicRuntimeIT.java delete mode 100644 tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/DefaultDeployment.java delete mode 100644 tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/FacesContextStub.java delete mode 100644 tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/ResourcesIT.java delete mode 100644 tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/TaskDaoIT.java delete mode 100644 tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/TaskDaoStub.java delete mode 100644 tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/TaskListBeanIT.java delete mode 100644 tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/Testing.java delete mode 100644 tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/UserDaoIT.java delete mode 100644 tasks-jsf/src/test/resources/META-INF/test-persistence.xml delete mode 100644 tasks-jsf/src/test/resources/arquillian.xml delete mode 100644 tasks-jsf/src/test/resources/test-ds.xml delete mode 100644 tasks-jsf/src/test/webapp/WEB-INF/beans.xml diff --git a/.github/workflows/quickstart_tasks-jsf_ci.yml b/.github/workflows/quickstart_tasks-jsf_ci.yml new file mode 100644 index 0000000000..009847a769 --- /dev/null +++ b/.github/workflows/quickstart_tasks-jsf_ci.yml @@ -0,0 +1,14 @@ +name: WildFly tasks-jsf Quickstart CI + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths: + - 'tasks-jsf/**' + - '.github/workflows/quickstart_ci.yml' +jobs: + call-quickstart_ci: + uses: ./.github/workflows/quickstart_ci.yml + with: + QUICKSTART_PATH: tasks-jsf + TEST_PROVISIONED_SERVER: true diff --git a/tasks-jsf/README-source.adoc b/tasks-jsf/README-source.adoc index 4fd0c92201..1eb58ff37e 100644 --- a/tasks-jsf/README-source.adoc +++ b/tasks-jsf/README-source.adoc @@ -28,12 +28,6 @@ JSF is used to present the user two views. * authentication form: This provides the simple login * task view: This view contains the task list, a task detail, and a task addition form. The task view uses AJAX. -//************************************************* -// Product Release content only -//************************************************* - -ifndef::EAPCDRelease[] - // Link to the quickstart source include::../shared-doc/view-the-source.adoc[leveloffset=+1] // Considerations for Use in a Production Environment @@ -42,16 +36,20 @@ include::../shared-doc/development-shortcuts.adoc[leveloffset=+1] include::../shared-doc/system-requirements.adoc[leveloffset=+1] // Use of {jbossHomeName} include::../shared-doc/use-of-jboss-home-name.adoc[leveloffset=+1] + +// build and run with standard server distribution +[[build_and_run_the_quickstart_with_server_dist]] +== Building and running the quickstart application with a {productName} server distribution // Start the {productName} Standalone Server -include::../shared-doc/start-the-standalone-server.adoc[leveloffset=+1] +include::../shared-doc/start-the-standalone-server.adoc[leveloffset=+2] // Build and Deploy the Quickstart -include::../shared-doc/build-and-deploy-the-quickstart.adoc[leveloffset=+1] +include::../shared-doc/build-and-deploy-the-quickstart.adoc[leveloffset=+2] -== Access the Application +=== Access the Application The application will be running at the following URL http://localhost:8080/{artifactId}/. -== Server Log: Expected Warnings and Errors +=== Server Log: Expected Warnings and Errors You will see the following warnings in the server log. You can ignore these warnings. @@ -62,38 +60,13 @@ WFLYJCA0091: -ds.xml file deployments are deprecated. Support may be removed in HHH000431: Unable to determine H2 database version, certain features may not work ---- +// Server Distribution Testing +include::../shared-doc/run-integration-tests-with-server-distribution.adoc[leveloffset=+2] // Undeploy the Quickstart -include::../shared-doc/undeploy-the-quickstart.adoc[leveloffset=+1] -// Run the Arquillian Tests -include::../shared-doc/run-arquillian-tests.adoc[leveloffset=+1] -// Run the Quickstart in Red Hat CodeReady Studio or Eclipse -include::../shared-doc/run-the-quickstart-in-jboss-developer-studio.adoc[leveloffset=+1] +include::../shared-doc/undeploy-the-quickstart.adoc[leveloffset=+2] -== Debug the Application - -If you want to debug the source code of any library in the project, run the following command to pull the source into your local repository. The IDE should then detect it. - -[source,options="nowrap"] ----- -$ mvn dependency:sources ----- +// Build and run sections for other environments/builds +ifndef::ProductRelease,EAPXPRelease[] +include::../shared-doc/build-and-run-the-quickstart-with-provisioned-server.adoc[leveloffset=+1] endif::[] - -//************************************************* -// Product Release content only -//************************************************* -ifdef::ProductRelease[] - -// Getting Started with OpenShift -include::../shared-doc/openshift-getting-started.adoc[leveloffset=+1] -//Prepare OpenShift for Quickstart Deployment -include::../shared-doc/openshift-create-project.adoc[leveloffset=+1] -// Import the Latest {xpaasproduct-shortname} Image Streams and Templates -include::../shared-doc/openshift-import-imagestreams-templates.adoc[leveloffset=+1] -// Deploy the {ProductShortName} Source-to-Image (S2I) Quickstart to OpenShift -include::../shared-doc/openshift-deploy-project.adoc[leveloffset=+1] -// Openshift post deployment tasks -include::../shared-doc/openshift-post-deployment-tasks.adoc[leveloffset=+1] - - -endif::[] \ No newline at end of file +include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] \ No newline at end of file diff --git a/tasks-jsf/charts/helm.yaml b/tasks-jsf/charts/helm.yaml new file mode 100644 index 0000000000..ae14e27a5c --- /dev/null +++ b/tasks-jsf/charts/helm.yaml @@ -0,0 +1,6 @@ +build: + uri: https://github.com/wildfly/quickstart.git + ref: main + contextDir: tasks-jsf +deploy: + replicas: 1 \ No newline at end of file diff --git a/tasks-jsf/pom.xml b/tasks-jsf/pom.xml index 1573ccbb74..36a2fdf881 100644 --- a/tasks-jsf/pom.xml +++ b/tasks-jsf/pom.xml @@ -16,7 +16,7 @@ limitations under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 org.wildfly.quickstarts @@ -44,8 +44,15 @@ - - 32.0.0.Beta1 + + 32.0.0.Beta1 + + ${version.server} + 7.0.0.Final + 8.0.0.Final + 5.0.0.Final + + 5.9.1 @@ -109,7 +116,7 @@ org.wildfly.bom wildfly-ee-with-tools - ${version.server.bom} + ${version.bom.ee} pom import @@ -118,6 +125,9 @@ + + jakarta.enterprise @@ -125,13 +135,6 @@ provided - - - junit - junit - test - - jakarta.persistence @@ -139,18 +142,6 @@ provided - - org.jboss.arquillian.junit - arquillian-junit-container - test - - - - org.jboss.arquillian.protocol - arquillian-protocol-servlet-jakarta - test - - jakarta.ejb @@ -165,37 +156,92 @@ provided + + + org.junit.jupiter + junit-jupiter-engine + ${version.org.junit.jupiter} + test + - - ${project.artifactId} + + + + org.wildfly.plugins + wildfly-maven-plugin + ${version.plugin.wildfly} + + + - - arq-managed - - - org.wildfly.arquillian - wildfly-arquillian-container-managed - test - - + provisioned-server - org.apache.maven.plugins - maven-failsafe-plugin - ${version.failsafe.plugin} + org.wildfly.plugins + wildfly-maven-plugin + + + + org.wildfly:wildfly-galleon-pack:${version.server} + + + org.wildfly:wildfly-datasources-galleon-pack:${version.pack.datasources} + + + + cloud-server + h2-datasource + jsf + + ROOT.war + - integration-test - verify + package + + + + + + + + + openshift + + + + org.wildfly.plugins + wildfly-maven-plugin + + + + org.wildfly:wildfly-galleon-pack:${version.server} + + + org.wildfly.cloud:wildfly-cloud-galleon-pack:${version.pack.cloud} + + + org.wildfly:wildfly-datasources-galleon-pack:${version.pack.datasources} + + + + cloud-server + h2-datasource + jsf + + ROOT.war + + + + + package @@ -204,22 +250,17 @@ - - arq-remote - - - org.wildfly.arquillian - wildfly-arquillian-container-remote - test - - + integration-testing org.apache.maven.plugins maven-failsafe-plugin - ${version.failsafe.plugin} + + + **/*IT + + @@ -233,5 +274,4 @@ - diff --git a/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/BasicRuntimeIT.java b/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/BasicRuntimeIT.java new file mode 100644 index 0000000000..2e5b990a87 --- /dev/null +++ b/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/BasicRuntimeIT.java @@ -0,0 +1,57 @@ +/* + * Copyright 2024 JBoss by Red Hat. + * + * 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 org.jboss.as.quickstarts.servlet.async; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; + +/** + * The very basic runtime integration testing. + * @author istudens + */ +public class BasicRuntimeIT { + + private static final String DEFAULT_SERVER_HOST = "http://localhost:8080/tasks-jsf"; + + @Test + public void testHTTPEndpointIsAvailable() throws IOException, InterruptedException, URISyntaxException { + String serverHost = System.getenv("SERVER_HOST"); + if (serverHost == null) { + serverHost = System.getProperty("server.host"); + } + if (serverHost == null) { + serverHost = DEFAULT_SERVER_HOST; + } + final HttpRequest request = HttpRequest.newBuilder() + .uri(new URI(serverHost+"/")) + .GET() + .build(); + final HttpClient client = HttpClient.newBuilder() + .followRedirects(HttpClient.Redirect.ALWAYS) + .connectTimeout(Duration.ofMinutes(1)) + .build(); + final HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); + Assertions.assertEquals(200, response.statusCode()); + } +} diff --git a/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/DefaultDeployment.java b/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/DefaultDeployment.java deleted file mode 100644 index e886df2210..0000000000 --- a/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/DefaultDeployment.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual - * contributors by the @authors tag. See the copyright.txt in the - * distribution for a full listing of individual contributors. - * - * 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 org.jboss.as.quickstarts.tasksJsf; - -import java.io.File; - -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.spec.WebArchive; - -/** - * Enables prepare project-specific {@link WebArchive} for deployment. - * - * @author Lukas Fryc - * - */ -public class DefaultDeployment { - - private static final String WEBAPP_SRC = "src/main/webapp"; - private static final String TEST_WEBAPP_SRC = "src/test/webapp"; - - private WebArchive webArchive; - - public DefaultDeployment() { - this(false); - } - - public DefaultDeployment(boolean useAlternative) { - if (useAlternative) { - webArchive = ShrinkWrap.create(WebArchive.class, "test.war").addAsWebInfResource( - new File(TEST_WEBAPP_SRC, "WEB-INF/beans.xml")); - } else { - webArchive = ShrinkWrap.create(WebArchive.class, "test.war").addAsWebInfResource( - new File(WEBAPP_SRC, "WEB-INF/beans.xml")); - } - } - - public DefaultDeployment withPersistence() { - webArchive = webArchive.addAsResource("META-INF/test-persistence.xml", "META-INF/persistence.xml").addAsWebInfResource( - "test-ds.xml", "test-ds.xml"); - return this; - } - - public DefaultDeployment withImportedData() { - webArchive = webArchive.addAsResource("import.sql"); - return this; - } - - public DefaultDeployment withFaces() { - webArchive = webArchive.addAsWebInfResource(new File(WEBAPP_SRC, "WEB-INF/faces-config.xml")); - return this; - } - - public WebArchive getArchive() { - return webArchive; - } -} diff --git a/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/FacesContextStub.java b/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/FacesContextStub.java deleted file mode 100644 index 49ce2ec6d0..0000000000 --- a/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/FacesContextStub.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual - * contributors by the @authors tag. See the copyright.txt in the - * distribution for a full listing of individual contributors. - * - * 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 org.jboss.as.quickstarts.tasksJsf; - -import java.util.Iterator; - -import jakarta.faces.application.Application; -import jakarta.faces.application.FacesMessage; -import jakarta.faces.application.FacesMessage.Severity; -import jakarta.faces.component.UIViewRoot; -import jakarta.faces.context.ExternalContext; -import jakarta.faces.context.FacesContext; -import jakarta.faces.context.ResponseStream; -import jakarta.faces.context.ResponseWriter; -import jakarta.faces.lifecycle.Lifecycle; -import jakarta.faces.render.RenderKit; - -/** - * Stub of {@link FacesContext} to allow testing without real JSF session. - * - * @author Lukas Fryc - * - */ -public class FacesContextStub extends FacesContext { - - FacesContextStub(String test) { - } - - public static void setCurrentInstance(FacesContext facesContext) { - FacesContext.setCurrentInstance(facesContext); - } - - @Override - public Application getApplication() { - return null; - } - - @Override - public Iterator getClientIdsWithMessages() { - return null; - } - - @Override - public ExternalContext getExternalContext() { - return null; - } - - @Override - public Severity getMaximumSeverity() { - return null; - } - - @Override - public Iterator getMessages() { - return null; - } - - @Override - public Iterator getMessages(String clientId) { - return null; - } - - @Override - public RenderKit getRenderKit() { - return null; - } - - @Override - public boolean getRenderResponse() { - return false; - } - - @Override - public boolean getResponseComplete() { - return false; - } - - @Override - public ResponseStream getResponseStream() { - - return null; - } - - @Override - public void setResponseStream(ResponseStream responseStream) { - - } - - @Override - public ResponseWriter getResponseWriter() { - - return null; - } - - @Override - public void setResponseWriter(ResponseWriter responseWriter) { - - } - - @Override - public UIViewRoot getViewRoot() { - - return null; - } - - @Override - public void setViewRoot(UIViewRoot root) { - - } - - @Override - public void addMessage(String clientId, FacesMessage message) { - - } - - @Override - public void release() { - - } - - @Override - public void renderResponse() { - - } - - @Override - public void responseComplete() { - - } - - @Override - public Lifecycle getLifecycle() { - return null; - } - -} diff --git a/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/ResourcesIT.java b/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/ResourcesIT.java deleted file mode 100644 index 1c43cf9328..0000000000 --- a/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/ResourcesIT.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual - * contributors by the @authors tag. See the copyright.txt in the - * distribution for a full listing of individual contributors. - * - * 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 org.jboss.as.quickstarts.tasksJsf; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.io.FileNotFoundException; -import java.util.logging.Level; -import java.util.logging.Logger; - -import jakarta.enterprise.inject.Instance; -import jakarta.faces.context.FacesContext; -import jakarta.inject.Inject; - -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.junit.Arquillian; -import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * @author Lukas Fryc - */ -@RunWith(Arquillian.class) -public class ResourcesIT { - - public static final String WEBAPP_SRC = "src/main/webapp"; - - @Deployment - public static WebArchive deployment() throws IllegalArgumentException, FileNotFoundException { - return new DefaultDeployment().withPersistence().withFaces().getArchive() - .addClasses(Resources.class, FacesContextStub.class); - } - - @Inject - private Instance facesContextInstance; - - @Inject - private Instance loggerInstance; - - @Test - public void facesContext_should_be_provided_from_current_context() { - FacesContextStub.setCurrentInstance(new FacesContextStub("stub")); - - FacesContext facesContext = facesContextInstance.get(); - assertNotNull(facesContext); - assertTrue(facesContext instanceof FacesContextStub); - - FacesContextStub.setCurrentInstance(null); - - facesContext = facesContextInstance.get(); - assertNull(facesContext); - } - - @Test - public void logger_should_be_provided_and_be_able_to_log_information_message() { - Logger logger = loggerInstance.get(); - assertNotNull(logger); - assertTrue(logger instanceof Logger); - logger.log(Level.INFO, "test message"); - } - -} diff --git a/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/TaskDaoIT.java b/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/TaskDaoIT.java deleted file mode 100644 index 288e1370c3..0000000000 --- a/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/TaskDaoIT.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual - * contributors by the @authors tag. See the copyright.txt in the - * distribution for a full listing of individual contributors. - * - * 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 org.jboss.as.quickstarts.tasksJsf; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.io.FileNotFoundException; -import java.util.List; -import jakarta.inject.Inject; -import jakarta.persistence.EntityManager; - -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.junit.Arquillian; -import org.jboss.arquillian.junit.InSequence; -import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * @author Lukas Fryc - * @author Oliver Kiss - */ -@RunWith(Arquillian.class) -public class TaskDaoIT { - - @Deployment - public static WebArchive deployment() throws IllegalArgumentException, FileNotFoundException { - return new DefaultDeployment().withPersistence().withImportedData().getArchive() - .addClasses(Resources.class, Person.class, PersonDao.class, Task.class, TaskDao.class, TaskDaoImpl.class); - } - - @Inject - private EntityManager em; - - @Inject - private TaskDao taskDao; - - private Person detachedUser; - - @Before - public void setUp() throws Exception { - detachedUser = new Person("jdoe"); - detachedUser.setId(1L); - } - - @Test - @InSequence(1) - public void user_should_be_created_with_one_task_attached() throws Exception { - // given - Person user = new Person("New user"); - Task task = new Task("New task"); - - // when - em.persist(user); - taskDao.createTask(user, task); - List userTasks = em.createQuery("SELECT t FROM Task t WHERE t.owner = :owner", Task.class) - .setParameter("owner", user).getResultList(); - - // then - assertEquals(1, userTasks.size()); - assertEquals(task, userTasks.get(0)); - } - - @Test - @InSequence(2) - public void all_tasks_should_be_obtained_from_detachedUser() { - // when - List userTasks = taskDao.getAll(detachedUser); - - // then - assertEquals(2, userTasks.size()); - } - - @Test - @InSequence(3) - public void range_of_tasks_should_be_provided_by_taskDao() { - // when - List headOfTasks = taskDao.getRange(detachedUser, 0, 1); - List tailOfTasks = taskDao.getRange(detachedUser, 1, 1); - - // then - assertEquals(1, headOfTasks.size()); - assertEquals(1, tailOfTasks.size()); - assertTrue(headOfTasks.get(0).getTitle().contains("first")); - assertTrue(tailOfTasks.get(0).getTitle().contains("second")); - } - - @Test - @InSequence(4) - public void taskDao_should_provide_basic_case_insensitive_full_text_search() { - // given - String taskTitlePart = "FIRST"; - - // when - List titledTasks = taskDao.getForTitle(detachedUser, taskTitlePart); - - // then - assertEquals(1, titledTasks.size()); - assertTrue(titledTasks.get(0).getTitle().contains("first")); - } - - @Test - @InSequence(5) - public void taskDao_should_remove_task_from_detachedUser() { - // given - Task task = new Task(); - task.setId(1L); - task.setOwner(detachedUser); - assertEquals(2, taskDao.getAll(detachedUser).size()); - - // when - taskDao.deleteTask(task); - - // then - assertEquals(1, taskDao.getAll(detachedUser).size()); - } -} diff --git a/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/TaskDaoStub.java b/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/TaskDaoStub.java deleted file mode 100644 index 021fa198cb..0000000000 --- a/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/TaskDaoStub.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual - * contributors by the @authors tag. See the copyright.txt in the - * distribution for a full listing of individual contributors. - * - * 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 org.jboss.as.quickstarts.tasksJsf; - -import java.util.Arrays; -import java.util.List; - -@Testing -public class TaskDaoStub implements TaskDao { - - private int getAllCallsCount = 0; - - @Override - public void createTask(Person user, Task task) { - } - - @Override - public List getAll(Person user) { - getAllCallsCount += 1; - return Arrays.asList(new Task[] {}); - } - - @Override - public List getRange(Person user, int offset, int count) { - return null; - } - - @Override - public List getForTitle(Person user, String title) { - return null; - } - - @Override - public void deleteTask(Task task) { - } - - public int getGetAllCallsCount() { - return getAllCallsCount; - } -} diff --git a/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/TaskListBeanIT.java b/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/TaskListBeanIT.java deleted file mode 100644 index a39f838900..0000000000 --- a/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/TaskListBeanIT.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual - * contributors by the @authors tag. See the copyright.txt in the - * distribution for a full listing of individual contributors. - * - * 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 org.jboss.as.quickstarts.tasksJsf; - -import static org.junit.Assert.assertEquals; - -import java.io.FileNotFoundException; -import jakarta.inject.Inject; - -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.junit.Arquillian; -import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * @author Lukas Fryc - */ -@RunWith(Arquillian.class) -public class TaskListBeanIT { - - public static final String WEBAPP_SRC = "src/main/webapp"; - - @Deployment - public static WebArchive deployment() throws IllegalArgumentException, FileNotFoundException { - return new DefaultDeployment(true).withPersistence().withImportedData().getArchive() - .addClasses(Person.class, Task.class, TaskList.class, TaskListBean.class, TaskDao.class, TaskDaoStub.class, Testing.class); - } - - @Inject - private TaskDao taskDaoStub; - - @Inject - private TaskList taskList; - - @Test - public void dao_method_getAll_should_be_called_only_once_on() { - taskList.getAll(); - taskList.getAll(); - taskList.getAll(); - assertEquals(1, ((TaskDaoStub) taskDaoStub).getGetAllCallsCount()); - } - - @Test - public void dao_method_getAll_should_be_called_after_invalidation() { - taskList.getAll(); - taskList.getAll(); - assertEquals(1, ((TaskDaoStub) taskDaoStub).getGetAllCallsCount()); - taskList.invalidate(); - assertEquals(1, ((TaskDaoStub) taskDaoStub).getGetAllCallsCount()); - taskList.getAll(); - taskList.getAll(); - assertEquals(2, ((TaskDaoStub) taskDaoStub).getGetAllCallsCount()); - } -} diff --git a/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/Testing.java b/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/Testing.java deleted file mode 100644 index 47c7403972..0000000000 --- a/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/Testing.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual - * contributors by the @authors tag. See the copyright.txt in the - * distribution for a full listing of individual contributors. - * - * 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 org.jboss.as.quickstarts.tasksJsf; - -import java.lang.annotation.Documented; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import jakarta.enterprise.context.RequestScoped; -import jakarta.enterprise.inject.Alternative; -import jakarta.enterprise.inject.Stereotype; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * Alternative testing annotation, used to enable all testing alternatives. - * @author jporter - */ -@Stereotype -@Inherited -@Alternative -@RequestScoped -@Target({ TYPE, METHOD, FIELD }) -@Retention(RUNTIME) -@Documented -public @interface Testing { - -} diff --git a/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/UserDaoIT.java b/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/UserDaoIT.java deleted file mode 100644 index c49a926ea6..0000000000 --- a/tasks-jsf/src/test/java/org/jboss/as/quickstarts/tasksJsf/UserDaoIT.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual - * contributors by the @authors tag. See the copyright.txt in the - * distribution for a full listing of individual contributors. - * - * 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 org.jboss.as.quickstarts.tasksJsf; - -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.io.FileNotFoundException; -import jakarta.inject.Inject; -import jakarta.persistence.EntityManager; - -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.junit.Arquillian; -import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * @author Lukas Fryc - * @author Oliver Kiss - */ -@RunWith(Arquillian.class) -public class UserDaoIT { - - @Deployment - public static WebArchive deployment() throws IllegalArgumentException, FileNotFoundException { - return new DefaultDeployment().withPersistence().withImportedData().getArchive() - .addClasses(Resources.class, Person.class, PersonDao.class, Task.class, TaskDao.class, PersonDaoImpl.class); - } - - @Inject - private PersonDao userDao; - - @Inject - private EntityManager em; - - @Test - public void userDao_should_create_user_so_it_could_be_retrieved_from_userDao_by_username() { - // given - Person created = new Person("username1"); - - // when - userDao.createUser(created); - Person retrieved = userDao.getForUsername("username1"); - - // then - assertTrue(em.contains(created)); - assertTrue(em.contains(retrieved)); - Assert.assertEquals(created, retrieved); - } - - @Test - public void user_should_be_retrievable_from_userDao_by_username() { - // given - String username = "jdoe"; - - // when - Person retrieved = userDao.getForUsername(username); - - // then - Assert.assertEquals(username, retrieved.getUsername()); - } - - @Test - public void userDao_should_return_null_when_searching_for_non_existent_user() { - // given - String nonExistent = "nonExistent"; - - // when - Person retrieved = userDao.getForUsername(nonExistent); - - // then - assertNull(retrieved); - } -} diff --git a/tasks-jsf/src/test/resources/META-INF/test-persistence.xml b/tasks-jsf/src/test/resources/META-INF/test-persistence.xml deleted file mode 100644 index fa4764e613..0000000000 --- a/tasks-jsf/src/test/resources/META-INF/test-persistence.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - java:jboss/datasources/TasksJsfQuickstartTestDS - - - - - - - diff --git a/tasks-jsf/src/test/resources/arquillian.xml b/tasks-jsf/src/test/resources/arquillian.xml deleted file mode 100644 index fdeb809fee..0000000000 --- a/tasks-jsf/src/test/resources/arquillian.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/tasks-jsf/src/test/resources/test-ds.xml b/tasks-jsf/src/test/resources/test-ds.xml deleted file mode 100644 index 6968390886..0000000000 --- a/tasks-jsf/src/test/resources/test-ds.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - jdbc:h2:mem:tasks-jsf-quickstart-test;DB_CLOSE_DELAY=-1 - h2 - - sa - sa - - - - diff --git a/tasks-jsf/src/test/webapp/WEB-INF/beans.xml b/tasks-jsf/src/test/webapp/WEB-INF/beans.xml deleted file mode 100644 index 193e543397..0000000000 --- a/tasks-jsf/src/test/webapp/WEB-INF/beans.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - org.jboss.as.quickstarts.tasksJsf.Testing - -