1 26 27 package net.sourceforge.groboutils.uicapture.v1.javamaker; 28 29 import net.sourceforge.groboutils.autodoc.v1.AutoDoc; 30 import net.sourceforge.groboutils.junit.v1.iftc.*; 31 import junit.framework.Test; 32 import junit.framework.TestCase; 33 import junit.framework.TestSuite; 34 35 import java.io.*; 36 import net.sourceforge.groboutils.uicapture.v1.*; 37 38 39 40 47 public class JavaMakerUTest extends TestCase 48 { 49 52 private static final Class THIS_CLASS = JavaMakerUTest.class; 53 private static final AutoDoc DOC = new AutoDoc( THIS_CLASS ); 54 55 public JavaMakerUTest( String name ) 56 { 57 super( name ); 58 } 59 60 61 62 63 64 67 public void testInstantiation1() 68 throws IOException 69 { 70 try 71 { 72 new JavaMaker( (File)null, null, null ); 73 } 74 catch (IllegalArgumentException e) 75 { 76 } 78 } 79 80 81 public void testInstantiation2() 82 { 83 try 84 { 85 new JavaMaker( (Writer)null, null, null ); 86 } 87 catch (IllegalArgumentException e) 88 { 89 } 91 } 92 93 94 public void testInstantiation3() 95 { 96 JavaMaker jm = new JavaMaker( new StringWriter(), "a", "b" ); 97 } 98 99 100 public void testInstantiation4() 101 throws IOException 102 { 103 File f = File.createTempFile( "JavaMakerUTest", ".tmp" ); 104 JavaMaker jm = new JavaMaker( f, "a", "b" ); 105 } 106 107 108 109 110 public void testStartEnd1() 111 { 112 DOC.getIT().testsIssue( 618295 ); 113 StringWriter sw = new StringWriter(); 114 JavaMaker jm = new JavaMaker( sw, "a", "b" ); 115 116 jm.start(); 117 jm.end(); 118 119 assertTrue( 120 "Did not create Java package header correctly.", 121 sw.toString().indexOf( "package a;" ) >= 0 ); 122 assertTrue( 123 "Did not create Java class definition header correctly.", 124 sw.toString().indexOf( "public class b" ) >= 0 ); 125 } 126 127 128 129 130 133 134 public static Test suite() 135 { 136 InterfaceTestSuite suite = IScriptMakerUTestI.suite(); 137 138 suite.addTestSuite( THIS_CLASS ); 141 142 suite.addFactory( new CxFactory( "A" ) { 143 public Object createImplObject() { 144 return new JavaMaker( new StringWriter(), 145 "my.package", "MyClass" ); 146 } 147 } ); 148 149 return suite; 150 } 151 152 public static void main( String [] args ) 153 { 154 String [] name = { THIS_CLASS.getName() }; 155 156 159 junit.textui.TestRunner.main( name ); 160 } 161 162 166 protected void setUp() throws Exception 167 { 168 super.setUp(); 169 170 } 172 173 174 178 protected synchronized void tearDown() throws Exception 179 { 180 182 super.tearDown(); 183 } 184 } 185 186 | Popular Tags |