/******************************************************************************* * Copyright (c) 2012-2015 Codenvy, S.A. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ package org.eclipse.che.jdt.refactoring; import org.eclipse.che.jdt.testplugin.TestOptions; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; import org.eclipse.jdt.internal.corext.template.java.CodeTemplateContextType; import org.eclipse.jdt.internal.ui.JavaPlugin; import java.util.Hashtable; public class AbstractRefactoringTestSetup /*extends TestSetup*/ { private boolean fWasAutobuild; /*public AbstractRefactoringTestSetup(Test test) { super(test); } */ protected void setUp() throws Exception { // super.setUp(); // fWasAutobuild= CoreUtility.setAutoBuilding(false); // if (JavaPlugin.getActivePage() != null) // JavaPlugin.getActivePage().close(); Hashtable options= TestOptions.getDefaultOptions(); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "0"); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, String.valueOf(9999)); JavaCore.setOptions(options); TestOptions.initializeCodeGenerationOptions(); JavaPlugin.getDefault().getCodeTemplateStore().load(); StringBuffer comment= new StringBuffer(); comment.append("/**\n"); comment.append(" * ${tags}\n"); comment.append(" */"); StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORCOMMENT_ID, comment.toString(), null); } protected void tearDown() throws Exception { // CoreUtility.setAutoBuilding(fWasAutobuild); /* * ensure the workbench state gets saved when running with the Automated Testing Framework * TODO: remove when https://bugs.eclipse.org/bugs/show_bug.cgi?id=71362 is fixed */ /* Not needed for JDT/UI tests right now. StackTraceElement[] elements= new Throwable().getStackTrace(); for (int i= 0; i < elements.length; i++) { StackTraceElement element= elements[i]; if (element.getClassName().equals("org.eclipse.test.EclipseTestRunner")) { PlatformUI.getWorkbench().close(); break; } } */ // super.tearDown(); } }