View Javadoc

1   /*
2    * $Id: UsernameTokenTestCase.java 22471 2011-07-20 10:36:17Z claude.mamo $
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  
11  package org.mule.module.cxf.wssec;
12  
13  import static org.junit.Assert.assertTrue;
14  
15  import org.mule.tck.AbstractServiceAndFlowTestCase;
16  import org.mule.tck.junit4.rule.DynamicPort;
17  import org.mule.util.concurrent.Latch;
18  
19  import java.util.Arrays;
20  import java.util.Collection;
21  import java.util.concurrent.TimeUnit;
22  
23  import org.junit.Rule;
24  import org.junit.Test;
25  import org.junit.runners.Parameterized.Parameters;
26  
27  public class UsernameTokenTestCase extends AbstractServiceAndFlowTestCase
28  {
29      private Latch greetLatch;
30  
31      @Rule
32      public DynamicPort dynamicPort = new DynamicPort("port1");
33      
34      public UsernameTokenTestCase(ConfigVariant variant, String configResources)
35      {
36          super(variant, configResources);
37      }
38  
39      @Parameters
40      public static Collection<Object[]> parameters()
41      {
42          return Arrays.asList(new Object[][]{
43              {ConfigVariant.SERVICE, "org/mule/module/cxf/wssec/cxf-secure-service-service.xml, org/mule/module/cxf/wssec/username-token-conf.xml"},
44              {ConfigVariant.FLOW, "org/mule/module/cxf/wssec/cxf-secure-service-flow.xml, org/mule/module/cxf/wssec/username-token-conf.xml"}
45          });
46      }      
47          
48      @Override
49      protected void doSetUp() throws Exception
50      {
51          ClientPasswordCallback.setPassword("secret");        
52          super.doSetUp();
53          
54          greetLatch = getGreeter().getLatch();
55      }
56  
57      @Test
58      public void testUsernameToken() throws Exception
59      {
60          assertTrue(greetLatch.await(60, TimeUnit.SECONDS));
61      }
62  
63      private GreeterWithLatch getGreeter() throws Exception
64      {
65          Object instance = getComponent("greeterService");
66          return (GreeterWithLatch) instance;
67      }
68  
69  }
70  
71