You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rz...@apache.org on 2024/03/21 20:11:00 UTC
(tomee) branch batchee-downgrade-for-10.x-m1 updated: small test
This is an automated email from the ASF dual-hosted git repository.
rzo1 pushed a commit to branch batchee-downgrade-for-10.x-m1
in repository https://gitbox.apache.org/repos/asf/tomee.git
The following commit(s) were added to refs/heads/batchee-downgrade-for-10.x-m1 by this push:
new ae634ce17d small test
ae634ce17d is described below
commit ae634ce17dbf39afe15a1d63c359d13623891b7a
Author: Richard Zowalla <rz...@apache.org>
AuthorDate: Thu Mar 21 21:10:49 2024 +0100
small test
---
.../org/apache/openejb/batchee/InjectionsTest.java | 64 ++++++++++++++++++++++
.../src/test/resources/batch-jobs/injections.xml | 24 ++++++++
.../src/test/resources/batch-jobs/simple.xml | 18 ++++++
3 files changed, 106 insertions(+)
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/batchee/InjectionsTest.java b/container/openejb-core/src/test/java/org/apache/openejb/batchee/InjectionsTest.java
new file mode 100644
index 0000000000..23ef5ee428
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/batchee/InjectionsTest.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2012 International Business Machines Corp.
+ *
+ * See the NOTICE file distributed with this work for additional information
+ * regarding copyright ownership. 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.apache.openejb.batchee;
+
+import jakarta.batch.operations.JobOperator;
+import jakarta.batch.runtime.BatchRuntime;
+import jakarta.inject.Inject;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.testing.Module;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.batchee.util.Batches.waitForEnd;
+import static org.testng.Assert.assertEquals;
+
+@RunWith(ApplicationComposer.class)
+public class InjectionsTest {
+ @Test
+ public void run() {
+ final JobOperator operator = BatchRuntime.getJobOperator();
+ final long id = operator.start("injections", null);
+ waitForEnd(operator, id);
+ assertEquals(operator.getStepExecutions(id).iterator().next().getExitStatus(), "true");
+ }
+
+ @Module
+ public Class<?>[] cdi() {
+ return new Class<?>[]{BatchBean.class};
+ }
+
+ @Inject
+ private BatchBean bean;
+
+ @Test
+ public void test() {
+ Assert.assertEquals("true", bean.run());
+ }
+
+ public static class BatchBean {
+
+ public String run() {
+ final JobOperator operator = BatchRuntime.getJobOperator();
+ final long id = operator.start("injections", null);
+ waitForEnd(operator, id);
+ return operator.getStepExecutions(id).iterator().next().getExitStatus();
+ }
+
+ }
+}
diff --git a/container/openejb-core/src/test/resources/batch-jobs/injections.xml b/container/openejb-core/src/test/resources/batch-jobs/injections.xml
new file mode 100644
index 0000000000..0076454353
--- /dev/null
+++ b/container/openejb-core/src/test/resources/batch-jobs/injections.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ See the NOTICE file distributed with this work for additional information
+ regarding copyright ownership. 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.
+-->
+<job id="injections" version="1.0" xmlns="http://xmlns.jcp.org/xml/ns/javaee">
+ <step id="inject-step">
+ <batchlet ref="injected">
+ <properties>
+ <property name="url" value="http://batchee.incubator.org"/>
+ </properties>
+ </batchlet>
+ </step>
+</job>
diff --git a/container/openejb-core/src/test/resources/batch-jobs/simple.xml b/container/openejb-core/src/test/resources/batch-jobs/simple.xml
new file mode 100644
index 0000000000..e7fab0f645
--- /dev/null
+++ b/container/openejb-core/src/test/resources/batch-jobs/simple.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- See the NOTICE file distributed with this work for additional information
+ regarding copyright ownership. 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. -->
+<job id="simple" version="1.0" xmlns="http://xmlns.jcp.org/xml/ns/javaee">
+ <step id="exec">
+ <batchlet ref="org.apache.batchee.component.SimpleBatchlet">
+ <properties>
+ <property name="duration" value="#{jobParameters['duration']}"/>
+ </properties>
+ </batchlet>
+ </step>
+</job>