| /******************************************************************************* |
| * Copyright (c) 2000, 2004 IBM Corporation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Common Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/cpl-v10.html |
| * |
| * Contributors: |
| * IBM Corporation - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.jdt.ui.tests.refactoring; |
| |
| import java.util.Hashtable; |
| |
| import junit.extensions.TestSetup; |
| import junit.framework.Test; |
| |
| import org.eclipse.core.resources.IWorkspace; |
| import org.eclipse.core.resources.IWorkspaceDescription; |
| import org.eclipse.core.resources.ResourcesPlugin; |
| |
| import org.eclipse.jdt.core.IJavaProject; |
| import org.eclipse.jdt.core.IPackageFragment; |
| import org.eclipse.jdt.core.IPackageFragmentRoot; |
| import org.eclipse.jdt.core.JavaCore; |
| import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; |
| |
| import org.eclipse.jdt.internal.ui.JavaPlugin; |
| |
| import org.eclipse.jdt.testplugin.JavaProjectHelper; |
| import org.eclipse.jdt.testplugin.TestOptions; |
| import org.eclipse.ltk.core.refactoring.RefactoringCore; |
| |
| public class SefTestSetup extends TestSetup { |
| |
| private IJavaProject fJavaProject; |
| private IPackageFragmentRoot fRoot; |
| private static final String CONTAINER= "src"; |
| |
| private IPackageFragment fBaseTypes; |
| private IPackageFragment fObjectTypes; |
| private IPackageFragment fInvalid; |
| |
| public SefTestSetup(Test test) { |
| super(test); |
| } |
| |
| public IPackageFragmentRoot getRoot() { |
| return fRoot; |
| } |
| |
| protected void setUp() throws Exception { |
| super.setUp(); |
| |
| Hashtable options= TestOptions.getFormatterOptions(); |
| 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"); |
| JavaCore.setOptions(options); |
| TestOptions.initializeCodeGenerationOptions(); |
| JavaPlugin.getDefault().getCodeTemplateStore().load(); |
| |
| fJavaProject= JavaProjectHelper.createJavaProject("TestProject", "bin"); |
| JavaProjectHelper.addRTJar(fJavaProject); |
| fRoot= JavaProjectHelper.addSourceContainer(fJavaProject, CONTAINER); |
| |
| RefactoringCore.getUndoManager().flush(); |
| IWorkspace workspace= ResourcesPlugin.getWorkspace(); |
| IWorkspaceDescription description= workspace.getDescription(); |
| description.setAutoBuilding(false); |
| workspace.setDescription(description); |
| |
| fBaseTypes= getRoot().createPackageFragment("base_in", true, null); |
| fObjectTypes= getRoot().createPackageFragment("object_in", true, null); |
| fInvalid= getRoot().createPackageFragment("invalid", true, null); |
| } |
| |
| protected void tearDown() throws Exception { |
| super.tearDown(); |
| RefactoringTest.performDummySearch(fJavaProject); |
| JavaProjectHelper.delete(fJavaProject); |
| } |
| |
| public IPackageFragment getBasePackage() { |
| return fBaseTypes; |
| } |
| |
| public IPackageFragment getObjectPackage() { |
| return fObjectTypes; |
| } |
| |
| public IPackageFragment getInvalidPackage() { |
| return fInvalid; |
| } |
| } |
| |