View Javadoc

1   /*
2    * $Id: JettyEndpointTestCase.java 22387 2011-07-12 03:53:36Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.transport.servlet.jetty;
12  
13  import org.mule.api.endpoint.EndpointURI;
14  import org.mule.endpoint.MuleEndpointURI;
15  import org.mule.tck.junit4.AbstractMuleContextTestCase;
16  
17  import org.junit.Test;
18  
19  import static org.junit.Assert.assertEquals;
20  
21  public class JettyEndpointTestCase extends AbstractMuleContextTestCase
22  {
23      @Test
24      public void testHostPortOnlyUrl() throws Exception
25      {
26          EndpointURI endpointUri = new MuleEndpointURI("jetty:http://localhost:8080", muleContext);
27          endpointUri.initialise();
28          assertEquals("http", endpointUri.getScheme());
29          assertEquals("http://localhost:8080", endpointUri.getAddress());
30          assertEquals(8080, endpointUri.getPort());
31          assertEquals("localhost", endpointUri.getHost());
32          assertEquals("http://localhost:8080", endpointUri.toString());
33          assertEquals(0, endpointUri.getParams().size());
34          assertEquals("jetty", endpointUri.getSchemeMetaInfo());
35      }
36  
37      @Test
38      public void testHostPortOnlyUrlAndUserInfo() throws Exception
39      {
40          EndpointURI endpointUri = new MuleEndpointURI("jetty:http://admin:pwd@localhost:8080", muleContext);
41          endpointUri.initialise();
42          assertEquals("http", endpointUri.getScheme());
43          assertEquals("http://localhost:8080", endpointUri.getAddress());
44          assertEquals(8080, endpointUri.getPort());
45          assertEquals("localhost", endpointUri.getHost());
46          assertEquals("http://localhost:8080", endpointUri.getAddress());
47          assertEquals(0, endpointUri.getParams().size());
48          assertEquals("admin:pwd", endpointUri.getUserInfo());
49          assertEquals("admin", endpointUri.getUser());
50          assertEquals("pwd", endpointUri.getPassword());
51          assertEquals("jetty", endpointUri.getSchemeMetaInfo());
52      }
53  
54      @Test
55      public void testHostPortAndPathUrl() throws Exception
56      {
57          EndpointURI endpointUri = new MuleEndpointURI("jetty:http://localhost:8080/app/path", muleContext);
58          endpointUri.initialise();
59          assertEquals("http", endpointUri.getScheme());
60          assertEquals("http://localhost:8080/app/path", endpointUri.getAddress());
61          assertEquals(8080, endpointUri.getPort());
62          assertEquals("localhost", endpointUri.getHost());
63          assertEquals("http://localhost:8080/app/path", endpointUri.getAddress());
64          assertEquals(endpointUri.getPath(), "/app/path");
65          assertEquals(0, endpointUri.getParams().size());
66          assertEquals("jetty", endpointUri.getSchemeMetaInfo());
67      }
68  
69      @Test
70      public void testHostPortAndPathUrlAndUserInfo() throws Exception
71      {
72          EndpointURI endpointUri = new MuleEndpointURI("jetty:http://admin:pwd@localhost:8080/app/path", muleContext);
73          endpointUri.initialise();
74          assertEquals("http", endpointUri.getScheme());
75          assertEquals("http://localhost:8080/app/path", endpointUri.getAddress());
76          assertEquals(8080, endpointUri.getPort());
77          assertEquals("localhost", endpointUri.getHost());
78          assertEquals("http://localhost:8080/app/path", endpointUri.getAddress());
79          assertEquals(endpointUri.getPath(), "/app/path");
80          assertEquals(0, endpointUri.getParams().size());
81          assertEquals("admin:pwd", endpointUri.getUserInfo());
82          assertEquals("admin", endpointUri.getUser());
83          assertEquals("pwd", endpointUri.getPassword());
84          assertEquals("jetty", endpointUri.getSchemeMetaInfo());
85      }
86  
87  }