View Javadoc

1   /*
2    * $Id: OptionalParamsTestCase.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 java.net.UnknownHostException;
13  
14  import org.ibeans.annotation.IntegrationBean;
15  import org.junit.Ignore;
16  import org.junit.Test;
17  
18  import static org.junit.Assert.assertEquals;
19  
20  public class OptionalParamsTestCase extends AbstractIBeansTestCase
21  {
22      @IntegrationBean
23      private TestUriIBean test;
24  
25      @Test
26      public void testOptionalParams() throws Exception
27      {
28          String result = test.doSomethingOptional("x", "y");
29          assertEquals("http://doesnotexist.bom?param1=x&param2=y", result);
30  
31          result = test.doSomethingOptional("x", null);
32          assertEquals("http://doesnotexist.bom?param1=x", result);
33  
34          result = test.doSomethingOptional(null, "y");
35          assertEquals("http://doesnotexist.bom?param2=y", result);
36      }
37  
38      @Test(expected = IllegalArgumentException.class)
39      @Ignore("TODO: test is wrong because uses the expected attribute but that exception is never thrown. Running" +
40              " the test you get java.lang.reflect.UndeclaredThrowableException instead of the IllegalArgumentException")
41      public void paramNull() throws UnknownHostException
42      {
43          test.doSomethingElse("x", null);
44      }
45  }