3. Unit Test

Spring Configuration

The unit test's main XML configuration was shown in the Client Spring Configuration section, but this is the configuration that it imported. It creates an embedded Jetty instance and registers the Spring Web Service MessageDispatcherServlet. The spring-ws-context.xml configuration is passed into the servlet.

jetty-context.xml
                    
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context 
                           http://www.springframework.org/schema/context/spring-context.xsd">

    <context:property-placeholder location="org/springbyexample/ws/client/ws.properties"/>
    
    <bean id="jettyServer"
          class="org.mortbay.jetty.Server"
          init-method="start" destroy-method="stop">
        <property name="threadPool">
            <bean id="ThreadPool"
                  class="org.mortbay.thread.concurrent.ThreadPool">
                <constructor-arg value="0" />
            </bean>
        </property>
        <property name="connectors">
            <list>
                <bean id="Connector"
                      class="org.mortbay.jetty.nio.SelectChannelConnector"
                      p:port="${ws.port}"
                      p:maxIdleTime="30000"
                      p:acceptors="2"
                      p:confidentialPort="8443" />
            </list>
        </property>
        <property name="handlers">
            <list>
                <bean class="org.mortbay.jetty.servlet.Context"
                      p:contextPath="/${ws.context.path}">
                    <property name="sessionHandler">
                        <bean class="org.mortbay.jetty.servlet.SessionHandler" />
                    </property>
                    <property name="servletHandler">
                        <bean class="org.mortbay.jetty.servlet.ServletHandler">
                            <property name="servlets">
                                <list>
                                    <bean class="org.mortbay.jetty.servlet.ServletHolder"
                                          p:name="spring-ws">
                                        <property name="servlet">
                                            <bean class="org.springframework.ws.transport.http.MessageDispatcherServlet" />
                                        </property>
                                        <property name="initParameters">
                                            <map>
                                                <entry key="contextConfigLocation" value="classpath:/spring-ws-context.xml" />
                                            </map>
                                        </property>
                                    </bean>
                                </list>
                            </property>
                            <property name="servletMappings">
                                <list>
                                    <bean class="org.mortbay.jetty.servlet.ServletMapping"
                                          p:servletName="spring-ws"
                                          p:pathSpec="/*" />
                                </list>
                            </property>
                        </bean>
                    </property>
                </bean>
                <bean class="org.mortbay.jetty.handler.DefaultHandler" />
                <bean class="org.mortbay.jetty.handler.RequestLogHandler" />
            </list>
        </property>
    </bean>

</beans>