View Javadoc

1   /*
2    * $Id: AtomEndpointTestCase.java 20321 2010-11-24 15:21:24Z dfeist $
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  package org.mule.module.atom.endpoint;
11  
12  import org.mule.api.endpoint.EndpointFactory;
13  import org.mule.api.endpoint.InboundEndpoint;
14  import org.mule.api.registry.ServiceException;
15  import org.mule.tck.AbstractMuleTestCase;
16  import org.mule.transport.file.FileConnector;
17  import org.mule.transport.http.HttpPollingConnector;
18  
19  /**
20   * Simple test that endpoints get parsed correctly
21   */
22  public class AtomEndpointTestCase extends AbstractMuleTestCase
23  {
24      public void testHttpInboundEndpointCreation() throws Exception
25      {
26          String uri = "atom:http://blog.com/atom";
27          EndpointFactory factory = muleContext.getRegistry().lookupEndpointFactory();
28          InboundEndpoint in = factory.getEndpointBuilder(uri).buildInboundEndpoint();
29          assertNotNull(in);
30          assertEquals("atom:http", in.getEndpointURI().getFullScheme());
31          assertEquals("http", in.getProtocol());
32          assertTrue(in.getConnector() instanceof HttpPollingConnector);
33          assertTrue(in instanceof AtomInboundEndpoint);
34      }
35  
36      public void testHttpOutboundEndpointCreation() throws Exception
37      {
38          String uri = "atom:http://blog.com/atom";
39          EndpointFactory factory = muleContext.getRegistry().lookupEndpointFactory();
40          try
41          {
42              factory.getEndpointBuilder(uri).buildOutboundEndpoint();
43              fail("ATOM outbound endpoints are not supported");
44          }
45          catch (UnsupportedOperationException e)
46          {
47              //exprected
48          }
49      }
50  
51      public void testFileInboundEndpointCreation() throws Exception
52      {
53          String uri = "atom:file://./src/foo";
54          EndpointFactory factory = muleContext.getRegistry().lookupEndpointFactory();
55          InboundEndpoint in = factory.getEndpointBuilder(uri).buildInboundEndpoint();
56          assertNotNull(in);
57          assertEquals("atom:file", in.getEndpointURI().getFullScheme());
58          assertEquals("file", in.getProtocol());
59          assertTrue(in.getConnector() instanceof FileConnector);
60          assertTrue(in instanceof AtomInboundEndpoint);
61      }
62  
63      public void testFileOutboundEndpointCreation() throws Exception
64      {
65          String uri = "atom:file://./src/foo";
66          EndpointFactory factory = muleContext.getRegistry().lookupEndpointFactory();
67          try
68          {
69              factory.getEndpointBuilder(uri).buildOutboundEndpoint();
70              fail("ATOM outbound endpoints are not supported");
71          }
72          catch (UnsupportedOperationException e)
73          {
74              //exprected
75          }
76      }
77  
78      public void testXXInboundEndpointCreation() throws Exception
79      {
80          String uri = "atom:xxx://./src/foo";
81          EndpointFactory factory = muleContext.getRegistry().lookupEndpointFactory();
82          try
83          {
84              factory.getEndpointBuilder(uri).buildInboundEndpoint();
85              fail("xxx is not a valid transport");
86          }
87          catch (ServiceException e)
88          {
89              //expected
90          }
91      }
92  }