org.junit.tools/src/org/junit/tools/preferences/JUTPreferences.java
public class JUTPreferences implements IJUTPreferenceConstants {

	// from main-page
	private static Boolean writeTML = null;

	private static String tmlContainer = null;

	private static String testProjectPostfix = null;

	private static String testSourceFolderName = null;

	private static String testPackagePostfix = null;

	private static String testMethodPrefix = null;

	private static String testMethodPostfix = null;

	private static String testClassSuperType = null;

	private static String testClassPrefix = null;

	private static String testClassPostfix = null;

	private static String mockProject = null;
	
	private static Boolean mockSaveInTestProject = null;

	private static String mockFramework = null;
	
	// from annotations-page
	private static String[] testClassAnnotations = null;

	private static String[] mockClassAnnotations = null;

	// from filter-page
	private static String[] testMethodFilterName = null;

	private static String[] testMethodFilterModifier = null;

	// from static-bindings-page
	private static String[] staticBindings = null;
	private static Map<String, String> staticBindingsMapBase = null;
	private static Map<String, String> staticBindingsMapTest = null;

	public static boolean getPreferenceBoolean(String name) {
		return getPreferenceStore().getBoolean(name);
	}

	public static String getPreference(String name) {
		return getPreferenceStore().getString(name);
	}

	private static IPreferenceStore getPreferenceStore() {
		return Activator.getDefault().getPreferenceStore();
	}

	public static String getTmlContainer() {
		if (tmlContainer == null) {
			tmlContainer = getPreference(TML_CONTAINER);
		}
		return tmlContainer;
	}

	public static boolean isWriteTML() {
		if (writeTML == null) {
			writeTML = getPreferenceBoolean(WRITE_TML);
		}
		return writeTML;
	}

	public static String getTestProjectPostfix() {
		if (testProjectPostfix == null) {
			testProjectPostfix = getPreference(TEST_PROJECT_POSTFIX);
		}
		return testProjectPostfix;
	}

	public static String getTestSourceFolderName() {
		if (testSourceFolderName == null) {
			testSourceFolderName = getPreference(TEST_SOURCE_FOLDER_NAME);
		}
		return testSourceFolderName;
	}

	public static String getTestMethodPostfix() {
		if (testMethodPostfix == null) {
			testMethodPostfix = getPreference(TEST_METHOD_POSTFIX);
		}
		return testMethodPostfix;
	}

	protected static void setMockClassAnnotations(String[] mockClassAnnotations) {
		JUTPreferences.mockClassAnnotations = mockClassAnnotations;
	}

	protected static void setTestClassAnnotations(String[] testClassAnnotations) {
		JUTPreferences.testClassAnnotations = testClassAnnotations;
	}

	public static String[] getTestClassAnnotations() {
		if (testClassAnnotations == null) {
			testClassAnnotations = convert(getPreference(TEST_CLASS_ANNOTATIONS));
		}
		return testClassAnnotations;
	}

	public static String[] getMockClassAnnotations() {
		if (mockClassAnnotations == null) {
			mockClassAnnotations = convert(getPreference(MOCK_CLASS_ANNOTATIONS));
		}
		return mockClassAnnotations;
	}

	protected static void setStaticBindings(String[] staticBindings) {
		JUTPreferences.staticBindings = staticBindings;
		initStaticBindingsMaps();
	}

	protected static void setTestMethodFilterName(String[] testMethodFilterName) {
		JUTPreferences.testMethodFilterName = testMethodFilterName;
	}

	protected static void setTestMethodFilterModifier(
			String[] testmethodFilterModifier) {
		JUTPreferences.testMethodFilterModifier = testmethodFilterModifier;
	}

	public static String[] getTestMethodFilterName() {
		if (testMethodFilterName == null) {
			testMethodFilterName = convert(getPreference(TEST_METHOD_FILTER_NAME));
		}
		return testMethodFilterName;
	}

	public static String[] getTestMethodFilterModifier() {
		if (testMethodFilterModifier == null) {
			testMethodFilterModifier = convert(getPreference(TEST_METHOD_FILTER_MODIFIER));
		}
		return testMethodFilterModifier;
	}

	public static String[] getStaticBindings() {
		if (staticBindings == null) {
			staticBindings = convert(getPreference(STATIC_BINDINGS));
		}
		return staticBindings;
	}

	private static void initStaticBindingsMaps() {
		if (staticBindings == null) {
			staticBindings = getStaticBindings();
		}

		staticBindingsMapBase = new HashMap<String, String>();
		staticBindingsMapTest = new HashMap<String, String>();

		for (String staticBinding : staticBindings) {
			String baseProject, testProject;
			String[] projects = staticBinding.split(LIST_ENTRY_SEPERATOR);

			if (projects.length == 2) {
				baseProject = projects[0];
				testProject = projects[1];

				staticBindingsMapBase.put(baseProject, testProject);
				staticBindingsMapTest.put(testProject, baseProject);
			}
		}
	}

	public static Map<String, String> getStaticBindingsMapBaseProject() {
		if (staticBindingsMapBase == null) {
			initStaticBindingsMaps();
		}

		return staticBindingsMapBase;
	}

	public static Map<String, String> getStaticBindingsMapTestProject() {
		if (staticBindingsMapTest == null) {
			initStaticBindingsMaps();
		}

		return staticBindingsMapTest;
	}

	protected static void setTmlContainer(String tmlContainerPref) {
		JUTPreferences.tmlContainer = tmlContainerPref;
	}

	protected static void setWriteTML(Boolean writeTML) {
		JUTPreferences.writeTML = writeTML;
	}

	protected static void setTestProjectPostfix(String testProjectPostfixPref) {
		JUTPreferences.testProjectPostfix = testProjectPostfixPref;
	}

	protected static void setTestSourceFolderName(String testSourceFolderName) {
		JUTPreferences.testSourceFolderName = testSourceFolderName;
	}

	protected static void setTestMethodPostfix(String testmethodPostfixPref) {
		JUTPreferences.testMethodPostfix = testmethodPostfixPref;
	}

	public static String getTestMethodPrefix() {
		if (testMethodPrefix == null)
			testMethodPrefix = getPreference(TEST_METHOD_PREFIX);
		return testMethodPrefix;
	}

	protected static void setTestMethodPrefix(String testMethodPrefix) {
		JUTPreferences.testMethodPrefix = testMethodPrefix;
	}

	public static String getTestClassSuperType() {
		if (testClassSuperType == null) {
			testClassSuperType = getPreference(TEST_CLASS_SUPER_TYPE);
		}
		return testClassSuperType;
	}

	protected static void setTestClassSuperType(String testClassSuperType) {
		JUTPreferences.testClassSuperType = testClassSuperType;
	}

	protected static void setTestPackagePostfix(String newValue) {
		JUTPreferences.testPackagePostfix = newValue;
	}

	public static String getTestPackagePostfix() {
		if (testPackagePostfix == null) {
			testPackagePostfix = getPreference(TEST_PACKAGE_POSTFIX);
		}
		return testPackagePostfix;
	}

	protected static void setTestClassPrefix(String newValue) {
		JUTPreferences.testClassPrefix = newValue;
	}

	public static String getTestClassPrefix() {
		if (testClassPrefix == null) {
			testClassPrefix = getPreference(TEST_CLASS_PREFIX);
		}
		return testClassPrefix;
	}

	protected static void setTestClassPostfix(String newValue) {
		JUTPreferences.testClassPostfix = newValue;
	}

	public static String getTestClassPostfix() {
		if (testClassPostfix == null) {
			testClassPostfix = getPreference(TEST_CLASS_POSTFIX);
		}
		return testClassPostfix;
	}

	public static String getMockProject() {
		if (mockProject == null) {
			mockProject = getPreference(MOCK_PROJECT);
		}
		return mockProject;
	}

	public static Boolean isMockSaveInTestProject() {
		if (mockSaveInTestProject == null) {
			mockSaveInTestProject = getPreferenceBoolean(MOCK_SAVE_IN_TESTPROJECT);
		}
		return mockSaveInTestProject;
	}
	
	public static void setMockProject(String mockProject) {
		JUTPreferences.mockProject = mockProject;
	}
	
	public static String getMockFramework() {
		return mockFramework;
	}
	
	public static void setMockSaveInTestProject(Boolean mockSaveInTestProject) {
		JUTPreferences.mockSaveInTestProject = mockSaveInTestProject;
	}
	
	public static void setMockFramework(String mockFramework) {
		JUTPreferences.mockFramework= mockFramework;
	}
	
	/**
	 * Converter for lists
	 * 
	 * @param value
	 * @return Array with list-entries
	 */
	public static String[] convert(String value) {
		StringTokenizer tokenizer = new StringTokenizer(value, LIST_DELIMITER);
		int tokenCount = tokenizer.countTokens();
		String[] elements = new String[tokenCount];

		for (int i = 0; i < tokenCount; i++) {
			elements[i] = tokenizer.nextToken();
		}

		return elements;
	}

	/**
	 * Converter for lists
	 * 
	 * @return value
	 */
	public static String convert(String[] values) {
		StringBuffer buffer = new StringBuffer();
		for (int i = 0; i < values.length; i++) {
			buffer.append(values[i]);
			buffer.append(LIST_DELIMITER);
		}

		return buffer.toString();
	}

	public static void initialize() {
		getPreferenceStore().addPropertyChangeListener(
				new IPropertyChangeListener() {

					@Override
					public void propertyChange(PropertyChangeEvent event) {
						if (event.getProperty() == TEST_PROJECT_POSTFIX) {
							setTestProjectPostfix((String) event.getNewValue());
							return;
						} else if (event.getProperty() == TEST_SOURCE_FOLDER_NAME) {
							setTestSourceFolderName((String) event
									.getNewValue());
							return;
						} else if (event.getProperty() == TML_CONTAINER) {
							setTmlContainer((String) event.getNewValue());
							return;
						} else if (event.getProperty() == WRITE_TML) {
							setWriteTML((Boolean) event.getNewValue());
							return;
						} else if (event.getProperty() == TEST_PACKAGE_POSTFIX) {
							setTestPackagePostfix((String) event.getNewValue());
							return;
						} else if (event.getProperty() == TEST_METHOD_PREFIX) {
							setTestMethodPrefix((String) event.getNewValue());
							return;
						} else if (event.getProperty() == TEST_METHOD_POSTFIX) {
							setTestMethodPostfix((String) event.getNewValue());
							return;
						} else if (event.getProperty() == TEST_METHOD_FILTER_MODIFIER) {
							setTestMethodFilterModifier(convert((String) event
									.getNewValue()));
							return;
						} else if (event.getProperty() == TEST_CLASS_SUPER_TYPE) {
							setTestClassSuperType((String) event.getNewValue());
							return;
						} else if (event.getProperty() == TEST_CLASS_PREFIX) {
							setTestClassPrefix((String) event.getNewValue());
							return;
						} else if (event.getProperty() == TEST_CLASS_POSTFIX) {
							setTestClassPostfix((String) event.getNewValue());
							return;
						} else if (event.getProperty() == MOCK_PROJECT) {
							setMockProject((String) event.getNewValue());
							return;
						} else if (event.getProperty() == MOCK_SAVE_IN_TESTPROJECT) {
							setMockSaveInTestProject((Boolean) event.getNewValue());
							return;
						} else if (event.getProperty() == MOCK_FRAMEWORK) {
							setMockFramework((String) event.getNewValue());
							return;							
						} else if (event.getProperty() == TEST_CLASS_ANNOTATIONS) {
							setTestClassAnnotations(convert((String) event
									.getNewValue()));
							return;
						} else if (event.getProperty() == MOCK_CLASS_ANNOTATIONS) {
							setMockClassAnnotations(convert((String) event
									.getNewValue()));
							return;
						} else if (event.getProperty() == STATIC_BINDINGS) {
							setStaticBindings(convert((String) event
									.getNewValue()));
							return;
						}
					}

				});
	}

}
org.junit.tools/src/org/junit/tools/base/MethodRef.java
public class MethodRef {

    private String name;

    private String signature;

    private boolean signatureChanged = false;

    private String signatureNew;

    private boolean unresolvedConflict = false;

    public MethodRef(String name, String signature) {
	this.name = name;
	this.signature = signature;
    }

    public String getName() {
	return name;
    }

    public String getSignature() {
	return signature;
    }

    @Override
    public String toString() {
	return name + signature;
    }

    public boolean isSignatureChanged() {
	return signatureChanged;
    }

    public void setSignatureChanged(boolean signatureChanged) {
	this.signatureChanged = signatureChanged;
    }

    public void setSignatureNew(String signatureNew) {
	setSignatureChanged(true);
	this.signatureNew = signatureNew;
    }

    public String getSignatureNew() {
	return signatureNew;
    }

    public void setUnresolvedConflict(boolean unresolvedConflict) {
	this.unresolvedConflict = unresolvedConflict;
    }

    public boolean isUnresolvedConflict() {
	return unresolvedConflict;
    }

    public String getSignatureToCompare() {
	if (isSignatureChanged()) {
	    return getSignatureNew();
	}
	return getSignature();
    }

    public boolean isEquals(MethodRef mrToCompare) {
	if (mrToCompare.getName().equals(getName())
		&& mrToCompare.getSignatureToCompare().equals(
			getSignatureToCompare())) {
	    return true;
	}

	return false;
    }

    public boolean isEquals(IMethod methodToCompare) {
	try {
	    return isEquals(new MethodRef(methodToCompare.getElementName(),
		    methodToCompare.getSignature()));
	} catch (JavaModelException e) {
	    return false;
	}
    }

}
org.junit.tools/src/org/junit/tools/generator/model/tml/Constructor.java
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Constructor", propOrder = {
    "param",
    "testBase"
})
public class Constructor {

