Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03ecaf5
commit df4e0eb
Showing
6 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
tests/src/test/java/org/jboss/weld/tests/interceptors/hierarchical/Attacker.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.weld.tests.interceptors.hierarchical; | ||
|
||
/** | ||
* @author Marius Bogoevici | ||
*/ | ||
@Play | ||
public class Attacker extends Player | ||
{ | ||
|
||
public void playBall() | ||
{ | ||
// do nothing | ||
} | ||
|
||
|
||
public Attacker cloneMe() | ||
{ | ||
return this; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
tests/src/test/java/org/jboss/weld/tests/interceptors/hierarchical/Defender.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,37 @@ | ||
/* | ||
* 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.weld.tests.interceptors.hierarchical; | ||
|
||
import javax.interceptor.AroundInvoke; | ||
import javax.interceptor.Interceptor; | ||
import javax.interceptor.InvocationContext; | ||
|
||
/** | ||
* @author Marius Bogoevici | ||
*/ | ||
@Interceptor @Play | ||
public class Defender | ||
{ | ||
static int invocationsCount = 0; | ||
|
||
@AroundInvoke | ||
public Object tackle(InvocationContext invocationContext) throws Exception | ||
{ | ||
invocationsCount ++; | ||
return invocationContext.proceed(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...st/java/org/jboss/weld/tests/interceptors/hierarchical/InterceptorsWithHierarchyTest.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,30 @@ | ||
package org.jboss.weld.tests.interceptors.hierarchical; | ||
|
||
import org.jboss.testharness.impl.packaging.Artifact; | ||
import org.jboss.testharness.impl.packaging.jsr299.BeansXml; | ||
import org.jboss.weld.test.AbstractWeldTest; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
/** | ||
* @author Marius Bogoevici | ||
*/ | ||
@Artifact | ||
@BeansXml("beans.xml") | ||
public class InterceptorsWithHierarchyTest extends AbstractWeldTest | ||
{ | ||
@BeforeClass | ||
public static void initialize() | ||
{ | ||
Defender.invocationsCount = 0; | ||
} | ||
|
||
@Test(groups = "broken") | ||
public void testInterceptorsWithHierarchy() | ||
{ | ||
Attacker player = this.getReference(Attacker.class); | ||
player.cloneMe(); | ||
assert Defender.invocationsCount == 1; | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
tests/src/test/java/org/jboss/weld/tests/interceptors/hierarchical/Play.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,38 @@ | ||
/* | ||
* 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.weld.tests.interceptors.hierarchical; | ||
|
||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import javax.interceptor.InterceptorBinding; | ||
|
||
/** | ||
* @author <a href="mailto:mariusb@redhat.com">Marius Bogoevici</a> | ||
*/ | ||
@InterceptorBinding | ||
@Retention(RUNTIME) | ||
@Target({ElementType.METHOD, ElementType.TYPE}) | ||
@Documented | ||
public @interface Play | ||
{ | ||
} |
33 changes: 33 additions & 0 deletions
33
tests/src/test/java/org/jboss/weld/tests/interceptors/hierarchical/Player.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,33 @@ | ||
/* | ||
* 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.weld.tests.interceptors.hierarchical; | ||
|
||
/** | ||
* @author Marius Bogoevici | ||
*/ | ||
public class Player | ||
{ | ||
public void playBall() | ||
{ | ||
|
||
} | ||
|
||
public Player cloneMe() | ||
{ | ||
return this; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
tests/src/test/resources/org/jboss/weld/tests/interceptors/hierarchical/beans.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,5 @@ | ||
<beans> | ||
<interceptors> | ||
<class>org.jboss.weld.tests.interceptors.hierarchical.Defender</class> | ||
</interceptors> | ||
</beans> |