View Javadoc

1   /*
2    * $Id: ReturnAnnotationTestCase.java 20072 2010-11-04 18:12:14Z mike.schilling $
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.ibeans.annotations;
11  
12  import org.mule.api.annotations.ContainsTransformerMethods;
13  import org.mule.api.annotations.Transformer;
14  
15  import java.net.MalformedURLException;
16  import java.net.URL;
17  
18  import org.ibeans.annotation.IntegrationBean;
19  import org.junit.Test;
20  
21  @ContainsTransformerMethods
22  public class ReturnAnnotationTestCase extends AbstractIBeansTestCase
23  {
24      @SuppressWarnings("unused")
25      @IntegrationBean
26      private SearchIBean search;
27  
28      @Test
29      public void testReturnCallURL() throws Exception
30      {
31          if (isOffline(getClass().getName() + ".testReturnCallURL"))
32          {
33              return;
34          }
35  
36          String result = search.searchGoogleAndReturnURLString("foo");
37          assertNotNull(result);
38          assertEquals("http://www.google.com/search?q=foo", result);
39  
40          URL url = search.searchGoogleAndReturnURL("foo");
41          assertNotNull(url);
42          assertEquals("http://www.google.com/search?q=foo", url.toString());
43      }
44  
45      @Transformer
46      public URL stringToURL(String urlString) throws MalformedURLException
47      {
48          return new URL(urlString);
49      }
50  
51  }