@@ -47,65 +47,70 @@ public class CompilerTest extends TestCase {
4747 }
4848 }
4949
50- public static void test_compiler () throws ClassNotFoundException {
51- // CompilerUtils.setDebug(true);
52- // added so the test passes in Maven.
53- CompilerUtils .addClassPath ("target/test-classes" );
50+ public void test_compiler () throws ClassNotFoundException {
51+ try {
52+ // CompilerUtils.setDebug(true);
53+ // added so the test passes in Maven.
54+ CompilerUtils .addClassPath ("target/test-classes" );
5455// ClassLoader loader = CompilerTest.class.getClassLoader();
5556// URLClassLoader urlClassLoader = new URLClassLoader(((URLClassLoader)loader).getURLs(), null);
5657// Class fooBarTee1 = urlClassLoader.loadClass("eg.FooBarTee");
5758
58- // this writes the file to disk only when debugging is enabled.
59- CachedCompiler cc = CompilerUtils .DEBUGGING ?
60- new CachedCompiler (new File (parent , "src/test/java" ), new File (parent , "target/compiled" )) :
61- CompilerUtils .CACHED_COMPILER ;
62-
63- String text = "generated test " + new Date ();
64- cc .loadFromJava (EG_FOO_BAR_TEE , "package eg;\n " +
65- '\n' +
66- "import eg.components.BarImpl;\n " +
67- "import eg.components.TeeImpl;\n " +
68- "import eg.components.Foo;\n " +
69- '\n' +
70- "public class FooBarTee{\n " +
71- " public final String name;\n " +
72- " public final TeeImpl tee;\n " +
73- " public final BarImpl bar;\n " +
74- " public final BarImpl copy;\n " +
75- " public final Foo foo;\n " +
76- '\n' +
77- " public FooBarTee(String name) {\n " +
78- " // when viewing this file, ensure it is synchronised with the copy on disk.\n " +
79- " System.out.println(\" " + text + "\" );\n " +
80- " this.name = name;\n " +
81- '\n' +
82- " tee = new TeeImpl(\" test\" );\n " +
83- '\n' +
84- " bar = new BarImpl(tee, 55);\n " +
85- '\n' +
86- " copy = new BarImpl(tee, 555);\n " +
87- '\n' +
88- " // you should see the current date here after synchronisation.\n " +
89- " foo = new Foo(bar, copy, \" " + text + "\" , 5);\n " +
90- " }\n " +
91- '\n' +
92- " public void start() {\n " +
93- " }\n " +
94- '\n' +
95- " public void stop() {\n " +
96- " }\n " +
97- '\n' +
98- " public void close() {\n " +
99- " stop();\n " +
100- '\n' +
101- " }\n " +
102- "}\n " );
103-
104- // add a debug break point here and step into this method.
105- FooBarTee fooBarTee = new FooBarTee ("test foo bar tee" );
106- Foo foo = fooBarTee .foo ;
107- assertNotNull (foo );
108- assertEquals (text , foo .s );
59+ // this writes the file to disk only when debugging is enabled.
60+ CachedCompiler cc = CompilerUtils .DEBUGGING ?
61+ new CachedCompiler (new File (parent , "src/test/java" ), new File (parent , "target/compiled" )) :
62+ CompilerUtils .CACHED_COMPILER ;
63+
64+ String text = "generated test " + new Date ();
65+ cc .loadFromJava (EG_FOO_BAR_TEE , "package eg;\n " +
66+ '\n' +
67+ "import eg.components.BarImpl;\n " +
68+ "import eg.components.TeeImpl;\n " +
69+ "import eg.components.Foo;\n " +
70+ '\n' +
71+ "public class FooBarTee{\n " +
72+ " public final String name;\n " +
73+ " public final TeeImpl tee;\n " +
74+ " public final BarImpl bar;\n " +
75+ " public final BarImpl copy;\n " +
76+ " public final Foo foo;\n " +
77+ '\n' +
78+ " public FooBarTee(String name) {\n " +
79+ " // when viewing this file, ensure it is synchronised with the copy on disk.\n " +
80+ " System.out.println(\" " + text + "\" );\n " +
81+ " this.name = name;\n " +
82+ '\n' +
83+ " tee = new TeeImpl(\" test\" );\n " +
84+ '\n' +
85+ " bar = new BarImpl(tee, 55);\n " +
86+ '\n' +
87+ " copy = new BarImpl(tee, 555);\n " +
88+ '\n' +
89+ " // you should see the current date here after synchronisation.\n " +
90+ " foo = new Foo(bar, copy, \" " + text + "\" , 5);\n " +
91+ " }\n " +
92+ '\n' +
93+ " public void start() {\n " +
94+ " }\n " +
95+ '\n' +
96+ " public void stop() {\n " +
97+ " }\n " +
98+ '\n' +
99+ " public void close() {\n " +
100+ " stop();\n " +
101+ '\n' +
102+ " }\n " +
103+ "}\n " );
104+
105+ // add a debug break point here and step into this method.
106+ FooBarTee fooBarTee = new FooBarTee ("test foo bar tee" );
107+ Foo foo = fooBarTee .foo ;
108+ assertNotNull (foo );
109+ assertEquals (text , foo .s );
110+ } catch (Throwable t ) {
111+ t .printStackTrace (System .out );
112+ fail (t .getMessage ());
113+ }
109114 }
110115
111116 public void test_fromFile ()
0 commit comments