-
Notifications
You must be signed in to change notification settings - Fork 692
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TOMEE-4307 - Batchee Downgrade to 1.0.4 (#1115)
* Downgrade to BatchEE 1.0.3 (Jakarta) to avoid henn-egg issues * small test * Small test for batchee * BatchEE 1.0.4 (with CDI-4 fix)
- Loading branch information
Showing
9 changed files
with
165 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
container/openejb-core/src/test/java/org/apache/openejb/batchee/InjectionsMock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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.api.AbstractBatchlet; | ||
import jakarta.batch.api.BatchProperty; | ||
import jakarta.batch.runtime.context.JobContext; | ||
import jakarta.enterprise.inject.spi.Bean; | ||
import jakarta.enterprise.inject.spi.BeanManager; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Named; | ||
import org.junit.Assert; | ||
|
||
import java.net.URL; | ||
|
||
@Named("injected") | ||
public class InjectionsMock extends AbstractBatchlet { | ||
@Inject | ||
@BatchProperty | ||
private URL url; | ||
|
||
@Inject | ||
private JobContext jobContext; | ||
|
||
@Inject | ||
private BeanManager beanManager; | ||
|
||
@Override | ||
public String process() throws Exception { | ||
Assert.assertTrue(url.toExternalForm().equals("http://batchee.incubator.org")); | ||
Assert.assertNotNull(jobContext); | ||
Assert.assertEquals(jobContext.getJobName(), "injections"); | ||
|
||
// now check whether injection also works during the runtime of the batch | ||
// this is needed if you e.g have a NormalScoped bean which only now gets initialized. | ||
Assert.assertNotNull(beanManager); | ||
Bean<?> bean = beanManager.resolve(beanManager.getBeans(JobContext.class)); | ||
JobContext jc = (JobContext) beanManager.getReference(bean, JobContext.class, beanManager.createCreationalContext(bean)); | ||
Assert.assertNotNull(jc); | ||
Assert.assertEquals(jc.getJobName(), "injections"); | ||
|
||
return "true"; | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
container/openejb-core/src/test/java/org/apache/openejb/batchee/InjectionsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* 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; | ||
|
||
@RunWith(ApplicationComposer.class) | ||
public class InjectionsTest { | ||
|
||
@Module | ||
public Class<?>[] cdi() { | ||
return new Class<?>[]{BatchBean.class, InjectionsMock.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(); | ||
} | ||
|
||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
container/openejb-core/src/test/resources/META-INF/batch-jobs/injections.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters