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 ModelTestSuite 7 { 8 protected static String nl; 9 public static synchronized ModelTestSuite create(String lineSeparator) 10 { 11 nl = lineSeparator; 12 ModelTestSuite result = new ModelTestSuite(); 13 nl = null; 14 return result; 15 } 16 17 protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; 18 protected final String TEXT_1 = ""; 19 protected final String TEXT_2 = "/**" + NL + " * <copyright>" + NL + " * </copyright>" + NL + " *" + NL + " * "; 20 protected final String TEXT_3 = "Id"; 21 protected final String TEXT_4 = NL + " */" + NL + "package "; 22 protected final String TEXT_5 = ";" + NL; 23 protected final String TEXT_6 = NL + NL + "/**" + NL + " * <!-- begin-user-doc -->" + NL + " * A test suite for the '<em><b>"; 24 protected final String TEXT_7 = "</b></em>' model." + NL + " * <!-- end-user-doc -->" + NL + " * @generated" + NL + " */" + NL + "public class "; 25 protected final String TEXT_8 = " extends "; 26 protected final String TEXT_9 = NL + "{"; 27 protected final String 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 TEXT_11 = " copyright = \""; 29 protected final String TEXT_12 = "\";"; 30 protected final String 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 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 TEXT_15 = " suite()" + NL + "\t{" + NL + "\t\t"; 33 protected final String TEXT_16 = " suite = new "; 34 protected final String TEXT_17 = "(\""; 35 protected final String TEXT_18 = " Tests\");"; 36 protected final String TEXT_19 = NL + "\t\tsuite.addTest("; 37 protected final String TEXT_20 = ".suite());"; 38 protected final String 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 TEXT_22 = "(String name)" + NL + "\t{" + NL + "\t\tsuper(name);" + NL + "\t}" + NL + "" + NL + "} //"; 40 protected final String TEXT_23 = NL; 41 42 public String generate(Object argument) 43 { 44 StringBuffer stringBuffer = new StringBuffer (); 45 46 60 61 GenModel genModel = (GenModel)argument; 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(genModel.getTestSuitePackageName()); 69 stringBuffer.append(TEXT_5); 70 genModel.markImportLocation(stringBuffer); 71 stringBuffer.append(TEXT_6); 72 stringBuffer.append(genModel.getModelName()); 73 stringBuffer.append(TEXT_7); 74 stringBuffer.append(genModel.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(genModel.getTestSuiteClassName()); 94 stringBuffer.append(TEXT_17); 95 stringBuffer.append(genModel.getModelName()); 96 stringBuffer.append(TEXT_18); 97 stringBuffer.append(genModel.getNonNLS()); 98 for (Iterator genPackages = genModel.getAllGenPackagesWithClassifiers().iterator(); genPackages.hasNext();) { GenPackage genPackage = (GenPackage)genPackages.next(); 99 if (genPackage.hasTests()) { 100 stringBuffer.append(TEXT_19); 101 stringBuffer.append(genModel.getImportedName(genPackage.getImportedTestSuiteClassName())); 102 stringBuffer.append(TEXT_20); 103 } 104 } 105 stringBuffer.append(TEXT_21); 106 stringBuffer.append(genModel.getTestSuiteClassName()); 107 stringBuffer.append(TEXT_22); 108 stringBuffer.append(genModel.getTestSuiteClassName()); 109 genModel.emitSortedImports(); 110 stringBuffer.append(TEXT_23); 111 return stringBuffer.toString(); 112 } 113 } 114 | Popular Tags |