-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ArC - add basic validation for normal scoped beans
- resolves #549
- Loading branch information
Showing
8 changed files
with
247 additions
and
35 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
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
37 changes: 37 additions & 0 deletions
37
.../tests/src/test/java/org/jboss/protean/arc/test/validation/BoundInterceptorFinalTest.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 @@ | ||
package org.jboss.protean.arc.test.validation; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import javax.enterprise.context.Dependent; | ||
import javax.enterprise.inject.spi.DefinitionException; | ||
import javax.enterprise.inject.spi.DeploymentException; | ||
|
||
import org.jboss.protean.arc.test.ArcTestContainer; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
public class BoundInterceptorFinalTest { | ||
|
||
@Rule | ||
public ArcTestContainer container = ArcTestContainer.builder().beanClasses(Unproxyable.class, Simple.class, SimpleInterceptor.class).shouldFail().build(); | ||
|
||
@Test | ||
public void testFailure() { | ||
Throwable error = container.getFailure(); | ||
assertNotNull(error); | ||
assertTrue(error instanceof DeploymentException); | ||
assertNotNull(error.getCause()); | ||
assertTrue(error.getCause() instanceof DefinitionException); | ||
} | ||
|
||
@Dependent | ||
@Simple | ||
static final class Unproxyable { | ||
|
||
void ping() { | ||
} | ||
|
||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
...ests/src/test/java/org/jboss/protean/arc/test/validation/NormalScopedConstructorTest.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,39 @@ | ||
package org.jboss.protean.arc.test.validation; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.inject.Instance; | ||
import javax.enterprise.inject.spi.DefinitionException; | ||
import javax.enterprise.inject.spi.DeploymentException; | ||
import javax.inject.Inject; | ||
|
||
import org.jboss.protean.arc.test.ArcTestContainer; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
public class NormalScopedConstructorTest { | ||
|
||
@Rule | ||
public ArcTestContainer container = ArcTestContainer.builder().beanClasses(Unproxyable.class).shouldFail().build(); | ||
|
||
@Test | ||
public void testFailure() { | ||
Throwable error = container.getFailure(); | ||
assertNotNull(error); | ||
assertTrue(error instanceof DeploymentException); | ||
assertNotNull(error.getCause()); | ||
assertTrue(error.getCause() instanceof DefinitionException); | ||
} | ||
|
||
@ApplicationScoped | ||
static class Unproxyable { | ||
|
||
@Inject | ||
public Unproxyable(Instance<String> instance) { | ||
} | ||
|
||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
.../arc/tests/src/test/java/org/jboss/protean/arc/test/validation/NormalScopedFinalTest.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 @@ | ||
package org.jboss.protean.arc.test.validation; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.inject.spi.DefinitionException; | ||
import javax.enterprise.inject.spi.DeploymentException; | ||
|
||
import org.jboss.protean.arc.test.ArcTestContainer; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
public class NormalScopedFinalTest { | ||
|
||
@Rule | ||
public ArcTestContainer container = ArcTestContainer.builder().beanClasses(Unproxyable.class).shouldFail().build(); | ||
|
||
@Test | ||
public void testFailure() { | ||
Throwable error = container.getFailure(); | ||
assertNotNull(error); | ||
assertTrue(error instanceof DeploymentException); | ||
assertNotNull(error.getCause()); | ||
assertTrue(error.getCause() instanceof DefinitionException); | ||
} | ||
|
||
@ApplicationScoped | ||
static final class Unproxyable { | ||
|
||
void ping() { | ||
} | ||
|
||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
...endent-projects/arc/tests/src/test/java/org/jboss/protean/arc/test/validation/Simple.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 @@ | ||
/* | ||
* Copyright 2018 Red Hat, Inc. | ||
* | ||
* 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.protean.arc.test.validation; | ||
|
||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import javax.interceptor.InterceptorBinding; | ||
|
||
@Target({ TYPE, METHOD }) | ||
@Retention(RUNTIME) | ||
@Documented | ||
@InterceptorBinding | ||
public @interface Simple { | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...ects/arc/tests/src/test/java/org/jboss/protean/arc/test/validation/SimpleInterceptor.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 @@ | ||
/* | ||
* Copyright 2018 Red Hat, Inc. | ||
* | ||
* 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.protean.arc.test.validation; | ||
|
||
import javax.annotation.Priority; | ||
import javax.inject.Inject; | ||
import javax.interceptor.AroundInvoke; | ||
import javax.interceptor.Interceptor; | ||
import javax.interceptor.InvocationContext; | ||
|
||
import org.jboss.protean.arc.InvocationContextImpl; | ||
|
||
@Simple | ||
@Priority(1) | ||
@Interceptor | ||
public class SimpleInterceptor { | ||
|
||
@AroundInvoke | ||
Object mySuperCoolAroundInvoke(InvocationContext ctx) throws Exception { | ||
return ctx.proceed(); | ||
} | ||
} |