    protected List<Param> param;
    @XmlElement(required = true)
    protected List<TestBase> testBase;

    /**
     * Gets the value of the param property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the param property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getParam().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link Param }
     * 
     * 
     */
    public List<Param> getParam() {
        if (param == null) {
            param = new ArrayList<Param>();
        }
        return this.param;
    }

    /**
     * Gets the value of the testBase property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the testBase property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getTestBase().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link TestBase }
     * 
     * 
     */
    public List<TestBase> getTestBase() {
        if (testBase == null) {
            testBase = new ArrayList<TestBase>();
        }
        return this.testBase;
    }

}
org.junit.tools/src/org/junit/tools/generator/model/JUTElements.java
public class JUTClassesAndPackages {

	private ICompilationUnit baseClass = null;

	private String testBaseName = "";

	private ICompilationUnit testClass = null;

	private String testClassName = "";

	private List<IPackageFragmentRoot> baseSrcFolders = null;

	private IPackageFragmentRoot testSrcFolder = null;

	private List<IPackageFragment> basePackages = null;

	private IPackageFragment testPackage = null;

	private String testPackageName = null;

	/**
	 * @return test base
	 */
	public ICompilationUnit getBaseClass() {
		return baseClass;
	}

	/**
	 * @param baseClass
	 */
	public void setBaseTest(ICompilationUnit baseClass) {
		this.baseClass = baseClass;
	}

	/**
	 * @return test class
	 */
	public ICompilationUnit getTestClass() {
		return testClass;
	}

	/**
	 * @return test class
	 * @throws CoreException
	 * @throws JUTWarning
	 */
	public ICompilationUnit getTestClass(boolean createIfNotExists) throws CoreException, JUTWarning {
		if (createIfNotExists && (testClass == null || !testClass.exists())) {
			IPackageFragment testPckg = getTestPackage(true);
			testClass = testPckg.createCompilationUnit(testClassName + ".java", "", true, null);
		}

		return testClass;
	}

	/**
	 * @param testClass
	 */
	public void setTestClass(ICompilationUnit testClass) {
		this.testClass = testClass;
	}

	/**
	 * @return base package
	 */
	public List<IPackageFragment> getBasePackages() {
		return basePackages;
	}

	/**
	 * @param basePackage
	 */
	public void setBasePackages(List<IPackageFragment> basePackages) {
		this.basePackages = basePackages;
	}

	/**
	 * @return test package
	 */
	public IPackageFragment getTestPackage() {
		return testPackage;
	}

	/**
	 * @return test package
	 * @throws CoreException
	 * @throws JUTWarning
	 */
	public IPackageFragment getTestPackage(boolean createIfNotExists) throws CoreException, JUTWarning {
		if (createIfNotExists && (testPackage == null || !testPackage.exists())) {
			testPackage = JDTUtils.getPackage(projects.getTestProject(),
					getTestSourceFolder(projects.getTestProject(), classesAndPackages.getBasePackages().get(0)),
					testPackageName, true);
		}
		return testPackage;
	}

	/**
	 * @param testPackage
	 */
	public void setTestPackage(IPackageFragment testPackage) {
		this.testPackage = testPackage;
	}

	/**
	 * @return test class name
	 */
	public String getTestClassName() {
		return testClassName;
	}

	/**
	 * @param testClassName
	 */
	public void setTestClassName(String testClassName) {
		this.testClassName = testClassName;
	}

	/**
	 * @return base class name
	 */
	public String getBaseClassName() {
		return testBaseName;
	}

	/**
	 * @param baseClassName
	 */
	public void setBaseClassName(String baseClassName) {
		this.testBaseName = baseClassName;
	}

	public void setTestPackageName(String testPackageName) {
		this.testPackageName = testPackageName;
	}

	public String getTestPackageName() {
		return testPackageName;
	}

	public void setTestSrcFolder(IPackageFragmentRoot testSrcFolder) {
		this.testSrcFolder = testSrcFolder;
	}

	public IPackageFragmentRoot getTestFolder() {
		return testSrcFolder;
	}

	public void addBaseSrcFolder(IPackageFragmentRoot baseSrcFolder) {
		if (getBaseSrcFolders() == null) {
			baseSrcFolders = new ArrayList<IPackageFragmentRoot>();
		}

		baseSrcFolders.add(baseSrcFolder);
	}

	public void setBaseSrcFolders(List<IPackageFragmentRoot> baseSrcFolders) {
		this.baseSrcFolders = baseSrcFolders;
	}

	public List<IPackageFragmentRoot> getBaseSrcFolders() {
		return baseSrcFolders;
	}
}
org.junit.tools/src/org/junit/tools/generator/model/tml/TestBases.java
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "TestBases", propOrder = {
    "constructor"
})
public class TestBases {

    protected List<Constructor> constructor;

    /**
     * Gets the value of the constructor property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the constructor property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getConstructor().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link Constructor }
     * 
     * 
     */
    public List<Constructor> getConstructor() {
        if (constructor == null) {
            constructor = new ArrayList<Constructor>();
        }
        return this.constructor;
    }

}
org.junit.tools/src/org/junit/tools/generator/model/tml/TestBase.java
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "TestBase", propOrder = {
    "paramValue",
    "mocks"
})
public class TestBase {

    protected List<String> paramValue;
    protected Mocks mocks;
    @XmlAttribute(name = "name")
    protected String name;

    /**
     * Gets the value of the paramValue property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the paramValue property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getParamValue().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link String }
     * 
     * 
     */
    public List<String> getParamValue() {
        if (paramValue == null) {
            paramValue = new ArrayList<String>();
        }
        return this.paramValue;
    }

    /**
     * Gets the value of the mocks property.
     * 
     * @return
     *     possible object is
     *     {@link Mocks }
     *     
     */
    public Mocks getMocks() {
        return mocks;
    }

    /**
     * Sets the value of the mocks property.
     * 
     * @param value
     *     allowed object is
     *     {@link Mocks }
     *     
     */
    public void setMocks(Mocks value) {
        this.mocks = value;
    }

    /**
     * Gets the value of the name property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getName() {
        return name;
    }

    /**
     * Sets the value of the name property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setName(String value) {
        this.name = value;
    }

}
org.junit.tools/src/org/junit/tools/generator/model/tml/Testprio.java
@XmlType(name = "Testprio")
@XmlEnum
public enum Testprio {

    @XmlEnumValue("high")
    HIGH("high"),
    @XmlEnumValue("default")
    DEFAULT("default"),
    @XmlEnumValue("low")
    LOW("low");
    private final String value;

    Testprio(String v) {
        value = v;
    }

    public String value() {
        return value;
    }

    public static Testprio fromValue(String v) {
        for (Testprio c: Testprio.values()) {
            if (c.value.equals(v)) {
                return c;
            }
        }
        throw new IllegalArgumentException(v);
    }

}
org.junit.tools/src/org/junit/tools/generator/model/tml/TestCase.java
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "TestCase", propOrder = {
    "paramAssignments",
    "preconditions",
    "assertion"
})
public class TestCase {

    protected List<ParamAssignment> paramAssignments;
    protected List<Precondition> preconditions;
    protected List<Assertion> assertion;
    @XmlAttribute(name = "name")
    protected String name;
    @XmlAttribute(name = "testBase")
    protected String testBase;

    /**
     * Gets the value of the paramAssignments property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the paramAssignments property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getParamAssignments().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link ParamAssignment }
     * 
     * 
     */
    public List<ParamAssignment> getParamAssignments() {
        if (paramAssignments == null) {
            paramAssignments = new ArrayList<ParamAssignment>();
        }
        return this.paramAssignments;
    }

    /**
     * Gets the value of the preconditions property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the preconditions property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getPreconditions().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link Precondition }
     * 
     * 
     */
    public List<Precondition> getPreconditions() {
        if (preconditions == null) {
            preconditions = new ArrayList<Precondition>();
        }
        return this.preconditions;
    }

    /**
     * Gets the value of the assertion property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the assertion property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getAssertion().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link Assertion }
     * 
     * 
     */
    public List<Assertion> getAssertion() {
        if (assertion == null) {
            assertion = new ArrayList<Assertion>();
        }
        return this.assertion;
    }

    /**
     * Gets the value of the name property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getName() {
        return name;
    }

    /**
     * Sets the value of the name property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setName(String value) {
        this.name = value;
    }

    /**
     * Gets the value of the testBase property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getTestBase() {
        return testBase;
    }

    /**
     * Sets the value of the testBase property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setTestBase(String value) {
        this.testBase = value;
    }

}
org.junit.tools/src/org/junit/tools/generator/model/tml/Method.java
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Method", propOrder = {
    "param",
    "paramsDefault",
    "preconditions",
    "testCase",
    "result",
    "assertion"
})
public class Method {

    protected List<Param> param;
    protected List<ParamAssignment> paramsDefault;
    protected List<Precondition> preconditions;
    protected List<TestCase> testCase;
    @XmlElement(required = true)
    protected Result result;
    protected List<Assertion> assertion;
    @XmlAttribute(name = "name")
    protected String name;
    @XmlAttribute(name = "modifier")
    protected String modifier;
    @XmlAttribute(name = "static")
    protected Boolean _static;
    @XmlAttribute(name = "signature")
    protected String signature;

    /**
     * Gets the value of the param property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the param property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getParam().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link Param }
     * 
     * 
     */
    public List<Param> getParam() {
        if (param == null) {
            param = new ArrayList<Param>();
        }
        return this.param;
    }

    /**
     * Gets the value of the paramsDefault property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the paramsDefault property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getParamsDefault().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link ParamAssignment }
     * 
     * 
     */
    public List<ParamAssignment> getParamsDefault() {
        if (paramsDefault == null) {
            paramsDefault = new ArrayList<ParamAssignment>();
        }
        return this.paramsDefault;
    }

    /**
     * Gets the value of the preconditions property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the preconditions property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getPreconditions().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link Precondition }
     * 
     * 
     */
    public List<Precondition> getPreconditions() {
        if (preconditions == null) {
            preconditions = new ArrayList<Precondition>();
        }
        return this.preconditions;
    }

    /**
     * Gets the value of the testCase property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the testCase property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getTestCase().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link TestCase }
     * 
     * 
     */
    public List<TestCase> getTestCase() {
        if (testCase == null) {
            testCase = new ArrayList<TestCase>();
        }
        return this.testCase;
    }

    /**
     * Gets the value of the result property.
     * 
     * @return
     *     possible object is
     *     {@link Result }
     *     
     */
    public Result getResult() {
        return result;
    }

    /**
     * Sets the value of the result property.
     * 
     * @param value
     *     allowed object is
     *     {@link Result }
     *     
     */
    public void setResult(Result value) {
        this.result = value;
    }

    /**
     * Gets the value of the assertion property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the assertion property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getAssertion().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link Assertion }
     * 
     * 
     */
    public List<Assertion> getAssertion() {
        if (assertion == null) {
            assertion = new ArrayList<Assertion>();
        }
        return this.assertion;
    }

    /**
     * Gets the value of the name property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getName() {
        return name;
    }

    /**
     * Sets the value of the name property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setName(String value) {
        this.name = value;
    }

    /**
     * Gets the value of the modifier property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getModifier() {
        return modifier;
    }

    /**
     * Sets the value of the modifier property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setModifier(String value) {
        this.modifier = value;
    }

    /**
     * Gets the value of the static property.
     * 
     * @return
     *     possible object is
     *     {@link Boolean }
     *     
     */
    public Boolean isStatic() {
        return _static;
    }

    /**
     * Sets the value of the static property.
     * 
     * @param value
     *     allowed object is
     *     {@link Boolean }
     *     
     */
    public void setStatic(Boolean value) {
        this._static = value;
    }

    /**
     * Gets the value of the signature property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getSignature() {
        return signature;
    }

    /**
     * Sets the value of the signature property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setSignature(String value) {
        this.signature = value;
    }

}
org.junit.tools/src/org/junit/tools/generator/model/GeneratorModel.java
public class GeneratorModel {

    private JUTElements jutElements;
    private Test tmlTest;

    private HashMap<IMethod, Method> methodMap = new HashMap<IMethod, Method>();
    private List<IMethod> methodsToCreate;
    private List<IMethod> methodsToDelete;
    private HashMap<MethodRef, IMethod> existingMethods;

    /**
     * @param jutElements
     * @param tmlTest
     */
    public GeneratorModel(JUTElements jutElements, Test tmlTest) {
	this.jutElements = jutElements;
	this.tmlTest = tmlTest;
    }

    /**
     * @return JUT-elements
     */
    public JUTElements getJUTElements() {
	return jutElements;
    }

    /**
     * @param jutElements
     */
    public void setJUTElements(JUTElements jutElements) {
	this.jutElements = jutElements;
    }

    /**
     * @return TML-Test
     */
    public Test getTmlTest() {
	return tmlTest;
    }

    /**
     * @param tmlTest
     */
    public void setTmlTest(Test tmlTest) {
	this.tmlTest = tmlTest;
    }

    /**
     * @return the method map
     */
    public HashMap<IMethod, Method> getMethodMap() {
	return methodMap;
    }

    /**
     * @param methodMap
     */
    public void setMethodMap(HashMap<IMethod, Method> methodMap) {
	this.methodMap = methodMap;
    }

    public void setMethodsToCreate(List<IMethod> methodsToCreate) {
	this.methodsToCreate = methodsToCreate;
    }

    public void setMethodsToDelete(List<IMethod> methodsToDelete) {
	this.methodsToDelete = methodsToDelete;
    }

    public List<IMethod> getMethodsToCreate() {
	return methodsToCreate;
    }

