-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #438 Fix the interceptor ordering test for both CDI Lite and Full
- Loading branch information
Showing
13 changed files
with
227 additions
and
28 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...tion/interceptorOrder/AccountBinding.java → ...tion/interceptorOrder/AccountBinding.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
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
...g/jboss/cdi/tck/tests/full/interceptors/definition/interceptorOrder/FirstInterceptor.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 2010, 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.cdi.tck.tests.full.interceptors.definition.interceptorOrder; | ||
|
||
import jakarta.annotation.Priority; | ||
import jakarta.interceptor.AroundInvoke; | ||
import jakarta.interceptor.Interceptor; | ||
import jakarta.interceptor.InvocationContext; | ||
import org.jboss.cdi.tck.util.ActionSequence; | ||
|
||
@Interceptor | ||
@Secure | ||
@Priority(Interceptor.Priority.APPLICATION+1) | ||
public class FirstInterceptor { | ||
|
||
@AroundInvoke | ||
public Object alwaysReturnThis(InvocationContext ctx) throws Exception { | ||
ActionSequence.addAction(FirstInterceptor.class.getName()); | ||
return ctx.proceed(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
.../main/java/org/jboss/cdi/tck/tests/full/interceptors/definition/interceptorOrder/Foo.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,26 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2010, 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.cdi.tck.tests.full.interceptors.definition.interceptorOrder; | ||
|
||
import jakarta.enterprise.context.Dependent; | ||
|
||
@Secure | ||
@Dependent | ||
public class Foo { | ||
public void bar() { | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
...oss/cdi/tck/tests/full/interceptors/definition/interceptorOrder/InterceptorOrderTest.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,80 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2010, 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.cdi.tck.tests.full.interceptors.definition.interceptorOrder; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.cdi.tck.AbstractTest; | ||
import org.jboss.cdi.tck.shrinkwrap.WebArchiveBuilder; | ||
import org.jboss.cdi.tck.util.ActionSequence; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.jboss.shrinkwrap.impl.BeansXml; | ||
import org.jboss.test.audit.annotations.SpecAssertion; | ||
import org.jboss.test.audit.annotations.SpecAssertions; | ||
import org.jboss.test.audit.annotations.SpecVersion; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.List; | ||
|
||
import static org.jboss.cdi.tck.TestGroups.CDI_FULL; | ||
import static org.jboss.cdi.tck.cdi.Sections.ENABLED_INTERCEPTORS; | ||
import static org.testng.Assert.assertEquals; | ||
import static org.testng.Assert.assertNotNull; | ||
|
||
@SpecVersion(spec = "cdi", version = "2.0") | ||
@Test(groups = CDI_FULL) | ||
public class InterceptorOrderTest extends AbstractTest { | ||
|
||
@Deployment | ||
public static WebArchive createTestArchive() { | ||
return new WebArchiveBuilder() | ||
.withTestClassPackage(InterceptorOrderTest.class) | ||
.withBeansXml(new BeansXml().interceptors(SecondInterceptor.class, FirstInterceptor.class, TransactionalInterceptor.class)) | ||
.build(); | ||
} | ||
|
||
@Test(dataProvider = ARQUILLIAN_DATA_PROVIDER) | ||
@SpecAssertions({ @SpecAssertion(section = ENABLED_INTERCEPTORS, id = "b"), @SpecAssertion(section = ENABLED_INTERCEPTORS, id = "c") }) | ||
public void testInterceptorsCalledInOrderDefinedByBeansXml(Foo foo) { | ||
|
||
assertNotNull(foo); | ||
ActionSequence.reset(); | ||
|
||
foo.bar(); | ||
|
||
List<String> sequence = ActionSequence.getSequenceData(); | ||
assertEquals(sequence.size(), 2); | ||
assertEquals(sequence.get(0), SecondInterceptor.class.getName()); | ||
assertEquals(sequence.get(1), FirstInterceptor.class.getName()); | ||
} | ||
|
||
@Test(dataProvider = ARQUILLIAN_DATA_PROVIDER) | ||
@SpecAssertion(section = ENABLED_INTERCEPTORS, id = "g") | ||
public void testInterceptorsInvocationOrder(AccountTransaction transaction) { | ||
|
||
assertNotNull(transaction); | ||
ActionSequence.reset(); | ||
|
||
transaction.execute(); | ||
|
||
List<String> sequence = ActionSequence.getSequenceData(); | ||
assertEquals(sequence.size(), 4, sequence.toString()); | ||
assertEquals(sequence.get(0), AnotherInterceptor.class.getName()); | ||
assertEquals(sequence.get(1), TransactionalInterceptor.class.getName()); | ||
assertEquals(sequence.get(2), Transaction.class.getName()); | ||
assertEquals(sequence.get(3), AccountTransaction.class.getName()); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
.../jboss/cdi/tck/tests/full/interceptors/definition/interceptorOrder/SecondInterceptor.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,36 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2010, 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.cdi.tck.tests.full.interceptors.definition.interceptorOrder; | ||
|
||
import jakarta.annotation.Priority; | ||
import jakarta.interceptor.AroundInvoke; | ||
import jakarta.interceptor.Interceptor; | ||
import jakarta.interceptor.InvocationContext; | ||
import org.jboss.cdi.tck.util.ActionSequence; | ||
|
||
@Interceptor | ||
@Secure | ||
@Priority(Interceptor.Priority.APPLICATION) | ||
public class SecondInterceptor { | ||
public static boolean calledFirst = false; | ||
|
||
@AroundInvoke | ||
public Object alwaysReturnThis(InvocationContext ctx) throws Exception { | ||
ActionSequence.addAction(SecondInterceptor.class.getName()); | ||
return ctx.proceed(); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...in/java/org/jboss/cdi/tck/tests/full/interceptors/definition/interceptorOrder/Secure.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 2010, 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.cdi.tck.tests.full.interceptors.definition.interceptorOrder; | ||
|
||
import jakarta.interceptor.InterceptorBinding; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
@Target({ TYPE, METHOD }) | ||
@Retention(RUNTIME) | ||
@Documented | ||
@InterceptorBinding | ||
public @interface Secure { | ||
|
||
} |
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
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