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-2006 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: * Config.java
043: *
044: * Created on May 2, 2001, 9:54 PM
045: */
046:
047: package org.netbeans.xtest;
048:
049: import java.util.Vector;
050: import java.util.Enumeration;
051: import java.util.Hashtable;
052: import java.util.LinkedList;
053: import java.util.Iterator;
054: import java.util.HashSet;
055: import java.io.File;
056: import org.apache.tools.ant.Task;
057: import org.apache.tools.ant.taskdefs.Ant;
058:
059: //import org.apache.tools.ant.types.PatternSet;
060:
061: /**
062: *
063: * @author mk97936
064: * @version
065: */
066: public class MConfig {
067:
068: private Vector mcfg;
069: private Setup setup;
070:
071: /** Creates new Config */
072: public MConfig(Vector cfg) {
073: this .mcfg = cfg;
074: }
075:
076: /** Returns enumeration of TestGroup */
077: public Enumeration getAllTests() {
078: return mcfg.elements();
079: }
080:
081: public void setConfigSetup(Setup setup) {
082: this .setup = setup;
083: }
084:
085: public Setup getConfigSetup() {
086: return setup;
087: }
088:
089: public static class TestGroup {
090: private Vector tests = new Vector();
091: private Setup setup = null;
092: private Hashtable properties = new Hashtable();
093:
094: public TestGroup() {
095: }
096:
097: public void addTest(Test test) {
098: tests.add(test);
099: }
100:
101: public Enumeration getTests() {
102: return tests.elements();
103: }
104:
105: public void setSetup(Setup s) {
106: setup = s;
107: }
108:
109: public Setup getSetup() {
110: return setup;
111: }
112:
113: public void setProperties(Hashtable t) {
114: properties = t;
115: }
116:
117: public void addProperties(Hashtable t) {
118: properties.putAll(t);
119: }
120:
121: public Hashtable getProperties() {
122: return properties;
123: }
124: }
125:
126: public static class Test {
127: private String[] attribs;
128: private String type;
129: private String module;
130:
131: public Test(String module, String type) {
132: this .type = type;
133: this .module = module;
134: }
135:
136: public String[] getAttributes() {
137: return attribs;
138: }
139:
140: public String getAttributesAsString() {
141: StringBuffer sb = new StringBuffer();
142: for (int i = 0; i < attribs.length; i++) {
143: sb.append(attribs[i]);
144: sb.append(",");
145: }
146: if (sb.length() > 0) {
147: sb.deleteCharAt(sb.length() - 1);
148: }
149: return sb.toString();
150: }
151:
152: public void setAttributes(String[] attr) {
153: attribs = attr;
154: }
155:
156: public String getType() {
157: return type;
158: }
159:
160: public String getModule() {
161: return module;
162: }
163: }
164:
165: public static class Setup {
166:
167: public static class StartStop {
168: public File dir = null;
169: public String antfile = null;
170: public String target = null;
171: public boolean onBackground = false;
172: public int delay = 0;
173: }
174:
175: private StartStop start = null, stop = null;
176: private String name;
177:
178: public void setName(String n) {
179: name = n;
180: }
181:
182: public String getName() {
183: return name;
184: }
185:
186: public void setStart(StartStop start) {
187: this .start = start;
188: }
189:
190: public void setStop(StartStop stop) {
191: this .stop = stop;
192: }
193:
194: public File getStartDir() {
195: return start == null ? null : start.dir;
196: }
197:
198: public File getStopDir() {
199: return stop == null ? null : stop.dir;
200: }
201:
202: public String getStartAntfile() {
203: return start == null ? null : start.antfile;
204: }
205:
206: public String getStopAntfile() {
207: return stop == null ? null : stop.antfile;
208: }
209:
210: public String getStartTarget() {
211: return start == null ? null : start.target;
212: }
213:
214: public String getStopTarget() {
215: return stop == null ? null : stop.target;
216: }
217:
218: public boolean getStartOnBackground() {
219: return start == null ? false : start.onBackground;
220: }
221:
222: public boolean getStopOnBackground() {
223: return stop == null ? false : stop.onBackground;
224: }
225:
226: public int getStartDelay() {
227: return start == null ? 0 : start.delay;
228: }
229:
230: public int getStopDelay() {
231: return stop == null ? 0 : stop.delay;
232: }
233: }
234:
235: }
|