Search in sources :

Example 16 with RemoteInvocation

use of org.springframework.remoting.support.RemoteInvocation in project gocd by gocd.

the class AgentRemoteInvokerServiceExporterTest method reportCurrentStatus_allowedForSameUUID.

@Test
void reportCurrentStatus_allowedForSameUUID() throws Exception {
    final AgentRuntimeInfo agent = runtimeInfo(AGENT_UUID);
    final AgentRemoteInvokerServiceExporter invoker = deserializingWith(new RemoteInvocation("reportCurrentStatus", new Class[] { AgentRuntimeInfo.class, JobIdentifier.class, JobState.class }, new Object[] { agent, null, null }));
    invoker.handleRequest(req, res);
    verify(target, only()).reportCurrentStatus(agent, null, null);
    assertEquals(SC_OK, res.getStatus());
}
Also used : RemoteInvocation(org.springframework.remoting.support.RemoteInvocation) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) JobState(com.thoughtworks.go.domain.JobState) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Test(org.junit.jupiter.api.Test)

Example 17 with RemoteInvocation

use of org.springframework.remoting.support.RemoteInvocation in project gocd by gocd.

the class AgentRemoteInvokerServiceExporterTest method getCookie_allowedForSameUUID.

@Test
void getCookie_allowedForSameUUID() throws Exception {
    final AgentRuntimeInfo agent = runtimeInfo(AGENT_UUID);
    final AgentRemoteInvokerServiceExporter invoker = deserializingWith(new RemoteInvocation("getCookie", new Class[] { AgentRuntimeInfo.class }, new Object[] { agent }));
    invoker.handleRequest(req, res);
    verify(target, only()).getCookie(agent);
    assertEquals(SC_OK, res.getStatus());
}
Also used : RemoteInvocation(org.springframework.remoting.support.RemoteInvocation) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) Test(org.junit.jupiter.api.Test)

Example 18 with RemoteInvocation

use of org.springframework.remoting.support.RemoteInvocation in project gocd by gocd.

the class AgentRemoteInvokerServiceExporterTest method isIgnored_allowedForSameUUID.

@Test
void isIgnored_allowedForSameUUID() throws Exception {
    final AgentRuntimeInfo agent = runtimeInfo(AGENT_UUID);
    final AgentRemoteInvokerServiceExporter invoker = deserializingWith(new RemoteInvocation("isIgnored", new Class[] { AgentRuntimeInfo.class, JobIdentifier.class }, new Object[] { agent, null }));
    invoker.handleRequest(req, res);
    verify(target, only()).isIgnored(agent, null);
    assertEquals(SC_OK, res.getStatus());
}
Also used : RemoteInvocation(org.springframework.remoting.support.RemoteInvocation) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Test(org.junit.jupiter.api.Test)

Example 19 with RemoteInvocation

use of org.springframework.remoting.support.RemoteInvocation in project gocd by gocd.

the class AgentRemoteInvokerServiceExporterTest method getCookie_rejectedForDifferentUUID.

@Test
void getCookie_rejectedForDifferentUUID() throws Exception {
    final AgentRuntimeInfo agent = runtimeInfo("other");
    final AgentRemoteInvokerServiceExporter invoker = deserializingWith(new RemoteInvocation("getCookie", new Class[] { AgentRuntimeInfo.class }, new Object[] { agent }));
    invoker.handleRequest(req, res);
    verify(target, never()).getCookie(any(AgentRuntimeInfo.class));
    assertEquals(SC_FORBIDDEN, res.getStatus());
}
Also used : RemoteInvocation(org.springframework.remoting.support.RemoteInvocation) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) Test(org.junit.jupiter.api.Test)

Example 20 with RemoteInvocation

use of org.springframework.remoting.support.RemoteInvocation in project spring-framework by spring-projects.

the class HttpInvokerClientInterceptor method invoke.

@Override
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
    if (AopUtils.isToStringMethod(methodInvocation.getMethod())) {
        return "HTTP invoker proxy for service URL [" + getServiceUrl() + "]";
    }
    RemoteInvocation invocation = createRemoteInvocation(methodInvocation);
    RemoteInvocationResult result;
    try {
        result = executeRequest(invocation, methodInvocation);
    } catch (Throwable ex) {
        RemoteAccessException rae = convertHttpInvokerAccessException(ex);
        throw (rae != null ? rae : ex);
    }
    try {
        return recreateRemoteInvocationResult(result);
    } catch (Throwable ex) {
        if (result.hasInvocationTargetException()) {
            throw ex;
        } else {
            throw new RemoteInvocationFailureException("Invocation of method [" + methodInvocation.getMethod() + "] failed in HTTP invoker remote service at [" + getServiceUrl() + "]", ex);
        }
    }
}
Also used : RemoteInvocation(org.springframework.remoting.support.RemoteInvocation) RemoteInvocationResult(org.springframework.remoting.support.RemoteInvocationResult) RemoteAccessException(org.springframework.remoting.RemoteAccessException) RemoteInvocationFailureException(org.springframework.remoting.RemoteInvocationFailureException)

Aggregations

RemoteInvocation (org.springframework.remoting.support.RemoteInvocation)39 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)16 Test (org.junit.jupiter.api.Test)16 RemoteInvocationResult (org.springframework.remoting.support.RemoteInvocationResult)14 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)8 Test (org.junit.Test)8 RemoteAccessException (org.springframework.remoting.RemoteAccessException)7 IOException (java.io.IOException)6 MethodInvocation (org.aopalliance.intercept.MethodInvocation)6 ITestBean (org.springframework.tests.sample.beans.ITestBean)5 JobResult (com.thoughtworks.go.domain.JobResult)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 TestBean (org.springframework.tests.sample.beans.TestBean)4 NestedServletException (org.springframework.web.util.NestedServletException)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 Method (java.lang.reflect.Method)3 ServletException (javax.servlet.ServletException)3 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)3 MockHttpServletResponse (org.springframework.mock.web.test.MockHttpServletResponse)3