<commit_before>package org.codehaus.xfire.transport.http;

import org.codehaus.xfire.handler.HandlerPipeline;
import org.codehaus.xfire.service.AsyncService;
import org.codehaus.xfire.service.BadEcho;
import org.codehaus.xfire.service.Echo;
import org.codehaus.xfire.service.OperationInfo;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.soap.Soap11;
import org.codehaus.xfire.soap.SoapConstants;
import org.codehaus.xfire.test.AbstractServletTest;
import org.codehaus.xfire.transport.Transport;
import org.codehaus.xfire.wsdl.ResourceWSDL;
import org.codehaus.xfire.wsdl.WSDLWriter;
import org.codehaus.yom.Document;

import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.PostMethodWebRequest;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;

/**
 * XFireServletTest
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 */
public class XFireServletTest
        extends AbstractServletTest
{
    public void setUp()
            throws Exception
    {
        super.setUp();

        Service service = getServiceFactory().create(Echo.class,
                                                     Soap11.getInstance(),
                                                     SoapConstants.STYLE_MESSAGE,
                                                     SoapConstants.USE_LITERAL);
        WSDLWriter writer = new ResourceWSDL(getClass().getResource("/org/codehaus/xfire/echo11.wsdl"));
        service.setWSDLWriter(writer);

        service.setInPipeline(new HandlerPipeline());
        service.getInPipeline().addHandler(new MockSessionHandler());
        getServiceRegistry().register(service);

        Service faultService = getServiceFactory().create(BadEcho.class,
                                                          Soap11.getInstance(),
                                                          SoapConstants.STYLE_MESSAGE,
                                                          SoapConstants.USE_LITERAL);

        getServiceRegistry().register(faultService);
        
        // Asynchronous service
        Service asyncService = getServiceFactory().create(AsyncService.class,
                                                          Soap11.getInstance(),
                                                          SoapConstants.STYLE_MESSAGE,
                                                          SoapConstants.USE_LITERAL);
        OperationInfo op = asyncService.getServiceInfo().getOperation("echo");
        op.setMEP(SoapConstants.MEP_IN);
        getServiceRegistry().register(asyncService);
    }

    public void testServlet()
            throws Exception
    {
    	WebRequest getReq = new GetMethodWebRequest("http://localhost/services/Echo?wsdl"){
    		
				/* Work around bug 1212204 in httpUnit where as of 1.6
				 * there was not a way to support query strings with null values.
				 * @see com.meterware.httpunit.HeaderOnlyWebRequest#getQueryString()
				 */
				public String getQueryString() {
					return "WSDL";
				}
    	};
    	WebResponse response = newClient().getResponse(getReq);

        WebRequest req = new PostMethodWebRequest("http://localhost/services/Echo",
                                                  getClass().getResourceAsStream("/org/codehaus/xfire/echo11.xml"),
                                                  "text/xml");

        response = newClient().getResponse(req);<commit_msg>Fix formatting - spaces, not tabs.<commit_after>package org.codehaus.xfire.transport.http;

import org.codehaus.xfire.handler.HandlerPipeline;
import org.codehaus.xfire.service.AsyncService;
import org.codehaus.xfire.service.BadEcho;
import org.codehaus.xfire.service.Echo;
import org.codehaus.xfire.service.OperationInfo;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.soap.Soap11;
import org.codehaus.xfire.soap.SoapConstants;
import org.codehaus.xfire.test.AbstractServletTest;
import org.codehaus.xfire.transport.Transport;
import org.codehaus.xfire.wsdl.ResourceWSDL;
import org.codehaus.xfire.wsdl.WSDLWriter;
import org.codehaus.yom.Document;

import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.PostMethodWebRequest;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;

/**
 * XFireServletTest
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 */
public class XFireServletTest
        extends AbstractServletTest
{
    public void setUp()
            throws Exception
    {
        super.setUp();

        Service service = getServiceFactory().create(Echo.class,
                                                     Soap11.getInstance(),
                                                     SoapConstants.STYLE_MESSAGE,
                                                     SoapConstants.USE_LITERAL);
        WSDLWriter writer = new ResourceWSDL(getClass().getResource("/org/codehaus/xfire/echo11.wsdl"));
        service.setWSDLWriter(writer);

        service.setInPipeline(new HandlerPipeline());
        service.getInPipeline().addHandler(new MockSessionHandler());
        getServiceRegistry().register(service);

        Service faultService = getServiceFactory().create(BadEcho.class,
                                                          Soap11.getInstance(),
                                                          SoapConstants.STYLE_MESSAGE,
                                                          SoapConstants.USE_LITERAL);

        getServiceRegistry().register(faultService);
        
        // Asynchronous service
        Service asyncService = getServiceFactory().create(AsyncService.class,
                                                          Soap11.getInstance(),
                                                          SoapConstants.STYLE_MESSAGE,
                                                          SoapConstants.USE_LITERAL);
        OperationInfo op = asyncService.getServiceInfo().getOperation("echo");
        op.setMEP(SoapConstants.MEP_IN);
        getServiceRegistry().register(asyncService);
    }

    public void testServlet()
            throws Exception
    {
    	WebRequest getReq = new GetMethodWebRequest("http://localhost/services/Echo?wsdl")
        {

            /*
             * Work around bug 1212204 in httpUnit where as of 1.6 there was not
             * a way to support query strings with null values.
             * 
             * @see com.meterware.httpunit.HeaderOnlyWebRequest#getQueryString()
             */
            public String getQueryString()
            {
                return "WSDL";
            }
        };
        
    	WebResponse response = newClient().getResponse(getReq);

        WebRequest req = new PostMethodWebRequest("http://localhost/services/Echo",
                                                  getClass().getResourceAsStream("/org/codehaus/xfire/echo11.xml"),
                                                  "text/xml");

        response = newClient().getResponse(req);
{'fraction_non_alphanumeric': 0.09136259977194983, 'fraction_numerical': 0.0059863169897377425, 'mean_word_length': 1.8864664747017688, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 44, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5530024', 'n_tokens_mistral': 1787, 'n_tokens_neox': 1680, 'n_words': 275}