/*******************************************************************************
 * Copyright (c) 2012 Pivotal Software, Inc.
 * 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:
 *     Pivotal Software, Inc. - initial API and implementation
 *******************************************************************************/
package org.springsource.ide.eclipse.commons.tests.util;

import java.io.IOException;

import junit.framework.TestCase;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;

/**
 * Derived from AbstractBeansCoreTestCase
 * @author Steffen Pingel
 * @author Terry Denney
 */
public abstract class StsTestCase extends TestCase {

	protected IProject createPredefinedProject(final String projectName) throws CoreException, IOException {
		return StsTestUtil.createPredefinedProject(projectName, getBundleName());
	}

	protected IResource createPredefinedProjectAndGetResource(String projectName, String resourcePath)
			throws CoreException, IOException {
		IProject project = createPredefinedProject(projectName);
		// XXX do a second full build to ensure markers are up-to-date
		project.build(IncrementalProjectBuilder.FULL_BUILD, null);

		IResource resource = project.findMember(resourcePath);
		StsTestUtil.waitForResource(resource);
		return resource;
	}

	protected abstract String getBundleName();

	protected String getSourceWorkspacePath() {
		return StsTestUtil.getSourceWorkspacePath(getBundleName());
	}

	@Override
	protected void tearDown() throws Exception {
		StsTestUtil.cleanUpProjects();
		super.tearDown();
	}

}

@@ -615,16 +615,118 @@
 ception;
+%0Aimport java.util.Arrays;%0Aimport java.util.Collection;%0Aimport java.util.HashSet;%0Aimport java.util.Set;
 %0A%0Aimport
@@ -1893,16 +1893,597 @@
 ));%0A%09%7D%0A%0A
+%09public static %3CT%3E void assertElements(T%5B%5D actual, T... expect) %7B%0A%09%09assertElements(Arrays.asList(actual), expect);%0A%09%7D%0A%0A%09public static %3CT%3E void assertElements(Collection%3CT%3E actual, T... expect) %7B%0A%09%09Set%3CT%3E expectedSet = new HashSet%3CT%3E(Arrays.asList(expect));%0A%0A%09%09for (T propVal : actual) %7B%0A%09%09%09if (!expectedSet.remove(propVal)) %7B%0A%09%09%09%09fail(%22Unexpected element: %22+propVal);%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09if (!expectedSet.isEmpty()) %7B%0A%09%09%09StringBuilder missing = new StringBuilder();%0A%09%09%09for (T propVal : expectedSet) %7B%0A%09%09%09%09missing.append(propVal+%22%5Cn%22);%0A%09%09%09%7D%0A%09%09%09fail(%22Missing elements: %5Cn%22+missing);%0A%09%09%7D%0A%09%7D%0A%0A
 %09@Overri

Add some convenient methods to StsTestCase