0
私はSpring HTTP呼び出しを介してAPIをビルドします。私のconfig.xmlには、次のようになります。SpringのHTTP呼び出し:ビルドサーバーでのテストのクラッシュ
<bean id="apiUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/remoteapi/boat">boatEndpointExporter</prop>
</props>
</property>
</bean>
<bean id="boatEndpointExporter" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
<property name="service" ref="rApiBoatEndpointImpl"/>
<property name="serviceInterface" value="xxx.RApiBoatEndpoint"/>
</bean>
これは私のテストケースである: それはそれに対してpingを実行するために、アプリケーションとtrys外部からAPIをコールするふり。
@Test
public void invokePing() {
RApiBoatEndpoint remoteInteface = buildRemoteInteface();
assertEquals("test", remoteInteface.ping("test"));
}
private RApiBoatEndpoint buildRemoteInteface() {
String url = WebDriverResourceManager.BASE_URL + "/remoteapi/boat";
System.out.println("build remote interface for RApiBoatEndpoint - url=" + url);
PoolingHttpClientConnectionManager poolingHttpClientConnectionManager = new PoolingHttpClientConnectionManager();
poolingHttpClientConnectionManager.setMaxTotal(100);
poolingHttpClientConnectionManager.setDefaultMaxPerRoute(5);
CloseableHttpClient httpClient = HttpClientBuilder.create()
.setConnectionManager(poolingHttpClientConnectionManager)
.build();
HttpComponentsHttpInvokerRequestExecutor httpComponentsHttpInvokerRequestExecutor = new HttpComponentsHttpInvokerRequestExecutor();
httpComponentsHttpInvokerRequestExecutor.setHttpClient(httpClient);
HttpInvokerProxyFactoryBean factory = new HttpInvokerProxyFactoryBean();
factory.setServiceUrl(url);
factory.setServiceInterface(RApiBoatEndpoint.class);
factory.setHttpInvokerRequestExecutor(httpComponentsHttpInvokerRequestExecutor);
factory.afterPropertiesSet();
return (RApiBoatEndpoint) factory.getObject();
}
テストは、IDEとmavenの両方を通過します。 私はapiを手動で、そしてクライアントアプリケーションから呼び出すことができます。
しかし、私たちのビルドサーバーは、それが動作しないことを言って続けて:
org.springframework.remoting.RemoteAccessException: Could not access HTTP invoker remote service at [http://xxxx/remoteapi/boat]; nested exception is org.apache.http.NoHttpResponseException: Did not receive successful HTTP response: status code = 404, status message = [Not Found]
at org.springframework.remoting.httpinvoker.HttpComponentsHttpInvokerRequestExecutor.validateResponse(HttpComponentsHttpInvokerRequestExecutor.java:233)
at org.springframework.remoting.httpinvoker.HttpComponentsHttpInvokerRequestExecutor.doExecuteRequest(HttpComponentsHttpInvokerRequestExecutor.java:149)
at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.executeRequest(AbstractHttpInvokerRequestExecutor.java:138)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:194)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:176)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:144)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy36.ping(Unknown Source)
任意の提案、問題を解決する方法?
私はこれがあなたの例外で、 'xxxx'が実際に重要であるwher場合だと思います。それは 'localhost'ですか?そうでない場合、それは何ですか?ブラウザでそのURLを開くとどうなりますか?それは本当にHTTP 404ですか?あなたのテストが実行されるとき、そのURLには本当にどんなサーバーがありますか? – SergGr
@SergGr xxxそれぞれのビルドノードの名前です(http://hudsonjava05.xxx.org:8418/xxxxx/remoteapi/boat)。それは各ビルドノードのcontext.xmlで設定されます。テストはmaven経由で実行され、貨物を開始します。実行中のサーバーも必要な他のテスト(同じパッケージ内)があります。これらのテストは成功します。だから私はそれが一般的な問題ではないと思うが、私のテストのセットアップ/設定については何か。 – Shareil
通常、このサーバーは(セレン)テストでのみ実行されるため、URLを呼び出すことはできません。しかし、私はサーバーが構築している次回にそれを呼び出すようにしようとします...たぶん私は何かを発見するでしょう。 – Shareil