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: /*
043: * XTestReport.java
044: *
045: * Created on November 19, 2001, 4:45 PM
046: */
047:
048: package org.netbeans.xtest.pe.xmlbeans;
049:
050: import java.io.*;
051:
052: /**
053: *
054: * @author mb115822
055: * @version
056: */
057: public class XTestResultsReport extends XMLBean {
058:
059: /** Creates new XTestReport */
060: public XTestResultsReport() {
061: }
062:
063: // XML attributes
064: public java.sql.Timestamp xmlat_timeStamp;
065: public long xmlat_time;
066: public String xmlat_project;
067: public String xmlat_build;
068: public String xmlat_testingGroup;
069: public String xmlat_testedType;
070: public String xmlat_host;
071: public long xmlat_testsTotal;
072: public long xmlat_testsPass;
073: public long xmlat_testsFail;
074: public long xmlat_testsUnexpectedPass;
075: public long xmlat_testsExpectedFail;
076: public long xmlat_testsError;
077: public boolean xmlat_fullReport;
078: // project_id - project_id of the report in the database
079: public String xmlat_project_id;
080: // link - link to local pes -> this is not full link, but only the part from
081: // root of team web server
082: public String xmlat_webLink;
083: // team - id of team which submitted the results
084: public String xmlat_team;
085: // short info from TestRun's ModuleError element
086: public String xmlat_brokenModules;
087:
088: // child elements
089: public SystemInfo[] xmlel_SystemInfo;
090: public TestRun[] xmlel_TestRun;
091:
092: /** Holds value of property systemInfo_id. */
093: private long systemInfo_id;
094:
095: private String invalidMessage = "";
096:
097: /** Returns a reason why this report is not valid.
098: * @return reason
099: */
100: public String getInvalidMessage() {
101: return invalidMessage;
102: }
103:
104: public void setInvalidMessage(String invalidMessage) {
105: this .invalidMessage += " " + invalidMessage;
106: }
107:
108: // business methods
109: public boolean isValid() {
110: boolean status = true;
111: if (xmlat_project == null) {
112: setInvalidMessage("Project is null.");
113: status = false;
114: }
115: if (xmlat_build == null) {
116: setInvalidMessage("Build number is null.");
117: status = false;
118: }
119: if (xmlat_testingGroup == null) {
120: setInvalidMessage("Testing group is null.");
121: status = false;
122: }
123: if (xmlat_testedType == null) {
124: setInvalidMessage("Tested type is null.");
125: status = false;
126: }
127: if (xmlat_host == null) {
128: setInvalidMessage("Host is null.");
129: status = false;
130: }
131: if (xmlat_testsTotal < 1) {
132: setInvalidMessage("Tests total is " + xmlat_testsTotal
133: + ". Must be > 0.");
134: status = false;
135: }
136: if (xmlel_SystemInfo == null || xmlel_SystemInfo.length < 1) {
137: setInvalidMessage("System info is null or empty.");
138: status = false;
139: }
140: return status;
141: }
142:
143: public boolean equals(Object obj) {
144: return equalByAttributes(obj);
145: }
146:
147: /** Getter for property timeStamp.
148: * @return Value of property timeStamp.
149: */
150: public java.sql.Timestamp getTimeStamp() {
151: return xmlat_timeStamp;
152: }
153:
154: /** Setter for property timeStamp.
155: * @param timeStamp New value of property timeStamp.
156: */
157: public void setTimeStamp(java.sql.Timestamp timeStamp) {
158: xmlat_timeStamp = timeStamp;
159: }
160:
161: /** Getter for property time.
162: * @return Value of property time.
163: */
164: public long getTime() {
165: return xmlat_time;
166: }
167:
168: /** Setter for property time.
169: * @param time New value of property time.
170: */
171: public void setTime(long time) {
172: xmlat_time = time;
173: }
174:
175: /** Getter for property build.
176: * @return Value of property build.
177: */
178: public String getBuild() {
179: return xmlat_build;
180: }
181:
182: /** Setter for property build.
183: * @param build New value of property build.
184: */
185: public void setBuild(String build) {
186: xmlat_build = build;
187: }
188:
189: /** Getter for property host.
190: * @return Value of property host.
191: */
192: public String getHost() {
193: return xmlat_host;
194: }
195:
196: /** Setter for property host.
197: * @param host New value of property host.
198: */
199: public void setHost(String host) {
200: xmlat_host = host;
201: }
202:
203: /** Getter for property project.
204: * @return Value of property project.
205: */
206: public String getProject() {
207: return xmlat_project;
208: }
209:
210: /** Setter for property project.
211: * @param project New value of property project.
212: */
213: public void setProject(String project) {
214: xmlat_project = project;
215: }
216:
217: /** Getter for property testedType.
218: * @return Value of property testedType.
219: */
220: public String getTestedType() {
221: return xmlat_testedType;
222: }
223:
224: /** Setter for property testedType.
225: * @param testedType New value of property testedType.
226: */
227: public void setTestedType(String testedType) {
228: xmlat_testedType = testedType;
229: }
230:
231: /** Getter for property testingGroup.
232: * @return Value of property testingGroup.
233: */
234: public String getTestingGroup() {
235: return xmlat_testingGroup;
236: }
237:
238: /** Setter for property testingGroup.
239: * @param testingGroup New value of property testingGroup.
240: */
241: public void setTestingGroup(String testingGroup) {
242: xmlat_testingGroup = testingGroup;
243: }
244:
245: /** Getter for property testsError.
246: * @return Value of property testsError.
247: */
248: public long getTestsError() {
249: return xmlat_testsError;
250: }
251:
252: /** Setter for property testsError.
253: * @param testsError New value of property testsError.
254: */
255: public void setTestsError(long testsError) {
256: xmlat_testsError = testsError;
257: }
258:
259: /** Getter for property testsFail.
260: * @return Value of property testsFail.
261: */
262: public long getTestsFail() {
263: return xmlat_testsFail;
264: }
265:
266: /** Setter for property testsFail.
267: * @param testsFail New value of property testsFail.
268: */
269: public void setTestsFail(long testsFail) {
270: xmlat_testsFail = testsFail;
271: }
272:
273: /** Getter for property testsPass.
274: * @return Value of property testsPass.
275: */
276: public long getTestsPass() {
277: return xmlat_testsPass;
278: }
279:
280: /** Setter for property testsPass.
281: * @param testsPass New value of property testsPass.
282: */
283: public void setTestsPass(long testsPass) {
284: xmlat_testsPass = testsPass;
285: }
286:
287: /** Getter for property testsUnexpectedPass.
288: * @return Value of property testsUnexpectedPass.
289: */
290: public long getTestsUnexpectedPass() {
291: return xmlat_testsUnexpectedPass;
292: }
293:
294: /** Setter for property testsUnexpectedPass.
295: * @param testsPass New value of property testsUnexpectedPass.
296: */
297: public void setTestsUnexpectedPass(long testsUnexpectedPass) {
298: xmlat_testsUnexpectedPass = testsUnexpectedPass;
299: }
300:
301: /** Getter for property testsExpectedFail.
302: * @return Value of property testsExpectedFail.
303: */
304: public long getTestsExpectedFail() {
305: return xmlat_testsExpectedFail;
306: }
307:
308: /** Setter for property testsExpectedFail.
309: * @param testsExpectedFail New value of property testsExpectedFail.
310: */
311: public void setTestsExpectedFail(long testsExpectedFail) {
312: xmlat_testsExpectedFail = testsExpectedFail;
313: }
314:
315: /** Getter for property testsTotal.
316: * @return Value of property testsTotal.
317: */
318: public long getTestsTotal() {
319: return xmlat_testsTotal;
320: }
321:
322: /** Setter for property testsTotal.
323: * @param testsTotal New value of property testsTotal.
324: */
325: public void setTestsTotal(long testsTotal) {
326: xmlat_testsTotal = testsTotal;
327: }
328:
329: /** Getter for property systemInfo_id.
330: * @return Value of property systemInfo_id.
331: */
332: public long getSystemInfo_id() {
333: return this .systemInfo_id;
334: }
335:
336: /** Setter for property systemInfo_id.
337: * @param systemInfo_id New value of property systemInfo_id.
338: */
339: public void setSystemInfo_id(long systemInfo_id) {
340: this .systemInfo_id = systemInfo_id;
341: }
342:
343: /** getter for weblink
344: */
345: public void setWebLink(String webLink) {
346: xmlat_webLink = webLink;
347: }
348:
349: /** setter for weblink
350: */
351: public String getWebLink() {
352: return xmlat_webLink;
353: }
354:
355: public void setProject_id(String project_id) {
356: this .xmlat_project_id = project_id;
357: }
358:
359: public String getProject_id() {
360: return this .xmlat_project_id;
361: }
362:
363: /** getter for team
364: */
365: public void setTeam(String team) {
366: xmlat_team = team;
367: }
368:
369: /** setter for weblink
370: */
371: public String getTeam() {
372: return xmlat_team;
373: }
374:
375: /** Getter for property brokenModules.
376: * @return Value of property brokenModules.
377: */
378: public String getBrokenModules() {
379: return xmlat_brokenModules;
380: }
381:
382: /** Setter for property brokenModules.
383: * @param brokenModules New value of property brokenModules.
384: */
385: public void setBrokenModules(String brokenModules) {
386: this .xmlat_brokenModules = brokenModules;
387: }
388:
389: // read xtest result report (without testruns)
390: public void readXTestResultsReport(XTestResultsReport xtr) {
391: xmlat_timeStamp = xtr.xmlat_timeStamp;
392: xmlat_time = xtr.xmlat_time;
393: xmlat_project = xtr.xmlat_project;
394: xmlat_project_id = xtr.xmlat_project_id;
395: xmlat_team = xtr.xmlat_team;
396: xmlat_build = xtr.xmlat_build;
397: xmlat_testingGroup = xtr.xmlat_testingGroup;
398: xmlat_testedType = xtr.xmlat_testedType;
399: xmlat_host = xtr.xmlat_host;
400: xmlat_testsTotal = xtr.xmlat_testsTotal;
401: xmlat_testsPass = xtr.xmlat_testsPass;
402: xmlat_testsFail = xtr.xmlat_testsFail;
403: xmlat_testsUnexpectedPass = xtr.xmlat_testsUnexpectedPass;
404: xmlat_testsExpectedFail = xtr.xmlat_testsExpectedFail;
405: xmlat_testsError = xtr.xmlat_testsError;
406: xmlat_fullReport = xtr.xmlat_fullReport;
407: xmlat_webLink = xtr.xmlat_webLink;
408: }
409:
410: // load XTestResultsReport from a file
411: /** this one should be deprecated as well :-(
412: * @param reportFile
413: * @throws IOException
414: * @throws ClassNotFoundException
415: * @return
416: */
417: public static XTestResultsReport loadFromFile(File reportFile)
418: throws IOException, ClassNotFoundException {
419: XMLBean xmlBean = XMLBean.loadXMLBean(reportFile);
420: if (!(xmlBean instanceof XTestResultsReport)) {
421: throw new ClassNotFoundException("Loaded file "
422: + reportFile
423: + " does not contain XTestRestultsReport");
424: }
425: return (XTestResultsReport) xmlBean;
426: }
427:
428: public static XTestResultsReport loadXTestResultsReportFromFile(
429: File reportFile) throws IOException {
430: try {
431: XMLBean xmlBean = XMLBean.loadXMLBean(reportFile);
432: if (!(xmlBean instanceof XTestResultsReport)) {
433: throw new ClassNotFoundException("Loaded file "
434: + reportFile
435: + " does not contain XTestRestultsReport");
436: }
437: return (XTestResultsReport) xmlBean;
438: } catch (ClassNotFoundException cnfe) {
439: throw new IOException(
440: "Loaded file "
441: + reportFile
442: + " does not contain XTestRestultsReport, caused by ClassNotFoundException :"
443: + cnfe.getMessage());
444: }
445: }
446:
447: // old method name - should be deprecated
448: /**
449: * @param reportFile
450: * @throws IOException
451: * @throws ClassNotFoundException
452: * @return
453: * @deprecated
454: */
455: public static XTestResultsReport loadReportFromFile(File reportFile)
456: throws IOException, ClassNotFoundException {
457: return loadFromFile(reportFile);
458: }
459:
460: }
|