This file contains hidden or 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
| // The Annotation | |
| @InterceptorBinding | |
| @Retention(RetentionPolicy.RUNTIME) | |
| @Target({FIELD, METHOD, PARAMETER, TYPE}) | |
| @Qualifier | |
| public @interface RunInRequestScope { | |
| } | |
| // The Interceptor for the annotation |
This file contains hidden or 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
| @RequestScoped | |
| public class MyCdiBean { | |
| private boolean flag = true; | |
| @Inject | |
| private MyService service; | |
| public void doSomething() { | |
| if (!flag) { | |
| service.callMethod(); |
This file contains hidden or 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
| List list = Arrays.asList("foo", "bar"); | |
| assertThat(list, is(not(empty()))); | |
| assertThat(list.get(0), is("foo")); | |
| assertThat(list, hasItem("bar")); |
This file contains hidden or 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
| assertThat(list, hasItem("baz")); |
This file contains hidden or 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
| assertThat(myObject.getBar(), is(nullValue())); |
This file contains hidden or 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
| assertThat(myObject.isBar(), is(true)); |
This file contains hidden or 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
| assertThat(myObject, hasProperty("bar", is(true))); |
This file contains hidden or 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
| assertThat(myObject).isBar(); |
This file contains hidden or 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
| assertThatNot(myObject).isBar(); |
This file contains hidden or 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
| import static org.junit.Assert.assertEquals; | |
| import java.lang.reflect.Method; | |
| import org.hamcrest.Matcher; | |
| import org.hamcrest.MatcherAssert; | |
| import net.sf.cglib.proxy.Enhancer; | |
| import net.sf.cglib.proxy.InvocationHandler; |