| 1 | | | |
| 2 | | | |
| 3 | | | |
| 4 | | | |
| 5 | | | |
| 6 | | | |
| 7 | | | |
| 8 | | | |
| 9 | | | |
| 10 | | | |
| 11 | | | |
| 12 | | | |
| 13 | | | |
| 14 | | | |
| 15 | | | |
| 16 | | | |
| 17 | | | |
| 18 | | | |
| 19 | | | |
| 20 | | | |
| 21 | | | |
| 22 | | | |
| 23 | | | |
| 24 | | | |
| 25 | | | |
| 26 | | | |
| 27 | | | |
| 28 | | | |
| 29 | | | |
| 30 | | | |
| 31 | | | |
| 32 | | | |
| 33 | | | package org.jcoderz.commons.taskdefs; |
| 34 | | | |
| 35 | | | import java.io.File; |
| 36 | | | import org.apache.tools.ant.Location; |
| 37 | | | import org.apache.tools.ant.Project; |
| 38 | | | import org.jcoderz.commons.TestCase; |
| 39 | | | |
| 40 | | | |
| 41 | | | |
| 42 | | | |
| 43 | | | {@link } |
| 44 | | | |
| 45 | | | @author |
| 46 | | | |
| 47 | 100 | | public class SimpleTypeGeneratorTest |
| 48 | | | extends TestCase |
| 49 | | | { |
| 50 | | | private SimpleTypeGenerator mGenerator; |
| 51 | | | private File mDestDir; |
| 52 | | | |
| 53 | | | {@inheritDoc} |
| 54 | | | protected void setUp () |
| 55 | | | throws Exception |
| 56 | | | { |
| 57 | 100 | | super.setUp(); |
| 58 | 100 | | mDestDir = LogMessageGeneratorTest.mkdir("build/test"); |
| 59 | 100 | | final File in = new File(getBaseDir(), "test/xml/simple-types.xml"); |
| 60 | 100 | | final File out = new File(mDestDir, "simple-types.out"); |
| 61 | 100 | | final SimpleTypeGenerator g = new SimpleTypeGenerator(); |
| 62 | 100 | | g.setDestdir(mDestDir); |
| 63 | 100 | | g.setFailonerror(false); |
| 64 | 100 | | g.setForce(true); |
| 65 | 100 | | g.setIn(in); |
| 66 | 100 | | g.setOut(out); |
| 67 | 100 | | g.setTaskName("test-message-generator"); |
| 68 | 100 | | g.setFailonerror(true); |
| 69 | 100 | | g.setLocation(new Location("location")); |
| 70 | | | |
| 71 | 100 | | final Project project = new Project(); |
| 72 | 100 | | project.setBaseDir(getBaseDir()); |
| 73 | 100 | | project.setName("JUnit test"); |
| 74 | 100 | | g.setProject(project); |
| 75 | 100 | | mGenerator = g; |
| 76 | 100 | | } |
| 77 | | | |
| 78 | | | |
| 79 | | | public void testExecute () |
| 80 | | | { |
| 81 | 100 | | mGenerator.execute(); |
| 82 | | | |
| 83 | 100 | | final File testEnumerationFile = new File(mDestDir, |
| 84 | | | "org/jcoderz/commons/Color.java"); |
| 85 | 100 | | assertTrue("Generated Enumeration Java File " |
| 86 | | (1) | + testEnumerationFile + " exists", |
| 87 | | | testEnumerationFile.exists()); |
| 88 | | | |
| 89 | 100 | | final File testRestrictedStringFile = new File(mDestDir, |
| 90 | | | "org/jcoderz/commons/FooString.java"); |
| 91 | 100 | | assertTrue("Generated restricted string Java File " |
| 92 | | | + testRestrictedStringFile + " exists", |
| 93 | | | testRestrictedStringFile.exists()); |
| 94 | 100 | | final File testRegexStringFile = new File(mDestDir, |
| 95 | | | "org/jcoderz/commons/RegexString.java"); |
| 96 | 100 | | assertTrue("Generated regex string Java File " |
| 97 | | | + testRegexStringFile + " exists", |
| 98 | | | testRegexStringFile.exists()); |
| 99 | 100 | | final File testRestrictedLongFile = new File(mDestDir, |
| 100 | | | "org/jcoderz/commons/FooLong.java"); |
| 101 | 100 | | assertTrue("Generated restricted Long Java File " |
| 102 | | | + testRestrictedLongFile + " exists", |
| 103 | | | testRestrictedLongFile.exists()); |
| 104 | 100 | | } |
| 105 | | | |
| 106 | | | } |