    public List<IMethod> getMethodsToDelete() {
	return methodsToDelete;
    }

    public void setExistingMethods(HashMap<MethodRef, IMethod> existingMethods) {
	this.existingMethods = existingMethods;
    }

    public HashMap<MethodRef, IMethod> getExistingMethods() {
	return existingMethods;
    }
}
org.junit.tools/src/org/junit/tools/generator/model/tml/ParamAssignment.java
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ParamAssignment")
public class ParamAssignment {

    @XmlAttribute(name = "paramName")
    protected String paramName;
    @XmlAttribute(name = "assignment")
    protected String assignment;

    /**
     * Gets the value of the paramName property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getParamName() {
        return paramName;
    }

    /**
     * Sets the value of the paramName property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setParamName(String value) {
        this.paramName = value;
    }

    /**
     * Gets the value of the assignment property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getAssignment() {
        return assignment;
    }

    /**
     * Sets the value of the assignment property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setAssignment(String value) {
        this.assignment = value;
    }

}
org.junit.tools/src/org/junit/tools/generator/model/tml/Test.java
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "settings",
    "testBases",
    "method"
})
@XmlRootElement(name = "test")
public class Test {

    @XmlElement(required = true)
    protected Settings settings;
    @XmlElement(required = true)
    protected TestBases testBases;
    @XmlElement(required = true)
    protected List<Method> method;
    @XmlAttribute(name = "testBase")
    protected String testBase;
    @XmlAttribute(name = "testClass")
    protected String testClass;
    @XmlAttribute(name = "testPrio")
    protected Testprio testPrio;
    @XmlAttribute(name = "version")
    protected String version;
    @XmlAttribute(name = "superClass")
    protected String superClass;
    @XmlAttribute(name = "superClassPackage")
    protected String superClassPackage;

    /**
     * Gets the value of the settings property.
     * 
     * @return
     *     possible object is
     *     {@link Settings }
     *     
     */
    public Settings getSettings() {
        return settings;
    }

    /**
     * Sets the value of the settings property.
     * 
     * @param value
     *     allowed object is
     *     {@link Settings }
     *     
     */
    public void setSettings(Settings value) {
        this.settings = value;
    }

    /**
     * Gets the value of the testBases property.
     * 
     * @return
     *     possible object is
     *     {@link TestBases }
     *     
     */
    public TestBases getTestBases() {
        return testBases;
    }

    /**
     * Sets the value of the testBases property.
     * 
     * @param value
     *     allowed object is
     *     {@link TestBases }
     *     
     */
    public void setTestBases(TestBases value) {
        this.testBases = value;
    }

    /**
     * Gets the value of the method property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the method property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getMethod().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link Method }
     * 
     * 
     */
    public List<Method> getMethod() {
        if (method == null) {
            method = new ArrayList<Method>();
        }
        return this.method;
    }

    /**
     * Gets the value of the testBase property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getTestBase() {
        return testBase;
    }

    /**
     * Sets the value of the testBase property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setTestBase(String value) {
        this.testBase = value;
    }

    /**
     * Gets the value of the testClass property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getTestClass() {
        return testClass;
    }

    /**
     * Sets the value of the testClass property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setTestClass(String value) {
        this.testClass = value;
    }

    /**
     * Gets the value of the testPrio property.
     * 
     * @return
     *     possible object is
     *     {@link Testprio }
     *     
     */
    public Testprio getTestPrio() {
        return testPrio;
    }

    /**
     * Sets the value of the testPrio property.
     * 
     * @param value
     *     allowed object is
     *     {@link Testprio }
     *     
     */
    public void setTestPrio(Testprio value) {
        this.testPrio = value;
    }

    /**
     * Gets the value of the version property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getVersion() {
        return version;
    }

    /**
     * Sets the value of the version property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setVersion(String value) {
        this.version = value;
    }

    /**
     * Gets the value of the superClass property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getSuperClass() {
        return superClass;
    }

    /**
     * Sets the value of the superClass property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setSuperClass(String value) {
        this.superClass = value;
    }

    /**
     * Gets the value of the superClassPackage property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getSuperClassPackage() {
        return superClassPackage;
    }

    /**
     * Sets the value of the superClassPackage property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setSuperClassPackage(String value) {
        this.superClassPackage = value;
    }

}
org.junit.tools/src/org/junit/tools/generator/utils/GeneratorUtils.java
public class GeneratorUtils implements IGeneratorConstants {

	/**
	 * Creates a test-method-name.
	 * 
	 * @param methodName
	 * @return test-method-name
	 */
	public static String createTestMethodName(String methodName) {
		return createMethodName(methodName,
				JUTPreferences.getTestMethodPrefix());
	}

	/**
	 * Creates a method-name with a prefix.
	 * 
	 * @param methodName
	 * @param methodPrefix
	 * @return method-name with prefix
	 */
	public static String createMethodName(String methodName, String methodPrefix) {
		return createMethodName(methodName, methodPrefix, true);
	}

	/**
	 * Concats or replaces the methodPrefix.
	 * 
	 * @param methodName
	 * @param methodPrefix
	 * @param concat
	 *            if <code>true</code> the methodPrefix will be concat otherwise
	 *            it will be replaced
	 * @return method-name with or without prefix
	 */
	public static String createMethodName(String methodName,
			String methodPrefix, boolean concat) {
		if (concat) {
			if (methodName.length() == 0) {
				return methodPrefix;
			} else if (methodPrefix.length() == 0) {
				return methodName;
			}

			String firstLetter = String.valueOf(methodName.charAt(0))
					.toUpperCase();
			String restMethodName = methodName.substring(1);

			methodName = methodPrefix + firstLetter + restMethodName;
		} else {
			methodName = methodName.replaceFirst(methodPrefix, "");
			String firstLetter = String.valueOf(methodName.charAt(0))
					.toLowerCase();
			String restMethodName = methodName.substring(1);

			methodName = firstLetter + restMethodName;
		}

		return methodName;
	}

	public static String createMethodNameFromTest(String testMethodName) {
		return createMethodName(testMethodName,
				JUTPreferences.getTestMethodPrefix(), false);
	}

	/**
	 * Creates a class-name.
	 * 
	 * @param className
	 * @return class-name with a upper cased first letter
	 */
	public static String createTestClassName(String className) {
		if (className.length() == 0)
			return ""; //$NON-NLS-1$
		String firstLetter = String.valueOf(className.charAt(0)).toUpperCase();
		String restClassName = className.substring(1);

		String testClassPostfix = JUTPreferences.getTestClassPostfix();
		if (testClassPostfix == null) {
			testClassPostfix = "";
		}

		return firstLetter + restClassName + testClassPostfix;
	}

	/**
	 * Changes the first character to upper.
	 * 
	 * @param value
	 * @return String with a upper first character
	 */
	public static String firstCharToUpper(String value) {
		if (value != null && value.length() > 0)
			return Character.toUpperCase(value.charAt(0)) + value.substring(1);

		return value;
	}

	/**
	 * Changes the first character to lower.
	 * 
	 * @param value
	 * @return String with a lower first character
	 */
	public static String firstCharToLower(String value) {
		if (value != null && value.length() > 0)
			return Character.toLowerCase(value.charAt(0)) + value.substring(1);

		return value;
	}

	/**
	 * Compares the methods.
	 * 
	 * @param method
	 * @param tmlMethod
	 * @return true if the methods are equal
	 */
	public static boolean compareMethods(IMethod method, Method tmlMethod) {
		List<Param> tmlParams;
		ILocalVariable[] parameters;
		String paramType;

		if (tmlMethod == null) {
			if (method == null)
				return true;

			return false;
		}

		if (tmlMethod.getName() == null) {
			return false;
		}

		if (tmlMethod.getName().equals(method.getElementName())) {
			tmlParams = tmlMethod.getParam();
			try {
				parameters = method.getParameters();
			} catch (JavaModelException e) {
				throw new RuntimeException(e);
			}

			// check parameters
			if (tmlParams.size() == parameters.length) {
				for (int i = 0; i < tmlParams.size(); i++) {
					paramType = Signature.getSignatureSimpleName(parameters[i]
							.getTypeSignature());
					if (!tmlParams.get(i).getType().equals(paramType)) {
						return false;
					}
				}

				return true;
			}

		}

		return false;
	}

	/**
	 * Creates the annotation generated.
	 * 
	 * @return the created annotation
	 */
	public static String createAnnoGenerated() {
		return ANNO_GENERATED + "(value=" + QUOTES + VERSION + QUOTES + ")"
				+ RETURN;
	}

	public static String createAnnoMethodRef(IMethod method)
			throws JavaModelException {
		return createAnnoMethodRef(method.getElementName(),
				method.getSignature());
	}

	public static String createAnnoMethodRef(String methodName,
			String methodSignature) {
		return "@MethodRef(name=\"" + methodName + "\", signature=\""
				+ methodSignature + "\")";
	}

	public static HashMap<MethodRef, IMethod> getExistingTestMethods(
			ICompilationUnit cuBase, ICompilationUnit cu)
			throws JavaModelException {
		return getExistingTestMethods(cuBase, cu, false);
	}

	public static HashMap<MethodRef, IMethod> getExistingTestMethods(
			ICompilationUnit cu) throws JavaModelException {
		return getExistingTestMethods(null, cu, false);
	}

	public static HashMap<MethodRef, IMethod> getExistingTestMethods(
			ICompilationUnit cuBase, ICompilationUnit cuWithRef,
			boolean withByName) throws JavaModelException {
		HashMap<MethodRef, IMethod> existingMethods = new HashMap<MethodRef, IMethod>();

		if (cuWithRef == null) {
			return existingMethods;
		}

		IType primaryType = cuWithRef.findPrimaryType();

		if (primaryType == null) {
			return existingMethods;
		}

		IMethod[] methods = primaryType.getMethods();

		for (IMethod method : methods) {
			MethodRef mr = getMethodRef(method);

			if (mr != null) {
				existingMethods.put(mr, method);
			} else {
				if (withByName) {
					if (method.getElementName().startsWith(
							JUTPreferences.getTestMethodPrefix())) {
						// find base method
						String baseMethodName = createMethodNameFromTest(method
								.getElementName());
						List<IMethod> baseMethods = JDTUtils.getMethods(cuBase,
								false, baseMethodName);

						if (baseMethods.size() == 1) {
							IMethod baseMethod = baseMethods.get(0);
							mr = new MethodRef(baseMethod.getElementName(),
									baseMethod.getSignature());
							mr.setSignatureNew(baseMethod.getSignature());
							existingMethods.put(mr, method);
						} else {
							mr = new MethodRef(baseMethodName, "");
							mr.setUnresolvedConflict(true);
							existingMethods.put(mr, method);
						}

					}
				}
			}
		}

		if (cuBase != null) {
			checkSignatures(existingMethods, cuBase);
		}

		return existingMethods;
	}

	private static boolean matchesMethodRef(MethodRef methodRefToCheck,
			IType typeBase, Set<MethodRef> allMethodRefs)
			throws JavaModelException {

		List<IMethod> baseMethodsWithMatchingName = new ArrayList<IMethod>();

		for (IMethod method : typeBase.getMethods()) {
			if (method.getElementName().equals(methodRefToCheck.getName())) {
				if (method.getSignature().equals(
						methodRefToCheck.getSignature())) {
					return true;
				}

				baseMethodsWithMatchingName.add(method);
			}
		}

		if (baseMethodsWithMatchingName.size() == 0) {
			return false;
		} else if (baseMethodsWithMatchingName.size() == 1) {
			methodRefToCheck.setSignatureNew(baseMethodsWithMatchingName.get(0)
					.getSignature());
		} else {
			// check if method-references are available for the other methods
			boolean found;
			List<IMethod> notMatchingBaseMethods = new ArrayList<IMethod>();

			for (IMethod method : baseMethodsWithMatchingName) {
				found = false;
				for (MethodRef methodRefTmp : allMethodRefs) {
					if (isMethodRefEqual(method, methodRefTmp)) {
						found = true;
						break;
					}
				}

				if (found) {
					continue;
				} else {
					notMatchingBaseMethods.add(method);
				}

			}

			// if == 1, it is obvious
			if (notMatchingBaseMethods.size() == 1) {
				methodRefToCheck.setSignatureNew(baseMethodsWithMatchingName
						.get(0).getSignature());
				return true;
			} else {
				// unresolved method-reference conflict
				methodRefToCheck.setUnresolvedConflict(true);
				return true;
			}
		}

		return false;
	}

	public static boolean isMethodRefEqual(IMethod method, MethodRef methodRef)
			throws JavaModelException {
		return method.getElementName().equals(methodRef.getName())
				&& method.getSignature().equals(methodRef.getSignature());
	}

	public static MethodRef getMethodRef(IMethod method)
			throws JavaModelException {
		if (method == null) {
			return null;
		}

		IAnnotation annotation = method.getAnnotation("MethodRef");

		if (annotation != null && annotation.exists()) {

			boolean found = false;

			String methodName = "", methodSignature = "";

			for (IMemberValuePair valuePair : annotation.getMemberValuePairs()) {
				String valueName = valuePair.getMemberName();
				String value = valuePair.getValue().toString();

				if ("name".equals(valueName)) {
					methodName = value;
					found = true;
				} else if ("signature".equals(valueName)) {
					methodSignature = value;
				}

			}

			if (found) {
				MethodRef methodRef = new MethodRef(methodName, methodSignature);
				return methodRef;
			}
		}

		return null;
	}

