1 20 package org.apache.cactus.integration.ant.container; 21 22 import java.io.File ; 23 import java.io.Reader ; 24 import java.io.StringReader ; 25 import java.util.Vector ; 26 27 import junit.framework.TestCase; 28 29 import org.apache.cactus.integration.ant.deployment.EarParser; 30 import org.apache.tools.ant.filters.util.ChainReaderHelper; 31 import org.apache.tools.ant.types.FilterChain; 32 33 38 public class TestAbstractContainer extends TestCase 39 { 40 43 private AbstractContainer container; 44 45 48 protected void setUp() 49 { 50 this.container = new AbstractContainer() 51 { 52 public String getName() 53 { 54 return "test container"; 55 } 56 57 public int getPort() 58 { 59 return 8080; 60 } 61 62 public void startUp() 63 { 64 } 65 66 public void shutDown() 67 { 68 } 69 }; 70 } 71 72 78 public void testCreateFilterChainOk() throws Exception 79 { 80 String testInputDirProperty = System.getProperty("testinput.dir"); 81 assertTrue("The system property 'testinput.dir' must be set", 82 testInputDirProperty != null); 83 File testInputDir = new File (testInputDirProperty); 84 assertTrue("The system property 'testinput.dir' must point to an " 85 + "existing directory", testInputDir.isDirectory()); 86 String fileName = 87 "org/apache/cactus/integration/ant/cactified.ear"; 88 File earFile = new File (testInputDir, fileName); 89 assertTrue("The test input " + fileName + " does not exist", 90 earFile.exists()); 91 92 this.container.setDeployableFile(EarParser.parse(earFile)); 93 94 String buffer = "@cactus.port@:@cactus.context@:"; 98 99 FilterChain chain = this.container.createFilterChain(); 100 101 ChainReaderHelper helper = new ChainReaderHelper(); 102 Vector chains = new Vector (); 103 chains.addElement(chain); 104 helper.setFilterChains(chains); 105 helper.setPrimaryReader(new StringReader (buffer)); 106 Reader reader = helper.getAssembledReader(); 107 assertEquals("8080:empty:", helper.readFully(reader)); 108 } 109 } 110 | Popular Tags |