View Javadoc

1   /*
2    * $Id: ReturnAnnotationTestCase.java 22409 2011-07-14 05:14:27Z 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  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  import static org.junit.Assert.assertEquals;
22  import static org.junit.Assert.assertNotNull;
23  
24  @ContainsTransformerMethods
25  public class ReturnAnnotationTestCase extends AbstractIBeansTestCase
26  {
27      @IntegrationBean
28      private SearchIBean search;
29  
30      @Test
31      public void testReturnCallURL() throws Exception
32      {
33          if (isOffline(getClass().getName() + ".testReturnCallURL"))
34          {
35              return;
36          }
37  
38          String result = search.searchGoogleAndReturnURLString("foo");
39          assertNotNull(result);
40          assertEquals("http://www.google.com/search?q=foo", result);
41  
42          URL url = search.searchGoogleAndReturnURL("foo");
43          assertNotNull(url);
44          assertEquals("http://www.google.com/search?q=foo", url.toString());
45      }
46  
47      @Transformer
48      public URL stringToURL(String urlString) throws MalformedURLException
49      {
50          return new URL(urlString);
51      }
52  }