	public static List<IMethod> getMethodsToCreate(
			HashMap<MethodRef, IMethod> existingMethods,
			Vector<IMethod> checkedMethods) throws JavaModelException {
		List<IMethod> methodsToCreate = new ArrayList<IMethod>();

		if (existingMethods == null || existingMethods.size() == 0) {
			return checkedMethods;
		}

		boolean found;

		for (IMethod checkedMethod : checkedMethods) {
			found = false;

			for (MethodRef methodRef : existingMethods.keySet()) {
				if (methodRef.getName().equals(checkedMethod.getElementName())) {
					if (methodRef.getSignatureToCompare().equals(
							checkedMethod.getSignature())) {
						found = true;
						break;
					}
				}
			}

			if (!found) {
				methodsToCreate.add(checkedMethod);
			}

		}

		return methodsToCreate;
	}

	/**
	 * @param type
	 * @param b
	 * @return a random value for the type
	 */
	public static String createRandomValue(String type, boolean formatValue) {
		String value;

		if (JDTUtils.isString(type) || JDTUtils.isChar(type)) {
			value = "A";
		} else if (JDTUtils.isByte(type)) {
			value = "A";
		} else if (JDTUtils.isBoolean(type)) {
			value = "false";
		} else if (JDTUtils.isNumber(type)) {
			if (JDTUtils.isDouble(type)) {
				value = "100.0";
			} else {
				value = "1";
			}
		} else {
			value = "null";
		}

		if (formatValue) {
			value = JDTUtils.formatValue(value, type);
		}

		return value;
	}

	public static List<String> createCombination(String type) {
		String initValue = JDTUtils.createInitValue(type);
		return createCombination(type, initValue);
	}

	public static List<String> createCombination(String type, String initValue) {
		List<String> combs = new ArrayList<String>();

		// add init value
		combs.add(initValue);

		// add combinations
		if (JDTUtils.isString(type) || JDTUtils.isChar(type)) {
			combs.add("null");
			combs.add("abc");
		} else if (JDTUtils.isByte(type)) {
			combs.add("A");
		} else if (JDTUtils.isBoolean(type)) {
			combs.add("true");
		} else if (JDTUtils.isNumber(type)) {
			if (JDTUtils.isDouble(type)) {
				double value;
				try {
					value = Double.parseDouble(initValue);
				} catch (NumberFormatException exception) {
					value = 0.0;
				}

				combs.add(Double.toString(value - 1));
				combs.add(Double.toString(value + 1));
			} else {
				int value;
				try {
					value = Integer.parseInt(initValue);
				} catch (NumberFormatException exception) {
					value = 0;
				}

				combs.add(Integer.toString(value - 1));
				combs.add(Integer.toString(value + 1));
			}
		}

		for (int i = 0; i < combs.size(); i++) {
			String value = combs.get(i);
			combs.set(i, JDTUtils.formatValue(value, type));
		}

		return combs;
	}

	public static boolean checkMethodReference(String baseMethodName,
			String baseMethodSignature, IMethod methodToCheck)
			throws JavaModelException {
		IAnnotation anno = methodToCheck.getAnnotation("MethodRef");

		if (anno == null || !anno.exists()) {
			return false;
		}

		IMemberValuePair[] valuePair = anno.getMemberValuePairs();
		boolean signatureFound = false, nameFound = false;

		for (IMemberValuePair vP : valuePair) {
			Object o = vP.getValue();
			if (o != null) {
				String methodRefValue = o.toString();

				if ("signature".equals(vP.getMemberName())) {
					if (methodRefValue.equals(baseMethodSignature)) {
						signatureFound = true;
					} else {
						return false;
					}
				} else if ("name".equals(vP.getMemberName())) {
					if (methodRefValue.equals(baseMethodName)) {
						nameFound = true;
					} else {
						return false;
					}
				}
			}
		}

		return signatureFound && nameFound;

	}

	public static boolean checkMethodReferenceAndName(String baseMethodName,
			String baseMethodSignature, String nameToCheck,
			IMethod methodToCheck) throws JavaModelException {
		// check by method-reference
		if (checkMethodReference(baseMethodName, baseMethodSignature,
				methodToCheck)) {
			return true;
		}

		// check by name

		if (nameToCheck != null
				&& nameToCheck.equals(methodToCheck.getElementName())) {
			return true;
		}

		return false;
	}

	public static void checkSignatures(
			HashMap<MethodRef, IMethod> existingMethods, ICompilationUnit cuBase)
			throws JavaModelException {

		IType typeBase = cuBase.findPrimaryType();

		for (Entry<MethodRef, IMethod> entry : existingMethods.entrySet()) {
			if (matchesMethodRef(entry.getKey(), typeBase,
					existingMethods.keySet())) {
				continue;
			}

			// handle conflict
		}

	}

	public static IMethod findMethod(Collection<IMethod> methods,
			MethodRef methodRef) throws JavaModelException {
		boolean nameMatched;
		IMethod nameMatchedMethod = null;
		int nameMatchedCounter = 0;

		for (IMethod method : methods) {

			nameMatched = false;

			if (methodRef.getName().equals(method.getElementName())) {
				if (methodRef.getSignature().equals(method.getSignature())) {
					return method;
				} else {
					nameMatched = true;
				}
			}

			MethodRef methodRefTarget = getMethodRef(method);
			String baseMethodName = createMethodNameFromTest(methodRef
					.getName());
			if (methodRefTarget != null
					&& methodRefTarget.getName().equals(baseMethodName)
					&& methodRefTarget.getSignatureToCompare().equals(
							methodRef.getSignatureToCompare())) {
				return method;
			}

			if (nameMatched) {
				nameMatchedCounter++;
				nameMatchedMethod = method;
			}

		}

		if (nameMatchedCounter == 1) {
			return nameMatchedMethod;
		}

		return null;
	}

	/**
	 * @param methodRefs
	 * @param method
	 * @return the
	 * @throws JavaModelException
	 */
	public static IMethod findMethod(Collection<MethodRef> methodRefs,
			IMethod method) throws JavaModelException {
		for (MethodRef methodRef : methodRefs) {
			if (methodRef.getName().equals(method.getElementName())
					&& methodRef.getSignature().equals(method.getSignature())) {
				return method;
			}
		}

		return null;
	}

	public static List<IMethod> getMethodsToDelete(
			HashMap<MethodRef, IMethod> existingMethods,
			Vector<IMethod> checkedMethods) throws JavaModelException {
		List<IMethod> methodsToDelete = new ArrayList<IMethod>();
		boolean found;

		if (existingMethods == null) {
			return methodsToDelete;
		}

		MethodRef methodRef;
		for (Entry<MethodRef, IMethod> method : existingMethods.entrySet()) {
			found = false;
			methodRef = method.getKey();

			if (methodRef.isUnresolvedConflict()) {
				continue;
			}

			for (IMethod checkedMethod : checkedMethods) {
				if (methodRef.isEquals(checkedMethod)) {
					found = true;
					break;

				}
			}

			if (!found) {
				methodsToDelete.add(method.getValue());
			}

		}

		return methodsToDelete;
	}

	/**
	 * Searches the closest method.
	 * 
	 * @param method
	 * @param tmlMethods
	 * @return closest method
	 */
	public static Method getClosestMethod(IMethod method,
			List<Method> tmlMethods) {
		Method tmlMethodTmp = null;
		for (Method tmlMethod : tmlMethods) {
			if (compareMethods(method, tmlMethod)) {
				if (JDTUtils.isMethodModifierEqual(method,
						tmlMethod.getModifier())) {
					return tmlMethod;
				}
				tmlMethodTmp = tmlMethod;
			}
		}

		return tmlMethodTmp;
	}

	/**
	 * checks if the type belongs to a test-class
	 * 
	 * @param type
	 * @return true if it is a test-class
	 */
	public static boolean isTestClass(IType type) {
		if (type == null) {
			return false;
		}
		
		String elementName = type.getElementName();
		
		String projectPostfix = JUTPreferences.getTestProjectPostfix();
		String packagePostfix = JUTPreferences.getTestPackagePostfix();
		String testclassPrefix = JUTPreferences.getTestClassPrefix();
		String testclassPostfix = JUTPreferences.getTestClassPostfix();
		
		if (testclassPrefix != null && !"".equals(testclassPrefix)) {
			if (!elementName.startsWith(testclassPrefix)) {
				return false;
			}
		}
		
		if (testclassPostfix != null && !"".equals(testclassPostfix)) {
			if (!elementName.endsWith(testclassPostfix)) {
				return false;
			}
		}
		
		if (projectPostfix != null && !"".equals(projectPostfix)) {
			IJavaProject javaProject = type.getJavaProject();
			elementName = javaProject.getElementName();
			if (!elementName.endsWith(projectPostfix)) {
				return false;
			}
		}
		
		if (packagePostfix != null && !"".equals(packagePostfix)) {
			IPackageFragment pack = type.getPackageFragment();
			elementName = pack.getElementName();
			if (!elementName.endsWith(packagePostfix)) {
				return false;
			}
		}
		
		return true;
	}

	public static String getMockedClassName(IType type) throws JavaModelException {
		String mockedClassName = null; 
		String superclassName = type.getSuperclassName();
		if (superclassName != null && superclassName.indexOf("MockUp<") > -1) {
			int ixStart = superclassName.indexOf("<") + 1;
			int ixEnd = superclassName.indexOf(">");

			mockedClassName = superclassName.substring(ixStart, ixEnd);
		}
		
		// mocked name via name conventions
		if (mockedClassName == null) {
			String elementName = type.getElementName();

			// TODO mock-postfix
			if (elementName.endsWith("Mock")) {
				int endIndex = elementName.indexOf("Mock");
				mockedClassName = elementName.substring(0, endIndex);
			}
			else {
				mockedClassName = elementName;
			}
		}
		
		return mockedClassName;
	}
}
org.junit.tools/src/org/junit/tools/generator/model/tml/AssertionType.java
@XmlType(name = "AssertionType")
@XmlEnum
public enum AssertionType {

    IS_NULL,
    NOT_NULL,
    EQUALS,
    NOT_EQUALS,
    IS_TRUE,
    IS_FALSE,
    CREATER_THAN,
    LOWER_THAN;

    public String value() {
        return name();
    }

    public static AssertionType fromValue(String v) {
        return valueOf(v);
    }

}
org.junit.tools/src/org/junit/tools/generator/model/tml/Result.java
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Result", propOrder = {
    "value"
})
public class Result {

    @XmlElement(required = true)
    protected String value;
    @XmlAttribute(name = "name")
    protected String name;
    @XmlAttribute(name = "type")
    protected String type;

    /**
     * Gets the value of the value property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getValue() {
        return value;
    }

    /**
     * Sets the value of the value property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setValue(String value) {
        this.value = value;
    }

    /**
     * Gets the value of the name property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getName() {
        return name;
    }

    /**
     * Sets the value of the name property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setName(String value) {
        this.name = value;
    }

    /**
     * Gets the value of the type property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getType() {
        return type;
    }

    /**
     * Sets the value of the type property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setType(String value) {
        this.type = value;
    }

}
org.junit.tools/src/org/junit/tools/generator/utils/JDTUtils.java
public class JDTUtils implements IGeneratorConstants {

	private static Logger logger = Logger.getLogger(JDTUtils.class.getName());

	private static ICompilationUnit lastParsedCu = null;

	private static CompilationUnit parsedCu = null;

	/**
	 * Creates a AST-root from a compilation unit an caches it (only the last
	 * one).
	 * 
	 * @param cu
	 * @return CompilationUnit
	 * @throws JavaModelException
	 */
	public static CompilationUnit createASTRoot(ICompilationUnit cu)
			throws JavaModelException {
		// creation of DOM/AST from a ICompilationUnit (without caching)
		// if (lastParsedCu != null && lastParsedCu.getSource().length() ==
		// cu.getSource().length()) {
		// return parsedCu;
		// }
		// lastParsedCu = cu;

		ASTParser parser = createASTParser(cu);
		parsedCu = (CompilationUnit) parser.createAST(null);

		return parsedCu;
	}

	/**
	 * Collects the compilation units.
	 * 
	 * @param javaElements
	 * @param compilationUnits
	 * @throws JavaModelException
	 */
	private static void collectCompilationUnits(IJavaElement[] javaElements,
			Vector<IJavaElement> compilationUnits, String filter)
			throws JavaModelException {
		for (IJavaElement javaElement : javaElements) {
			collectCompilationUnits(javaElement, compilationUnits, filter);
		}
	}

	public static Vector<IJavaElement> collectCompilationUnits(
			List<IJavaProject> javaProjects) throws JavaModelException {
		Vector<IJavaElement> compilationUnits = new Vector<IJavaElement>();
		for (IJavaElement javaProject : javaProjects) {
			collectCompilationUnits(javaProject, compilationUnits, "");
		}
		return compilationUnits;
	}

	public static void collectCompilationUnits(IJavaElement javaElement,
			Vector<IJavaElement> compilationUnits) throws JavaModelException {
		collectCompilationUnits(javaElement, compilationUnits, "");
	}

	public static Vector<IJavaElement> collectCompilationUnits(
			IJavaElement javaElement) throws JavaModelException {
		Vector<IJavaElement> selectedCompilationUnits = new Vector<IJavaElement>();
		collectCompilationUnits(javaElement, selectedCompilationUnits, null);
		return selectedCompilationUnits;
	}

