1 20 package org.apache.cactus.integration.ant.deployment; 21 22 import org.apache.cactus.integration.ant.deployment.application.ApplicationXml; 23 import org.apache.cactus.integration.ant.deployment.application.EarArchive; 24 import org.apache.tools.ant.BuildException; 25 26 import com.mockobjects.dynamic.Mock; 27 28 import junit.framework.TestCase; 29 30 35 public final class TestEarParser extends TestCase 36 { 37 40 private Mock mockApplicationXml; 41 42 45 private ApplicationXml applicationXml; 46 47 50 private Mock mockArchive; 51 52 55 private EarArchive archive; 56 57 60 protected void setUp() 61 { 62 mockApplicationXml = new Mock(ApplicationXml.class); 63 applicationXml = (ApplicationXml) mockApplicationXml.proxy(); 64 65 mockArchive = new Mock(EarArchive.class); 66 archive = (EarArchive) mockArchive.proxy(); 67 mockArchive.expectAndReturn("getApplicationXml", applicationXml); 68 } 69 70 78 public void testParseTestContextWhenWebUriDefined() throws Exception 79 { 80 mockApplicationXml.expectAndReturn("getWebModuleContextRoot", 81 "test.war", "/testcontext"); 82 83 String context = EarParser.parseTestContext(archive, "test.war"); 84 assertEquals("testcontext", context); 85 } 86 87 93 public void testParseTestContextWhenNoWebUriInApplicationXml() 94 throws Exception 95 { 96 mockApplicationXml.expectAndReturn("getWebModuleContextRoot", 97 "test.war", null); 98 99 try 100 { 101 EarParser.parseTestContext(archive, "test.war"); 102 } 103 catch (BuildException expected) 104 { 105 assertTrue(true); 106 } 107 } 108 } 109 | Popular Tags |