blob: b00676f1a34f3756248d4f43431737ea76acb7d1 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2009 IBM Corporation and others 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: IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.e4.languages.javascript.framework.test;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.ListIterator;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.e4.languages.javascript.junit.JavaScriptTestSuite;
public class AllTests extends TestSuite {
public static Test suite() throws IOException {
return new AllTests();
}
public static String getResource(String path) {
try {
return FileLocator.toFileURL(AllTests.class.getResource(path)).toURI().toString();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public AllTests() throws IOException {
super(AllTests.class.getName());
addTest(createFrameworkTest("BundleTest"));
addTest(createFrameworkTest("FrameworkTest"));
addTest(createFrameworkTest("VersionTest"));
addTest(createFrameworkTest("VersionRangeTest"));
}
private Test createFrameworkTest(String testCaseName) throws IOException {
return createFrameworkTest(testCaseName, Activator.getContext().getBundle().getEntry("/scripts/"+testCaseName+".js"));
}
private Test createFrameworkTest(String testCaseName, URL entry) throws IOException {
ArrayList scripts = new ArrayList(Activator.getFrameworkScripts());
scripts.add(entry);
for (ListIterator iterator = scripts.listIterator(); iterator.hasNext();) {
iterator.set(FileLocator.toFileURL((URL) iterator.next()));
}
return new JavaScriptTestSuite(testCaseName, scripts, this.getClass().getClassLoader());
}
}