	/**
	 * Collects the compilation units.
	 * 
	 * @param javaElement
	 * @param selectedCompilationUnits
	 * @throws JavaModelException
	 */
	public static void collectCompilationUnits(IJavaElement javaElement,
			Vector<IJavaElement> selectedCompilationUnits, String filter)
			throws JavaModelException {

		switch (javaElement.getElementType()) {
		case IJavaElement.FIELD:
			addCompilationUnit(selectedCompilationUnits,
					((IField) javaElement).getCompilationUnit(), filter);
			break;
		case IJavaElement.METHOD:
			addCompilationUnit(selectedCompilationUnits,
					((IMethod) javaElement).getCompilationUnit(), filter);
			break;
		case IJavaElement.JAVA_MODEL:
			break;
		case IJavaElement.JAVA_PROJECT:
			collectCompilationUnits(((IJavaProject) javaElement).getChildren(),
					selectedCompilationUnits, filter);
			break;
		case IJavaElement.PACKAGE_FRAGMENT_ROOT:
			collectCompilationUnits(
					((IPackageFragmentRoot) javaElement).getChildren(),
					selectedCompilationUnits, filter);
			break;
		case IJavaElement.PACKAGE_FRAGMENT:
			collectCompilationUnits((IPackageFragment) javaElement,
					selectedCompilationUnits, filter);
			break;
		case IJavaElement.COMPILATION_UNIT:
			addCompilationUnit(selectedCompilationUnits,
					(ICompilationUnit) javaElement, filter);
			break;
		case IJavaElement.TYPE:
			addCompilationUnit(selectedCompilationUnits, (IType) javaElement,
					filter);
			break;
		case IJavaElement.CLASS_FILE:
			addCompilationUnit(selectedCompilationUnits,
					(IClassFile) javaElement, filter);
			break;
		default:
		}
	}

	private static void addCompilationUnit(
			Vector<IJavaElement> selectedCompilationUnits,
			IClassFile classFile, String filter) {
		selectedCompilationUnits.add(classFile);
	}

	private static void addCompilationUnit(
			Vector<IJavaElement> selectedCompilationUnits, IType type,
			String filter) {
		addCompilationUnit(selectedCompilationUnits, type.getCompilationUnit(),
				filter);
	}

	private static void addCompilationUnit(
			Vector<IJavaElement> selectedCompilationUnits, ICompilationUnit cu,
			String filter) {
		if (filter == null || "".equals(filter)) {
			selectedCompilationUnits.add(cu);
		} else if (cu.getElementName().startsWith(filter)) {
			selectedCompilationUnits.add(cu);
		}

	}

	/**
	 * Collect the compilation units.
	 * 
	 * @param pkgFrgmt
	 * @param selectedCompilationUnits
	 * @throws JavaModelException
	 */
	private static void collectCompilationUnits(IPackageFragment pkgFrgmt,
			Vector<IJavaElement> selectedCompilationUnits, String filter)
			throws JavaModelException {
		ICompilationUnit[] compilationUnits = pkgFrgmt.getCompilationUnits();
		for (ICompilationUnit cu : compilationUnits) {
			addCompilationUnit(selectedCompilationUnits, cu, filter);
		}
	}

	public static IJavaProject getProject(ISelection selection)
			throws JUTWarning {
		return getProject(selection, null);
	}

	/**
	 * @param selection
	 * @param fileEditorInput
	 * @return java-project from the selection or from the editor.
	 * @throws JUTWarning
	 */
	public static IJavaProject getProject(ISelection selection,
			IFileEditorInput fileEditorInput) throws JUTWarning {
		Object firstElement;
		IProject project = null;

		if (fileEditorInput != null) {
			firstElement = fileEditorInput;
		} else {
			firstElement = EclipseUIUtils.getFirstSelectedElement(selection);

			if (firstElement == null) {
				return null;
			}
		}

		if (firstElement instanceof IJavaElement) {
			return getProject((IJavaElement) firstElement);
		} else if (firstElement instanceof IJavaProject) {
			return (IJavaProject) firstElement;
		}
		if (firstElement instanceof IProject) {
			project = (IProject) firstElement;
		} else if (firstElement instanceof IFile) {
			IFile file = (IFile) firstElement;
			project = file.getProject();
		} else if (firstElement instanceof IFileEditorInput) {
			IFileEditorInput fileEditorInputTmp = (IFileEditorInput) firstElement;
			project = fileEditorInputTmp.getFile().getProject();
		} else if (firstElement instanceof ICompilationUnit) {
			ICompilationUnit compilationUnit = (ICompilationUnit) firstElement;
			return compilationUnit.getJavaProject();
		}

		if (project == null) {
			return null;
		}

		return convertToJavaProject(project);
	}

	/**
	 * @param project
	 * @return converted java project
	 * @throws JUTWarning
	 */
	public static IJavaProject convertToJavaProject(IProject project)
			throws JUTWarning {
		IJavaProject jProject;
		try {
			if (project.hasNature(JavaCore.NATURE_ID)) {
				jProject = JavaCore.create(project);
			} else {
				throw new JUTWarning(Messages.GeneratorUtils_OnlyJavaProjects);
			}
		} catch (CoreException e) {
			return null;
		}

		return jProject;
	}

	public static IFolder createFolder(IJavaProject jproject, String folderName) {
		// folderName = folderName.replace(".", "/");
		IFolder folder = jproject.getProject().getFolder(folderName);
		return createFolder(jproject, folder);
	}

	private static IFolder createFolder(IJavaProject jproject, IFolder folder) {
		try {
			if (!folder.exists()) {
				folder.create(true, true, null);
			}

		} catch (Exception e) {
			logger.severe(e.getMessage());
			throw new RuntimeException(
					Messages.GeneratorUtils_ErrorPackageCreation);
		}

		return folder;
	}

	@Deprecated
	public static IPackageFragment getPackage(IJavaProject javaProject,
			String name, boolean createIfNotExists) throws CoreException,
			JUTWarning {
		return getPackage(javaProject, "src", name, createIfNotExists);
	}

	public static IPackageFragment getPackage(IJavaProject javaProject,
			String name, IFolder srcFolder, boolean createIfNotExists)
			throws CoreException {
		// create package fragment
		IPackageFragmentRoot parentFolder = javaProject
				.getPackageFragmentRoot(srcFolder);

		return getPackage(javaProject, parentFolder, name, createIfNotExists);
	}

	public static IPackageFragment getPackage(IJavaProject javaProject,
			String srcFolder, String name, boolean createIfNotExists)
			throws CoreException, JUTWarning {
		String srcFolderName = "";

		if (srcFolder == null || "".equals(srcFolder)) {
			srcFolderName = "src";
		} else {
			srcFolderName = srcFolder;
		}

		IFolder folder = javaProject.getProject().getFolder(srcFolderName);

		if (!folder.exists()) {
			if (createIfNotExists) {
				createSourceFolder(javaProject, folder);
			} else {
				return null;
			}
		}

		return getPackage(javaProject, name, folder, createIfNotExists);
	}
	
	public static boolean existsClassPathEntry(IJavaProject project, IPath path) throws JavaModelException {

		for (IClasspathEntry classpath : project.getRawClasspath()) {
			if (classpath.getPath().equals(path) ) {
				return true;
			}
		}
		return false;
	}
	
	public static void addClassPathEntry(IJavaProject project, IPath path) {
		
	}

	public static IPackageFragmentRoot createSourceFolder(
			IJavaProject javaProject, IPath folderPath) throws CoreException,
			JUTWarning {
		IFolder folder = javaProject.getProject().getFolder(folderPath);
		
		if (!folder.exists()) {
			return createSourceFolder(javaProject, folder);
		}
		else {
			IPackageFragmentRoot root = javaProject.getPackageFragmentRoot(folder);
			
			if (!existsClassPathEntry(javaProject, root.getPath())) {
				addPathToClasspath(javaProject, root.getPath());	
			}
		}

		return javaProject.getPackageFragmentRoot(folder);
	}

	public static IPackageFragmentRoot createSourceFolder(
			IJavaProject javaProject, IFolder folder) throws CoreException,
			JUTWarning {

		IPath fullPath = folder.getFullPath();

		fullPath = fullPath.removeFirstSegments(1); // without project

		IFolder tmpFolder = null;
		for (String segment : fullPath.segments()) {
			if (segment.indexOf(".") > 0) {
				throw new JUTWarning("Dots are not supported in folder names");
			}

			// nested folders
			if (tmpFolder != null) {
				tmpFolder = tmpFolder.getFolder(segment);
			} else {
				tmpFolder = javaProject.getProject().getFolder(segment);
			}

			if (!tmpFolder.exists()) {
				tmpFolder.create(true, true, null);
			}
		}

		return createSourceFolder(javaProject, tmpFolder, null);
	}

	private static IPackageFragmentRoot createSourceFolder(
			IJavaProject javaProject, IFolder folder, IPath parentPath)
			throws CoreException {
		// create default folder
		if (folder == null) {
			folder = javaProject.getProject().getFolder("src");
		}

		// create only if exists
		if (!folder.exists()) {
			folder.create(true, true, null);
		}

		// add new folder to class path
		IPackageFragmentRoot root = javaProject.getPackageFragmentRoot(folder);
		addPathToClasspath(javaProject, root.getPath());
		return root;
	}

