Package org.jboss.arquillian.graphene.proxy

Examples of org.jboss.arquillian.graphene.proxy.Interceptor


        Assert.assertEquals(1, counter2.get());
        Assert.assertEquals(1, counterDefault.get());
    }

    protected Interceptor createInterceptor(final AtomicInteger counter) {
        return new Interceptor() {
            @Override
            public Object intercept(InvocationContext context) throws Throwable {
                counter.incrementAndGet();
                return context.invoke();
            }
View Full Code Here


        // having
        MyObject target = new MyObject();
        MyObject proxy = GrapheneProxy.getProxyForTarget(null, target);

        // when
        ((GrapheneProxyInstance) proxy).registerInterceptor(new Interceptor() {
            @Override
            public Object intercept(InvocationContext context) throws Throwable {
                return context.invoke();
            }
View Full Code Here

    @Test
    public void test() throws Throwable {
        InterceptorBuilder builder = new InterceptorBuilder();
        builder.interceptInvocation(WebDriver.class, interceptor1).findElement(Interceptors.any(By.class));
        builder.interceptInvocation(WebDriver.class, interceptor2).findElement(Interceptors.any(By.class));
        Interceptor builtInterceptor = builder.build();

        WebDriver driverProxy = GrapheneProxy.getProxyForTargetWithInterfaces(context, driver, WebDriver.class);
        GrapheneProxyInstance proxy = (GrapheneProxyInstance) driverProxy;

        proxy.registerInterceptor(builtInterceptor);
View Full Code Here

        interceptor_registered_before_test_invoked = false;
    }

    @Before
    public void register_interceptor_before_test() {
        ((GrapheneProxyInstance) browser).registerInterceptor(new Interceptor() {
            public Object intercept(InvocationContext context) throws Throwable {
                interceptor_registered_before_test_invoked = true;
                return context.invoke();
            }
            public int getPrecedence() {
View Full Code Here

        invoked = false;
        try {
            Test event = ctx.getEvent();
            if (event.getTestClass().getJavaClass() == TestInterceptorRegistration.class) {
                WebDriver browser = org.jboss.arquillian.graphene.context.GrapheneContext.getContextFor(Default.class).getWebDriver();
                ((GrapheneProxyInstance) browser).registerInterceptor(new Interceptor() {

                    @Override
                    public Object intercept(InvocationContext context) throws Throwable {
                        invoked = true;
                        return context.invoke();
View Full Code Here

    }

    @Test
    @InSequence(1)
    public void interceptor_can_be_registered_in_test_itself() {
        ((GrapheneProxyInstance) browser).registerInterceptor(new Interceptor() {

            @Override
            public Object intercept(InvocationContext context) throws Throwable {
                invoked = true;
                return context.invoke();
View Full Code Here

        if (GrapheneProxy.isProxyInstance(target)) {
            proxy = (GrapheneProxyInstance) ((GrapheneProxyInstance) target).copy();
        } else {
            proxy = (GrapheneProxyInstance) GrapheneProxy.getProxyForTarget(target);
        }
        proxy.registerInterceptor(new Interceptor() {
            @Override
            public Object intercept(InvocationContext context) throws Throwable {

                guard.clearRequestDone();
View Full Code Here

     *
     * @return the final version of {@link Interceptor}
     */
    public Interceptor build() {

        return new Interceptor() {

            final Map<Method, List<Interceptor>> interceptors = new HashMap<Method, List<Interceptor>>(
                    InterceptorBuilder.this.interceptors);

            @Override
            public Object intercept(final InvocationContext originalContext) throws Throwable {
                Collection<Interceptor> interceptors = this.interceptors.get(originalContext.getMethod());

                if (interceptors != null) {
                    final Iterator<Interceptor> iterator = interceptors.iterator();

                    if (iterator.hasNext()) {
                        Interceptor interceptor = iterator.next();

                        return interceptor.intercept(new InvocationContext() {

                            @Override
                            public Object invoke() throws Throwable {
                                if (iterator.hasNext()) {
                                    return iterator.next().intercept(this);
View Full Code Here

        @Override
        public Object lookup(ArquillianResource resource, Annotation... qualifiers) {
            final M base = base();

            ((GrapheneProxyInstance) base).registerInterceptor(new Interceptor() {

                @Override
                public Object intercept(final InvocationContext context) throws Throwable {
                    final Method method = context.getMethod();
                    if (method.getDeclaringClass() == mediatorType) {
View Full Code Here

     *
     * @return the final version of {@link Interceptor}
     */
    public Interceptor build() {

        return new Interceptor() {

            final Map<Method, List<Interceptor>> interceptors = new HashMap<Method, List<Interceptor>>(
                    InterceptorBuilder.this.interceptors);

            @Override
            public Object intercept(final InvocationContext originalContext) throws Throwable {
                Collection<Interceptor> interceptors = this.interceptors.get(originalContext.getMethod());

                if (interceptors != null) {
                    final Iterator<Interceptor> iterator = interceptors.iterator();

                    if (iterator.hasNext()) {
                        Interceptor interceptor = iterator.next();

                        return interceptor.intercept(new InvocationContext() {

                            @Override
                            public Object invoke() throws Throwable {
                                if (iterator.hasNext()) {
                                    return iterator.next().intercept(this);
View Full Code Here

TOP

Related Classes of org.jboss.arquillian.graphene.proxy.Interceptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.