blob: 5d5c4ceba1c38f601a75778740c2a53c8d2d6d4b [file] [log] [blame]
/**********************************************************************
* Copyright (c) 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 - Initial API and implementation
**********************************************************************/
package org.eclipse.wst.wsdl.tests.performance;
import java.io.IOException;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.intro.IIntroManager;
import org.eclipse.ui.intro.IIntroPart;
public class OpenStockQuoteWSDLSetup extends TestCase
{
public static String PROJECT_NAME = "Project";
public static Test suite()
{
return new TestSuite(OpenStockQuoteWSDLSetup.class, "OpenStockQuoteWSDLSetup");
}
protected void closeIntro()
{
IIntroManager introManager = PlatformUI.getWorkbench().getIntroManager();
IIntroPart introPart = introManager.getIntro();
if (introPart != null)
introManager.closeIntro(introPart);
}
protected IProject createSimpleProject(String name) throws CoreException
{
IProject simpleProject = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
simpleProject.create(null);
simpleProject.open(null);
return simpleProject;
}
protected void copyFile(IProject project, String source, String dest) throws IOException, CoreException
{
IFile file = project.getFile(dest);
file.create(PerformancePlugin.getDefault().getBundle().getEntry(source).openStream(), true, null);
}
protected void joinAutoBuild() throws CoreException
{
boolean interrupted = true;
while (interrupted)
{
try
{
Platform.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
interrupted = false;
}
catch (InterruptedException e)
{
interrupted = true;
}
}
}
public void testSetup() throws Exception
{
closeIntro();
IProject project = createSimpleProject(PROJECT_NAME);
copyFile(project, "data/StockQuote/StockQuote.wsdl", "StockQuote.wsdl");
joinAutoBuild();
}
}