1   /*
2    * $Id: HttpEndpointTestCase.java 7963 2007-08-21 08:53:15Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.providers.http;
12  
13  import org.mule.impl.endpoint.MuleEndpointURI;
14  import org.mule.tck.AbstractMuleTestCase;
15  import org.mule.umo.endpoint.UMOEndpointURI;
16  
17  public class HttpEndpointTestCase extends AbstractMuleTestCase
18  {
19      public void testHostPortOnlyUrl() throws Exception
20      {
21          UMOEndpointURI endpointUri = new MuleEndpointURI("http://localhost:8080");
22          assertEquals("http", endpointUri.getScheme());
23          assertEquals("http://localhost:8080", endpointUri.getAddress());
24          assertNull(endpointUri.getEndpointName());
25          assertEquals(8080, endpointUri.getPort());
26          assertEquals("localhost", endpointUri.getHost());
27          assertEquals("http://localhost:8080", endpointUri.getAddress());
28          assertEquals(0, endpointUri.getParams().size());
29      }
30  
31      public void testHostPortOnlyUrlAndUserInfo() throws Exception
32      {
33          UMOEndpointURI endpointUri = new MuleEndpointURI("http://admin:pwd@localhost:8080");
34          assertEquals("http", endpointUri.getScheme());
35          assertEquals("http://localhost:8080", endpointUri.getAddress());
36          assertNull(endpointUri.getEndpointName());
37          assertEquals(8080, endpointUri.getPort());
38          assertEquals("localhost", endpointUri.getHost());
39          assertEquals("http://localhost:8080", endpointUri.getAddress());
40          assertEquals(0, endpointUri.getParams().size());
41          assertEquals("admin:pwd", endpointUri.getUserInfo());
42          assertEquals("admin", endpointUri.getUsername());
43          assertEquals("pwd", endpointUri.getPassword());
44      }
45  
46      public void testHostPortAndPathUrl() throws Exception
47      {
48          UMOEndpointURI url = new MuleEndpointURI("http://localhost:8080/app/path");
49          assertEquals("http", url.getScheme());
50          assertEquals("http://localhost:8080/app/path", url.getAddress());
51          assertNull(url.getEndpointName());
52          assertEquals(8080, url.getPort());
53          assertEquals("localhost", url.getHost());
54          assertEquals("http://localhost:8080/app/path", url.getAddress());
55          assertEquals(url.getPath(), "/app/path");
56          assertEquals(0, url.getParams().size());
57      }
58  
59      public void testHostPortAndPathUrlAndUserInfo() throws Exception
60      {
61          UMOEndpointURI endpointUri = new MuleEndpointURI("http://admin:pwd@localhost:8080/app/path");
62          assertEquals("http", endpointUri.getScheme());
63          assertEquals("http://localhost:8080/app/path", endpointUri.getAddress());
64          assertNull(endpointUri.getEndpointName());
65          assertEquals(8080, endpointUri.getPort());
66          assertEquals("localhost", endpointUri.getHost());
67          assertEquals("http://localhost:8080/app/path", endpointUri.getAddress());
68          assertEquals(endpointUri.getPath(), "/app/path");
69          assertEquals(0, endpointUri.getParams().size());
70          assertEquals("admin:pwd", endpointUri.getUserInfo());
71          assertEquals("admin", endpointUri.getUsername());
72          assertEquals("pwd", endpointUri.getPassword());
73      }
74  }