	private static void addPathToClasspath(IJavaProject javaProject, IPath path) throws JavaModelException {
		IClasspathEntry[] oldEntries = javaProject.getRawClasspath();
		IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1];
		System.arraycopy(oldEntries, 0, newEntries, 1, oldEntries.length);
		newEntries[0] = JavaCore.newSourceEntry(path);
		javaProject.setRawClasspath(newEntries, null);
	}

	public static IPackageFragment getPackage(IJavaProject javaProject,
			IPackageFragmentRoot srcFolder, String name,
			boolean createIfNotExists) throws CoreException {
		IPackageFragment packageFragment = srcFolder.getPackageFragment(name);
		if (packageFragment == null || !packageFragment.exists()) {
			if (createIfNotExists) {
				packageFragment = srcFolder.createPackageFragment(name, true,
						null);
			} else {
				packageFragment = srcFolder.getPackageFragment(name);
			}
		}

		return packageFragment;
	}

	public static List<IPackageFragment> getSubPackages(IPackageFragment p)
			throws JavaModelException {
		List<IPackageFragment> result = new ArrayList<IPackageFragment>();
		IJavaElement[] children = ((IPackageFragmentRoot) p.getParent())
				.getChildren();

		for (IJavaElement element : children) {
			if (element instanceof IPackageFragment) {
				if (isParentPackage(p.getElementName(),
						element.getElementName())) {
					result.add((IPackageFragment) element);
				}
			}
		}

		return result;
	}

	/**
	 * creates source- and package-folders
	 * 
	 * @param name
	 * @throws CoreException
	 * @throws JUTWarning
	 */
	public static IPackageFragment createPackage(IJavaProject javaProject,
			String name) throws CoreException, JUTWarning {
		return getPackage(javaProject, name, true);
	}

	/**
	 * creates src- and package-folders
	 * 
	 * @param name
	 * @throws CoreException
	 * @throws JUTWarning
	 */
	public static IPackageFragment createPackage(IJavaProject javaProject,
			String parentFolderName, String name) throws CoreException,
			JUTWarning {
		IFolder folder = javaProject.getProject().getFolder(parentFolderName);

		IPackageFragmentRoot parentFolder = null;
		if (!folder.exists()) {
			parentFolder = createSourceFolder(javaProject, folder);
		} else {
			parentFolder = javaProject.getPackageFragmentRoot(folder);
		}

		// create package fragment
		IPackageFragment packageFragment = parentFolder
				.getPackageFragment(name);
		if (packageFragment == null || !packageFragment.exists()) {
			packageFragment = parentFolder.createPackageFragment(name, true,
					null);
		}

		return packageFragment;
	}

	public static IJavaProject createProject(String name) throws CoreException {
		return createProject(name, null);
	}

	/**
	 * Creates a java project.
	 * 
	 * @param name
	 * @param baseProject
	 * @return the created java project
	 * @throws CoreException
	 */
	public static IJavaProject createProject(String name,
			IJavaProject baseProject) throws CoreException {
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
		IWorkspaceRoot root = workspace.getRoot();

		IProject project = root.getProject(name);

		if (project.exists())
			return JavaCore.create(project);

		// create if not exists
		project.create(null);
		project.open(null);

		// transfer the project-nature
		IProjectDescription description = project.getDescription();
		description.setNatureIds(new String[] { JavaCore.NATURE_ID });
		project.setDescription(description, null);

		// create Java-Project
		IJavaProject javaProject = JavaCore.create(project);
		javaProject.save(null, true);
		
		// create source folder
		IFolder sourceFolder = project.getFolder("src");
		if (!sourceFolder.exists()) {
			sourceFolder.create(false, true, null);	

			// add source folder to class path
			try {
				IPackageFragmentRoot rootPckg = javaProject.getPackageFragmentRoot(sourceFolder);
				IClasspathEntry[] oldEntries = javaProject.getRawClasspath();
				IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1];
				System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length);
				newEntries[oldEntries.length] = JavaCore.newSourceEntry(rootPckg.getPath());
				javaProject.setRawClasspath(newEntries, null);			
			}
			catch (Exception e) {
				// nothing
			}
		}

 
		if (baseProject != null) {
			description.setNatureIds(baseProject.getProject().getDescription()
					.getNatureIds());
			
			Vector<IClasspathEntry> buildPath = new Vector<IClasspathEntry>();
			for (IClasspathEntry entry : baseProject.getRawClasspath()) {
				if (!(entry.getEntryKind() == IClasspathEntry.CPE_SOURCE))
					buildPath.add(entry);
			}

			// add source-path
			buildPath.add(JavaCore.newSourceEntry(javaProject.getPath().append(
					"src"))); //$NON-NLS-1$
			// add base-project-path
			buildPath.add(JavaCore.newProjectEntry(baseProject.getPath()));

			// set the path
			IClasspathEntry[] entries = new IClasspathEntry[buildPath.size()];
			entries = buildPath.toArray(entries);
			javaProject.setRawClasspath(entries, null);
		}

		return javaProject;
	}

	/**
	 * Returns the java project.
	 * 
	 * @return java project
	 */
	public static IJavaProject getProject(IJavaElement javaElement) {
		return (IJavaProject) javaElement
				.getAncestor(IJavaElement.JAVA_PROJECT);
	}

	/**
	 * Returns the java project.
	 * 
	 * @param name
	 * @return java project
	 * @throws JUTWarning
	 */
	public static IJavaProject getProject(String name) throws JUTWarning {
		return getProject(name, false, null);
	}

	/**
	 * Gets or creates a java project.
	 * 
	 * @param name
	 * @param createIfNotExists
	 * @param baseProject
	 * @return the java project
	 * @throws JUTWarning
	 */
	public static IJavaProject getProject(String name,
			boolean createIfNotExists, IJavaProject baseProject)
			throws JUTWarning {
		for (IProject project : getProjects()) {
			if (project.getName().equals(name)) {
				return convertToJavaProject(project);
			}
		}

		// create project
		if (createIfNotExists) {
			try {
				return createProject(name, baseProject);
			} catch (CoreException e) {
				throw new RuntimeException(e);
			}
		}

		return null;
	}

	/**
	 * Returns the projects from the workspace.
	 * 
	 * @return projects
	 */
	public static IProject[] getProjects() {
		IProject[] projects = ResourcesPlugin.getWorkspace().getRoot()
				.getProjects();
		return projects;
	}

	public static List<IJavaProject> getJavaProjects() {
		List<IJavaProject> javaProjects = new ArrayList<IJavaProject>();
		IJavaProject javaProject;

		for (IProject project : getProjects()) {
			try {
				javaProject = convertToJavaProject(project);
			} catch (Exception ex) {
				continue;
			}

			if (javaProject != null) {
				javaProjects.add(javaProject);
			}
		}

		return javaProjects;
	}

	/**
	 * Returns the package.
	 * 
	 * @param javaElement
	 * @return the package
	 */
	public static IPackageFragment getPackage(IJavaElement javaElement) {
		IJavaElement tmp = javaElement
				.getAncestor(IJavaElement.PACKAGE_FRAGMENT);

		if (tmp == null)
			return null;

		return (IPackageFragment) tmp;
	}
	
	
	public static IPackageFragmentRoot getPackageFragmentRoot(IJavaElement javaElement) {
		IJavaElement tmp = javaElement
				.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);

		if (tmp == null)
			return null;

		return (IPackageFragmentRoot) tmp;
	}	

	/**
	 * Creates a method.
	 * 
	 * @param type
	 * @param modifier
	 * @param returnType
	 * @param methodName
	 * @param throwsClause
	 * @param params
	 * @param body
	 * @param annotations
	 * @return the created method
	 * @throws JavaModelException
	 */
	public static IMethod createMethod(IType type, String modifier,
			String returnType, String methodName, String throwsClause,
			String params, String body, String... annotations)
			throws JavaModelException {
		return createMethod(type, modifier, returnType, methodName,
				throwsClause, params, body, true, annotations);
	}

	/**
	 * Creates a method.
	 * 
	 * @param type
	 * @param modifier
	 * @param returnType
	 * @param methodName
	 * @param throwsClause
	 * @param params
	 * @param body
	 * @param increment
	 * @param annotations
	 * @return the created method
	 * @throws JavaModelException
	 */
	public static IMethod createMethod(IType type, String modifier,
			String returnType, String methodName, String throwsClause,
			String params, String body, boolean increment,
			String... annotations) throws JavaModelException {
		return createMethod(type, modifier, returnType, methodName,
				throwsClause, params, body, true, false, annotations);
	}

	/**
	 * @param type
	 * @param method
	 * @return created method
	 * @throws JavaModelException
	 */
	public static IMethod createMethod(IType type, IMethod method, String body,
			String annotations) throws JavaModelException {
		return createMethod(type, method, method.getElementName(), body,
				annotations);
	}

	/**
	 * @param type
	 * @param method
	 * @return created method
	 * @throws JavaModelException
	 */
	public static IMethod createMethod(IType type, IMethod method,
			String methodName, String body, String annotations)
			throws JavaModelException {
		String modifier = getMethodModifier(method);
		String returnType = createReturnType(method.getReturnType());
		String params = createParamList(method);

		String throwsClause = "";
		String comma = "";
		for (String exceptionType : method.getExceptionTypes()) {
			throwsClause = comma + exceptionType;
			comma = ",";
		}

		return createMethod(type, modifier, returnType, methodName,
				throwsClause, params, body, false, true, annotations);
	}

	/**
	 * @param type
	 * @param method
	 * @return created method
	 * @throws JavaModelException
	 */
	public static IMethod createMethod(IType type, IMethod method)
			throws JavaModelException {
		String returnType = createReturnType(method.getReturnType());
		String body = "";
		if (!TYPE_VOID.equals(returnType)) {
			body = "return " + createInitValue(returnType, true) + ";";
		}

		return createMethod(type, method, body, "");
	}

	/**
	 * @param type
	 * @param method
	 * @return created method
	 * @throws JavaModelException
	 */
	public static IMethod createMethod(IType type, IMethod method,
			String annotation) throws JavaModelException {
		String returnType = createReturnType(method.getReturnType());
		String body = "";
		if (!TYPE_VOID.equals(returnType)) {
			body = "return " + createInitValue(returnType, true) + ";";
		}

		return createMethod(type, method, body, annotation);
	}

	public static IMethod createMethod(IType type, String modifier,
			String returnType, String methodName, String throwsClause,
			String params, String body, boolean increment, boolean force,
			String... annotations) throws JavaModelException {
		IMethod tmpMethod = type.getMethod(methodName, null); // TODO mit
		// parametern
		StringBuilder sbMethod = new StringBuilder();

		if (force && tmpMethod.exists()) {
			tmpMethod.delete(true, null);
		}

		if (increment) {
			while (tmpMethod.exists()) {
				methodName = increment(methodName, "_"); //$NON-NLS-1$
				tmpMethod = type.getMethod(methodName, null);
			}
		}

		// if (tmpMethod.exists()) {
		// logger.fine(Messages.GeneratorUtils_MethodExists + methodName);
		// return tmpMethod;
		// }

		if (annotations != null) {
			for (String annotation : annotations) {
				if (!annotation.startsWith("@")) { //$NON-NLS-1$
					annotation = "@" + annotation; //$NON-NLS-1$
				}

				sbMethod.append(annotation);
				sbMethod.append("\n"); //$NON-NLS-1$
			}
		}

		if (throwsClause != null && throwsClause.length() > 0) {
			throwsClause = "throws " + throwsClause; //$NON-NLS-1$
		} else
			throwsClause = ""; //$NON-NLS-1$

		if (returnType == null)
			returnType = ""; //$NON-NLS-1$

		if (params == null)
			params = ""; //$NON-NLS-1$

		sbMethod.append(modifier)
				.append(" ").append(returnType).append(" ").append(methodName) //$NON-NLS-1$ //$NON-NLS-2$
				.append("(").append(params).append(") " + throwsClause + " {\n").append(body) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
				.append("\n}"); //$NON-NLS-1$

		try {
			tmpMethod = type.createMethod(sbMethod.toString(), null, force,
					null);
		} catch (Exception ex) {
			logger.severe(ExceptionUtils.getFullStackTrace(ex));
		}

		return tmpMethod;
	}

	/**
	 * Increments a method name.
	 * 
	 * @param input
	 * @param incrementSeperator
	 * @return incremented method name
	 */
	public static String increment(String input, String incrementSeperator) {
		if (incrementSeperator == null) {
			incrementSeperator = INCREMENT_SEPERATOR;
		}

		int inputLength = input.length();
		int incrementSeperatorIx = getIncrementSeperatorIndex(input,
				incrementSeperator);

		if (incrementSeperatorIx != -1) {
			int firstNumberIndex = incrementSeperatorIx + 1;
			int postfixNumber;
			if (firstNumberIndex < inputLength) {
				postfixNumber = Integer.parseInt(input.substring(
						incrementSeperatorIx + 1, inputLength));
			} else {
				postfixNumber = 0;
			}
			postfixNumber++;

			input = input.substring(0, incrementSeperatorIx + 1)
					+ postfixNumber;
		} else {
			// first increment
			input += incrementSeperator + "1"; //$NON-NLS-1$
		}

		return input;
	}

	private static int getIncrementSeperatorIndex(String input,
			String incrementSeperator) {
		if (incrementSeperator == null) {
			incrementSeperator = INCREMENT_SEPERATOR;
		}

		String lastLetter = ""; //$NON-NLS-1$
		int inputLength = input.length();
		int lastLetterIndex = inputLength - 1;

		for (int i = lastLetterIndex; i >= 0; i--) {
			lastLetter = input.substring(i, i + 1);

			try {
				Integer.parseInt(lastLetter);
			} catch (NumberFormatException e) {
				lastLetterIndex = i;
				break;
			}
		}

		if (lastLetter.equals(incrementSeperator)) {
			return lastLetterIndex;
		}

		return -1;

	}

	public static List<IMethod> getMethods(IJavaElement javaElement,
			boolean withSubTypes) throws JavaModelException {
		return getMethods(javaElement, withSubTypes, null);
	}

	public static List<IMethod> getMethods(IJavaElement javaElement,
			boolean withSubTypes, String nameFilter) throws JavaModelException {
		return getMethods(javaElement, withSubTypes, nameFilter, false, null);
	}

	public static List<IMethod> getMethods(IJavaElement javaElement,
			boolean withSubTypes, String nameFilter, boolean startsWith,
			String modifierFilter) throws JavaModelException {
		List<IMethod> methods = new ArrayList<IMethod>();

		IType[] types;
		ICompilationUnit cu = null;

		if (javaElement instanceof ICompilationUnit) {
			cu = (ICompilationUnit) javaElement;
			types = cu.getAllTypes();
		} else if (javaElement instanceof IClassFile) {
			javaElement = ((IClassFile) javaElement).findPrimaryType();
		}

		if (javaElement instanceof IType) {
			return getMethods((IType) javaElement, nameFilter, startsWith,
					modifierFilter);
		}

		if (cu == null) {
			return methods;
		}

		if (withSubTypes) {
			types = cu.getAllTypes();
		} else {
			types = new IType[1];
			types[0] = cu.findPrimaryType();
		}

		for (IType type : types) {
			methods.addAll(getMethods(type, nameFilter, startsWith,
					modifierFilter));
		}

		return methods;
	}

	public static List<IMethod> getMethods(IType type, String nameFilter,
			boolean startsWith, String modifierFilter)
			throws JavaModelException {
		List<IMethod> methods = new ArrayList<IMethod>();
		for (IMethod method : type.getMethods()) {

			if (validateMethod(method, nameFilter, startsWith, modifierFilter)) {
				methods.add(method);
			}

		}

		return methods;
	}

	public static boolean validateMethod(IMethod method, String nameFilter,
			boolean startsWith, String modifierFilter)
			throws JavaModelException {
		String methodName = method.getElementName();

		if (nameFilter != null) {
			if (startsWith) {
				if (!methodName.startsWith(nameFilter)) {
					return false;
				}
			} else if (!nameFilter.equals(methodName)) {
				return false;
			}
		}

		if (modifierFilter != null) {
			String methodModifier = getMethodModifier(method);
			if (!modifierFilter.equals(methodModifier)) {
				return false;
			}
		}

		return true;
	}

	public static List<IMethod> getMethods(ICompilationUnit cu)
			throws JavaModelException {
		return getMethods(cu, true);
	}

	public static MethodDeclaration createMethodDeclaration(CompilationUnit cu,
			IMethod method) {
		ASTNode declaringNode = null;
		if (method.isResolved()) {
			declaringNode = cu.findDeclaringNode(method.getKey());
		} else {
			for (IBinding binding : createBindings(method.getCompilationUnit(),
					method)) {
				if (binding instanceof IMethodBinding) {
					declaringNode = cu
							.findDeclaringNode(((IMethodBinding) binding)
									.getKey());
					break;
				}
			}
		}

		if (!(declaringNode instanceof MethodDeclaration)) {
			return null;
		}

		return (MethodDeclaration) declaringNode;
	}

	public static int getIncrement(String input, String incrementSeperator) {
		if (incrementSeperator == null) {
			incrementSeperator = INCREMENT_SEPERATOR;
		}

		int incrementIx = getIncrementSeperatorIndex(input, incrementSeperator);

		if (incrementIx != -1) {
			try {
				return Integer.parseInt(input.substring(incrementIx + 1));
			} catch (NumberFormatException ex) {
				// nothing
			}
		}

		return -1;
	}

	public static MethodDeclaration getASTMethod(ASTNode node) {
		if (node instanceof MethodDeclaration) {
			return (MethodDeclaration) node;
		}

		if (node != null && node.getParent() != null) {
			return getASTMethod(node.getParent());
		}

		return null;
	}

	private static String getFullQualifiedName(IImportDeclaration[] imports,
			String paramType) {
		if (imports == null) {
			return null;
		}

		String importFullQualifiedName;
		String importType;

		for (IImportDeclaration importDeclaration : imports) {
			importFullQualifiedName = importDeclaration.getElementName();
			importType = importFullQualifiedName
					.substring(importFullQualifiedName.lastIndexOf(".") + 1);
			if (paramType.equals(importType)) {
				return importFullQualifiedName;
			}
		}

		return null;
	}

	/**
	 * Gets the full qualified name from the type of a variable in a type from a
	 * compilation unit
	 * 
	 * @param type
	 * @param variableToSearch
	 * @return the full qualified name for the type of the variable
	 * @throws JavaModelException
	 */
	public static String getFullQualifiedName(IType type,
			ILocalVariable variableToSearch) throws JavaModelException {
		String variableTypeName = Signature
				.getSignatureSimpleName(variableToSearch.getTypeSignature());
		return getFullQualifiedName(type, variableTypeName);
	}

	public static String getFullQualifiedName(IType type,
			String variableTypeName) throws JavaModelException {

		IImportDeclaration[] imports = null;
		List<?> importsFromBinary = null;
		ICompilationUnit cu = type.getCompilationUnit();

		if (cu != null) {
			imports = cu.getImports();
		} else {
			ASTParser parser = ASTParser.newParser(AST.JLS8);
			parser.setSource(type.getClassFile().getBuffer().getCharacters());
			CompilationUnit cuParsed = (CompilationUnit) parser.createAST(null);

			if (cuParsed != null) {
				importsFromBinary = cuParsed.imports();
			}
		}

		String fullQualifiedName = null;

		if (imports != null) {
			// from source
			fullQualifiedName = getFullQualifiedName(imports, variableTypeName);
		} else if (importsFromBinary != null) {
			// from binary
			fullQualifiedName = getFullQualifiedName(importsFromBinary,
					variableTypeName);
		}

		if (fullQualifiedName == null) {
			// if no import available, then try to find in same package
			fullQualifiedName = type.getPackageFragment().getElementName()
					+ "." + variableTypeName;
		}

		return fullQualifiedName;
	}

	private static String getFullQualifiedName(List<?> importsFromBinary,
			String paramTypeName) {
		for (Object importFromBinary : importsFromBinary) {
			String importFromBinaryS = importFromBinary.toString()
					.replace("\\n", "").replace("\n", "").replace(";", "");
			int lastIndexOf = importFromBinaryS.lastIndexOf(".");
			if (lastIndexOf == -1) {
				lastIndexOf = 0;
			} else {
				lastIndexOf += 1;
			}

			String typeName = importFromBinaryS.substring(lastIndexOf);

			if (paramTypeName.equals(typeName)) {
				return importFromBinaryS.replace("import", "").trim();
			}
		}

		return null;
	}

	/**
	 * Returns the method modifier as String.
	 * 
	 * @param method
	 * @return method modifier
	 * @throws JavaModelException
	 */
	public static String getMethodModifier(IMethod method)
			throws JavaModelException {
		int methodFlags = method.getFlags();

		if (Flags.isPublic(methodFlags)) {
			return MOD_PUBLIC;
		} else if (Flags.isProtected(methodFlags)) {
			return MOD_PROTECTED;
		} else if (Flags.isPrivate(methodFlags)) {
			return MOD_PRIVATE;
		} else if (Flags.isPackageDefault(methodFlags)) {
			return MOD_PACKAGE;
		}

		return ""; //$NON-NLS-1$
	}

	/**
	 * Creates a AST-parser
	 * 
	 * @param cu
	 * @return the created AST-parser
	 */
	private static ASTParser createASTParser(ICompilationUnit cu) {
		ASTParser parser = ASTParser.newParser(AST.JLS8);
		parser.setProject(cu.getJavaProject());
		parser.setUnitName(cu.getElementName());
		parser.setResolveBindings(true);
		parser.setSource(cu);
		return parser;
	}

	public static IField createField(IType type, String modifier,
			String fieldType, String fieldName, String assignment,
			boolean increment) throws JavaModelException {

		if (increment) {
			while (type.getField(fieldName).exists()) {
				fieldName = increment(fieldName, "_");
			}
		}

		IField createdField = type.createField(modifier + " " + fieldType + " "
				+ fieldName + " = " + assignment + ";", null, true, null);

		return createdField;

	}

	public static IBinding[] createBindings(ICompilationUnit cu,
			IJavaElement... javaElements) {
		ASTParser parser = createASTParser(cu);
		return parser.createBindings(javaElements, null);
	}

	public static boolean isMethodNameUnique(IMethod method)
			throws JavaModelException {
		int methodCount = 0;

		IType type = (IType) method.getParent();
		IMethod[] methods = type.getMethods();

		for (IMethod tmpMethod : methods) {
			if (tmpMethod.getElementName().equals(method.getElementName())) {
				methodCount++;
			}
		}

		return methodCount <= 1;
	}

	/**
	 * @param p
	 *            the package fragment; may not be null
	 * @return the parent package fragment, or null if the given package
	 *         fragment is the default package or a top level package
	 */
	public static IPackageFragment getParentPackage(IPackageFragment p) {
		if (p.isDefaultPackage()) {
			return null;
		}

		final int index = p.getElementName().lastIndexOf('.');
		if (index == -1) {
			return null;
		}

		final IPackageFragmentRoot root = (IPackageFragmentRoot) p.getParent();
		final String parentPackageName = p.getElementName().substring(0, index);

		final IPackageFragment parent = root
				.getPackageFragment(parentPackageName);

		if (parent.exists()) {
			return parent;
		} else {
			return null;
		}
	}

	/**
	 * Deletes the packages if no sub-packages exists and all parent-packages
	 * without any compilation-unit.
	 * 
	 * @param packageToDelete
	 * @throws JavaModelException
	 */
	public static void deletePackages(IPackageFragment packageToDelete)
			throws JavaModelException {
		if (!packageToDelete.hasSubpackages()) {
			deletePackagesWithParents(packageToDelete);
		}
	}

	public static void deletePackagesWithParents(
			IPackageFragment packageToDelete) throws JavaModelException {

		if (packageToDelete == null) {
			return;
		}

		packageToDelete.delete(true, null);

		IPackageFragment parentPackage = getParentPackage(packageToDelete);

		if (parentPackage.getCompilationUnits().length == 0) {
			deletePackagesWithParents(parentPackage);
		}
	}

	public static boolean isParentPackage(String parentPackage,
			String childPackage) {
		int parentPackageSegmentSize = parentPackage.split("\\.").length;
		int childPackageSegmentSize = childPackage.split("\\.").length;

		if (parentPackageSegmentSize != childPackageSegmentSize
				&& childPackage.startsWith(parentPackage)) {
			return true;
		}

		return false;
	}

	public static String createClassCreationChain(IType baseType,
			StringBuilder classCreationChain,
			List<ITestDataFactory> testDataFactories) {
		try {
			// begin creation block
			classCreationChain.append("new ").append(baseType.getElementName())
					.append("(");

			// create chain for the first constructor
			for (IMethod method : baseType.getMethods()) {
				if (method.isConstructor()) {
					createClassCreationChain(baseType, method,
							classCreationChain, testDataFactories);
					break;
				}
			}

		} catch (Exception e) {
			// TODO error log
			classCreationChain.append("null");
		} finally {
			// end creation block
			classCreationChain.append(")");
		}

		return classCreationChain.toString();
	}

	private static void createClassCreationChain(IType baseType,
			IMethod constructor, StringBuilder classCreationChain,
			List<ITestDataFactory> testDataFactories) throws JavaModelException {
		// add parameters
		ILocalVariable[] params = constructor.getParameters();

		String fullQualifiedName;
		IType paramType;

		if (params != null && params.length != 0) {
			String typeSignature;
			String comma = "";
			for (ILocalVariable param : params) {
				classCreationChain.append(comma);

				typeSignature = param.getTypeSignature();
				int typeSignatureKind = Signature
						.getTypeSignatureKind(typeSignature);
				String signatureSimpleName = Signature
						.getSignatureSimpleName(typeSignature);

				// if simple type
				if (Signature.BASE_TYPE_SIGNATURE == typeSignatureKind
						|| isString(signatureSimpleName)) {
					if (!TYPE_VOID.equals(Signature
							.getSimpleName(typeSignature))) {
						classCreationChain.append(decorateValue(
								JDTUtils.createInitValue(signatureSimpleName),
								signatureSimpleName));
					}
				} else {
					paramType = null;
					fullQualifiedName = getFullQualifiedName(baseType, param);

					try {
						paramType = baseType.getJavaProject().findType(
								fullQualifiedName);
					} catch (JavaModelException e) {
						paramType = null;
					}

					if (paramType != null) {
						boolean creationDone = false;
						// if it is a special type
						for (ITestDataFactory testDataFactory : testDataFactories) {
							creationDone = testDataFactory.createTypeCreation(
									paramType, classCreationChain);
						}

						if (paramType.getFullyQualifiedName().equals(
								baseType.getFullyQualifiedName())) {
							classCreationChain.append("null");
						} else if (!creationDone) {
							createClassCreationChain(paramType,
									classCreationChain, testDataFactories);
						}
					} else {
						classCreationChain.append("null");
					}

				}

				comma = ", ";
			}
		}
	}

	/**
	 * Returns if the modifiers are equal.
	 * 
	 * @param method
	 * @param modifier
	 * @return true if the modifiers are equal
	 */
	public static boolean isMethodModifierEqual(IMethod method, String modifier) {
		String methodModifier;
		try {
			methodModifier = getMethodModifier(method);
		} catch (JavaModelException e) {
			return false;
		}

		if (methodModifier.equals(modifier)) {
			return true;
		}

		return false;
	}

	/**
	 * @param method
	 * @return true if method is static
	 * @throws JavaModelException
	 */
	public static boolean isStatic(IMethod method) throws JavaModelException {
		return Flags.isStatic(method.getFlags());
	}

	/**
	 * Returns if the type is a number.
	 * 
	 * @param type
	 * @return true if type is a number
	 */
	public static boolean isNumber(String type) {
		if (isInt(type) || isInteger(type) || isDouble(type) || isFloat(type)) {
			return true;
		}

		return false;
	}

	/**
	 * Returns if the type is String.
	 * 
	 * @param type
	 * @return true if type is String
	 */
	public static boolean isString(String type) {
		if (type.startsWith(TYPE_STRING)) {
			return true;
		}

		return false;
	}

	public static String createReturnType(String returnType) {

		if (returnType != null && !returnType.equals("V")) {
			returnType = Signature.getSignatureSimpleName(returnType);
		} else {
			returnType = TYPE_VOID;
		}

		return returnType;
	}

	/**
	 * Do the type specific formats for the value if length greater than 0 or
	 * not null otherwise a formated initialized-value is created.
	 * 
	 * @param value
	 *            value to format
	 * @param type
	 *            JUT-type (mandatory parameter)
	 * @return formated an if value
	 */
	public static String formatValue(String value, String type) {
		String resultValue = "";

		if (value == null || value.length() == 0) {
			resultValue = createInitValue(type);
			resultValue = decorateValue(resultValue, type);
		} else {
			if (isArray(type)) {
				String[] values = value.split(",");
				boolean firstValue = true;

				for (String tmpValue : values) {
					tmpValue = tmpValue.trim();

					if ("".equals(tmpValue)) {
						tmpValue = createInitValue(type);
					}

					tmpValue = decorateValue(tmpValue, type);

					if (firstValue) {
						resultValue = tmpValue;
						firstValue = false;
					} else {
						resultValue = resultValue + (", ") + tmpValue;
					}
				}
			} else {
				resultValue = decorateValue(value, type);
			}
		}

		if (isArray(type)) {
			resultValue = "new " + type + "{" + resultValue + "}";
		}

		return resultValue;
	}

	/**
	 * Creates a initializer value.
	 * 
	 * @param type
	 * @return initializer value
	 */
	public static String createInitValue(String type) {
		return createInitValue(type, false);
	}

	/**
	 * Creates a initializer value.
	 * 
	 * @param type
	 * @return initializer value
	 */
	public static String createInitValue(String type, boolean formatValue) {
		String value;

		if (isString(type) || isChar(type)) {
			value = "";
		} else if (isByte(type)) {
			value = " ";
		} else if (isBoolean(type)) {
			value = "false";
		} else if (isNumber(type)) {
			if (isDouble(type)) {
				value = "0.0";
			} else {
				value = "0";
			}
		} else {
			value = "null";
		}

		if (formatValue) {
			value = formatValue(value, type);
		}

		return value;
	}

	public static String createParamList(IMethod method)
			throws JavaModelException {
		return createParamList(method, true);
	}

	public static String createParamList(IMethod method, boolean withParamTypes)
			throws JavaModelException {
		StringBuilder params = new StringBuilder();
		String comma = "";
		for (ILocalVariable variable : method.getParameters()) {
			params.append(comma);
			comma = ", ";

			if (withParamTypes) {
				params.append(
						Signature.getSignatureSimpleName(variable
								.getTypeSignature())).append(" ");
			}

			params.append(variable.getElementName());
		}

		return params.toString();
	}

	/**
	 * Decorates the value depend on the type.
	 * 
	 * @param value
	 * @param type
	 * @return decorated value
	 */
	public static String decorateValue(String value, String type) {
		if (isString(type)) {
			value = QUOTES + value + QUOTES;
		} else if (isChar(type) || isByte(type)) {
			if (value.length() == 0) {
				value = " ";
			}
			value = "'" + value + "'";
		}

		return value;
	}

	/**
	 * Returns if the type is a array.
	 * 
	 * @param type
	 * @return true if type is a array
	 */
	public static boolean isArray(String type) {
		if (type.endsWith(TYPE_ARRAY)) {
			return true;
		}

		return false;
	}

	/**
	 * Returns if the type is boolean.
	 * 
	 * @param type
	 * @return true if type is boolean
	 */
	public static boolean isBoolean(String type) {
		if (type.startsWith(TYPE_BOOLEAN)) {
			return true;
		}

		return false;
	}

	/**
	 * Returns if the type is char.
	 * 
	 * @param type
	 * @return true if type is char
	 */
	public static boolean isChar(String type) {
		if (type.startsWith(TYPE_CHAR)) {
			return true;
		}

		return false;
	}

	public static boolean isByte(String type) {
		if (type.startsWith(TYPE_BYTE)) {
			return true;
		}

		return false;
	}

	/**
	 * Returns if the type is double.
	 * 
	 * @param type
	 * @return true if type is double
	 */
	public static boolean isDouble(String type) {
		if (type.startsWith(TYPE_DOUBLE)) {
			return true;
		}

		return false;
	}

	/**
	 * Returns if the type is float.
	 * 
	 * @param type
	 * @return true if type is float
	 */
	public static boolean isFloat(String type) {
		if (type.startsWith(TYPE_FLOAT)) {
			return true;
		}

		return false;
	}

	/**
	 * Returns if the type is int.
	 * 
	 * @param type
	 * @return true if type is int
	 */
	public static boolean isInt(String type) {
		if (type.startsWith(TYPE_INT)) {
			return true;
		}

		return false;
	}

	/**
	 * Returns if the type is Integer.
	 * 
	 * @param type
	 * @return true if type is Integer
	 */

	public static boolean isInteger(String type) {
		if (type.startsWith(TYPE_INTEGER)) {
			return true;
		}

		return false;
	}

	public static IMethod getSelectedMethod(IFileEditorInput fileEditorInput)
			throws JavaModelException {
		ITextEditor editor = (ITextEditor) EclipseUIUtils.getActiveEditor();
		ITextSelection sel = (ITextSelection) editor.getSelectionProvider()
				.getSelection();
		ITypeRoot typeRoot = JavaUI.getEditorInputTypeRoot(editor
				.getEditorInput());
		ICompilationUnit icu = (ICompilationUnit) typeRoot
				.getAdapter(ICompilationUnit.class);
		CompilationUnit cu = createASTRoot(icu);
		NodeFinder finder = new NodeFinder(cu, sel.getOffset(), sel.getLength());

		ASTNode node = finder.getCoveringNode();

		MethodDeclaration methodDeclaration = getASTMethod(node);
		if (methodDeclaration == null) {
			return null;
		}

		IMethodBinding methodBinding = methodDeclaration.resolveBinding();

		IMethod selectedMethod = null;
		if (methodBinding != null) {
			selectedMethod = (IMethod) methodBinding.getJavaElement();
		}

		return selectedMethod;
	}

	public static IMethod getSelectedMethod() throws JavaModelException {
		IWorkbenchPage page = PlatformUI.getWorkbench()
				.getActiveWorkbenchWindow().getActivePage();
		ITextEditor editor = (ITextEditor) page.getActiveEditor();
		IJavaElement elem = JavaUI.getEditorInputJavaElement(editor
				.getEditorInput());
		if (elem instanceof ICompilationUnit) {
			ITextSelection sel = (ITextSelection) editor.getSelectionProvider()
					.getSelection();
			IJavaElement selected = ((ICompilationUnit) elem).getElementAt(sel
					.getOffset());
			if (selected != null
					&& selected.getElementType() == IJavaElement.METHOD) {
				return (IMethod) selected;
			}
		}

		return null;
	}

	public static Vector<IJavaElement> getCompilationUnits(
			ISelection selection, IFileEditorInput fileEditorInput)
			throws JavaModelException, JUTWarning {
		Vector<IJavaElement> javaElements = getJavaElements(selection,
				fileEditorInput);

		return javaElements;
	}

	/**
	 * Collect the compilation units from the selection.
	 * 
	 * @param selection
	 * @param fileEditorInput
	 * @return all compilationUnits in the selection
	 * @throws JavaModelException
	 * @throws JUTWarning
	 */
	public static Vector<IJavaElement> getJavaElements(ISelection selection,
			IFileEditorInput fileEditorInput, boolean withBinary)
			throws JavaModelException, JUTWarning {

		Object[] selectionArray;

		if (fileEditorInput != null) {
			selectionArray = new Object[1];
			selectionArray[0] = fileEditorInput;
		} else {
			IStructuredSelection structuredSelection;

			if (selection instanceof IStructuredSelection) {
				structuredSelection = ((IStructuredSelection) selection);
			} else
				return null;

			selectionArray = structuredSelection.toArray();
		}

		Vector<IJavaElement> selectedCompilationUnits = new Vector<IJavaElement>();

		for (Object tmpSelection : selectionArray) {
			if (tmpSelection instanceof IJavaElement) {
				IJavaElement javaElement = (IJavaElement) tmpSelection;
				collectCompilationUnits(javaElement, selectedCompilationUnits);
			} else if (tmpSelection instanceof IParent) {
				IParent parentSelection = (IParent) tmpSelection;
				IJavaElement[] javaElements = parentSelection.getChildren();

				for (IJavaElement javaElement : javaElements) {
					collectCompilationUnits(javaElement,
							selectedCompilationUnits);
				}
			} else if (tmpSelection instanceof IFileEditorInput) {
				IFileEditorInput fileEditorInputTmp = (IFileEditorInput) tmpSelection;
				IFile ifile = fileEditorInputTmp.getFile();

				if (ifile.getName().endsWith(".java")) { //$NON-NLS-1$
					ICompilationUnit cu = JavaCore
							.createCompilationUnitFrom(ifile);
					selectedCompilationUnits.add(cu);
				} else {
					throw new JUTWarning(Messages.GeneratorUtils_SelectionEnd);
				}
			}
		}

		return selectedCompilationUnits;
	}

	public static Vector<IJavaElement> getJavaElements(ISelection selection,
			IFileEditorInput fileEditorInput) throws JavaModelException,
			JUTWarning {
		return getJavaElements(selection, fileEditorInput, false);
	}

	public static Vector<IJavaElement> getCompilationUnits(ISelection selection)
			throws JavaModelException, JUTWarning {
		if (selection instanceof IStructuredSelection) {
			return getCompilationUnits(selection, null);
		} else {
			IEditorInput editorInput = EclipseUIUtils.getEditorInput();

			if (editorInput instanceof IFileEditorInput) {

				return getCompilationUnits(null, (IFileEditorInput) editorInput);

			}
		}

		return new Vector<IJavaElement>();
	}

}
org.junit.tools/src/org/junit/tools/generator/model/tml/Assertion.java
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Assertion", propOrder = {
    "value",
    "message"
})
public class Assertion {

