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.module.launcher;
8   
9   import static org.junit.Assert.fail;
10  import static org.mockito.Mockito.doThrow;
11  import static org.mockito.Mockito.mock;
12  import static org.mockito.Mockito.times;
13  import static org.mockito.Mockito.verify;
14  import org.mule.module.launcher.application.Application;
15  import org.mule.tck.junit4.AbstractMuleTestCase;
16  
17  import org.junit.Test;
18  
19  public class DefaultMuleDeployerTestCase extends AbstractMuleTestCase
20  {
21  
22      @Test
23      public void disposesAppOnDeployFailure() throws Exception
24      {
25          DeploymentService deploymentService = new DeploymentService();
26          DefaultMuleDeployer deployer = new DefaultMuleDeployer(deploymentService);
27          Application app = mock(Application.class);
28          doThrow(new IllegalStateException()).when(app).init();
29  
30          try
31          {
32              deployer.deploy(app);
33              fail("Deployment is supposed to fail");
34          }
35          catch (DeploymentException expected)
36          {
37          }
38  
39          verify(app, times(1)).dispose();
40      }
41  }