Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WELD-2393 Fix event firing ordering for ProcessInjectionTarget, Proce…
…ssProducer and ProcessBeanAttributes. Added a tests for this.
- Loading branch information
Showing
8 changed files
with
340 additions
and
22 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
35 changes: 35 additions & 0 deletions
35
...rquillian/src/test/java/org/jboss/weld/tests/event/lifecycle/ordering/HastilyWritten.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,35 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2017, Red Hat, Inc., 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.weld.tests.event.lifecycle.ordering; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import javax.inject.Qualifier; | ||
|
||
/** | ||
* | ||
* @author <a href="mailto:manovotn@redhat.com">Matej Novotny</a> | ||
*/ | ||
@Qualifier | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ ElementType.METHOD, ElementType.FIELD, ElementType.TYPE, ElementType.PARAMETER }) | ||
public @interface HastilyWritten { | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
...test/java/org/jboss/weld/tests/event/lifecycle/ordering/HighQualityAndLowCostProduct.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,31 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2017, Red Hat, Inc., 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.weld.tests.event.lifecycle.ordering; | ||
|
||
import javax.enterprise.inject.Vetoed; | ||
|
||
/** | ||
* | ||
* @author <a href="mailto:manovotn@redhat.com">Matej Novotny</a> | ||
*/ | ||
@Vetoed | ||
public class HighQualityAndLowCostProduct { | ||
|
||
public void operateUntilWarrantyVoids() { | ||
|
||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
...c/test/java/org/jboss/weld/tests/event/lifecycle/ordering/LifecycleEventOrderingTest.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,75 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2017, Red Hat, Inc., 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.weld.tests.event.lifecycle.ordering; | ||
|
||
import java.util.List; | ||
|
||
import javax.enterprise.inject.spi.Extension; | ||
import javax.enterprise.inject.spi.ProcessBeanAttributes; | ||
import javax.enterprise.inject.spi.ProcessInjectionPoint; | ||
import javax.enterprise.inject.spi.ProcessInjectionTarget; | ||
import javax.enterprise.inject.spi.ProcessManagedBean; | ||
import javax.enterprise.inject.spi.ProcessProducer; | ||
import javax.enterprise.inject.spi.ProcessProducerMethod; | ||
import javax.inject.Inject; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.shrinkwrap.api.Archive; | ||
import org.jboss.shrinkwrap.api.BeanArchive; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.weld.test.util.Utils; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* | ||
* @author <a href="mailto:manovotn@redhat.com">Matej Novotny</a> | ||
*/ | ||
@RunWith(Arquillian.class) | ||
public class LifecycleEventOrderingTest { | ||
|
||
@Deployment | ||
public static Archive<?> getDeployment() { | ||
return ShrinkWrap.create(BeanArchive.class, Utils.getDeploymentNameAsHash(LifecycleEventOrderingTest.class)).addPackage(LifecycleEventOrderingTest.class.getPackage()) | ||
.addAsServiceProvider(Extension.class, ProductManagement.class); | ||
} | ||
|
||
@Inject | ||
ProductManagement extension; | ||
|
||
@Test | ||
public void testEventsWereFiredInCorrectOrderForProducer() { | ||
List<Object> actualListOfEvents = extension.getListOfProducerEvents(); | ||
Assert.assertEquals(4, actualListOfEvents.size()); | ||
Assert.assertTrue(actualListOfEvents.get(0) instanceof ProcessInjectionPoint); | ||
Assert.assertTrue(actualListOfEvents.get(1) instanceof ProcessProducer); | ||
Assert.assertTrue(actualListOfEvents.get(2) instanceof ProcessBeanAttributes); | ||
Assert.assertTrue(actualListOfEvents.get(3) instanceof ProcessProducerMethod); | ||
} | ||
|
||
@Test | ||
public void testEventsWereFiredInCorrectOrderForOrdinaryBean() { | ||
List<Object> actualListOfEvents = extension.getListOfBeanEvents(); | ||
Assert.assertEquals(4, actualListOfEvents.size()); | ||
Assert.assertTrue(actualListOfEvents.get(0) instanceof ProcessInjectionPoint); | ||
Assert.assertTrue(actualListOfEvents.get(1) instanceof ProcessInjectionTarget); | ||
Assert.assertTrue(actualListOfEvents.get(2) instanceof ProcessBeanAttributes); | ||
Assert.assertTrue(actualListOfEvents.get(3) instanceof ProcessManagedBean); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...uillian/src/test/java/org/jboss/weld/tests/event/lifecycle/ordering/MassiveJugCoffee.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,28 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2017, Red Hat, Inc., 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.weld.tests.event.lifecycle.ordering; | ||
|
||
import javax.enterprise.context.Dependent; | ||
|
||
/** | ||
* | ||
* @author <a href="mailto:manovotn@redhat.com">Matej Novotny</a> | ||
*/ | ||
@Dependent | ||
public class MassiveJugCoffee { | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
tests-arquillian/src/test/java/org/jboss/weld/tests/event/lifecycle/ordering/PoorWorker.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,43 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2017, Red Hat, Inc., 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.weld.tests.event.lifecycle.ordering; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.inject.Produces; | ||
import javax.inject.Inject; | ||
|
||
/** | ||
* | ||
* @author <a href="mailto:manovotn@redhat.com">Matej Novotny</a> | ||
*/ | ||
@ApplicationScoped | ||
public class PoorWorker { | ||
|
||
@Inject | ||
MassiveJugCoffee coffee; | ||
|
||
@Produces | ||
public HighQualityAndLowCostProduct makeManagersHappy(@HastilyWritten String docs) { | ||
return new HighQualityAndLowCostProduct(); | ||
} | ||
|
||
@Produces | ||
@HastilyWritten | ||
public String dontForgetTheDocumentation() { | ||
return "Made in NeverLand!"; | ||
} | ||
} |
Oops, something went wrong.