// Path: src/test/framework/FrameworkException.java
// public class FrameworkException extends RuntimeException {
// 	private static final long serialVersionUID = 2221405766881026986L;
// 	private static final String GIT_HUB_POINTER = "This is a serious issue. But we'd like to help solve this!\n"
// 			+ "Please report what happened on GitHub. Create a new issue at:\n"
// 			+ "https://github.com/jGleitz/JUnit-KIT/issues";
// 
// 	/**
// 	 * New Framework Exception.
// 	 *
// 	 * @param message
// 	 *            Detailed error description
// 	 */
// 	public FrameworkException(String message) {
// 		super(message);
// 	}
// 
// 	@Override
// 	public String getMessage() {
// 		String details = super.getMessage();
// 		return details + "\n\n" + GIT_HUB_POINTER;
// 	}
// }


import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import javax.tools.JavaCompiler;
import javax.tools.ToolProvider;
import test.framework.FrameworkException;
package test.mocking;




/**
 * Helper class to compile a {@link MockerJavaSourceFile}.
 *
 * @author Joshua Gleitze
 * @version 1.0
 * @since 04.02.2015
 */
public abstract class MockCompiler {
	private static final File cacheFile = new File(".serialization/mockCompilerCache.ser");
	private static Map<String, MockerJavaClassFile> cache = getCache();
	private static final JavaCompiler compiler = getJavaCompiler();
	private static final MockCompilerFileManager fileManager = new MockCompilerFileManager(
			compiler.getStandardFileManager(null, null, null));
	private static String OS = null;

	/**
	 * Compiles the source code provided in {@code sourceFile}. The compiler will run silent. If an error occurs while
	 * compiling, the compiler's error text will be provided with the exception.
	 *
	 * @param sourceFile
	 *            The {@link MockerJavaSourceFile} to compile
	 * @return the {@link MockerJavaClassFile} containing the compiled java byte code
	 * @throws FrameworkException
	 *             if an error occurs while compiling. The exception will contain the compiler's error text.
	 */
	public static MockerJavaClassFile compile(MockerJavaSourceFile sourceFile) {
		// check if this version of the class is already cached
		if (!cache.containsKey(sourceFile.getName()) || !cache.get(sourceFile.getName()).isFromSourceFile(sourceFile)) {
			// will contain the compiler's error output
			final Writer errorWriter = new StringWriter();
			// creates the compilation task, runs it and returns the result
			final boolean compilationSuccessful = compiler.getTask(errorWriter, fileManager, null, null, null,
				Arrays.asList(sourceFile)).call();
			if (!compilationSuccessful) {
// Path: src/test/framework/FrameworkException.java
// public class FrameworkException extends RuntimeException {
// 	private static final long serialVersionUID = 2221405766881026986L;
// 	private static final String GIT_HUB_POINTER = "This is a serious issue. But we'd like to help solve this!\n"
// 			+ "Please report what happened on GitHub. Create a new issue at:\n"
// 			+ "https://github.com/jGleitz/JUnit-KIT/issues";
// 
// 	/**
// 	 * New Framework Exception.
// 	 *
// 	 * @param message
// 	 *            Detailed error description
// 	 */
// 	public FrameworkException(String message) {
// 		super(message);
// 	}
// 
// 	@Override
// 	public String getMessage() {
// 		String details = super.getMessage();
// 		return details + "\n\n" + GIT_HUB_POINTER;
// 	}
// }


// Path: src/test/mocking/MockCompiler.java
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import javax.tools.JavaCompiler;
import javax.tools.ToolProvider;
import test.framework.FrameworkException;

package test.mocking;




/**
 * Helper class to compile a {@link MockerJavaSourceFile}.
 *
 * @author Joshua Gleitze
 * @version 1.0
 * @since 04.02.2015
 */
public abstract class MockCompiler {
	private static final File cacheFile = new File(".serialization/mockCompilerCache.ser");
	private static Map<String, MockerJavaClassFile> cache = getCache();
	private static final JavaCompiler compiler = getJavaCompiler();
	private static final MockCompilerFileManager fileManager = new MockCompilerFileManager(
			compiler.getStandardFileManager(null, null, null));
	private static String OS = null;

	/**
	 * Compiles the source code provided in {@code sourceFile}. The compiler will run silent. If an error occurs while
	 * compiling, the compiler's error text will be provided with the exception.
	 *
	 * @param sourceFile
	 *            The {@link MockerJavaSourceFile} to compile
	 * @return the {@link MockerJavaClassFile} containing the compiled java byte code
	 * @throws FrameworkException
	 *             if an error occurs while compiling. The exception will contain the compiler's error text.
	 */
	public static MockerJavaClassFile compile(MockerJavaSourceFile sourceFile) {
		// check if this version of the class is already cached
		if (!cache.containsKey(sourceFile.getName()) || !cache.get(sourceFile.getName()).isFromSourceFile(sourceFile)) {
			// will contain the compiler's error output
			final Writer errorWriter = new StringWriter();
			// creates the compilation task, runs it and returns the result
			final boolean compilationSuccessful = compiler.getTask(errorWriter, fileManager, null, null, null,
				Arrays.asList(sourceFile)).call();
			if (!compilationSuccessful) {
				throw new FrameworkException("Unable to compile " + sourceFile.getName() + ":\n\n"