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
0df85a9
commit afbaefa
Showing
7 changed files
with
227 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/Intercepted.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,34 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright2010, Red Hat, Inc. and/or its affiliates, 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.decorators.interceptor; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import javax.interceptor.InterceptorBinding; | ||
|
||
@Inherited | ||
@InterceptorBinding | ||
@Target({ElementType.TYPE, ElementType.METHOD}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface Intercepted | ||
{ | ||
} |
43 changes: 43 additions & 0 deletions
43
...rc/test/java/org/jboss/weld/tests/decorators/interceptor/InterceptorAndDecoratorTest.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 | ||
* Copyright2010, Red Hat, Inc. and/or its affiliates, 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.decorators.interceptor; | ||
|
||
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.Test; | ||
|
||
@Artifact | ||
@BeansXml("beans.xml") | ||
public class InterceptorAndDecoratorTest extends AbstractWeldTest | ||
{ | ||
|
||
@Test(description="WELD-314", groups = "broken") | ||
public void test() | ||
{ | ||
ServiceImpl.invocationCount = 0; | ||
ServiceDecorator.invocationCount = 0; | ||
ServiceInterceptor.invocationCount = 0; | ||
getReference(Service.class).execute(); | ||
assert ServiceImpl.invocationCount == 1; | ||
assert ServiceDecorator.invocationCount == 1; | ||
assert ServiceInterceptor.invocationCount == 1; | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/Service.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,23 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright2010, Red Hat, Inc. and/or its affiliates, 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.decorators.interceptor; | ||
|
||
public interface Service | ||
{ | ||
void execute(); | ||
} |
52 changes: 52 additions & 0 deletions
52
tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/ServiceDecorator.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,52 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright2010, Red Hat, Inc. and/or its affiliates, 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. | ||
*/ | ||
|
||
/* | ||
* To change this template, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
|
||
package org.jboss.weld.tests.decorators.interceptor; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
import javax.decorator.Decorator; | ||
import javax.decorator.Delegate; | ||
import javax.inject.Inject; | ||
|
||
/** | ||
* Secure PaymentService implemented by decator | ||
* | ||
* @author wayne | ||
*/ | ||
@Decorator | ||
class ServiceDecorator implements Service | ||
{ | ||
|
||
@Inject | ||
@Delegate | ||
private Service service; | ||
|
||
public static int invocationCount = 0; | ||
|
||
public void execute() | ||
{ | ||
invocationCount++; | ||
service.execute(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/ServiceImpl.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 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright2010, Red Hat, Inc. and/or its affiliates, 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.decorators.interceptor; | ||
|
||
public class ServiceImpl implements Service | ||
{ | ||
|
||
public static int invocationCount = 0; | ||
|
||
@Intercepted | ||
public void execute() | ||
{ | ||
invocationCount ++; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/ServiceInterceptor.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/or its affiliates, 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.decorators.interceptor; | ||
|
||
import javax.interceptor.AroundInvoke; | ||
import javax.interceptor.Interceptor; | ||
import javax.interceptor.InvocationContext; | ||
|
||
@Intercepted @Interceptor | ||
public class ServiceInterceptor | ||
{ | ||
|
||
public static int invocationCount = 0; | ||
|
||
@AroundInvoke | ||
public Object interceptService(InvocationContext invocationContext) throws Exception | ||
{ | ||
this.invocationCount++; | ||
return invocationContext.proceed(); | ||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
tests/src/test/resources/org/jboss/weld/tests/decorators/interceptor/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,8 @@ | ||
<beans> | ||
<decorators> | ||
<class>org.jboss.weld.tests.decorators.interceptor.ServiceDecorator</class> | ||
</decorators> | ||
<interceptors> | ||
<class>org.jboss.weld.tests.decorators.interceptor.ServiceInterceptor</class> | ||
</interceptors> | ||
</beans> |