    @XmlElement(required = true)
    protected String value;
    @XmlElement(required = true)
    protected String message;
    @XmlAttribute(name = "base")
    protected String base;
    @XmlAttribute(name = "baseType")
    protected String baseType;
    @XmlAttribute(name = "type")
    protected AssertionType type;

    /**
     * Gets the value of the value property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getValue() {
        return value;
    }

    /**
     * Sets the value of the value property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setValue(String value) {
        this.value = value;
    }

    /**
     * Gets the value of the message property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getMessage() {
        return message;
    }

    /**
     * Sets the value of the message property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setMessage(String value) {
        this.message = value;
    }

    /**
     * Gets the value of the base property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getBase() {
        return base;
    }

    /**
     * Sets the value of the base property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setBase(String value) {
        this.base = value;
    }

    /**
     * Gets the value of the baseType property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getBaseType() {
        return baseType;
    }

    /**
     * Sets the value of the baseType property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setBaseType(String value) {
        this.baseType = value;
    }

    /**
     * Gets the value of the type property.
     * 
     * @return
     *     possible object is
     *     {@link AssertionType }
     *     
     */
    public AssertionType getType() {
        return type;
    }

    /**
     * Sets the value of the type property.
     * 
     * @param value
     *     allowed object is
     *     {@link AssertionType }
     *     
     */
    public void setType(AssertionType value) {
        this.type = value;
    }

}
org.junit.tools/src/org/junit/tools/generator/model/tml/Mocks.java
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Mocks", propOrder = {
    "method"
})
public class Mocks {

