/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.camel.component.cxf;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.junit.Test;

public class CxfConusmerNamespacePayLoadTest extends CxfConsumerPayloadTest {
    private static final String ECHO_REQUEST = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" "
        + "xmlns:ns1=\"http://cxf.component.camel.apache.org/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
        + "xmlns:ns2=\"http://cxf.component.camel.apache.org/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body>"
        + "<ns1:echo><ns2:arg0 xsi:type=\"xsd:string\">Hello World!</ns2:arg0></ns1:echo></soap:Body></soap:Envelope>";
    
    protected void checkRequest(String expect, String request) {
        if (expect.equals(ECHO_REQUEST)) {
            // just check the namespace of xsd
            assertTrue("Expect to find the namesapce", request.indexOf("xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"") > 0);
        }
    }
    
    @Test
    public void testInvokingServiceFromClient() throws Exception {
        // just send a request which has all the namespace in the soap header
        HttpPost post = new HttpPost(simpleEndpointAddress);
        post.addHeader("Accept" , "text/xml");
        
        StringEntity entity = new StringEntity(ECHO_REQUEST, "text/xml", "ISO-8859-1");
        post.setEntity(entity);
        HttpClient httpclient = new DefaultHttpClient();

        try {
            HttpResponse response = httpclient.execute(post);
            //assertEquals(200, response.getStatusLine().getStatusCode());
            String responseBody = EntityUtils.toString(response.getEntity());
            System.out.println(responseBody);
            
            //assertEquals("Get a wrong response", correct, responseBody);
        } finally {
            httpclient.getConnectionManager().shutdown();
        }

    }

}

@@ -1206,16 +1206,396 @@
 dTest %7B%0A
+    private static final String ECHO_RESPONSE = %22%3Csoap:Envelope xmlns:soap=%5C%22http://schemas.xmlsoap.org/soap/envelope/%5C%22%3E%22%0A        + %22%3Csoap:Body%3E%3Cns1:echoResponse xmlns:ns1=%5C%22http://cxf.component.camel.apache.org/%5C%22%3E%22%0A        + %22%3Creturn xmlns=%5C%22http://cxf.component.camel.apache.org/%5C%22%3Eecho Hello World!%3C/return%3E%22%0A        + %22%3C/ns1:echoResponse%3E%3C/soap:Body%3E%3C/soap:Envelope%3E%22;%0A    %0A
     priv
@@ -2912,34 +2912,32 @@
 t);%0A            
-//
 assertEquals(200
@@ -3075,69 +3075,21 @@
     
-System.out.println(responseBody);%0A            %0A            //
+%0A            
 asse
@@ -3125,15 +3125,21 @@
 e%22, 
-correct
+ECHO_RESPONSE
 , re

CAMEL-4336 clean up the test code