blob: 05593de9267d85c21d67be4fc28596f9119beabe [file] [log] [blame]
package org.eclipse.emf.codegen.ecore.templates.model.tests;
import java.util.Iterator;
import org.eclipse.emf.codegen.ecore.genmodel.GenBase;
import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
public class ModelTestSuite_
{
protected static String nl;
public static synchronized ModelTestSuite_ create(String lineSeparator)
{
nl = lineSeparator;
ModelTestSuite_ result = new ModelTestSuite_();
nl = null;
return result;
}
public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
protected final String TEXT_1 = "";
protected final String TEXT_2 = "/**";
protected final String TEXT_3 = NL + " * ";
protected final String TEXT_4 = NL + " * <copyright>" + NL + " * </copyright>" + NL + " *" + NL + " * ";
protected final String TEXT_5 = "Id";
protected final String TEXT_6 = NL + " */" + NL + "package ";
protected final String TEXT_7 = ";" + NL;
protected final String TEXT_8 = NL + NL + "/**" + NL + " * <!-- begin-user-doc -->" + NL + " * A test suite for the '<em><b>";
protected final String TEXT_9 = "</b></em>' model." + NL + " * <!-- end-user-doc -->" + NL + " * @generated" + NL + " */" + NL + "public class ";
protected final String TEXT_10 = " extends ";
protected final String TEXT_11 = NL + "{";
protected final String TEXT_12 = NL + NL + "\t/**" + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static final ";
protected final String TEXT_13 = " copyright = ";
protected final String TEXT_14 = ";";
protected final String TEXT_15 = 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";
protected final String TEXT_16 = ".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 ";
protected final String TEXT_17 = " suite()" + NL + "\t{" + NL + "\t\t";
protected final String TEXT_18 = " suite = new ";
protected final String TEXT_19 = "(\"";
protected final String TEXT_20 = " Tests\");";
protected final String TEXT_21 = NL + "\t\tsuite.addTest(";
protected final String TEXT_22 = ".suite());";
protected final String TEXT_23 = 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 ";
protected final String TEXT_24 = "(String name)" + NL + "\t{" + NL + "\t\tsuper(name);" + NL + "\t}" + NL + "" + NL + "} //";
protected final String TEXT_25 = NL;
public String generate(Object argument)
{
final StringBuffer stringBuffer = new StringBuffer();
/**
* <copyright>
*
* Copyright (c) 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM - Initial API and implementation
*
* </copyright>
*/
GenModel genModel = (GenModel)argument; /* Trick to import java.util.* without warnings */Iterator.class.getName();
stringBuffer.append(TEXT_1);
stringBuffer.append(TEXT_2);
{GenBase copyrightHolder = argument instanceof GenBase ? (GenBase)argument : argument instanceof Object[] && ((Object[])argument)[0] instanceof GenBase ? (GenBase)((Object[])argument)[0] : null;
if (copyrightHolder != null && copyrightHolder.hasCopyright()) {
stringBuffer.append(TEXT_3);
stringBuffer.append(copyrightHolder.getCopyright(copyrightHolder.getGenModel().getIndentation(stringBuffer)));
} else {
stringBuffer.append(TEXT_4);
stringBuffer.append("$");
stringBuffer.append(TEXT_5);
stringBuffer.append("$");
}}
stringBuffer.append(TEXT_6);
stringBuffer.append(genModel.getTestSuitePackageName());
stringBuffer.append(TEXT_7);
genModel.markImportLocation(stringBuffer);
stringBuffer.append(TEXT_8);
stringBuffer.append(genModel.getModelName());
stringBuffer.append(TEXT_9);
stringBuffer.append(genModel.getTestSuiteClassName());
stringBuffer.append(TEXT_10);
stringBuffer.append(genModel.getImportedName("junit.framework.TestSuite"));
stringBuffer.append(TEXT_11);
if (genModel.hasCopyrightField()) {
stringBuffer.append(TEXT_12);
stringBuffer.append(genModel.getImportedName("java.lang.String"));
stringBuffer.append(TEXT_13);
stringBuffer.append(genModel.getCopyrightFieldLiteral());
stringBuffer.append(TEXT_14);
stringBuffer.append(genModel.getNonNLS());
}
stringBuffer.append(TEXT_15);
stringBuffer.append(genModel.getImportedName("junit.textui.TestRunner"));
stringBuffer.append(TEXT_16);
stringBuffer.append(genModel.getImportedName("junit.framework.Test"));
stringBuffer.append(TEXT_17);
stringBuffer.append(genModel.getImportedName("junit.framework.TestSuite"));
stringBuffer.append(TEXT_18);
stringBuffer.append(genModel.getTestSuiteClassName());
stringBuffer.append(TEXT_19);
stringBuffer.append(genModel.getModelName());
stringBuffer.append(TEXT_20);
stringBuffer.append(genModel.getNonNLS());
for (GenPackage genPackage : genModel.getAllGenPackagesWithClassifiers()) {
if (genPackage.hasTests()) {
stringBuffer.append(TEXT_21);
stringBuffer.append(genModel.getImportedName(genPackage.getImportedTestSuiteClassName()));
stringBuffer.append(TEXT_22);
}
}
stringBuffer.append(TEXT_23);
stringBuffer.append(genModel.getTestSuiteClassName());
stringBuffer.append(TEXT_24);
stringBuffer.append(genModel.getTestSuiteClassName());
genModel.emitSortedImports();
stringBuffer.append(TEXT_25);
return stringBuffer.toString();
}
}