    protected List<Method> method;

    /**
     * Gets the value of the method property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the method property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getMethod().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link Method }
     * 
     * 
     */
    public List<Method> getMethod() {
        if (method == null) {
            method = new ArrayList<Method>();
        }
        return this.method;
    }

}
org.junit.tools/src/org/junit/tools/generator/model/tml/Param.java
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Param")
public class Param {

    @XmlAttribute(name = "name")
    protected String name;
    @XmlAttribute(name = "type")
    protected String type;
    @XmlAttribute(name = "primitive")
    protected Boolean primitive;

    /**
     * Gets the value of the name property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getName() {
        return name;
    }

    /**
     * Sets the value of the name property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setName(String value) {
        this.name = value;
    }

    /**
     * Gets the value of the type property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getType() {
        return type;
    }

    /**
     * Sets the value of the type property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setType(String value) {
        this.type = value;
    }

    /**
     * Gets the value of the primitive property.
     * 
     * @return
     *     possible object is
     *     {@link Boolean }
     *     
     */
    public Boolean isPrimitive() {
        return primitive;
    }

    /**
     * Sets the value of the primitive property.
     * 
     * @param value
     *     allowed object is
     *     {@link Boolean }
     *     
     */
    public void setPrimitive(Boolean value) {
        this.primitive = value;
    }

}
org.junit.tools/src/org/junit/tools/generator/model/tml/Settings.java
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Settings", propOrder = {
    "setUp",
    "setUpBeforeClass",
    "tearDown",
    "tearDownBeforeClass",
    "logger",
    "failAssertions",
    "testsuites"
})
public class Settings {

    protected boolean setUp;
    protected boolean setUpBeforeClass;
    protected boolean tearDown;
    protected boolean tearDownBeforeClass;
    protected boolean logger;
    protected boolean failAssertions;
    protected boolean testsuites;

    /**
     * Gets the value of the setUp property.
     * 
     */
    public boolean isSetUp() {
        return setUp;
    }

    /**
     * Sets the value of the setUp property.
     * 
     */
    public void setSetUp(boolean value) {
        this.setUp = value;
    }

    /**
     * Gets the value of the setUpBeforeClass property.
     * 
     */
    public boolean isSetUpBeforeClass() {
        return setUpBeforeClass;
    }

    /**
     * Sets the value of the setUpBeforeClass property.
     * 
     */
    public void setSetUpBeforeClass(boolean value) {
        this.setUpBeforeClass = value;
    }

    /**
     * Gets the value of the tearDown property.
     * 
     */
    public boolean isTearDown() {
        return tearDown;
    }

    /**
     * Sets the value of the tearDown property.
     * 
     */
    public void setTearDown(boolean value) {
        this.tearDown = value;
    }

    /**
     * Gets the value of the tearDownBeforeClass property.
     * 
     */
    public boolean isTearDownBeforeClass() {
        return tearDownBeforeClass;
    }

    /**
     * Sets the value of the tearDownBeforeClass property.
     * 
     */
    public void setTearDownBeforeClass(boolean value) {
        this.tearDownBeforeClass = value;
    }

    /**
     * Gets the value of the logger property.
     * 
     */
    public boolean isLogger() {
        return logger;
    }

    /**
     * Sets the value of the logger property.
     * 
     */
    public void setLogger(boolean value) {
        this.logger = value;
    }

    /**
     * Gets the value of the failAssertions property.
     * 
     */
    public boolean isFailAssertions() {
        return failAssertions;
    }

    /**
     * Sets the value of the failAssertions property.
     * 
     */
    public void setFailAssertions(boolean value) {
        this.failAssertions = value;
    }

    /**
     * Gets the value of the testsuites property.
     * 
     */
    public boolean isTestsuites() {
        return testsuites;
    }

    /**
     * Sets the value of the testsuites property.
     * 
     */
    public void setTestsuites(boolean value) {
        this.testsuites = value;
    }

}


Question: package org.junit.tools.generator;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Vector;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IImportDeclaration;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMemberValuePair;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.MemberValuePair;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.NormalAnnotation;
import org.eclipse.jdt.core.dom.StringLiteral;
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
import org.eclipse.jdt.internal.core.Annotation;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
import org.eclipse.text.edits.MalformedTreeException;
import org.eclipse.text.edits.TextEdit;
import org.junit.tools.base.MethodRef;
import org.junit.tools.generator.model.GeneratorModel;
import org.junit.tools.generator.model.JUTElements.JUTClassesAndPackages;
import org.junit.tools.generator.model.tml.Assertion;
import org.junit.tools.generator.model.tml.AssertionType;
import org.junit.tools.generator.model.tml.Constructor;
import org.junit.tools.generator.model.tml.Method;
import org.junit.tools.generator.model.tml.Mocks;
import org.junit.tools.generator.model.tml.Param;
import org.junit.tools.generator.model.tml.ParamAssignment;
import org.junit.tools.generator.model.tml.Result;
import org.junit.tools.generator.model.tml.Settings;
import org.junit.tools.generator.model.tml.Test;
import org.junit.tools.generator.model.tml.TestBase;
import org.junit.tools.generator.model.tml.TestBases;
import org.junit.tools.generator.model.tml.TestCase;
import org.junit.tools.generator.model.tml.Testprio;
import org.junit.tools.generator.utils.GeneratorUtils;
import org.junit.tools.generator.utils.JDTUtils;
import org.junit.tools.preferences.JUTPreferences;



/**
 * The default test-class java generator. On the base of the TML the test-class
 * will be generated.
 * 
 * @author Robert Streng
 * 
 */
@SuppressWarnings("restriction")
// TODO avoid restrictions
public class TestClassGenerator implements ITestClassGenerator, IGeneratorConstants {

    protected String testmethodPrefix;

    protected String testmethodPostfix;

    protected boolean defaultTestbaseMethodCreated = false;

    private String annoGenerated = null;

    @Override
    public ICompilationUnit generate(GeneratorModel model, List<ITestDataFactory> testDataFactories,
	    IProgressMonitor monitor) throws Exception {
	boolean writeTML = JUTPreferences.isWriteTML();

	defaultTestbaseMethodCreated = false;

Answer: 	Test tmlTest = model.getTmlTest();