root/trunk/test/java/org/jcoderz/commons/taskdefs/SimpleTypeGeneratorTest.java

Revision 1011, 3.9 kB (checked in by amandel, 4 years ago)

Aligned svn keyword settings.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1/*
2 * $Id$
3 *
4 * Copyright 2006, The jCoderZ.org Project. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 *    * Redistributions of source code must retain the above copyright
11 *      notice, this list of conditions and the following disclaimer.
12 *    * Redistributions in binary form must reproduce the above
13 *      copyright notice, this list of conditions and the following
14 *      disclaimer in the documentation and/or other materials
15 *      provided with the distribution.
16 *    * Neither the name of the jCoderZ.org Project nor the names of
17 *      its contributors may be used to endorse or promote products
18 *      derived from this software without specific prior written
19 *      permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33package org.jcoderz.commons.taskdefs;
34
35import java.io.File;
36import org.apache.tools.ant.Location;
37import org.apache.tools.ant.Project;
38import org.jcoderz.commons.TestCase;
39
40
41/**
42 * JUnit test for the Ant task
43 * {@link org.jcoderz.commons.taskdefs.SimpleTypeGenerator}.
44 *
45 * @author Michael Griffel
46 */
47public 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      super.setUp();
58      mDestDir =  LogMessageGeneratorTest.mkdir("build/test");
59      final File in = new File(getBaseDir(), "test/xml/simple-types.xml");
60      final File out = new File(mDestDir, "simple-types.out");
61      final SimpleTypeGenerator g = new SimpleTypeGenerator();
62      g.setDestdir(mDestDir);
63      g.setFailonerror(false);
64      g.setForce(true);
65      g.setIn(in);
66      g.setOut(out);
67      g.setTaskName("test-message-generator");
68      g.setFailonerror(true);
69      g.setLocation(new Location("location"));
70
71      final Project project = new Project();
72      project.setBaseDir(getBaseDir());
73      project.setName("JUnit test");
74      g.setProject(project);
75      mGenerator = g;
76   }
77
78   /** Tests the Ant task. */
79   public void testExecute ()
80   {
81      mGenerator.execute();
82
83      final File testEnumerationFile = new File(mDestDir,
84            "org/jcoderz/commons/Color.java");
85      assertTrue("Generated Enumeration Java File "
86            + testEnumerationFile + " exists",
87            testEnumerationFile.exists());
88
89      final File testRestrictedStringFile = new File(mDestDir,
90            "org/jcoderz/commons/FooString.java");
91      assertTrue("Generated restricted string Java File "
92            + testRestrictedStringFile + " exists",
93            testRestrictedStringFile.exists());
94      final File testRegexStringFile = new File(mDestDir,
95         "org/jcoderz/commons/RegexString.java");
96      assertTrue("Generated regex string Java File "
97            + testRegexStringFile + " exists",
98            testRegexStringFile.exists());
99      final File testRestrictedLongFile = new File(mDestDir,
100      "org/jcoderz/commons/FooLong.java");
101      assertTrue("Generated restricted Long Java File "
102            + testRestrictedLongFile + " exists",
103            testRestrictedLongFile.exists());
104   }
105
106}
Note: See TracBrowser for help on using the browser.