1   /*
2    * Copyright 2008 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.ws.client.support.destination;
18  
19  import java.net.URI;
20  import java.net.URISyntaxException;
21  
22  import junit.framework.TestCase;
23  
24  import org.springframework.core.io.ClassPathResource;
25  import org.springframework.core.io.Resource;
26  
27  public class Wsdl11DestinationProviderTest extends TestCase {
28  
29      private Wsdl11DestinationProvider provider;
30  
31      protected void setUp() throws Exception {
32          provider = new Wsdl11DestinationProvider();
33      }
34  
35      public void testSimple() throws URISyntaxException {
36          Resource wsdl = new ClassPathResource("simple.wsdl", getClass());
37          provider.setWsdl(wsdl);
38  
39          URI result = provider.getDestination();
40  
41          assertEquals("Invalid URI returned", new URI("http://example.com/myService"), result);
42      }
43  
44      public void testComplex() throws URISyntaxException {
45          Resource wsdl = new ClassPathResource("complex.wsdl", getClass());
46          provider.setWsdl(wsdl);
47  
48          URI result = provider.getDestination();
49  
50          assertEquals("Invalid URI returned", new URI("http://example.com/soap11"), result);
51      }
52  
53      public void testCustomExpression() throws URISyntaxException {
54          provider.setLocationExpression("/wsdl:definitions/wsdl:service/wsdl:port/soap12:address/@location");
55          Resource wsdl = new ClassPathResource("complex.wsdl", getClass());
56          provider.setWsdl(wsdl);
57  
58          URI result = provider.getDestination();
59  
60          assertEquals("Invalid URI returned", new URI("http://example.com/soap12"), result);
61      }
62  }