Home | History | Annotate | Download | only in generators
      1 /*
      2  * Created on Apr 8, 2003
      3  *
      4  * To change the template for this generated file go to
      5  * Window>Preferences>Java>Code Generation>Code and Comments
      6  */
      7 package org.eclipse.releng.generators;
      8 import java.io.File;
      9 
     10 
     11 
     12 /**
     13  * @author SDimitrov
     14  *
     15  * To change the template for this generated type comment go to
     16  * Window>Preferences>Java>Code Generation>Code and Comments
     17  */
     18 public class EclipseTestResultsGeneratorNoMail extends TestResultsGenerator {
     19 
     20 
     21 	// buildType used to determine if mail should be sent on
     22 	// successful build completion
     23 	private String buildType;
     24 	private boolean sendMail=true;
     25 	/**
     26 	 * @return
     27 	 */
     28 	public String getBuildType() {
     29 		return buildType;
     30 	}
     31 
     32 	/**
     33 	 * @param buildType
     34 	 */
     35 	public void setBuildType(String buildType) {
     36 		this.buildType = buildType;
     37 	}
     38 
     39 	public static void main(String[] args) {
     40 		String publishingContent="C:\\Documents and Settings\\IBMEmployee\\workspace\\org.eclipse.releng.eclipsebuilder\\eclipse\\publishingFiles";
     41 
     42 		EclipseTestResultsGeneratorNoMail test = new EclipseTestResultsGeneratorNoMail();
     43 		test.buildType="N";
     44 		test.setIsBuildTested(true);
     45 		test.setDropTokenList(
     46 		"%sdk%,%tests%,%example%,%rcpruntime%,%rcpsdk%,%deltapack%,%icubase%,%runtime%,%platformsdk%,%jdt%,%jdtsdk%,%jdtc%,%jarprocessor%,%pde%,%pdesdk%,%cvs%,%cvssdk%,%teamextras%,%swt%,%relengtools%");
     47 		test.getDropTokensFromList(test.getDropTokenList());
     48 		test.setXmlDirectoryName("C:\\junk\\testresults\\xml");
     49 		test.setHtmlDirectoryName("C:\\junk\\testresults\\html");
     50 		test.setDropDirectoryName("C:\\junk");
     51 		test.setTestResultsTemplateFileName(
     52 				publishingContent+"\\templateFiles\\testResults.php.template");
     53 		test.setDropTemplateFileName(
     54 				publishingContent+"\\templateFiles\\index.php.template");
     55 		test.setTestResultsHtmlFileName("testResults.php");
     56 		test.setDropHtmlFileName("index.php");
     57 		//test.setDropHtmlFileName("index.html");
     58 		test.setPlatformIdentifierToken("%platform%");
     59 
     60 		test.setPlatformSpecificTemplateList("Windows,"+publishingContent+"/templateFiles/platform.php.template,winPlatform.php;Linux,"+publishingContent+"/templateFiles/platform.php.template,linPlatform.php;Solaris,"+publishingContent+"/templateFiles/platform.php.template,solPlatform.php;AIX,"+publishingContent+"/templateFiles/platform.php.template,aixPlatform.php;Macintosh,"+publishingContent+"/templateFiles/platform.php.template,macPlatform.php;Source Build,"+publishingContent+"/templateFiles/sourceBuilds.php.template,sourceBuilds.php");
     61 		/*<property name="platformIdentifierToken" value="%platform%" />
     62 			<property name="platformSpecificTemplateList" value="Windows,${publishingContent}/templateFiles/platform.php.template,winPlatform.php;Linux,${publishingContent}/templateFiles/platform.php.template,linPlatform.php;Solaris,${publishingContent}/templateFiles/platform.php.template,solPlatform.php;AIX,${publishingContent}/templateFiles/platform.php.template,aixPlatform.php;Macintosh,${publishingContent}/templateFiles/platform.php.template,macPlatform.php;Source Build,${publishingContent}/templateFiles/sourceBuilds.php.template,sourceBuilds.php" />
     63 			*/
     64 
     65 		test.setHrefTestResultsTargetPath("testresults");
     66 		test.setCompileLogsDirectoryName(
     67 			"C:\\junk\\compilelogs");
     68 		test.setHrefCompileLogsTargetPath("compilelogs");
     69 		test.setTestManifestFileName("C:\\junk\\testManifest.xml");
     70 		test.execute();
     71 	}
     72 
     73 	public void execute() {
     74 		super.execute();
     75 //		if (sendMail)
     76 //			mailResults();
     77 	}
     78 
     79 	protected String processDropRow(PlatformStatus aPlatform) {
     80 		String imageName = "";
     81 
     82 		if (aPlatform.hasErrors()) {
     83 			imageName =
     84 				"<a href=\"" + getTestResultsHtmlFileName() + "\"><img src = \"FAIL.gif\" width=19 height=23></a>";
     85 			testResultsStatus = "failed";
     86 
     87 		} else {
     88 			if (testsRan()) {
     89 				imageName = "<img src = \"OK.gif\" width=19 height=23>";
     90 			} else {
     91 				if (isBuildTested()) {
     92 					imageName =
     93 						"<font size=\"-1\" color=\"#FF0000\">pending</font>";
     94 					testResultsStatus = "pending";
     95 				} else {
     96 					imageName = "<img src = \"OK.gif\" width=19 height=23>";
     97 				}
     98 			}
     99 		}
    100 
    101 		String result = "<tr>";
    102 
    103 		result = result + "<td><div align=left>" + imageName + "</div></td>\n";
    104 		result = result + "<td>" + aPlatform.getName() + "</td>";
    105 
    106 		//generate http, md5 and sha1 links by calling php functions in the template
    107 		result = result + "<td><?php genLinks($_SERVER[\"SERVER_NAME\"],\"@buildlabel@\",\"" + aPlatform.getFileName() +"\"); ?></td>\n";
    108 		result = result + "</tr>\n";
    109 
    110 		return result;
    111 	}
    112 
    113 //	private void mailResults() {
    114 //		//send a different message for the following cases:
    115 //		//build is not tested at all
    116 //		//build is tested, tests have not run
    117 //		//build is tested, tests have run with error and or failures
    118 //		//build is tested, tests have run with no errors or failures
    119 //		try {
    120 //			mailer = new Mailer();
    121 //		} catch (NoClassDefFoundError e) {
    122 //			return;
    123 //		}
    124 //		String buildLabel = mailer.getBuildProperties().getBuildLabel();
    125 //		String httpUrl = mailer.getBuildProperties().getHttpUrl()+"/"+buildLabel;
    126 ////		String ftpUrl = mailer.getBuildProperties().getftpUrl()+"/"+buildLabel;
    127 //
    128 //		String subject = "Build is complete.  ";
    129 //
    130 //		String downloadLinks="\n\nHTTP Download:\n\n\t"+httpUrl+" \n\n";
    131 //	/*	downloadLinks=downloadLinks.concat("FTP Download:\n\n");
    132 //		downloadLinks=downloadLinks.concat("\tuser: anonymous\n\tpassword: (e-mail address or leave blank)\n\tserver:  download.eclipse.org\n\tcd to directory:  "+buildLabel);
    133 //		downloadLinks=downloadLinks.concat("\n\n\tor");
    134 //		downloadLinks=downloadLinks.concat("\n\n\t"+ftpUrl);*/
    135 //
    136 //		//provide http links
    137 //		String message = "The build is complete."+downloadLinks;
    138 //
    139 //		if (testsRan()) {
    140 //			subject = "Automated JUnit testing complete.  ";
    141 //			message = "Automated JUnit testing is complete.  ";
    142 //			subject =
    143 //				subject.concat(
    144 //					(getTestResultsWithProblems().endsWith("\n"))
    145 //						? "All tests pass."
    146 //						: "Test failures/errors occurred.");
    147 //			message =
    148 //				message.concat(
    149 //					(getTestResultsWithProblems().endsWith("\n"))
    150 //						? "All tests pass."
    151 //						: "Test failures/errors occurred in the following:  "
    152 //							+ getTestResultsWithProblems())+downloadLinks;
    153 //		} else if (isBuildTested() && (!buildType.equals("N"))) {
    154 //			subject = subject.concat("Automated JUnit testing is starting.");
    155 //			message = "The " + subject+downloadLinks;
    156 //		}
    157 //
    158 //		if (subject.endsWith("Test failures/errors occurred."))
    159 //			mailer.sendMessage(subject, message);
    160 //		else if (!buildType.equals("N"))
    161 //			mailer.sendMessage(subject, message);
    162 //
    163 //	}
    164 
    165 	public boolean isSendMail() {
    166 		return sendMail;
    167 	}
    168 
    169 	public void setSendMail(boolean sendMail) {
    170 		this.sendMail = sendMail;
    171 	}
    172 
    173 }
    174