blob: 35babc90a7a8f67ecde0967d619625baa2a022b5 [file] [log] [blame]
/*
* Copyright 2008-2009 the EasyAnt project
*
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.easyant4e.tests;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.apache.easyant4e.Activator;
import org.apache.easyant4e.EasyAntPlugin;
import org.apache.easyant4e.services.EasyantCoreService;
import org.apache.easyant4e.services.EasyantProjectService;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.ui.IPackagesViewPart;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IPerspectiveDescriptor;
import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.junit.After;
import org.junit.Before;
import com.google.inject.Inject;
/**
*
* @author <a href="mailto:jerome@benois.fr">Jerome Benois</a>
*/
public abstract class AbstractEasyAntTest {
protected IProject testProject;
protected IJavaProject testJavaProject;
@Inject
EasyantCoreService coreService;
@Inject
EasyantProjectService projectService;
@Before
public void setUp() throws Exception {
EasyAntPlugin easyAntPlugin = Activator.getEasyAntPlugin();
assertNotNull(easyAntPlugin);
easyAntPlugin.injectMembers(this);
assertNotNull(coreService);
assertNotNull(projectService);
//System.out.println("setUp");
String testProjectName = "TestProject";
this.testProject = EclipseProjectBuilder.createProject(testProjectName);
assertNotNull(testProject);
IFile testModuleDesc = EclipseProjectBuilder.createModuleDescriptorFile(testProject, "org.apache.easyant");
assertNotNull(testModuleDesc);
assertTrue(testModuleDesc.exists());
String testJavaProjectName = "TestJavaProject";
this.testJavaProject = EclipseProjectBuilder.createJavaProject(testJavaProjectName);
assertNotNull(testProject);
IFile testJavaModuleDesc = EclipseProjectBuilder.createModuleDescriptorFile(testJavaProject.getProject(), "org.apache.easyant");
assertNotNull(testJavaModuleDesc);
assertTrue(testJavaModuleDesc.exists());
}
@After
public void tearDown() throws CoreException {
if(this.testProject!=null){
EclipseProjectBuilder.deleteProject(testProject);
this.testProject = null;
}
if(this.testJavaProject!=null){
EclipseProjectBuilder.deleteProject(testJavaProject.getProject());
this.testJavaProject = null;
}
}
}