Java Code Examples for org.spockframework.runtime.extension.IMethodInvocation#proceed()

The following examples show how to use org.spockframework.runtime.extension.IMethodInvocation#proceed() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FailsWithMessageExtension.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void intercept(IMethodInvocation invocation) throws Throwable {
    try {
        invocation.proceed();
    } catch (Throwable t) {
        if (!annotation.type().isInstance(t)) {
            throw new WrongExceptionThrownError(annotation.type(), t);
        }
        if (!annotation.message().equals(t.getMessage())) {
            throw new ComparisonFailure("Unexpected message for exception.", annotation.message(), t.getMessage());
        }
        return;
    }

    throw new WrongExceptionThrownError(annotation.type(), null);
}
 
Example 2
Source File: FailsWithMessageExtension.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void intercept(IMethodInvocation invocation) throws Throwable {
    try {
        invocation.proceed();
    } catch (Throwable t) {
        if (!annotation.type().isInstance(t)) {
            throw new WrongExceptionThrownError(annotation.type(), t);
        }
        if (!annotation.message().equals(t.getMessage())) {
            throw new ComparisonFailure("Unexpected message for exception.", annotation.message(), t.getMessage());
        }
        return;
    }

    throw new WrongExceptionThrownError(annotation.type(), null);
}
 
Example 3
Source File: FailsWithMessageExtension.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void intercept(IMethodInvocation invocation) throws Throwable {
    try {
        invocation.proceed();
    } catch (Throwable t) {
        if (!annotation.type().isInstance(t)) {
            throw new WrongExceptionThrownError(annotation.type(), t);
        }
        if (!annotation.message().equals(t.getMessage())) {
            throw new ComparisonFailure("Unexpected message for exception.", annotation.message(), t.getMessage());
        }
        return;
    }

    throw new WrongExceptionThrownError(annotation.type(), null);
}
 
Example 4
Source File: FailsWithMessageExtension.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void intercept(IMethodInvocation invocation) throws Throwable {
    try {
        invocation.proceed();
    } catch (Throwable t) {
        if (!annotation.type().isInstance(t)) {
            throw new WrongExceptionThrownError(annotation.type(), t);
        }
        if (!annotation.message().equals(t.getMessage())) {
            throw new ComparisonFailure("Unexpected message for exception.", annotation.message(), t.getMessage());
        }
        return;
    }

    throw new WrongExceptionThrownError(annotation.type(), null);
}
 
Example 5
Source File: LoggingTestInterceptor.java    From ogham with Apache License 2.0 5 votes vote down vote up
@Override
public void intercept(IMethodInvocation invocation) throws Throwable {
	String testName = invocation.getIteration().getName();
	try {
		logger.writeStart(testName);
		invocation.proceed();
		logger.writeSuccess(testName);
	} catch (Throwable e) { // NOSONAR
		logger.writeFailure(testName, e);
		throw e;
	}
}
 
Example 6
Source File: GuiceyConfigurationHookInterceptor.java    From dropwizard-guicey with MIT License 5 votes vote down vote up
@Override
public void interceptCleanupSpecMethod(final IMethodInvocation invocation) throws Throwable {
    // for case when base test is used without actual application start and so listeners will never be used
    // cleanup state after tests to not affect other tests
    ConfigurationHooksSupport.reset();
    invocation.proceed();
}
 
Example 7
Source File: GuiceyInterceptor.java    From dropwizard-guicey with MIT License 5 votes vote down vote up
@Override
public void interceptSharedInitializerMethod(final IMethodInvocation invocation) throws Throwable {
    hooks.forEach(GuiceyConfigurationHook::register);
    support.before();
    // static fields
    SpecialFieldsSupport.initClients(null, clientFields, support.getClient(), false);
    injector = support.getInjector();
    injectValues(invocation.getSharedInstance(), true);
    invocation.proceed();
}
 
Example 8
Source File: GuiceyInterceptor.java    From dropwizard-guicey with MIT License 5 votes vote down vote up
@Override
public void interceptCleanupSpecMethod(final IMethodInvocation invocation) throws Throwable {
    // just in case to avoid side-effects
    ConfigurationHooksSupport.reset();
    try {
        invocation.proceed();
    } finally {
        support.after();
    }
}
 
Example 9
Source File: UseActivityInterceptor.java    From android-spock with Apache License 2.0 4 votes vote down vote up
@Override public void interceptSetupMethod(IMethodInvocation invocation) throws Throwable {
  fieldInfo.writeValue(invocation.getInstance(), getActivity());
  invocation.proceed();
}
 
Example 10
Source File: UseApplicationInterceptor.java    From android-spock with Apache License 2.0 4 votes vote down vote up
@Override public void interceptSetupMethod(IMethodInvocation invocation) throws Throwable {
  final Application application =
      Instrumentation.newApplication(applicationClass, instrumentation.getTargetContext());
  fieldInfo.writeValue(invocation.getInstance(), application);
  invocation.proceed();
}
 
Example 11
Source File: WithContextInterceptor.java    From android-spock with Apache License 2.0 4 votes vote down vote up
@Override public void interceptSetupMethod(IMethodInvocation invocation) throws Throwable {
  fieldInfo.writeValue(invocation.getInstance(), InstrumentationRegistry.getTargetContext());
  invocation.proceed();
}
 
Example 12
Source File: GuiceyConfigurationHookInterceptor.java    From dropwizard-guicey with MIT License 4 votes vote down vote up
@Override
public void interceptSharedInitializerMethod(final IMethodInvocation invocation) throws Throwable {
    hooks.forEach(GuiceyConfigurationHook::register);
    invocation.proceed();
}
 
Example 13
Source File: GuiceyInterceptor.java    From dropwizard-guicey with MIT License 4 votes vote down vote up
@Override
public void interceptInitializerMethod(final IMethodInvocation invocation) throws Throwable {
    injectValues(invocation.getInstance(), false);
    invocation.proceed();
}