diff --git a/parent/pom.xml b/parent/pom.xml index c884fc1c..51bfe7de 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 org.springframework.ws spring-ws-parent @@ -174,6 +175,11 @@ spring-ws-security ${project.version} + + org.springframework.ws + spring-ws-test + ${project.version} + org.springframework @@ -536,6 +542,11 @@ + + org.springframework.security + spring-security-config + 3.0.2.RELEASE + net.sf.ehcache @@ -677,7 +688,7 @@ xmlunit xmlunit - 1.1 + 1.3 test diff --git a/samples/airline/client/spring-ws/pom.xml b/samples/airline/client/spring-ws/pom.xml index 592c8e9f..08faeabf 100644 --- a/samples/airline/client/spring-ws/pom.xml +++ b/samples/airline/client/spring-ws/pom.xml @@ -1,5 +1,6 @@ - + airline-client org.springframework.ws @@ -56,7 +57,7 @@ - + org.apache.xmlbeans @@ -70,6 +71,11 @@ org.springframework.ws spring-xml + + org.springframework.ws + spring-ws-test + test + org.springframework.ws spring-ws-security @@ -82,5 +88,20 @@ org.apache.ws.security wss4j + + org.springframework + spring-test + + + org.springframework.security + spring-security-core + test + + + log4j + log4j + compile + + diff --git a/samples/airline/client/spring-ws/readme.txt b/samples/airline/client/spring-ws/readme.txt deleted file mode 100644 index bdc6c832..00000000 --- a/samples/airline/client/spring-ws/readme.txt +++ /dev/null @@ -1,11 +0,0 @@ -SPRING WEB SERVICES - -This directory contains a Java client for the Airline Web Service that uses -the Spring-WS WebServiceTemplate in combination with XMLBeans marshalling. -The client can be run from the provided ant file, by calling "ant run". - -SAJA Client Sample table of contents ---------------------------------------------------- -* src - The source files for the client -* build.xml - Ant build file with a 'build' and a 'run' target - diff --git a/samples/airline/client/spring-ws/src/main/java/org/springframework/ws/samples/airline/client/sws/GetFlights.java b/samples/airline/client/spring-ws/src/main/java/org/springframework/ws/samples/airline/client/sws/GetFlights.java index c67f0937..72afccae 100644 --- a/samples/airline/client/spring-ws/src/main/java/org/springframework/ws/samples/airline/client/sws/GetFlights.java +++ b/samples/airline/client/spring-ws/src/main/java/org/springframework/ws/samples/airline/client/sws/GetFlights.java @@ -1,5 +1,5 @@ /* - * Copyright 2007 the original author or authors. + * Copyright 2005-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -104,7 +104,7 @@ public class GetFlights extends WebServiceGatewaySupport { public static void main(String[] args) { ApplicationContext applicationContext = new ClassPathXmlApplicationContext( "org/springframework/ws/samples/airline/client/sws/applicationContext.xml"); - GetFlights getFlights = (GetFlights) applicationContext.getBean("getFlights", GetFlights.class); + GetFlights getFlights = applicationContext.getBean("getFlights", GetFlights.class); getFlights.getFlights(); } diff --git a/samples/airline/client/spring-ws/src/main/resources/org/springframework/ws/samples/airline/client/sws/applicationContext.xml b/samples/airline/client/spring-ws/src/main/resources/org/springframework/ws/samples/airline/client/sws/applicationContext.xml index 2013f876..19c2ed62 100644 --- a/samples/airline/client/spring-ws/src/main/resources/org/springframework/ws/samples/airline/client/sws/applicationContext.xml +++ b/samples/airline/client/spring-ws/src/main/resources/org/springframework/ws/samples/airline/client/sws/applicationContext.xml @@ -2,15 +2,11 @@ - + - - - - - - + + diff --git a/samples/airline/client/spring-ws/src/test/java/org/springframework/ws/samples/airline/client/sws/GetFlightsTest.java b/samples/airline/client/spring-ws/src/test/java/org/springframework/ws/samples/airline/client/sws/GetFlightsTest.java new file mode 100644 index 00000000..c305de5e --- /dev/null +++ b/samples/airline/client/spring-ws/src/test/java/org/springframework/ws/samples/airline/client/sws/GetFlightsTest.java @@ -0,0 +1,93 @@ +/* + * Copyright 2005-2010 the original author or authors. + * + * Licensed 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.springframework.ws.samples.airline.client.sws; + +import java.util.Collections; +import java.util.Map; +import javax.xml.transform.Source; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.xml.transform.StringSource; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.springframework.ws.mock.client.WebServiceMock.*; + +/** + * This test illustrates the use of the client-side testing API, introduced in Spring-WS 2.0. + * + * @author Arjen Poutsma + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration("applicationContext.xml") +public class GetFlightsTest { + + @Autowired + GetFlights getFlights; + + private static final String MESSAGES_NS = + "http://www.springframework.org/spring-ws/samples/airline/schemas/messages"; + + private static final String TYPES_NS = "http://www.springframework.org/spring-ws/samples/airline/schemas/types"; + + @Before + public void setUpMocks() throws Exception { + mockWebServiceTemplate(getFlights.getWebServiceTemplate()); + } + + @Test + public void getFlights() throws Exception { + Source getFlightsRequest = new StringSource( + "" + "AMS" + "VCE" + + "2006-01-31" + ""); + + String flightInfo = + "KL1653" + "2006-01-31T10:05:00.000+01:00" + + "AMSSchiphol AirportAmsterdam" + + "2006-01-31T12:25:00.000+01:00" + + "VCEMarco Polo AirportVenice" + + "economy"; + + Source getFlightsResponse = new StringSource( + "" + "" + + flightInfo + "" + ""); + + expect(payload(getFlightsRequest)).andRespond(withPayload(getFlightsResponse)); + + Source bookFlightResponse = new StringSource( + "" + "4" + + "2010-07-28" + + "JohnDoe" + + "" + flightInfo + "" + ""); + + Map namespaces = Collections.singletonMap("m", MESSAGES_NS); + + expect(xpath("/m:BookFlightRequest/m:flightNumber", namespaces).exists()) + .andExpect(xpath("/m:BookFlightRequest/m:departureTime", namespaces).exists()) + .andExpect(xpath("/m:BookFlightRequest/m:passengers", namespaces).exists()) + .andRespond(withPayload(bookFlightResponse)); + + getFlights.getFlights(); + + } + + +} diff --git a/samples/airline/server/pom.xml b/samples/airline/server/pom.xml index 7b0dbfce..b89d6586 100644 --- a/samples/airline/server/pom.xml +++ b/samples/airline/server/pom.xml @@ -1,4 +1,5 @@ - + airline org.springframework.ws @@ -73,12 +74,12 @@ xjc - - - src/main/webapp/ - org.springframework.ws.samples.airline.schema - - + + + src/main/webapp/ + org.springframework.ws.samples.airline.schema + + org.codehaus.mojo openjpa-maven-plugin @@ -246,6 +247,10 @@ org.springframework.security spring-security-core + + org.springframework.security + spring-security-config + org.apache.activemq activemq-core @@ -265,7 +270,6 @@ org.springframework.security spring-security-core - 3.0.2.RELEASE tests test diff --git a/samples/airline/server/src/main/resources/org/springframework/ws/samples/airline/security/applicationContext-security.xml b/samples/airline/server/src/main/resources/org/springframework/ws/samples/airline/security/applicationContext-security.xml index 580a0825..8a764974 100644 --- a/samples/airline/server/src/main/resources/org/springframework/ws/samples/airline/security/applicationContext-security.xml +++ b/samples/airline/server/src/main/resources/org/springframework/ws/samples/airline/security/applicationContext-security.xml @@ -2,16 +2,18 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd"> - This application context contains the WS-Security and Sprign Security beans. + This application context contains the WS-Security and Spring Security beans. - + + + diff --git a/samples/airline/server/src/main/webapp/WEB-INF/mvc-servlet.xml b/samples/airline/server/src/main/webapp/WEB-INF/mvc-servlet.xml index f832c7f6..44e82e0d 100644 --- a/samples/airline/server/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/samples/airline/server/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -2,18 +2,17 @@ This web application context contains a simple Spring Web MVC web application that shows flights - + -