1   /*
2    * $Id: EndpointConverterTestCase.java 7976 2007-08-21 14:26:13Z 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.test.config;
12  
13  import org.mule.config.converters.EndpointConverter;
14  import org.mule.tck.AbstractMuleTestCase;
15  import org.mule.tck.MuleTestUtils;
16  import org.mule.umo.endpoint.UMOEndpoint;
17  
18  import org.apache.commons.beanutils.Converter;
19  
20  public class EndpointConverterTestCase extends AbstractMuleTestCase
21  {
22  
23      public Converter getConverter()
24      {
25          return new EndpointConverter();
26      }
27  
28      public Object getValidConvertedType()
29      {
30          try
31          {
32              return MuleTestUtils.getTestEndpoint("test://Test", UMOEndpoint.ENDPOINT_TYPE_SENDER);
33          }
34          catch (Exception e)
35          {
36              e.printStackTrace();
37              fail(e.getMessage());
38              return null;
39          }
40      }
41  
42      public String getLookupMethod()
43      {
44          return "lookupEndpointIdentifier";
45      }
46  
47      public void testValidConversion()
48      {
49  
50          // MuleManager.setInstance((UMOManager)mockManager.proxy());
51          // mockManager.expectAndReturn("lookupEndpointIdentifier",
52          // C.args(C.isA(String.class), C.isA(String.class)),
53          // "test://test");
54          // mockManager.expectAndReturn("lookupEndpointIdentifier",
55          // C.args(C.isA(String.class), C.isA(String.class)),
56          // "test://test");
57          // mockManager.expectAndReturn("lookupEndpointIdentifier",
58          // C.args(C.isA(String.class), C.isA(String.class)),
59          // "test://test");
60          // mockManager.expectAndReturn("lookupEndpoint", "test://test", null);
61          // mockManager.expectAndReturn("lookupEndpoint", "test://test", null);
62          //
63          // Object obj = getValidConvertedType();
64          // mockManager.expectAndReturn("lookupEndpointIdentifier",
65          // C.args(C.isA(String.class), C.isA(String.class)),
66          // "test://test");
67          //
68          // Object result = getConverter().convert(obj.getClass(),
69          // "test://Test");
70          //
71          // assertNotNull(result);
72          // mockManager.verify();
73      }
74  
75      public void testInvalidConversion()
76      {
77          // MuleManager.setInstance((UMOManager)mockManager.proxy());
78          // Object obj = getValidConvertedType();
79          // mockManager.expectAndReturn("lookupEndpointIdentifier",
80          // C.args(C.isA(String.class), C.isA(String.class)),
81          // null);
82          //
83          // try
84          // {
85          // getConverter().convert(obj.getClass(), "TestBad");
86          // fail("should throw an exception if not valid");
87          // } catch (Exception e)
88          // {
89          // //exprected
90          // mockManager.verify();
91          // }
92      }
93  }