View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.management.agents;
8   
9   import org.mule.module.management.agent.RmiRegistryAgent;
10  import org.mule.tck.junit4.AbstractMuleTestCase;
11  
12  import org.junit.Test;
13  
14  import static org.junit.Assert.assertEquals;
15  
16  public class RmiRegistryAgentTestCase extends AbstractMuleTestCase
17  {
18  
19      @Test
20      public void testHostSetOnly() throws Exception
21      {
22          RmiRegistryAgent agent = new RmiRegistryAgent();
23          agent.setHost("www.example.com");
24          agent.initialise();
25          assertEquals("rmi://www.example.com:1099", agent.getServerUri());
26      }
27  
28      @Test
29      public void testPortSetOnly() throws Exception
30      {
31          RmiRegistryAgent agent = new RmiRegistryAgent();
32          agent.setPort("1095");
33          agent.initialise();
34          assertEquals("rmi://localhost:1095", agent.getServerUri());
35      }
36  
37      @Test
38      public void testHostAndPortSet() throws Exception
39      {
40          RmiRegistryAgent agent = new RmiRegistryAgent();
41          agent.setPort("1095");
42          agent.setHost("www.example.com");
43          agent.initialise();
44          assertEquals("rmi://www.example.com:1095", agent.getServerUri());
45      }
46    
47      @Test
48      public void testStart() throws Exception
49      {
50          RmiRegistryAgent agent = new RmiRegistryAgent();
51          agent.initialise();
52          agent.start();
53      }
54  
55  }