KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > codegen > ecore > templates > model > tests > PackageTestSuite


1 package org.eclipse.emf.codegen.ecore.templates.model.tests;
2
3 import java.util.*;
4 import org.eclipse.emf.codegen.ecore.genmodel.*;
5
6 public class PackageTestSuite
7 {
8   protected static String JavaDoc nl;
9   public static synchronized PackageTestSuite create(String JavaDoc lineSeparator)
10   {
11     nl = lineSeparator;
12     PackageTestSuite result = new PackageTestSuite();
13     nl = null;
14     return result;
15   }
16
17   protected final String JavaDoc NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
18   protected final String JavaDoc TEXT_1 = "";
19   protected final String JavaDoc TEXT_2 = "/**" + NL + " * <copyright>" + NL + " * </copyright>" + NL + " *" + NL + " * ";
20   protected final String JavaDoc TEXT_3 = "Id";
21   protected final String JavaDoc TEXT_4 = NL + " */" + NL + "package ";
22   protected final String JavaDoc TEXT_5 = ";" + NL;
23   protected final String JavaDoc TEXT_6 = NL + NL + "/**" + NL + " * <!-- begin-user-doc -->" + NL + " * A test suite for the '<em><b>";
24   protected final String JavaDoc TEXT_7 = "</b></em>' package." + NL + " * <!-- end-user-doc -->" + NL + " * @generated" + NL + " */" + NL + "public class ";
25   protected final String JavaDoc TEXT_8 = " extends ";
26   protected final String JavaDoc TEXT_9 = NL + "{";
27   protected final String JavaDoc TEXT_10 = NL + NL + "\t/**" + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static final ";
28   protected final String JavaDoc TEXT_11 = " copyright = \"";
29   protected final String JavaDoc TEXT_12 = "\";";
30   protected final String JavaDoc TEXT_13 = NL + NL + "\t/**" + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static void main(String[] args)" + NL + "\t{" + NL + "\t\t";
31   protected final String JavaDoc TEXT_14 = ".run(suite());" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static ";
32   protected final String JavaDoc TEXT_15 = " suite()" + NL + "\t{" + NL + "\t\t";
33   protected final String JavaDoc TEXT_16 = " suite = new ";
34   protected final String JavaDoc TEXT_17 = "(\"";
35   protected final String JavaDoc TEXT_18 = " Tests\");";
36   protected final String JavaDoc TEXT_19 = NL + "\t\tsuite.addTestSuite(";
37   protected final String JavaDoc TEXT_20 = ".class);";
38   protected final String JavaDoc TEXT_21 = NL + "\t\treturn suite;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ";
39   protected final String JavaDoc TEXT_22 = "(String name)" + NL + "\t{" + NL + "\t\tsuper(name);" + NL + "\t}" + NL + "" + NL + "} //";
40   protected final String JavaDoc TEXT_23 = NL;
41
42   public String JavaDoc generate(Object JavaDoc argument)
43   {
44     StringBuffer JavaDoc stringBuffer = new StringBuffer JavaDoc();
45     
46 /**
47  * <copyright>
48  *
49  * Copyright (c) 2005 IBM Corporation and others.
50  * All rights reserved. This program and the accompanying materials
51  * are made available under the terms of the Eclipse Public License v1.0
52  * which accompanies this distribution, and is available at
53  * http://www.eclipse.org/legal/epl-v10.html
54  *
55  * Contributors:
56  * IBM - Initial API and implementation
57  *
58  * </copyright>
59  */

60
61     GenPackage genPackage = (GenPackage)argument; GenModel genModel = genPackage.getGenModel();
62     stringBuffer.append(TEXT_1);
63     stringBuffer.append(TEXT_2);
64     stringBuffer.append("$");
65     stringBuffer.append(TEXT_3);
66     stringBuffer.append("$");
67     stringBuffer.append(TEXT_4);
68     stringBuffer.append(genPackage.getTestsPackageName());
69     stringBuffer.append(TEXT_5);
70     genModel.markImportLocation(stringBuffer);
71     stringBuffer.append(TEXT_6);
72     stringBuffer.append(genPackage.getPackageName());
73     stringBuffer.append(TEXT_7);
74     stringBuffer.append(genPackage.getTestSuiteClassName());
75     stringBuffer.append(TEXT_8);
76     stringBuffer.append(genModel.getImportedName("junit.framework.TestSuite"));
77     stringBuffer.append(TEXT_9);
78     if (genModel.getCopyrightText() != null) {
79     stringBuffer.append(TEXT_10);
80     stringBuffer.append(genModel.getImportedName("java.lang.String"));
81     stringBuffer.append(TEXT_11);
82     stringBuffer.append(genModel.getCopyrightText());
83     stringBuffer.append(TEXT_12);
84     stringBuffer.append(genModel.getNonNLS());
85     }
86     stringBuffer.append(TEXT_13);
87     stringBuffer.append(genModel.getImportedName("junit.textui.TestRunner"));
88     stringBuffer.append(TEXT_14);
89     stringBuffer.append(genModel.getImportedName("junit.framework.Test"));
90     stringBuffer.append(TEXT_15);
91     stringBuffer.append(genModel.getImportedName("junit.framework.TestSuite"));
92     stringBuffer.append(TEXT_16);
93     stringBuffer.append(genPackage.getTestSuiteClassName());
94     stringBuffer.append(TEXT_17);
95     stringBuffer.append(genPackage.getPackageName());
96     stringBuffer.append(TEXT_18);
97     stringBuffer.append(genModel.getNonNLS());
98     for (Iterator genClasses = genPackage.getGenClasses().iterator(); genClasses.hasNext();) { GenClass genClass = (GenClass)genClasses.next();
99     if (!genClass.isExternalInterface() && !genClass.isAbstract() && genClass.hasTests()) {
100     stringBuffer.append(TEXT_19);
101     stringBuffer.append(genClass.getImportedTestCaseClassName());
102     stringBuffer.append(TEXT_20);
103     }
104     }
105     stringBuffer.append(TEXT_21);
106     stringBuffer.append(genPackage.getTestSuiteClassName());
107     stringBuffer.append(TEXT_22);
108     stringBuffer.append(genPackage.getTestSuiteClassName());
109     genModel.emitSortedImports();
110     stringBuffer.append(TEXT_23);
111     return stringBuffer.toString();
112   }
113 }
114
Popular Tags