0

Mule3.xを使用しています

MuleClientの接続をテストするコードがあります。

このテストは問題なく、適切に機能します。

public void testHello() throws Exception
    {
        MuleClient client = new MuleClient(muleContext);
        MuleMessage result = client.send("http://127.0.0.1:8080/hello", "some data", null);
        assertNotNull(result);
        assertNull(result.getExceptionPayload());
        assertFalse(result.getPayload() instanceof NullPayload);

        //TODO Assert the correct data has been received
        assertEquals("hello", result.getPayloadAsString());
    }

しかし、これは問題ありません-接続例外で失敗します:

public void testHello_with_Spring() throws Exception {

    MuleClient client = new MuleClient("mule-config-test.xml");
    client.getMuleContext().start();

    //it fails here
    MuleMessage result = client.send("http://127.0.0.1:8080/hello", "some data", null);
    assertNotNull(result);

    assertNull(result.getExceptionPayload());
    assertFalse(result.getPayload() instanceof NullPayload);

    //TODO Assert the correct data has been received
    assertEquals("hello", result.getPayloadAsString());
}

'mule-config-test.xml'は両方のテストで使用され、このファイルのパスは問題ありません。確認しました。

これは私が最後に持っているエラーメッセージです:

例外スタックは次のとおりです。1。すでに使用されているアドレス(java.net.BindException)java.net.PlainSocketImpl:-2(null)2. uri "http://127.0.0.1:8080/hello"(org .mule.transport.ConnectException)
org.mule.transport.tcp.TcpMessageReceiver:81(http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/transport/ConnectException.html)--- -------------------------------------------------- ---------------------------ルート例外スタックトレース:java.net.BindException:java.net.PlainSocketImpl.socketBindですでに使用されているアドレス(ネイティブメソッド)java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383)at java.net.ServerSocket.bind(ServerSocket.java:328)+ 3 more(デバッグレベルロギングまたは'-Dmule.verbose.exceptionsを設定=すべてに対してtrue')


[10-0516:33:37]エラーHttpConnector[main]:org.mule.transport.ConnectException:uri "http://127.0.0.1:8080/hello" [10-05 16:33: 37]エラーConnectNotifier[main]:接続/再接続に失敗しました:HttpConnector {
name = connectedor.http.mule.default lifecycle = stop this = 7578a7d9 numberOfConcurrentTransactedReceivers
= 4
createMultipleTransactedReceivers = true connected = false
supportedProtocols = [http]serviceOverrides=}。ルート例外は次のとおりです。アドレスはすでに使用されています。タイプ:class java.net.BindException [10-05 16:33:37]エラーDefaultSystemExceptionStrategy[main]:uri"http://127.0.0.1:8080/hello"へのバインドに失敗しました

org.mule.api.lifecycle.LifecycleException:「connector.http.mule.default」が停止しているため、イベントを処理できません

4

1 に答える 1

1

問題はあなたが見せていないことにあると思います:testHello_with_Spring()おそらくMuleがすでに実行されている間に実行されています。開始している2番目のMuleは、他のMuleとポート競合します。

testHello()testHello_with_Spring()は同じテストスイートにありますか?はいの場合、それtestHello()がすでに実行されているMuleに依存していることを考えると、それがのポート競合の原因になると思いますtestHello_with_Spring()

于 2012-10-05T20:47:10.847 に答える