1
2
3
4
5
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 }