From a2e2192494535b7c34f97a56bc28af4ee9b17bee Mon Sep 17 00:00:00 2001 From: Alex Vargas Date: Wed, 24 May 2017 14:23:49 -0700 Subject: [PATCH] Code example for article BAEL-818 (#1909) * Quartz example for article: Introduction to Quartz * Adding new module for Java Quartz * Removing Quartz code from jee7 module * Fixing folder structure --- java-quartz/pom.xml | 31 + .../baeldung/java_quartz/QuartzExample.java | 42 + .../com/baeldung/java_quartz/SimpleJob.java | 13 + .../com/baeldung/java_quartz/AppTest.java | 38 + jee7/pom.xml | 720 +++++++++--------- 5 files changed, 484 insertions(+), 360 deletions(-) create mode 100644 java-quartz/pom.xml create mode 100644 java-quartz/src/main/java/com/baeldung/java_quartz/QuartzExample.java create mode 100644 java-quartz/src/main/java/com/baeldung/java_quartz/SimpleJob.java create mode 100644 java-quartz/src/test/java/com/baeldung/java_quartz/AppTest.java diff --git a/java-quartz/pom.xml b/java-quartz/pom.xml new file mode 100644 index 0000000000..51b9d56a7b --- /dev/null +++ b/java-quartz/pom.xml @@ -0,0 +1,31 @@ + + 4.0.0 + + com.baeldung + java-quartz + 0.0.1-SNAPSHOT + jar + + java-quartz + http://maven.apache.org + + + UTF-8 + + + + + junit + junit + 3.8.1 + test + + + org.quartz-scheduler + quartz + 2.3.0 + + + + diff --git a/java-quartz/src/main/java/com/baeldung/java_quartz/QuartzExample.java b/java-quartz/src/main/java/com/baeldung/java_quartz/QuartzExample.java new file mode 100644 index 0000000000..89cd2680e2 --- /dev/null +++ b/java-quartz/src/main/java/com/baeldung/java_quartz/QuartzExample.java @@ -0,0 +1,42 @@ +package com.baeldung.java_quartz; + +import org.quartz.JobBuilder; +import org.quartz.JobDetail; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.quartz.SchedulerFactory; +import org.quartz.SimpleScheduleBuilder; +import org.quartz.Trigger; +import org.quartz.TriggerBuilder; +import org.quartz.impl.StdSchedulerFactory; + +public class QuartzExample { + + public static void main(String args[]) { + + SchedulerFactory schedFact = new StdSchedulerFactory(); + try { + + Scheduler sched = schedFact.getScheduler(); + + JobDetail job = JobBuilder.newJob(SimpleJob.class) + .withIdentity("myJob", "group1") + .build(); + + Trigger trigger = TriggerBuilder.newTrigger() + .withIdentity("myTrigger", "group1") + .startNow() + .withSchedule(SimpleScheduleBuilder.simpleSchedule() + .withIntervalInSeconds(40) + .repeatForever()) + .build(); + + sched.scheduleJob(job, trigger); + sched.start(); + + } catch (SchedulerException e) { + e.printStackTrace(); + } + } + +} \ No newline at end of file diff --git a/java-quartz/src/main/java/com/baeldung/java_quartz/SimpleJob.java b/java-quartz/src/main/java/com/baeldung/java_quartz/SimpleJob.java new file mode 100644 index 0000000000..a9e677c24f --- /dev/null +++ b/java-quartz/src/main/java/com/baeldung/java_quartz/SimpleJob.java @@ -0,0 +1,13 @@ +package com.baeldung.java_quartz; + +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +public class SimpleJob implements Job { + + public void execute(JobExecutionContext arg0) throws JobExecutionException { + System.out.println("This is a quartz job!"); + } + +} \ No newline at end of file diff --git a/java-quartz/src/test/java/com/baeldung/java_quartz/AppTest.java b/java-quartz/src/test/java/com/baeldung/java_quartz/AppTest.java new file mode 100644 index 0000000000..68754c2c15 --- /dev/null +++ b/java-quartz/src/test/java/com/baeldung/java_quartz/AppTest.java @@ -0,0 +1,38 @@ +package com.baeldung.java_quartz; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/jee7/pom.xml b/jee7/pom.xml index fe7c5e4c11..e633d2df3d 100644 --- a/jee7/pom.xml +++ b/jee7/pom.xml @@ -1,381 +1,381 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - com.baeldung - jee7 - 1.0-SNAPSHOT - JavaEE 7 Arquillian Archetype Sample + com.baeldung + jee7 + 1.0-SNAPSHOT + JavaEE 7 Arquillian Archetype Sample - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + - - 1.8 - 3.0.0 + + 1.8 + 3.0.0 - 7.0 - 1.1.11.Final - 8.2.1.Final - 1.7.0 - 1.4.6.Final - 3.0.19.Final - 4.1.1 - 1.0.4 - 1.13 - 2.25 - 1.0.0.Final + 7.0 + 1.1.11.Final + 8.2.1.Final + 1.7.0 + 1.4.6.Final + 3.0.19.Final + 4.1.1 + 1.0.4 + 1.13 + 2.25 + 1.0.0.Final - 2.6 - + 2.6 + - - ${maven.min.version} - + + ${maven.min.version} + - - - - org.jboss.arquillian - arquillian-bom - ${arquillian_core.version} - import - pom - - - org.jboss.arquillian.extension - arquillian-drone-bom - 2.0.1.Final - pom - import - - - + + + + org.jboss.arquillian + arquillian-bom + ${arquillian_core.version} + import + pom + + + org.jboss.arquillian.extension + arquillian-drone-bom + 2.0.1.Final + pom + import + + + - - - javax - javaee-api - ${javaee_api.version} - provided - - - - org.jboss.arquillian.junit - arquillian-junit-container - test - + - org.jboss.arquillian.graphene - graphene-webdriver - 2.1.0.Final - pom - test - - - com.jayway.awaitility - awaitility - ${awaitility.version} - test - + javax + javaee-api + ${javaee_api.version} + provided + - - org.jboss.shrinkwrap.resolver - shrinkwrap-resolver-impl-maven - test - jar - - - - org.jboss.shrinkwrap.resolver - shrinkwrap-resolver-impl-maven-archive - test - - - org.apache.httpcomponents - httpclient - 4.5 - - - commons-io - commons-io - 2.4 - - - com.sun.faces - jsf-api - 2.2.14 - - - com.sun.faces - jsf-impl - 2.2.14 - - - javax.servlet - jstl - 1.2 - - - javax.servlet - javax.servlet-api - 3.1.0 - - javax.servlet.jsp - jsp-api - 2.2 - provided + org.jboss.arquillian.junit + arquillian-junit-container + test - taglibs - standard - 1.1.2 - - + org.jboss.arquillian.graphene + graphene-webdriver + 2.1.0.Final + pom + test + + + com.jayway.awaitility + awaitility + ${awaitility.version} + test + - - - - org.apache.maven.plugins - maven-war-plugin - ${maven-war-plugin.version} - - false - - - - + + org.jboss.shrinkwrap.resolver + shrinkwrap-resolver-impl-maven + test + jar + - + + org.jboss.shrinkwrap.resolver + shrinkwrap-resolver-impl-maven-archive + test + + + org.apache.httpcomponents + httpclient + 4.5 + + + commons-io + commons-io + 2.4 + + + com.sun.faces + jsf-api + 2.2.14 + + + com.sun.faces + jsf-impl + 2.2.14 + + + javax.servlet + jstl + 1.2 + + + javax.servlet + javax.servlet-api + 3.1.0 + + + javax.servlet.jsp + jsp-api + 2.2 + provided + + + taglibs + standard + 1.1.2 + + - - wildfly-managed-arquillian - - true - - - standalone-full.xml - ${project.build.directory}/wildfly-${version.wildfly} - - - - io.undertow - undertow-websockets-jsr - ${undertow-websockets-jsr.version} - test - - - org.jboss.resteasy - resteasy-client - ${resteasy.version} - test - - - org.jboss.resteasy - resteasy-jaxb-provider - ${resteasy.version} - test - - - org.jboss.resteasy - resteasy-json-p-provider - ${resteasy.version} - test - - - org.wildfly - wildfly-arquillian-container-managed - ${wildfly.version} - test - - - - - - - maven-dependency-plugin - 2.8 - - ${maven.test.skip} - - - - unpack - process-test-classes - - unpack - - - - - org.wildfly - wildfly-dist - ${wildfly.version} - zip - false - ${project.build.directory} - - - - - - - - maven-surefire-plugin - 2.17 - - - ${project.build.directory}/wildfly-${wildfly.version} - - - - - - - - - wildfly-remote-arquillian - - - io.undertow - undertow-websockets-jsr - ${undertow-websockets-jsr.version} - test - - - org.jboss.resteasy - resteasy-client - ${resteasy.version} - test - - - org.jboss.resteasy - resteasy-jaxb-provider - ${resteasy.version} - test - - - org.jboss.resteasy - resteasy-json-p-provider - ${resteasy.version} - test - - - org.wildfly - wildfly-arquillian-container-remote - ${wildfly.version} - test - - - - - glassfish-embedded-arquillian - - - org.glassfish.main.extras - glassfish-embedded-all - ${glassfish-embedded-all.version} - test - - - org.glassfish - javax.json - ${javax.json.version} - test - - - org.glassfish.tyrus - tyrus-client - ${tyrus.version} - test - - - org.glassfish.tyrus - tyrus-container-grizzly-client - ${tyrus.version} - test - - - org.glassfish.jersey.core - jersey-client - ${jersey.version} - test - - - org.jboss.arquillian.container - arquillian-glassfish-embedded-3.1 - ${arquillian-glassfish.version} - test - - - - - glassfish-remote-arquillian - - - org.glassfish - javax.json - ${javax.json.version} - test - - - org.glassfish.tyrus - tyrus-client - ${tyrus.version} - test - - - org.glassfish.tyrus - tyrus-container-grizzly-client - ${tyrus.version} - test - - - org.glassfish.jersey.core - jersey-client - ${jersey.version} - test - - - org.glassfish.jersey.media - jersey-media-json-jackson - ${jersey.version} - test - - - org.glassfish.jersey.media - jersey-media-json-processing - ${jersey.version} - test - - - org.jboss.arquillian.container - arquillian-glassfish-remote-3.1 - ${arquillian-glassfish.version} - test - - - - - webdriver-chrome - - true - - - chrome - - + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + false + + + + - - webdriver-firefox - - firefox - + + + + wildfly-managed-arquillian + + true + + + standalone-full.xml + ${project.build.directory}/wildfly-${version.wildfly} + + + + io.undertow + undertow-websockets-jsr + ${undertow-websockets-jsr.version} + test + + + org.jboss.resteasy + resteasy-client + ${resteasy.version} + test + + + org.jboss.resteasy + resteasy-jaxb-provider + ${resteasy.version} + test + + + org.jboss.resteasy + resteasy-json-p-provider + ${resteasy.version} + test + + + org.wildfly + wildfly-arquillian-container-managed + ${wildfly.version} + test + + + + + + + maven-dependency-plugin + 2.8 + + ${maven.test.skip} + + + + unpack + process-test-classes + + unpack + + + + + org.wildfly + wildfly-dist + ${wildfly.version} + zip + false + ${project.build.directory} + + + + + + + + maven-surefire-plugin + 2.17 + + + ${project.build.directory}/wildfly-${wildfly.version} + + + + + + - + + wildfly-remote-arquillian + + + io.undertow + undertow-websockets-jsr + ${undertow-websockets-jsr.version} + test + + + org.jboss.resteasy + resteasy-client + ${resteasy.version} + test + + + org.jboss.resteasy + resteasy-jaxb-provider + ${resteasy.version} + test + + + org.jboss.resteasy + resteasy-json-p-provider + ${resteasy.version} + test + + + org.wildfly + wildfly-arquillian-container-remote + ${wildfly.version} + test + + + + + glassfish-embedded-arquillian + + + org.glassfish.main.extras + glassfish-embedded-all + ${glassfish-embedded-all.version} + test + + + org.glassfish + javax.json + ${javax.json.version} + test + + + org.glassfish.tyrus + tyrus-client + ${tyrus.version} + test + + + org.glassfish.tyrus + tyrus-container-grizzly-client + ${tyrus.version} + test + + + org.glassfish.jersey.core + jersey-client + ${jersey.version} + test + + + org.jboss.arquillian.container + arquillian-glassfish-embedded-3.1 + ${arquillian-glassfish.version} + test + + + + + glassfish-remote-arquillian + + + org.glassfish + javax.json + ${javax.json.version} + test + + + org.glassfish.tyrus + tyrus-client + ${tyrus.version} + test + + + org.glassfish.tyrus + tyrus-container-grizzly-client + ${tyrus.version} + test + + + org.glassfish.jersey.core + jersey-client + ${jersey.version} + test + + + org.glassfish.jersey.media + jersey-media-json-jackson + ${jersey.version} + test + + + org.glassfish.jersey.media + jersey-media-json-processing + ${jersey.version} + test + + + org.jboss.arquillian.container + arquillian-glassfish-remote-3.1 + ${arquillian-glassfish.version} + test + + + + + webdriver-chrome + + true + + + chrome + + + + + webdriver-firefox + + firefox + + +