|
What this is
This file is included in the DevDaily.com
"Java Source Code
Warehouse" project. The intent of this project is to help you "Learn
Java by Example" TM.
Other links
The source code
/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is NetBeans. The Initial Developer of the Original
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
* Microsystems, Inc. All Rights Reserved.
*/
/*
* SourceGenerator.java
*
* Created on June 26, 2000, 9:29 AM
*/
package org.netbeans.test.java.generating.SourceGenerator;
/** Java Module General API Test: SourceGenerator
*
What it tests:
* This test is more complex and checks adding Elements (especially order of adding).
* Test is focused on checking of correctness of generated code.
*
How it works:
* New class is created using DataObject.createFromTemplate().
* Then all possible Elements are added.
* These actions cause generating of .java code. This code is compared with supposed one.
*
Output:
* Generated Java code.
*
Possible reasons of failure:
*
Elements are added into bad positions or even not at all
* See .diff file to get which ones
*
Bad indentation
* This is probably not a bug of Java Module. (Editor Bug)
* In .diff file could be some whitespaces.
*
Exception occured:
* See .out file for StackTrace
*
*
* @author Jan Becicka
*/
public class SourceGenerator extends org.netbeans.test.java.XRunner {
public static void main(java.lang.String[] args) {
junit.textui.TestRunner.run(suite());
}
public SourceGenerator() {
super("");
}
public SourceGenerator(java.lang.String testName) {
super(testName);
}
public static org.netbeans.junit.NbTest suite() {
return new org.netbeans.junit.NbTestSuite(SourceGenerator.class);
}
/** "body" of this TestCase
* @param o SourceElement - target for generating
* @param log log is used for logging StackTraces
* @throws Exception
* @return true if test passed
* false if failed
*/
public boolean go(Object o, java.io.PrintWriter log) throws Exception {
org.openide.src.ClassElement clazz = ((org.openide.src.SourceElement) o).getClasses()[0];
org.netbeans.test.java.Common.simpleJavaSourceEtalonGenerator(clazz);
return true;
}
/**
*/
protected void setUp() {
super.setUp();
name = "JavaTestSourceSourceGenerator";
packageName = "org.netbeans.test.java.testsources";
}
}
|