Project Report: fawkez

Packagesummary org.jcoderz.commons.taskdefs

org.jcoderz.commons.taskdefs.SimpleTypeGeneratorTest

LineHitsNoteSource
1  /*
2   * $Id: SimpleTypeGeneratorTest.java 1011 2008-06-16 17:57:36Z amandel $
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   */
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   * JUnit test for the Ant task
43   * {@link org.jcoderz.commons.taskdefs.SimpleTypeGenerator}.
44   *
45   * @author Michael Griffel
46   */
47100 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     {
57100       super.setUp();
58100       mDestDir = LogMessageGeneratorTest.mkdir("build/test");
59100       final File in = new File(getBaseDir(), "test/xml/simple-types.xml");
60100       final File out = new File(mDestDir, "simple-types.out");
61100       final SimpleTypeGenerator g = new SimpleTypeGenerator();
62100       g.setDestdir(mDestDir);
63100       g.setFailonerror(false);
64100       g.setForce(true);
65100       g.setIn(in);
66100       g.setOut(out);
67100       g.setTaskName("test-message-generator");
68100       g.setFailonerror(true);
69100       g.setLocation(new Location("location"));
70  
71100       final Project project = new Project();
72100       project.setBaseDir(getBaseDir());
73100       project.setName("JUnit test");
74100       g.setProject(project);
75100       mGenerator = g;
76100    }
77  
78     /** Tests the Ant task. */
79     public void testExecute ()
80     {
81100       mGenerator.execute();
82  
83100       final File testEnumerationFile = new File(mDestDir,
84              "org/jcoderz/commons/Color.java");
85100       assertTrue("Generated Enumeration Java File "
86 (1)            + testEnumerationFile + " exists",
87              testEnumerationFile.exists());
88  
89100       final File testRestrictedStringFile = new File(mDestDir,
90              "org/jcoderz/commons/FooString.java");
91100       assertTrue("Generated restricted string Java File "
92              + testRestrictedStringFile + " exists",
93              testRestrictedStringFile.exists());
94100       final File testRegexStringFile = new File(mDestDir,
95           "org/jcoderz/commons/RegexString.java");
96100       assertTrue("Generated regex string Java File "
97              + testRegexStringFile + " exists",
98              testRegexStringFile.exists());
99100       final File testRestrictedLongFile = new File(mDestDir,
100        "org/jcoderz/commons/FooLong.java");
101100       assertTrue("Generated restricted Long Java File "
102              + testRestrictedLongFile + " exists",
103              testRestrictedLongFile.exists());
104100    }
105  
106  }

Findings in this File

i (2) SimpleTypeGeneratorTest.mGenerator not initialized in constructor (test code)
f (3) A method/constructor shouldn't explicitly throw java.lang.Exception Not required for testcode.
i (1) 86 : 37 The String literal " exists" appears 4 times in this file; the first occurrence is on line 86 (test code)