001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.junit;
043:
044: import java.util.Map;
045: import org.netbeans.modules.junit.plugin.JUnitPlugin;
046: import org.netbeans.modules.junit.plugin.JUnitPlugin.CreateTestParam;
047: import org.netbeans.modules.junit.plugin.JUnitPlugin.Location;
048: import org.openide.filesystems.FileObject;
049:
050: /**
051: *
052: * @author Marian Petras
053: */
054: public abstract class JUnitPluginTrampoline {
055:
056: /** the trampoline singleton, defined by {@link JUnitPlugin} */
057: public static JUnitPluginTrampoline DEFAULT;
058:
059: /**
060: * Provokes initialization of class JUnitPlugin.
061: */
062: {
063: Class c = JUnitPlugin.class;
064: try {
065: Class.forName(c.getName(), true, c.getClassLoader());
066: } catch (ClassNotFoundException ex) {
067: ex.printStackTrace();
068: }
069: }
070:
071: /** Used by {@link JUnitPlugin}. */
072: public JUnitPluginTrampoline() {
073: }
074:
075: /**
076: */
077: public abstract boolean createTestActionCalled(JUnitPlugin plugin,
078: FileObject[] filesToTest);
079:
080: /**
081: * Returns a specification of a Java element or file representing test
082: * for the given source Java element or file.
083: *
084: * @param sourceLocation specification of a Java element or file
085: * @return specification of a corresponding test Java element or file,
086: * or {@code null} if no corresponding test Java file is available
087: */
088: public abstract Location getTestLocation(JUnitPlugin plugin,
089: Location sourceLocation);
090:
091: /**
092: * Returns a specification of a Java element or file that is tested
093: * by the given test Java element or test file.
094: *
095: * @param testLocation specification of a Java element or file
096: * @return specification of a Java element or file that is tested
097: * by the given Java element or file.
098: */
099: public abstract Location getTestedLocation(JUnitPlugin plugin,
100: Location testLocation);
101:
102: /**
103: * Determines whether the given plugin is capable of creating tests
104: * for the given files at the moment.
105: * The default implementation returns {@code true}.
106: *
107: * @param plugin plugin to be queried
108: * @param fileObjects {@code FileObject}s for which the tests are about
109: * to be created
110: * @return {@code true} if the given plugin is able of creating tests
111: * for the given {@code FileObject}s, {@code false} otherwise
112: * @see #createTests
113: */
114: public abstract boolean canCreateTests(JUnitPlugin plugin,
115: FileObject... fileObjects);
116:
117: /**
118: * Creates test classes for given source classes.
119: *
120: * @param filesToTest source files for which test classes should be
121: * created
122: * @param targetRoot root folder of the target source root
123: * @param params parameters of creating test class
124: * - each key is an {@code Integer} whose value is equal
125: * to some of the constants defined in the class;
126: * the value is either
127: * a {@code String} (for key with value {@code CLASS_NAME})
128: * or a {@code Boolean} (for other keys)
129: * @return created test files
130: */
131: public abstract FileObject[] createTests(JUnitPlugin plugin,
132: FileObject[] filesToTest, FileObject targetRoot,
133: Map<CreateTestParam, Object> params);
134:
135: }
|