-
Notifications
You must be signed in to change notification settings - Fork 286
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
Showing
6 changed files
with
310 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...-arquillian/src/test/java/org/jboss/weld/tests/decorators/exception/CheckedException.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 | ||
* Copyright 2012, 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.decorators.exception; | ||
|
||
public class CheckedException extends Exception { | ||
|
||
private static final long serialVersionUID = 2272688680157036226L; | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...llian/src/test/java/org/jboss/weld/tests/decorators/exception/CustomRuntimeException.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 | ||
* Copyright 2012, 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.decorators.exception; | ||
|
||
public class CustomRuntimeException extends RuntimeException { | ||
|
||
private static final long serialVersionUID = 3598778994005468661L; | ||
|
||
} |
113 changes: 113 additions & 0 deletions
113
...st/java/org/jboss/weld/tests/decorators/exception/ExceptionThrownByDecoratedBeanTest.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,113 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2012, 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.decorators.exception; | ||
|
||
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.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(Arquillian.class) | ||
public class ExceptionThrownByDecoratedBeanTest { | ||
|
||
@Inject | ||
private Foo foo; | ||
|
||
@Deployment | ||
public static Archive<?> getDeployment() { | ||
return ShrinkWrap.create(BeanArchive.class).decorate(FooDecorator.class) | ||
.addPackage(ExceptionThrownByDecoratedBeanTest.class.getPackage()); | ||
} | ||
|
||
@Test | ||
public void testCheckedExceptionPropagatedThroughDecoratorCall() { | ||
try { | ||
foo.throwCheckedException1(); | ||
Assert.fail(); | ||
} catch (CheckedException expected) { | ||
} | ||
} | ||
|
||
@Test | ||
public void testCheckedExceptionThrownByDecorator() { | ||
try { | ||
foo.throwCheckedException2(); | ||
Assert.fail(); | ||
} catch (CheckedException expected) { | ||
} | ||
} | ||
|
||
@Test | ||
public void testCheckedExceptionPropagated() { | ||
try { | ||
foo.throwCheckedException3(); | ||
Assert.fail(); | ||
} catch (CheckedException expected) { | ||
} | ||
} | ||
|
||
@Test | ||
public void testCheckedExceptionPropagatedThroughAbstractDecoratorMethod() { | ||
try { | ||
foo.throwCheckedException4(); | ||
Assert.fail(); | ||
} catch (CheckedException expected) { | ||
} | ||
} | ||
|
||
@Test | ||
public void testRuntimeExceptionPropagatedThroughDecoratorCall() { | ||
try { | ||
foo.throwRuntimeException1(); | ||
Assert.fail(); | ||
} catch (CustomRuntimeException expected) { | ||
} | ||
} | ||
|
||
@Test | ||
public void testRuntimeExceptionThrownByDecorator() { | ||
try { | ||
foo.throwRuntimeException2(); | ||
Assert.fail(); | ||
} catch (CustomRuntimeException expected) { | ||
} | ||
} | ||
|
||
@Test | ||
public void testRuntimeExceptionPropagated() { | ||
try { | ||
foo.throwRuntimeException3(); | ||
Assert.fail(); | ||
} catch (CustomRuntimeException expected) { | ||
} | ||
} | ||
|
||
@Test | ||
public void testRuntimeExceptionPropagatedThroughAbstractDecoratorMethod() { | ||
try { | ||
foo.throwRuntimeException4(); | ||
Assert.fail(); | ||
} catch (CustomRuntimeException expected) { | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/exception/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,36 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2012, 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.decorators.exception; | ||
|
||
public interface Foo { | ||
|
||
void throwCheckedException1() throws CheckedException; | ||
|
||
void throwCheckedException2() throws CheckedException; | ||
|
||
void throwCheckedException3() throws CheckedException; | ||
|
||
void throwCheckedException4() throws CheckedException; | ||
|
||
void throwRuntimeException1(); | ||
|
||
void throwRuntimeException2(); | ||
|
||
void throwRuntimeException3(); | ||
|
||
void throwRuntimeException4(); | ||
} |
55 changes: 55 additions & 0 deletions
55
tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/exception/FooDecorator.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,55 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2012, 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.decorators.exception; | ||
|
||
import javax.decorator.Decorator; | ||
import javax.decorator.Delegate; | ||
import javax.inject.Inject; | ||
|
||
@Decorator | ||
public abstract class FooDecorator implements Foo { | ||
|
||
@Inject | ||
@Delegate | ||
private Foo delegate; | ||
|
||
@Override | ||
public void throwCheckedException1() throws CheckedException { | ||
delegate.throwCheckedException1(); | ||
} | ||
|
||
@Override | ||
public void throwCheckedException2() throws CheckedException { | ||
throw new CheckedException(); | ||
} | ||
|
||
@Override | ||
public void throwRuntimeException1() { | ||
delegate.throwRuntimeException1(); | ||
} | ||
|
||
@Override | ||
public void throwRuntimeException2() { | ||
throw new CustomRuntimeException(); | ||
} | ||
|
||
@Override | ||
public abstract void throwCheckedException4() throws CheckedException; | ||
|
||
@Override | ||
public abstract void throwRuntimeException4(); | ||
} |
60 changes: 60 additions & 0 deletions
60
tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/exception/FooImpl.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,60 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2012, 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.decorators.exception; | ||
|
||
public class FooImpl implements Foo { | ||
|
||
@Override | ||
public void throwCheckedException1() throws CheckedException { | ||
throw new CheckedException(); | ||
} | ||
|
||
@Override | ||
public void throwCheckedException2() throws CheckedException { | ||
throw new CheckedException(); | ||
} | ||
|
||
@Override | ||
public void throwCheckedException3() throws CheckedException { | ||
throw new CheckedException(); | ||
} | ||
|
||
@Override | ||
public void throwCheckedException4() throws CheckedException { | ||
throw new CheckedException(); | ||
} | ||
|
||
@Override | ||
public void throwRuntimeException1() { | ||
throw new CustomRuntimeException(); | ||
} | ||
|
||
@Override | ||
public void throwRuntimeException2() { | ||
throw new CustomRuntimeException(); | ||
} | ||
|
||
@Override | ||
public void throwRuntimeException3() { | ||
throw new CustomRuntimeException(); | ||
} | ||
|
||
@Override | ||
public void throwRuntimeException4() { | ||
throw new CustomRuntimeException(); | ||
} | ||
} |