1 12 13 17 package com.openedit; 18 19 import java.io.File ; 20 21 import junit.framework.TestCase; 22 23 import com.openedit.modules.BaseModule; 24 import com.openedit.page.Page; 25 26 27 32 public class BaseTestCase extends TestCase 33 { 34 protected TestFixture fieldFixture; 35 36 39 public BaseTestCase() 40 { 41 super(""); } 43 48 public BaseTestCase(String arg0) 49 { 50 super(arg0); 51 } 52 53 public Page getPage( String inPath ) throws OpenEditException 54 { 55 return getFixture().getPageManager().getPage( inPath ); 56 } 57 62 public void setFixture(TestFixture inFixture) 63 { 64 fieldFixture = inFixture; 65 } 66 67 72 public TestFixture getFixture() 73 { 74 if (fieldFixture == null) 75 { 76 fieldFixture = new TestFixture(); 77 } 78 return fieldFixture; 79 } 80 protected void tearDown() throws Exception 81 { 82 super.tearDown(); 83 if ( fieldFixture != null) 84 { 85 getFixture().getWebServer().getOpenEditEngine().shutdown(); 86 } 87 } 88 89 protected void deleteDirectory(File directory) 90 { 91 File [] containedFiles = directory.listFiles(); 92 if (containedFiles != null) 93 { 94 for (int n = 0; n < containedFiles.length; n++) 95 { 96 File file = containedFiles[ n ]; 97 if (file.isDirectory()) 98 { 99 deleteDirectory( file ); 100 } 101 else 102 { 103 file.delete(); 104 } 105 } 106 } 107 directory.delete(); 108 } 109 110 protected File getRoot() 111 { 112 return getFixture().getWebServer().getRootDirectory(); 113 } 114 115 protected BaseModule getModule( String inKey ) 116 { 117 return getFixture().getModuleManager().getModule( inKey ); 118 } 119 120 protected Object getBean( String inKey ) 121 { 122 return getFixture().getModuleManager().getBean( inKey ); 123 } 124 } 125 | Popular Tags |