View Javadoc

1   /*
2    * $Id: JdbcEndpointTestCase.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.jdbc;
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  import static org.junit.Assert.assertNotNull;
21  
22  public class JdbcEndpointTestCase extends AbstractMuleContextTestCase
23  {
24  
25      @Test
26      public void testWithoutEndpointName() throws Exception
27      {
28          EndpointURI url = new MuleEndpointURI("jdbc:/?sql=SELECT * FROM TABLE", muleContext);
29          url.initialise();
30          assertEquals("jdbc", url.getScheme());
31          assertEquals("", url.getAddress());
32          assertNotNull(url.getParams());
33          assertEquals("SELECT * FROM TABLE", url.getParams().get("sql"));
34          assertEquals("jdbc:/?sql=SELECT%20*%20FROM%20TABLE", url.toString());
35      }
36  
37      @Test
38      public void testWithoutEndpointName2() throws Exception
39      {
40          EndpointURI url = new MuleEndpointURI("jdbc://?sql=SELECT * FROM TABLE", muleContext);
41          url.initialise();
42          assertEquals("jdbc", url.getScheme());
43          assertEquals("jdbc", url.getAddress());
44          assertNotNull(url.getParams());
45          assertEquals("SELECT * FROM TABLE", url.getParams().get("sql"));
46          assertEquals("jdbc://?sql=SELECT%20*%20FROM%20TABLE", url.toString());
47      }
48  
49      @Test
50      public void testWithEndpointName() throws Exception
51      {
52          EndpointURI url = new MuleEndpointURI("jdbc://writeTests?type=2", muleContext);
53          url.initialise();
54          assertEquals("jdbc", url.getScheme());
55          assertEquals("writeTests", url.getAddress());
56          assertNotNull(url.getParams());
57          assertEquals("2", url.getParams().get("type"));
58          assertEquals("jdbc://writeTests?type=2", url.toString());
59      }
60  
61  }