diff options
Diffstat (limited to 'tests/org.eclipse.jst.validation.test/testFwk/org')
10 files changed, 0 insertions, 2305 deletions
diff --git a/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/BuildInfo.java b/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/BuildInfo.java deleted file mode 100644 index f56d29a8..00000000 --- a/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/BuildInfo.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.eclipse.jst.validation.test.fwk; -public class BuildInfo { - public static final String copyright = "Licensed Materials -- Property of IBM\n(c) Copyright International Business Machines Corporation, 2001,2003\nUS Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp."; - public static final String fgBuildLevel = "20031112_1915-WB212-AD-V511D-W5"; - public static String level() { return fgBuildLevel; } - public static String getWSABuildLevel() { return fgBuildLevel; } -} diff --git a/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/TestOpConstrBuilder.java b/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/TestOpConstrBuilder.java deleted file mode 100644 index 88250a24..00000000 --- a/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/TestOpConstrBuilder.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.eclipse.jst.validation.test.fwk; - -import java.util.Map; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; - -/** - */ -public class TestOpConstrBuilder extends IncrementalProjectBuilder { - public static final String BUILDER_ID = "org.eclipse.jst.validation.test.fwk.bvtbuilder"; //$NON-NLS-1$ - private IResourceDelta _delta = null; - private static TestOpConstrBuilder _inst = null; - - public TestOpConstrBuilder() { - _inst = this; - } - - /** - * @see org.eclipse.core.internal.events.InternalBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor) - */ - protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { - // Nothing to do; this class exists only so that an IResourceDelta can be constructed. - _delta = getDelta(getProject()); - return null; - } - - public IResourceDelta getDelta() { - return _delta; - } - - public static TestOpConstrBuilder singleton() { - return _inst; - } -} diff --git a/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/TestOpConstrInputOperation.java b/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/TestOpConstrInputOperation.java deleted file mode 100644 index 2c767b95..00000000 --- a/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/TestOpConstrInputOperation.java +++ /dev/null @@ -1,260 +0,0 @@ -package org.eclipse.jst.validation.test.fwk; - -import java.util.HashSet; -import java.util.Set; -import java.util.logging.Level; - -import org.eclipse.core.resources.ICommand; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jem.java.JavaHelpers; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.validation.test.BVTValidationPlugin; -import org.eclipse.jst.validation.test.fwk.validator.JDTUtility; -import org.eclipse.jst.validation.test.internal.registry.ValidatorTestcase; -import org.eclipse.jst.validation.test.setup.IBuffer; - -/** - * This class constructs the input for the TestOpConstrOperation. Because - * TestOpConstrOperation is not invoked as part of a build, when its IResources - * are touched, a build is invoked after each touch, and that means that the - * IResourceDelta that's constructed has only one IResource in it instead - * of the group of changed IResource instances. - */ -public class TestOpConstrInputOperation implements IWorkspaceRunnable { - public static final String FWK_NOBUILD_TEST_VALIDATOR_CLASS = "org.eclipse.jst.validation.test.fwk.validator.FwkNoBuildTestValidator"; //$NON-NLS-1$ - public static final String FWK_TEST_VALIDATOR_CLASS = "org.eclipse.jst.validation.test.fwk.validator.FwkTestValidator"; //$NON-NLS-1$ - public static final String PROPERTIES_VALIDATOR_CLASS = "org.eclipse.wst.validation.sample.PropertiesValidator"; //$NON-NLS-1$ - - private IProject _project = null; - private IBuffer _buffer = null; - private static ICommand _builderCommand = null; - - private IResourceDelta _changedDelta = null; - private IResourceDelta _emptyDelta = null; - private JavaHelpers[] _changedClasses = null; - - /** - * IProject must exist and be open. - */ - public TestOpConstrInputOperation(IBuffer buffer, IProject project) { - setProject(project); - setBuffer(buffer); - } - - public IBuffer getBuffer() { - return _buffer; - } - - public void setBuffer(IBuffer b) { - _buffer = b; - } - - public IProject getProject() { - return _project; - } - - public void setProject(IProject p) { - _project = p; - } - - /*package*/ static void debug(final IBuffer buffer, String title, IResourceDelta delta) { - try { - buffer.write(title); - delta.accept(new IResourceDeltaVisitor() { - public boolean visit(IResourceDelta subdelta) throws CoreException { - if (subdelta == null) - return true; - - IResource resource = subdelta.getResource(); - buffer.write("resource is: " + resource.getFullPath()); //$NON-NLS-1$ - return true; // visit the subdelta's children - } - }); - } - catch(CoreException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - } - } - } - - /** - * Return an IResource that is not validated by the Fwk Test Validator (this - * resource is used for the case where a resource is changed, and a build - * is invoked, but the Fwk Test validator does not validate that resource and - * should not be launched.) - */ - public static IResource[] getEmptyResources(IProject project) { - IResource[] changedResources = new IResource[]{ - project.getFile(".classpath"), //$NON-NLS-1$ - }; - return changedResources; - } - - public static void touch(IProject project, IResource[] changedResources) { - for(int i=0; i<changedResources.length; i++) { - IResource res = changedResources[i]; - try { - res.touch(null); // null IProgressMonitor - } - catch(CoreException exc) { - // Oh well...dirty the next file. - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - } - } - } - } - - private static IResourceDelta getDelta(IProject project, IResource[] changedResources) { - try { - touch(project, changedResources); - project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, TestOpConstrBuilder.BUILDER_ID, _builderCommand.getArguments(), null); // null IProgressMonitor - return TestOpConstrBuilder.singleton().getDelta(); - } - catch(CoreException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - } - return null; - } - } - - private static void addBuilder(IProject project, boolean doAdd) { - if(doAdd) { - // Add the builder to the project - try { - IProjectDescription description = project.getDescription(); - ICommand[] oldCommands = description.getBuildSpec(); - ICommand[] newCommands = new ICommand[oldCommands.length + 1]; - System.arraycopy(oldCommands, 0, newCommands, 0, oldCommands.length); - _builderCommand = description.newCommand(); - _builderCommand.setBuilderName(TestOpConstrBuilder.BUILDER_ID); - newCommands[oldCommands.length] = _builderCommand; - description.setBuildSpec(newCommands); - - project.setDescription(description, null); - } - catch(CoreException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - } - } - } - else { - // Remove the builder - try { - IProjectDescription description = project.getDescription(); - ICommand[] oldCommands = description.getBuildSpec(); - ICommand[] newCommands = new ICommand[oldCommands.length - 1]; - System.arraycopy(oldCommands, 0, newCommands, 0, newCommands.length); - description.setBuildSpec(newCommands); - project.setDescription(description, null); - } - catch(CoreException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - } - } - } - } - - public void run(IProgressMonitor monitor) { - try { - addBuilder(getProject(), true); - - // First, build the project so that the subsequent builds aren't started with a null delta. - getProject().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, TestOpConstrBuilder.BUILDER_ID, _builderCommand.getArguments(), null); // null IProgressMonitor - - ValidatorTestcase[] tmds = JDTUtility.getVFTests(monitor, getProject()); - if((tmds == null) || (tmds.length == 0)) { - return; - } - - // Then calculate the deltas - IResource[] changedResources = getChangedResources(getProject(), tmds); - _emptyDelta = getDelta(getProject(), getEmptyResources(getProject())); - _changedDelta = getDelta(getProject(), changedResources); - - // Then restore the project's build commands back to what they were. - addBuilder(getProject(), false); - - _changedClasses = getChangedClasses(changedResources); - } - catch(Throwable exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - } - } - finally { - } - } - - public IResourceDelta getChangedDelta() { - return _changedDelta; - } - - public IResourceDelta getEmptyDelta() { - return _emptyDelta; - } - - public static IResource[] getChangedResources(IProject project, ValidatorTestcase[] tmds) { - Set temp = new HashSet(); - for(int i=0; i<tmds.length; i++) { - ValidatorTestcase tmd = tmds[i]; - IResource[] res = tmd.getResources(project); - for(int j=0; j<res.length; j++) { - temp.add(res[j]); - } - } - IResource[] result = new IResource[temp.size()]; - temp.toArray(result); - return result; - } - - public JavaHelpers[] getChangedClasses(IResource[] resources) { - if(_changedClasses == null) { - if(resources == null) { - return new JavaHelpers[0]; - } - - JavaHelpers[] result = new JavaHelpers[resources.length]; - int count = 0; - for(int i=0; i<resources.length; i++) { - IResource resource = resources[i]; - if((resource instanceof IFile) && (resource.getFileExtension().equals("java") || resource.getFileExtension().equals("class"))) { //$NON-NLS-1$ //$NON-NLS-2$ - JavaHelpers h = JDTUtility.getJavaHelpers((IFile)resource); - if(h != null) { - result[count++] = h; - } - } - } - - if(count != resources.length) { - JavaHelpers[] temp = new JavaHelpers[count]; - System.arraycopy(result, 0, temp, 0, count); - return temp; - } - else { - return result; - } - } - return _changedClasses; - } -} - diff --git a/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/TestOpConstrOperation.java b/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/TestOpConstrOperation.java deleted file mode 100644 index 77818c4d..00000000 --- a/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/TestOpConstrOperation.java +++ /dev/null @@ -1,629 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 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.jst.validation.test.fwk; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.logging.Level; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jem.java.JavaHelpers; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.validation.test.BVTValidationException; -import org.eclipse.jst.validation.test.BVTValidationPlugin; -import org.eclipse.jst.validation.test.IOperationRunnable; -import org.eclipse.jst.validation.test.ValidationTypeEnum; -import org.eclipse.jst.validation.test.fwk.validator.JDTUtility; -import org.eclipse.jst.validation.test.internal.registry.ValidatorTestcase; -import org.eclipse.jst.validation.test.internal.util.BVTRunner; -import org.eclipse.jst.validation.test.setup.IBuffer; -import org.eclipse.wst.validation.internal.ConfigurationManager; -import org.eclipse.wst.validation.internal.GlobalConfiguration; -import org.eclipse.wst.validation.internal.InternalValidatorManager; -import org.eclipse.wst.validation.internal.TaskListUtility; -import org.eclipse.wst.validation.internal.ValidationConfiguration; -import org.eclipse.wst.validation.internal.ValidatorMetaData; -import org.eclipse.wst.validation.internal.operations.AllValidatorsOperation; -import org.eclipse.wst.validation.internal.operations.EnabledIncrementalValidatorsOperation; -import org.eclipse.wst.validation.internal.operations.EnabledValidatorsOperation; -import org.eclipse.wst.validation.internal.operations.IRuleGroup; -import org.eclipse.wst.validation.internal.operations.OneValidatorOperation; -import org.eclipse.wst.validation.internal.operations.ValidationOperation; -import org.eclipse.wst.validation.internal.operations.ValidatorSubsetOperation; - -/** - * This class tests every constructor available in the ValidationOperation - * hierarchy and ensures that an operation, created with that constructor, - * results in the expected validation IMarkers. - */ -public class TestOpConstrOperation implements IOperationRunnable { - private IProject _project = null; - private IBuffer _buffer = null; - private String _testCaseName = null; - - /** - * Must have a public default constructor in order to createExecutableExtension. - * MUST call setBuffer, setProject, and setName before using the operation. - */ - public TestOpConstrOperation() { - } - - /** - * IProject must exist and be open. - */ - public TestOpConstrOperation(IBuffer buffer, IProject project, String testCaseName) { - setBuffer(buffer); - setProject(project); - setName(testCaseName); - } - - public IBuffer getBuffer() { - return _buffer; - } - - public void setBuffer(IBuffer b) { - _buffer = b; - } - - public IProject getProject() { - return _project; - } - - public void setProject(IProject p) { - _project = p; - } - - public String getName() { - return _testCaseName; - } - - public void setName(String name) { - _testCaseName = name; - } - - public void run(IProgressMonitor monitor) { - try { - GlobalConfiguration gconf = ConfigurationManager.getManager().getGlobalConfiguration(); - GlobalConfiguration origGconf = new GlobalConfiguration(gconf); - boolean autoBuildEnabled = ResourcesPlugin.getWorkspace().isAutoBuilding(); - try { - // In order for the operations to work correctly, set the enabled validators to - // the validators for which tests exist, and turn off auto-build so that a - // validation is forced. - gconf.setCanProjectsOverride(false); - //gconf.setAutoValidate(false); - //gconf.setAutoValidate(true); - //gconf.setBuildValidate(true); - //gconf.setMaximumNumberOfMessages(WorkbenchReporter.NO_MESSAGE_LIMIT); - gconf.passivate(); - - JDTUtility.setAutoBuild(false); - - monitor.subTask("Loading operations; please wait..."); //$NON-NLS-1$ - TestWrapper[] testCaseAndOperations = getOperations(monitor, gconf); - if(testCaseAndOperations == null) { - String message = "Test case failed; cannot test null operations."; //$NON-NLS-1$ - getBuffer().write(message); - monitor.subTask(message); - return; - } - - int numPassed = 0; - for(int i=0; i<testCaseAndOperations.length; i++) { - TestWrapper testWrapper = testCaseAndOperations[i]; - ValidationOperation operation = testWrapper.getOperation(); - boolean tpassed = false; - try { - if(monitor.isCanceled()) { - break; - } - monitor.subTask("Testing " + (i+1) + " of " + testCaseAndOperations.length + " constructors."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - preTest(testWrapper); - if(test(monitor, testWrapper)) { - numPassed++; - tpassed = true; - } - } - catch(Throwable exc) { - getBuffer().write("Throwable caught while testing #" + (i+1) + " " + operation.getClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$ - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - } - } - finally { - String message = "Test #" + (i+1) + " of " + testCaseAndOperations.length + ((tpassed) ? " passed." : " failed."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - monitor.subTask(message); - getBuffer().write(message); - getBuffer().addExecutionStatus(getName(), testWrapper.getName(), tpassed); //$NON-NLS-1$ - } - } - - String status = numPassed + " of " + testCaseAndOperations.length + " tests passed."; //$NON-NLS-1$ //$NON-NLS-2$ - monitor.subTask(status); - getBuffer().write(status); - } - finally { - // Set the project's settings back to what they were. - gconf = origGconf; - gconf.passivate(); - - JDTUtility.setAutoBuild(autoBuildEnabled); - } - } - catch(InvocationTargetException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - if(exc.getTargetException() != null) { - logger.write(Level.SEVERE, exc.getTargetException()); - } - } - } - } - - private void preTest(TestWrapper wrapper) throws CoreException { - // First, remove all of the markers. Can't rely on the operation to remove the markers between - // one invocation and the next because sometimes the validation is not supposed to run. - TaskListUtility.removeAllTasks(getProject(), wrapper.getValidatorNames()); // null=delete markers on all objects - } - - /** - * Return true if the test passes, and false if it failed. - */ - private boolean test(IProgressMonitor monitor, TestWrapper testWrapper) throws InvocationTargetException { - boolean result = true; - try { - result = BVTRunner.singleton().test(getBuffer(), getName(), testWrapper.getName(), testWrapper.getExpectedMessages(), testWrapper.getOperation(), testWrapper.getValidatorNames()) && result; - } - catch(BVTValidationException exc) { - result = false; - if(exc.getTargetException() != null) { - throw new InvocationTargetException(exc.getTargetException(), exc.getMessage()); - } - } - return result; - } - - /** - * Return an array, with the first entry in the array the ValidatorTestcase that - * holds the expected results, and the second entry of the array a ValidationOperation[] - * containing the operations to be tested. - */ - private TestWrapper[] getOperations(IProgressMonitor monitor, ValidationConfiguration vconf) throws InvocationTargetException { - ValidatorTestcase[] allTmds = JDTUtility.getVFTests(monitor, getProject()); - if((allTmds == null) || (allTmds.length == 0)) { - return null; - } - - // Some of the operation constructors require file extensions. - String fileExtension = ".java"; //$NON-NLS-1$ - String defaultExtension = null; - IFile javaFile = getProject().getFile("foo.java"); //$NON-NLS-1$ - - // Some of the operations below pass if they don't produce any results. - // Create a test case that passes the operation if the operation does nothing. - List tmdEmpty = new ArrayList(); // expected messages == none - List tmdInc = new ArrayList(); // expected messages when incremental validators ran - List tmdEnabled = new ArrayList(); // expected messages when enabled validators ran - List tmdJava = new ArrayList(); // expected messages when validators that validate .java files are run - List tmdFull = new ArrayList(); // expected messages when validators that support only "Run Validation" are run - Set enabledValidators = new HashSet(); // enabled validators == FWK Val, FWK NoBuild Val, Properties Val - Set enabledIncrementalValidators = new HashSet(); // enabled incremental == FWK Val, Properties Val (support incremental validation) - Set javaValidators = new HashSet(); // java val == FWK Val, FWK NoBuild Val (validate .java files) - Set fullValidators = new HashSet(); // full val == FWK NoBuild Val (runs only when "Run Validation" clicked) - ValidatorMetaData[] enabledVmd = new ValidatorMetaData[allTmds.length]; - for(int i=0; i<allTmds.length; i++) { - ValidatorTestcase vt = allTmds[i]; - - ValidatorMetaData vmd = vt.getValidatorMetaData(); - enabledValidators.add(vmd); - enabledVmd[i] = vmd; - if(vmd.isIncremental()) { - enabledIncrementalValidators.add(vmd); - } - else { - fullValidators.add(vmd); - tmdFull.addAll(vt.getMessages(ValidationTypeEnum.RUN_VALIDATION)); - } - - // It is the responsibility of the code that instantiates the ValidatorSubsetOperation - // to ensure that when an array of changed resources or objects is passed to the operation, - // that only incremental validators are invoked by the operation. The framework does not - // check if the validators are incremental or not; instead, the named validators will run, - // even if they perform a full validation instead of validating just the arrays. - if(vmd.isApplicableTo(javaFile) && vmd.isIncremental()) { - javaValidators.add(vmd); - tmdJava.addAll(vt.getMessages(ValidationTypeEnum.INCREMENTAL_VALIDATION)); - } - - tmdEnabled.addAll(vt.getMessages(ValidationTypeEnum.RUN_VALIDATION)); - tmdInc.addAll(vt.getMessages(ValidationTypeEnum.INCREMENTAL_VALIDATION)); - } - String[] allValidatorNames = InternalValidatorManager.getManager().getValidatorNames(enabledValidators); - String[] incValidatorNames = InternalValidatorManager.getManager().getValidatorNames(enabledIncrementalValidators); - String[] javaValidatorNames = InternalValidatorManager.getManager().getValidatorNames(javaValidators); - String[] fullValidatorNames = InternalValidatorManager.getManager().getValidatorNames(fullValidators); - - vconf.setEnabledValidators(enabledVmd); - vconf.passivate(); - - // Start constructing the tests - // For the tests that depend on the value of the autoBuild setting, it is assumed that - // autoBuild is on. The tests will fail if autoBuild is disabled. - // - // Unlike the subsequent operations, these first two cannot use the allTmds TMD because - // more than one validator runs. The allTmdFull TMD contains all tmd of validators that - // will run. - AllValidatorsOperation op1 = new AllValidatorsOperation(getProject()); - TestWrapper test1 = new TestWrapper(op1, tmdEnabled, "op1", allValidatorNames); //$NON-NLS-1$ - - AllValidatorsOperation op2 = new AllValidatorsOperation(getProject(), false); // don't fork - TestWrapper test2 = new TestWrapper(op2, tmdEnabled, "op2", allValidatorNames); //$NON-NLS-1$ - - // Construct the input for the rest of the operations using the VF Test validators. - TestOpConstrInputOperation inputOp = new TestOpConstrInputOperation(getBuffer(), getProject()); - try { - ResourcesPlugin.getWorkspace().run(inputOp, monitor); - } - catch(Throwable exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - } - return new TestWrapper[0]; - } - - IResource[] changedResources = TestOpConstrInputOperation.getChangedResources(getProject(), allTmds); - IResource[] emptyResources = TestOpConstrInputOperation.getEmptyResources(getProject()); - JavaHelpers[] changedClasses = inputOp.getChangedClasses(changedResources); - IResourceDelta emptyDelta = inputOp.getEmptyDelta(); - IResourceDelta changedDelta = inputOp.getChangedDelta(); - // end construct input - - EnabledIncrementalValidatorsOperation op3 = new EnabledIncrementalValidatorsOperation(getProject(), null,true); - TestWrapper test3 = new TestWrapper(op3, tmdInc, "op3", incValidatorNames); //$NON-NLS-1$ - - EnabledIncrementalValidatorsOperation op4 = new EnabledIncrementalValidatorsOperation(getProject(), changedDelta,false); - TestWrapper test4 = new TestWrapper(op4, tmdInc, "op4", incValidatorNames); //$NON-NLS-1$ - - EnabledIncrementalValidatorsOperation op5 = new EnabledIncrementalValidatorsOperation(getProject(), emptyDelta,false); - TestWrapper test5 = new TestWrapper(op5, tmdEmpty, "op5", incValidatorNames); //$NON-NLS-1$ - - EnabledIncrementalValidatorsOperation op6 = new EnabledIncrementalValidatorsOperation(getProject(), null, IRuleGroup.PASS_FAST,false); - TestWrapper test6 = new TestWrapper(op6, tmdInc, "op6", incValidatorNames); //$NON-NLS-1$ - - EnabledIncrementalValidatorsOperation op7 = new EnabledIncrementalValidatorsOperation(getProject(), changedDelta, IRuleGroup.PASS_FAST,false); - TestWrapper test7 = new TestWrapper(op7, tmdInc, "op7", incValidatorNames); //$NON-NLS-1$ - - EnabledIncrementalValidatorsOperation op8 = new EnabledIncrementalValidatorsOperation(getProject(), emptyDelta, IRuleGroup.PASS_FAST,false); - TestWrapper test8 = new TestWrapper(op8, tmdEmpty, "op8", incValidatorNames); //$NON-NLS-1$ - - EnabledIncrementalValidatorsOperation op9 = new EnabledIncrementalValidatorsOperation(getProject(), enabledIncrementalValidators, null, IRuleGroup.PASS_FAST); - TestWrapper test9 = new TestWrapper(op9, tmdInc, "op9", incValidatorNames); //$NON-NLS-1$ - - EnabledIncrementalValidatorsOperation op10 = new EnabledIncrementalValidatorsOperation(getProject(), enabledIncrementalValidators, changedDelta, IRuleGroup.PASS_FAST); - TestWrapper test10 = new TestWrapper(op10, tmdInc, "op10", incValidatorNames); //$NON-NLS-1$ - - EnabledIncrementalValidatorsOperation op11 = new EnabledIncrementalValidatorsOperation(getProject(), enabledIncrementalValidators, emptyDelta, IRuleGroup.PASS_FAST); - TestWrapper test11 = new TestWrapper(op11, tmdEmpty, "op11", incValidatorNames); //$NON-NLS-1$ - - EnabledIncrementalValidatorsOperation op12 = new EnabledIncrementalValidatorsOperation(getProject(), null, false); // full validate, don't fork - TestWrapper test12 = new TestWrapper(op12, tmdInc, "op12", incValidatorNames); //$NON-NLS-1$ - - EnabledIncrementalValidatorsOperation op13 = new EnabledIncrementalValidatorsOperation(getProject(), changedDelta, false); // delta validate, don't fork - TestWrapper test13 = new TestWrapper(op13, tmdInc, "op13", incValidatorNames); //$NON-NLS-1$ - - EnabledIncrementalValidatorsOperation op14 = new EnabledIncrementalValidatorsOperation(getProject(), emptyDelta, false); // empty delta validate, don't fork - TestWrapper test14 = new TestWrapper(op14, tmdEmpty, "op14", incValidatorNames); //$NON-NLS-1$ - - EnabledIncrementalValidatorsOperation op15 = new EnabledIncrementalValidatorsOperation(getProject(), null, IRuleGroup.PASS_FAST, false); // full validate, don't fork - TestWrapper test15 = new TestWrapper(op15, tmdInc, "op15", incValidatorNames); //$NON-NLS-1$ - - EnabledIncrementalValidatorsOperation op16 = new EnabledIncrementalValidatorsOperation(getProject(), changedDelta, IRuleGroup.PASS_FAST, false); // delta validate, don't fork - TestWrapper test16 = new TestWrapper(op16, tmdInc, "op16", incValidatorNames); //$NON-NLS-1$ - - EnabledIncrementalValidatorsOperation op17 = new EnabledIncrementalValidatorsOperation(getProject(), emptyDelta, IRuleGroup.PASS_FAST, false); // empty delta validate, don't fork - TestWrapper test17 = new TestWrapper(op17, tmdEmpty, "op17", incValidatorNames); //$NON-NLS-1$ - - EnabledValidatorsOperation op18 = new EnabledValidatorsOperation(getProject()); - TestWrapper test18= new TestWrapper(op18, tmdEnabled, "op18", allValidatorNames); //$NON-NLS-1$ - - EnabledValidatorsOperation op19 = new EnabledValidatorsOperation(getProject(), false); // don't fork - TestWrapper test19 = new TestWrapper(op19, tmdEnabled, "op19", allValidatorNames); //$NON-NLS-1$ - - EnabledValidatorsOperation op20 = new EnabledValidatorsOperation(getProject(), IRuleGroup.PASS_FAST); - TestWrapper test20 = new TestWrapper(op20, tmdEnabled, "op20", allValidatorNames); //$NON-NLS-1$ - - EnabledValidatorsOperation op21 = new EnabledValidatorsOperation(getProject(), IRuleGroup.PASS_FAST, true,false); // force validation if it doesn't need to run - TestWrapper test21 = new TestWrapper(op21, tmdEnabled, "op21", allValidatorNames); //$NON-NLS-1$ - - EnabledValidatorsOperation op22 = new EnabledValidatorsOperation(getProject(), IRuleGroup.PASS_FAST, false,false); // no force validation if it doesn't need to run - TestWrapper test22 = new TestWrapper(op22, tmdEnabled, "op22", allValidatorNames); //$NON-NLS-1$ - - EnabledValidatorsOperation op23 = new EnabledValidatorsOperation(getProject(), IRuleGroup.PASS_FAST, true, false); // force, don't fork - TestWrapper test23 = new TestWrapper(op23, tmdEnabled, "op23", allValidatorNames); //$NON-NLS-1$ - - EnabledValidatorsOperation op24 = new EnabledValidatorsOperation(getProject(), IRuleGroup.PASS_FAST, false, false); // no force, don't fork - TestWrapper test24 = new TestWrapper(op24, tmdEnabled, "op24", allValidatorNames); //$NON-NLS-1$ - - EnabledValidatorsOperation op25 = new EnabledIncrementalValidatorsOperation(getProject(), null,true); - TestWrapper test25 = new TestWrapper(op25, tmdEnabled, "op25", allValidatorNames); //$NON-NLS-1$ - - EnabledValidatorsOperation op26 = new EnabledIncrementalValidatorsOperation(getProject(), changedDelta,true); - TestWrapper test26 = new TestWrapper(op26, tmdInc, "op26", incValidatorNames); //$NON-NLS-1$ - - EnabledValidatorsOperation op27 = new EnabledIncrementalValidatorsOperation(getProject(), emptyDelta,true); - TestWrapper test27 = new TestWrapper(op27, tmdEmpty, "op27", incValidatorNames); //$NON-NLS-1$ - - EnabledValidatorsOperation op28 = new EnabledIncrementalValidatorsOperation(getProject(), null, IRuleGroup.PASS_FAST,true); - TestWrapper test28 = new TestWrapper(op28, tmdEnabled, "op28", allValidatorNames); //$NON-NLS-1$ - - EnabledValidatorsOperation op29 = new EnabledIncrementalValidatorsOperation(getProject(), changedDelta, IRuleGroup.PASS_FAST,true); - TestWrapper test29 = new TestWrapper(op29, tmdInc, "op29", incValidatorNames); //$NON-NLS-1$ - - EnabledValidatorsOperation op30 = new EnabledIncrementalValidatorsOperation(getProject(), emptyDelta, IRuleGroup.PASS_FAST,true); - TestWrapper test30 = new TestWrapper(op30, tmdEmpty, "op30", incValidatorNames); //$NON-NLS-1$ - - ValidatorMetaData vmd = allTmds[0].getValidatorMetaData(); - String validatorName = vmd.getValidatorUniqueName(); - String[] vmdNames = InternalValidatorManager.getManager().getValidatorNames(new ValidatorMetaData[]{vmd}); - List expectedMessages = allTmds[0].getMessages(ValidationTypeEnum.RUN_VALIDATION); - OneValidatorOperation op31 = new OneValidatorOperation(getProject(), validatorName); - TestWrapper test31 = new TestWrapper(op31, expectedMessages, "op31", vmdNames); //$NON-NLS-1$ - - OneValidatorOperation op32 = new OneValidatorOperation(getProject(), validatorName, true); // force if necessary - TestWrapper test32 = new TestWrapper(op32, expectedMessages, "op32", vmdNames); //$NON-NLS-1$ - - OneValidatorOperation op33 = new OneValidatorOperation(getProject(), validatorName, false); // no force - TestWrapper test33 = new TestWrapper(op33, expectedMessages, "op33", vmdNames); //$NON-NLS-1$ - - OneValidatorOperation op34 = new OneValidatorOperation(getProject(), validatorName, true, false); // force, no fork - TestWrapper test34 = new TestWrapper(op34, expectedMessages, "op34", vmdNames); //$NON-NLS-1$ - - OneValidatorOperation op35 = new OneValidatorOperation(getProject(), validatorName, false, false); // no force, no fork - TestWrapper test35 = new TestWrapper(op35, expectedMessages, "op35", vmdNames); //$NON-NLS-1$ - - OneValidatorOperation op36 = new OneValidatorOperation(getProject(), validatorName, true, IRuleGroup.PASS_FAST); // force - TestWrapper test36 = new TestWrapper(op36, expectedMessages, "op36", vmdNames); //$NON-NLS-1$ - - OneValidatorOperation op37 = new OneValidatorOperation(getProject(), validatorName, false, IRuleGroup.PASS_FAST); // no force - TestWrapper test37 = new TestWrapper(op37, expectedMessages, "op37", vmdNames); //$NON-NLS-1$ - - OneValidatorOperation op38 = new OneValidatorOperation(getProject(), validatorName, true, IRuleGroup.PASS_FAST, false); // force, no fork - TestWrapper test38 = new TestWrapper(op38, expectedMessages, "op38", vmdNames); //$NON-NLS-1$ - - OneValidatorOperation op39 = new OneValidatorOperation(getProject(), validatorName, false, IRuleGroup.PASS_FAST, false); // no force, no fork - TestWrapper test39 = new TestWrapper(op39, expectedMessages, "op39", vmdNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op40 = new ValidatorSubsetOperation(getProject(),true,false); - op40.setValidators(allValidatorNames); - TestWrapper test40 = new TestWrapper(op40, tmdEnabled, "op40", allValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op41 = new ValidatorSubsetOperation(getProject(), true,false); // force - op41.setValidators(allValidatorNames); - TestWrapper test41 = new TestWrapper(op41, tmdEnabled, "op41", allValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op42 = new ValidatorSubsetOperation(getProject(), false,false); // no force - op42.setValidators(allValidatorNames); - TestWrapper test42 = new TestWrapper(op42, tmdEnabled, "op42", allValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op43 = new ValidatorSubsetOperation(getProject(), true, false); // force, no fork - op43.setValidators(allValidatorNames); - TestWrapper test43 = new TestWrapper(op43, tmdEnabled, "op43", allValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op44 = new ValidatorSubsetOperation(getProject(), false, false); // no force, no fork - op44.setValidators(allValidatorNames); - TestWrapper test44 = new TestWrapper(op44, tmdEnabled, "op44", allValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op45 = new ValidatorSubsetOperation(getProject(), true, IRuleGroup.PASS_FAST,false); // force - op45.setValidators(allValidatorNames); - TestWrapper test45 = new TestWrapper(op45, tmdEnabled, "op45", allValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op46 = new ValidatorSubsetOperation(getProject(), false, IRuleGroup.PASS_FAST,false); // no force - op46.setValidators(allValidatorNames); - TestWrapper test46 = new TestWrapper(op46, tmdEnabled, "op46", allValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op47 = new ValidatorSubsetOperation(getProject(), true, IRuleGroup.PASS_FAST, false); // force, no fork - op47.setValidators(allValidatorNames); - TestWrapper test47 = new TestWrapper(op47, tmdEnabled, "op47", allValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op48 = new ValidatorSubsetOperation(getProject(), false, IRuleGroup.PASS_FAST, false); // no force, no fork - op48.setValidators(allValidatorNames); - TestWrapper test48 = new TestWrapper(op48, tmdEnabled, "op48", allValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op49 = new EnabledIncrementalValidatorsOperation(getProject(), null,false); - op49.setValidators(allValidatorNames); - TestWrapper test49 = new TestWrapper(op49, tmdEnabled, "op49", allValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op50 = new EnabledIncrementalValidatorsOperation(getProject(), changedDelta,false); - op50.setValidators(incValidatorNames); - TestWrapper test50 = new TestWrapper(op50, tmdInc, "op50", incValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op51 = new EnabledIncrementalValidatorsOperation(getProject(), emptyDelta,false); - op51.setValidators(incValidatorNames); - TestWrapper test51 = new TestWrapper(op51, tmdEmpty, "op51", incValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op52 = new EnabledIncrementalValidatorsOperation(getProject(), null, false); // false=autoBuild disabled - op52.setValidators(allValidatorNames); - TestWrapper test52 = new TestWrapper(op52, tmdEnabled, "op52", allValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op53 = new EnabledIncrementalValidatorsOperation(getProject(), null, true); // true=autoBuild enabled - op53.setValidators(fullValidatorNames); - TestWrapper test53 = new TestWrapper(op53, tmdFull, "op53", fullValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op54 = new EnabledIncrementalValidatorsOperation(getProject(), changedDelta, false); // false=autoBuild disabled - op54.setValidators(incValidatorNames); - TestWrapper test54 = new TestWrapper(op54, tmdInc, "op54", incValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op55 = new EnabledIncrementalValidatorsOperation(getProject(), changedDelta, true); // true=autoBuild enabled - op55.setValidators(incValidatorNames); - TestWrapper test55 = new TestWrapper(op55, tmdEmpty, "op55", incValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op56 = new EnabledIncrementalValidatorsOperation(getProject(), emptyDelta, false); // false=autoBuild disabled - op56.setValidators(incValidatorNames); - TestWrapper test56 = new TestWrapper(op56, tmdEmpty, "op56", incValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op57 = new EnabledIncrementalValidatorsOperation(getProject(), emptyDelta, true); // true=autoBuild enabled - op57.setValidators(incValidatorNames); - TestWrapper test57 = new TestWrapper(op57, tmdEmpty, "op57", incValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op58 = new EnabledIncrementalValidatorsOperation(getProject(),null, IRuleGroup.PASS_FAST,false); // false=autoBuild disabled - op58.setValidators(allValidatorNames); - TestWrapper test58 = new TestWrapper(op58, tmdEnabled, "op58", allValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op59 = new EnabledIncrementalValidatorsOperation(getProject(), null, IRuleGroup.PASS_FAST,false); // true=autoBuild enabled - op59.setValidators(allValidatorNames); - TestWrapper test59 = new TestWrapper(op59, tmdFull, "op59", allValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op60 = new EnabledIncrementalValidatorsOperation(getProject(), changedDelta, IRuleGroup.PASS_FAST,false); // false=autoBuild disabled - op60.setValidators(incValidatorNames); - TestWrapper test60 = new TestWrapper(op60, tmdInc, "op60", incValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op61 = new EnabledIncrementalValidatorsOperation(getProject(), changedDelta, IRuleGroup.PASS_FAST,false); // true=autoBuild enabled - op61.setValidators(incValidatorNames); - TestWrapper test61 = new TestWrapper(op61, tmdEmpty, "op61", incValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op62 = new EnabledIncrementalValidatorsOperation(getProject(), emptyDelta,IRuleGroup.PASS_FAST,false); // false=autoBuild disabled - op62.setValidators(incValidatorNames); - TestWrapper test62 = new TestWrapper(op62, tmdEmpty, "op62", incValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op63 = new EnabledIncrementalValidatorsOperation(getProject(), emptyDelta,IRuleGroup.PASS_FAST,true); // true=autoBuild enabled - op63.setValidators(incValidatorNames); - TestWrapper test63 = new TestWrapper(op63, tmdEmpty, "op63", incValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op64 = new EnabledIncrementalValidatorsOperation(getProject(),null,IRuleGroup.PASS_FAST,true); - op64.setValidators(allValidatorNames); - TestWrapper test64 = new TestWrapper(op64, tmdEnabled, "op64", allValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op65 = new EnabledIncrementalValidatorsOperation(getProject(), changedDelta, IRuleGroup.PASS_FAST,true); - op65.setValidators(incValidatorNames); - TestWrapper test65 = new TestWrapper(op65, tmdInc, "op65", incValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op66 = new EnabledIncrementalValidatorsOperation(getProject(), emptyDelta, IRuleGroup.PASS_FAST,true); - op66.setValidators(incValidatorNames); - TestWrapper test66 = new TestWrapper(op66, tmdEmpty, "op66", incValidatorNames); //$NON-NLS-1$ - - if(changedClasses != null) { - ValidatorSubsetOperation op67 = new ValidatorSubsetOperation(getProject(), fileExtension, changedResources,false); - op67.setValidators(javaValidatorNames); - TestWrapper test67 = new TestWrapper(op67, tmdJava, "op67", javaValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op68 = new ValidatorSubsetOperation(getProject(), fileExtension, changedResources, false); // no fork - op68.setValidators(javaValidatorNames); - TestWrapper test68 = new TestWrapper(op68, tmdJava, "op68", javaValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op69 = new ValidatorSubsetOperation(getProject(), fileExtension, defaultExtension, changedResources,false); - op69.setValidators(javaValidatorNames); - TestWrapper test69 = new TestWrapper(op69, tmdJava, "op69", javaValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op70 = new ValidatorSubsetOperation(getProject(), fileExtension, defaultExtension, changedResources, false); // no fork - op70.setValidators(javaValidatorNames); - TestWrapper test70 = new TestWrapper(op70, tmdJava, "op70", javaValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op71 = new ValidatorSubsetOperation(getProject(), fileExtension, emptyResources,false); - op71.setValidators(javaValidatorNames); - TestWrapper test71 = new TestWrapper(op71, tmdEmpty, "op71", javaValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op72 = new ValidatorSubsetOperation(getProject(), fileExtension, emptyResources, false); // no fork - op72.setValidators(javaValidatorNames); - TestWrapper test72 = new TestWrapper(op72, tmdEmpty, "op72", javaValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op73 = new ValidatorSubsetOperation(getProject(), fileExtension, defaultExtension, emptyResources,false); - op73.setValidators(javaValidatorNames); - TestWrapper test73 = new TestWrapper(op73, tmdEmpty, "op73", javaValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op74 = new ValidatorSubsetOperation(getProject(), fileExtension, defaultExtension, emptyResources, false); // no fork - op74.setValidators(javaValidatorNames); - TestWrapper test74 = new TestWrapper(op74, tmdEmpty, "op74", javaValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op75 = new ValidatorSubsetOperation(getProject(), fileExtension, changedClasses,false); - op75.setValidators(javaValidatorNames); - TestWrapper test75 = new TestWrapper(op75, tmdJava, "op75", javaValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op76 = new ValidatorSubsetOperation(getProject(), fileExtension, changedClasses, false); // no fork - op76.setValidators(javaValidatorNames); - TestWrapper test76 = new TestWrapper(op76, tmdJava, "op76", javaValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op77 = new ValidatorSubsetOperation(getProject(), fileExtension, defaultExtension, changedClasses,false); - op77.setValidators(javaValidatorNames); - TestWrapper test77 = new TestWrapper(op77, tmdJava, "op77", javaValidatorNames); //$NON-NLS-1$ - - ValidatorSubsetOperation op78 = new ValidatorSubsetOperation(getProject(), fileExtension, defaultExtension, changedClasses, false); // no fork - op78.setValidators(javaValidatorNames); - TestWrapper test78 = new TestWrapper(op78, tmdJava, "op78", javaValidatorNames); //$NON-NLS-1$ - - TestWrapper[] result = new TestWrapper[] { - test1, test2, test3, test4, test5, test6, test7, test8, test9, - test10, test11, test12, test13, test14, test15, test16, test17, test18, test19, - test20, test21, test22, test23, test24, test25, test26, test27, test28, test29, - test30, test31, test32, test33, test34, test35, test36, test37, test38, test39, - test40, test41, test42, test43, test44, test45, test46, test47, test48, test49, - test50, test51, test52, test53, test54, test55, test56, test57, test58, test59, - test60, test61, test62, test63, test64, test65, test66, test67, test68, test69, - test70, test71, test72, test73, test74, test75, test76, test77, test78 - }; - return result; - } - else { - TestWrapper[] result = new TestWrapper[] { - test1, test2, test3, test4, test5, test6, test7, test8, test9, - test10, test11, test12, test13, test14, test15, test16, test17, test18, test19, - test20, test21, test22, test23, test24, test25, test26, test27, test28, test29, - test30, test31, test32, test33, test34, test35, test36, test37, test38, test39, - test40, test41, test42, test43, test44, test45, test46, test47, test48, test49, - test50, test51, test52, test53, test54, test55, test56, test57, test58, test59, - test60, test61, test62, test63, test64, test65, test66 - }; - return result; - } - } - - private class TestWrapper { - private List _messages = null; - private ValidationOperation _operation = null; - private String _testName = null; - private String[] _validatorNames = null; - - TestWrapper(ValidationOperation op, List expectedMessages, String testName, String[] validatorNames) { - _messages = expectedMessages; - _operation = op; - _testName = testName; - _validatorNames = validatorNames; - } - - public List getExpectedMessages() { - return _messages; - } - - public ValidationOperation getOperation() { - return _operation; - } - - public String getName() { - return _testName; - } - - public String[] getValidatorNames() { - return _validatorNames; - } - } -} - diff --git a/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/VALFWK02Operation.java b/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/VALFWK02Operation.java deleted file mode 100644 index c7f9cf2f..00000000 --- a/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/VALFWK02Operation.java +++ /dev/null @@ -1,711 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 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.jst.validation.test.fwk; - -import java.lang.reflect.InvocationTargetException; -import java.util.Collections; -import java.util.Set; -import java.util.logging.Level; - -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.validation.test.BVTValidationPlugin; -import org.eclipse.jst.validation.test.IOperationRunnable; -import org.eclipse.jst.validation.test.ValidationTypeEnum; -import org.eclipse.jst.validation.test.fwk.validator.JDTUtility; -import org.eclipse.jst.validation.test.internal.registry.ValidatorTestcase; -import org.eclipse.jst.validation.test.internal.util.BVTRunner; -import org.eclipse.jst.validation.test.setup.IBuffer; -import org.eclipse.wst.validation.internal.ConfigurationManager; -import org.eclipse.wst.validation.internal.GlobalConfiguration; -import org.eclipse.wst.validation.internal.ProjectConfiguration; -import org.eclipse.wst.validation.internal.TaskListUtility; -import org.eclipse.wst.validation.internal.Tracing; -import org.eclipse.wst.validation.internal.ValidationConfiguration; -import org.eclipse.wst.validation.internal.ValidationRegistryReader; -import org.eclipse.wst.validation.internal.ValidatorMetaData; -import org.eclipse.wst.validation.internal.operations.EnabledValidatorsOperation; -import org.eclipse.wst.validation.internal.operations.ValidatorManager; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; - -/** - * This class runs the VALFWK02 test. - */ -public final class VALFWK02Operation implements IOperationRunnable { - private IProject _project = null; - private IBuffer _buffer = null; - private String _testCaseName = null; - public static String NEWLINE = System.getProperty("line.separator"); //$NON-NLS-1$ - - /** - * Must have a public default constructor in order to createExecutableExtension. - * MUST call setBuffer, setProject, and setName before using the operation. - */ - public VALFWK02Operation() { - } - - /** - * IProject must exist and be open. - */ - public VALFWK02Operation(IBuffer buffer, IProject project, String testCaseName) { - setProject(project); - setBuffer(buffer); - setName(testCaseName); - } - - public IBuffer getBuffer() { - return _buffer; - } - - public void setBuffer(IBuffer b) { - _buffer = b; - } - - public IProject getProject() { - return _project; - } - - public void setProject(IProject p) { - _project = p; - } - - public String getName() { - return _testCaseName; - } - - public void setName(String name) { - _testCaseName = name; - } - - public void run(IProgressMonitor monitor) { - IProject project = getProject(); - if(project == null) { - throw new IllegalArgumentException("Run VALFWK02 on an existing open IProject."); //$NON-NLS-1$ - } - - // First, add the ValidationBuilder to the Java Project - ValidatorManager.addProjectBuildValidationSupport(project); - - // Save the old user configuration and restore it in the finally block. - try { - GlobalConfiguration gconf = ConfigurationManager.getManager().getGlobalConfiguration(); - ProjectConfiguration pconf = ConfigurationManager.getManager().getProjectConfiguration(project); - GlobalConfiguration origGconf = new GlobalConfiguration(gconf); // copy the original values so that they can be restored in the finally block - ProjectConfiguration origPconf = new ProjectConfiguration(pconf); // copy the original values so that they can be restored in the finally block - boolean autoBuildEnabled = ResourcesPlugin.getWorkspace().isAutoBuilding(); - - ValidatorMetaData[] configuredValidators = pconf.getValidators(); - if(configuredValidators.length < 2) { - monitor.subTask("Run VALFWK02 on an existing open project that has at least two validators configured: one to enable, and one to disable."); //$NON-NLS-1$ - return; - } - - // Disable at least one validator for this test. - // Remove the first enabled validator from the Properties, and the second enabled validator from the - // Preferences. (It doesn't matter which validator is removed; it only matters that the Properties and - // the Preferences have different validators.) - ValidatorMetaData vfTestValidator = ValidationRegistryReader.getReader().getValidatorMetaData(TestOpConstrInputOperation.FWK_NOBUILD_TEST_VALIDATOR_CLASS); //$NON-NLS-1$ - ValidatorMetaData vfNoBuildTestValidator = ValidationRegistryReader.getReader().getValidatorMetaData(TestOpConstrInputOperation.FWK_TEST_VALIDATOR_CLASS); //$NON-NLS-1$ - ValidatorMetaData propertiesValidator = ValidationRegistryReader.getReader().getValidatorMetaData(TestOpConstrInputOperation.PROPERTIES_VALIDATOR_CLASS); //$NON-NLS-1$ - ValidatorMetaData[] enabledPropValidators = new ValidatorMetaData[2]; - enabledPropValidators[0] = vfTestValidator; - enabledPropValidators[1] = vfNoBuildTestValidator; - pconf.setEnabledValidators(enabledPropValidators); - //pconf.setMaximumNumberOfMessages(1); - pconf.passivate(); - - ValidatorMetaData[] enabledPrefValidators = new ValidatorMetaData[1]; - enabledPrefValidators[0] = propertiesValidator; - gconf.setEnabledValidators(enabledPrefValidators); - //gconf.setMaximumNumberOfMessages(10); - gconf.passivate(); - - - ValidatorTestcase[] tmds = JDTUtility.getVFTests(monitor, getProject()); - if((tmds == null) || (tmds.length == 0)) { - monitor.subTask("Cannot run VALFWK02 because there are no test cases registered for JavaProject."); //$NON-NLS-1$ - return; - } - - ValidatorTestcase fwkNobuildTestTMD = null; - ValidatorTestcase fwkTestTMD = null; - ValidatorTestcase propTMD = null; - for(int i=0; i<tmds.length; i++) { - ValidatorTestcase tmd = tmds[i]; - if(tmd.getValidatorClass().equals(TestOpConstrInputOperation.FWK_TEST_VALIDATOR_CLASS)) { - fwkTestTMD = tmd; - } - else if(tmd.getValidatorClass().equals(TestOpConstrInputOperation.PROPERTIES_VALIDATOR_CLASS)) { - propTMD = tmd; - } - else if(tmd.getValidatorClass().equals(TestOpConstrInputOperation.FWK_NOBUILD_TEST_VALIDATOR_CLASS)) { - fwkNobuildTestTMD = tmd; - } - - if((fwkTestTMD != null) && (propTMD != null) && (fwkNobuildTestTMD != null)) { - break; - } - } - - if((fwkTestTMD == null) || (propTMD == null) || (fwkNobuildTestTMD == null)) { - // Can't run the tests - monitor.subTask("Cannot run VALFWK02 because the test case is missing for either the VF Test Validator, Properties Validator, or both."); //$NON-NLS-1$ - return; - } - - try { - // Set level to FINEST so that the launch validators are accumulated in ValidationOperation. - // (See ValidationOperation::getLaunchedValidators()) - Tracing.setForceLogging(true); - - getBuffer().write("testPropNotOverride"); //$NON-NLS-1$ - int allowPass = testPropNotOverride(monitor, project, gconf, pconf, propTMD); - getBuffer().write(NEWLINE); //$NON-NLS-1$ - getBuffer().write("testPropOverride"); //$NON-NLS-1$ - int propPass = testPropOverride(monitor, project, gconf, pconf, fwkTestTMD); - getBuffer().write(NEWLINE); //$NON-NLS-1$ - getBuffer().write("testPrefNotAllowOverride"); //$NON-NLS-1$ - int notAllowPass = testPrefNotAllowOverride(monitor, project, gconf, pconf, propTMD); - StringBuffer result = new StringBuffer(NEWLINE); - result.append("Properties Doesn't Override: "); //$NON-NLS-1$ - result.append(allowPass); - result.append(" of 7 pass."); //$NON-NLS-1$ - result.append(NEWLINE); - result.append("Properites Overrides: "); //$NON-NLS-1$ - result.append(propPass); - result.append(" of 7 pass."); //$NON-NLS-1$ - result.append(NEWLINE); - result.append("Preference Doesn't Allow Override: "); //$NON-NLS-1$ - result.append(notAllowPass); - result.append(" of 7 pass."); //$NON-NLS-1$ - result.append(NEWLINE); - monitor.subTask(result.toString()); - getBuffer().write(NEWLINE); //$NON-NLS-1$ - getBuffer().write(result.toString()); - } - finally { - gconf = origGconf; - gconf.passivate(); - - pconf = origPconf; - pconf.passivate(); - - JDTUtility.setAutoBuild(autoBuildEnabled); - - } - } - catch(InvocationTargetException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - if(exc.getTargetException() != null) { - logger.write(Level.SEVERE, exc.getTargetException()); - } - } - } - catch(Throwable exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - } - } - } - - private static void debug(IBuffer buffer, String title, ValidatorMetaData[] enabledValidators) { - buffer.write("Contents of " + title); //$NON-NLS-1$ - for(int i=0; i<enabledValidators.length; i++) { - ValidatorMetaData vmd = enabledValidators[i]; - buffer.write("\t" + vmd.getValidatorDisplayName()); //$NON-NLS-1$ - } - buffer.write("End contents of " + title); //$NON-NLS-1$ - buffer.write(NEWLINE); //$NON-NLS-1$ - } - - - private int testPropNotOverride(final IProgressMonitor monitor, final IProject project, GlobalConfiguration gconf, ProjectConfiguration pconf, ValidatorTestcase tmd) { - int numPass = 0; - try { - // Set up the user configuration for the test. The run(IProgressMonitor) method - // will set the values back to what they were before the test. - gconf.setCanProjectsOverride(true); - gconf.passivate(); - pconf.setDoesProjectOverride(false); - pconf.passivate(); - - ValidatorManager.getManager().updateTaskList(project); // Update the task list because the preference and properties page do, so the configuration classes don't. - - debug(getBuffer(), "Enabled Properties Validators", pconf.getEnabledValidators()); //$NON-NLS-1$ - debug(getBuffer(), "Enabled Preference Validators", gconf.getEnabledValidators()); //$NON-NLS-1$ - - numPass = validate(monitor, project, gconf, tmd, "testPropNotOverride"); //$NON-NLS-1$ - } - catch(InvocationTargetException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - if(exc.getTargetException() != null) { - logger.write(Level.SEVERE, exc.getTargetException()); - } - } - numPass = 0; - } - catch(Throwable exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - } - numPass = 0; - } - - return numPass; - } - - - private int testPropOverride(final IProgressMonitor monitor, final IProject project, GlobalConfiguration gconf, ProjectConfiguration pconf, ValidatorTestcase tmd) { - int numPass = 0; - try { - // Set up the user configuration for the test. The run(IProgressMonitor) method - // will set the values back to what they were before the test. - gconf.setCanProjectsOverride(true); - gconf.passivate(); - pconf.setDoesProjectOverride(true); - pconf.passivate(); - - ValidatorManager.getManager().updateTaskList(project); // Update the task list because the preference and properties page do, so the configuration classes don't. - - debug(getBuffer(), "Enabled Properties Validators", pconf.getEnabledValidators()); //$NON-NLS-1$ - debug(getBuffer(), "Enabled Preference Validators", gconf.getEnabledValidators()); //$NON-NLS-1$ - - numPass = validate(monitor, project, pconf, tmd, "testPropOverride"); //$NON-NLS-1$ - } - catch(InvocationTargetException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - if(exc.getTargetException() != null) { - logger.write(Level.SEVERE, exc.getTargetException()); - } - } - } - catch(Throwable exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - } - } - return numPass; - } - - private int testPrefNotAllowOverride(final IProgressMonitor monitor, final IProject project, GlobalConfiguration gconf, ProjectConfiguration pconf, ValidatorTestcase tmd) { - int numPass = 0; - try { - // Set up the user configuration for the test. The run(IProgressMonitor) method - // will set the values back to what they were before the test. - gconf.setCanProjectsOverride(false); - gconf.passivate(); - pconf.setDoesProjectOverride(true); - pconf.passivate(); - - ValidatorManager.getManager().updateTaskList(project); // Update the task list because the preference and properties page do, so the configuration classes don't. - - debug(getBuffer(), "Enabled Properties Validators", pconf.getEnabledValidators()); //$NON-NLS-1$ - debug(getBuffer(), "Enabled Preference Validators", gconf.getEnabledValidators()); //$NON-NLS-1$ - - numPass = validate(monitor, project, gconf, tmd, "testPrefNotAllowOverride"); //$NON-NLS-1$ - } - catch(InvocationTargetException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - if(exc.getTargetException() != null) { - logger.write(Level.SEVERE, exc.getTargetException()); - } - } - } - catch(Throwable exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - } - } - return numPass; - } - - private int validate(IProgressMonitor monitor, IProject project, ValidationConfiguration vconf, ValidatorTestcase tmd, String testName) { - int numPass = 0; - boolean successful = true; // Assume that all of the test cases will pass. - try { - // For the first four tests, need all of the messages to be reported - //int originalLimit = vconf.getMaximumNumberOfMessages(); - //vconf.setMaximumNumberOfMessages(WorkbenchReporter.NO_MESSAGE_LIMIT); - vconf.passivate(); - - boolean pass = runValidation(monitor, project, vconf); - if(!pass) { -// getBuffer().write(testName + "::runValidation failed"); //$NON-NLS-1$ - successful = false; - } - else { - numPass++; -// getBuffer().write(testName + "::runValidation passed"); //$NON-NLS-1$ - } - getBuffer().addExecutionStatus(getName(), "::" + testName + "runValidation", pass); //$NON-NLS-1$ //$NON-NLS-2$ - - pass = fullBuildValidate(monitor, project, vconf, tmd); - if(!pass) { -// getBuffer().write(testName + "::fullBuildValidation failed"); //$NON-NLS-1$ - successful = false; - } - else { - numPass++; -// getBuffer().write(testName + "::fullBuildValidation passed"); //$NON-NLS-1$ - } - getBuffer().addExecutionStatus(getName(), "::" + testName + "fullBuildValidation", pass); //$NON-NLS-1$ //$NON-NLS-2$ - - pass = autoValidateEnabled(monitor, project, vconf, tmd); - if(!pass) { - successful = false; -// getBuffer().write(testName + "::autoValidateEnabled failed"); //$NON-NLS-1$ - } - else { - numPass++; -// getBuffer().write(testName + "::autoValidateEnabled passed"); //$NON-NLS-1$ - } - getBuffer().addExecutionStatus(getName(), "::" + testName + "autoValidateEnabled", pass); //$NON-NLS-1$ //$NON-NLS-2$ - - pass = autoValidateDisabled(monitor, project, vconf, tmd); - if(!pass) { -// getBuffer().write(testName + "::autoValidateDisabled failed"); //$NON-NLS-1$ - successful = false; - } - else { - numPass++; -// getBuffer().write(testName + "::autoValidateDisabled passed"); //$NON-NLS-1$ - } - getBuffer().addExecutionStatus(getName(), "::" + testName + "autoValidateDisabled", pass); //$NON-NLS-1$ //$NON-NLS-2$ - - pass = buildValidateEnabled(monitor, project, vconf, tmd); - if(!pass) { -// getBuffer().write(testName + "::buildValidateEnabled failed"); //$NON-NLS-1$ - successful = false; - } - else { - numPass++; -// getBuffer().write(testName + "::buildValidateEnabled passed"); //$NON-NLS-1$ - } - getBuffer().addExecutionStatus(getName(), "::" + testName + "buildValidateEnabled", pass); //$NON-NLS-1$ //$NON-NLS-2$ - - pass = buildValidateDisabled(monitor, project, vconf, tmd); - if(!pass) { -// getBuffer().write(testName + "::buildValidateDisabled failed"); //$NON-NLS-1$ - successful = false; - } - else { - numPass++; -// getBuffer().write(testName + "::buildValidateDisabled passed"); //$NON-NLS-1$ - } - getBuffer().addExecutionStatus(getName(), "::" + testName + "buildValidateDisabled", pass); //$NON-NLS-1$ //$NON-NLS-2$ - - // And for this test, the original limit needs to be enforced - //vconf.setMaximumNumberOfMessages(originalLimit); - vconf.passivate(); - - pass = maxMessagesReported(monitor, project, vconf); - if(!pass) { - successful = false; -// getBuffer().write(testName + "::maxMessagesReported failed"); //$NON-NLS-1$ - } - else { - numPass++; -// getBuffer().write(testName + "::maxMessagesReported passed"); //$NON-NLS-1$ - } - getBuffer().addExecutionStatus(getName(), "::" + testName + "maxMessagesReported", pass); //$NON-NLS-1$ //$NON-NLS-2$ - } - catch(InvocationTargetException exc) { - successful = false; - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - if(exc.getTargetException() != null) { - logger.write(Level.SEVERE, exc.getTargetException()); - } - } - } - finally { - getBuffer().addExecutionStatus(getName(), testName, successful); //$NON-NLS-1$ - } - return numPass; - } - - private boolean runValidation(IProgressMonitor monitor, IProject project, ValidationConfiguration vconf) { - boolean passed = true; - try { - // Unlike the other validations, which rely on a build, this method has access to the - // operation and can query it for the list of validators that were launched. This technique - // is better because it doesn't rely on the validator producing the correct output (markers). - // VALFWK02 just wants to check that the correct validators were launched; the TestOpConstr - // test wants to check the result given different output and constructor of the Operation. - - EnabledValidatorsOperation validOp = new EnabledValidatorsOperation(project,false); - ResourcesPlugin.getWorkspace().run(validOp, monitor); - // Launched validators should be configured, enabled, and had files to validate on the project. - Set<ValidatorMetaData> launchedValidators = validOp.getLaunchedValidators(); - - // Since a full validation was run, the launched validators should be equivalent - // to the configured enabled valdiators. - ValidatorMetaData[] enabledValidators = vconf.getEnabledValidators(); - for(int i=0; i<enabledValidators.length; i++) { - ValidatorMetaData vmd = enabledValidators[i]; - - // If it's configured on the project, ensure that the enabled validator was launched. - // (May not be configured if the enabled validators is the list of Preference enabled - // validators.) - if(!launchedValidators.contains(vmd)) { - getBuffer().write("ERROR: Expected validator " + vmd.getValidatorDisplayName() + " was not run on project " + project.getName() + ". Failing test."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - passed = false; - } - else { - getBuffer().write("INFO: Expected validator " + vmd.getValidatorDisplayName() + " ran as expected on project " + project.getName() + "."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - } - - if(passed == false) { - getBuffer().write("launched validators are the following:"); //$NON-NLS-1$ - for(ValidatorMetaData vmd : launchedValidators) { - getBuffer().write("\t" + vmd.getValidatorDisplayName()); //$NON-NLS-1$ - } - getBuffer().write("end of launched validators"); //$NON-NLS-1$ - } - } - catch(CoreException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - } - passed = false; - } - catch(InvocationTargetException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - if(exc.getTargetException() != null) { - logger.write(Level.SEVERE, exc.getTargetException()); - } - } - } - - - return passed; - } - - private boolean fullBuildValidate(IProgressMonitor monitor, IProject project, ValidationConfiguration vconf, ValidatorTestcase tmd) { - try { - //vconf.setBuildValidate(true); - vconf.passivate(); - - TaskListUtility.removeAllTasks(project); - IResource[] changedResources = tmd.getResources(project);; - TestOpConstrInputOperation.touch(project, changedResources); - - project.build(IncrementalProjectBuilder.FULL_BUILD, monitor); - IMarker[] messagesAfterBuild = TaskListUtility.getValidationTasks(project, IMessage.ALL_MESSAGES); - - return BVTRunner.singleton().compare(getBuffer(), getName(), tmd.getName(), tmd.getMessages(ValidationTypeEnum.FULL_VALIDATION), messagesAfterBuild); - } - catch(CoreException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - } - return false; - } - catch(InvocationTargetException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - if(exc.getTargetException() != null) { - logger.write(Level.SEVERE, exc.getTargetException()); - } - } - return false; - } - } - - private boolean autoValidateEnabled(IProgressMonitor monitor, IProject project, ValidationConfiguration vconf, ValidatorTestcase tmd) { - JDTUtility.setAutoBuild(true); - - try { - //vconf.setAutoValidate(true); - vconf.passivate(); - - TaskListUtility.removeAllTasks(project); - IResource[] changedResources = tmd.getResources(project);; - TestOpConstrInputOperation.touch(project, changedResources); - - project.build(IncrementalProjectBuilder.AUTO_BUILD, monitor); - IMarker[] messagesAfterBuild = TaskListUtility.getValidationTasks(project, IMessage.ALL_MESSAGES); - - return BVTRunner.singleton().compare(getBuffer(), getName(), tmd.getName(), tmd.getMessages(ValidationTypeEnum.AUTO_VALIDATION), messagesAfterBuild); - } - catch(CoreException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - } - return false; - } - catch(InvocationTargetException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - if(exc.getTargetException() != null) { - logger.write(Level.SEVERE, exc.getTargetException()); - } - } - return false; - } - } - - private boolean autoValidateDisabled(IProgressMonitor monitor, IProject project, ValidationConfiguration vconf, ValidatorTestcase tmd) { - JDTUtility.setAutoBuild(true); - - try { - //vconf.setAutoValidate(false); - vconf.passivate(); - - TaskListUtility.removeAllTasks(project); - IResource[] changedResources = tmd.getResources(project); - TestOpConstrInputOperation.touch(project, changedResources); - - project.build(IncrementalProjectBuilder.AUTO_BUILD, monitor); - IMarker[] messagesAfterBuild = TaskListUtility.getValidationTasks(project, IMessage.ALL_MESSAGES); - - // Pass in an empty list because the validation isn't supposed to run. - return BVTRunner.singleton().compare(getBuffer(), getName(), tmd.getName(), Collections.EMPTY_LIST, messagesAfterBuild); - } - catch(CoreException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - } - return false; - } - catch(InvocationTargetException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - if(exc.getTargetException() != null) { - logger.write(Level.SEVERE, exc.getTargetException()); - } - } - return false; - } - } - - private boolean buildValidateEnabled(IProgressMonitor monitor, IProject project, ValidationConfiguration vconf, ValidatorTestcase tmd) { - try { - //vconf.setBuildValidate(true); - vconf.passivate(); - JDTUtility.setAutoBuild(false); - - // Construct the input - TaskListUtility.removeAllTasks(project); - IResource[] changedResources = tmd.getResources(project); - TestOpConstrInputOperation.touch(project, changedResources); - try { - project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor); - } - catch(CoreException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - } - return false; - } - IMarker[] messagesAfterBuild = TaskListUtility.getValidationTasks(project, IMessage.ALL_MESSAGES); - - return BVTRunner.singleton().compare(getBuffer(), getName(), tmd.getName(), tmd.getMessages(ValidationTypeEnum.INCREMENTAL_VALIDATION), messagesAfterBuild); - } - catch(InvocationTargetException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - if(exc.getTargetException() != null) { - logger.write(Level.SEVERE, exc.getTargetException()); - } - } - return false; - } - } - - private boolean buildValidateDisabled(IProgressMonitor monitor, IProject project, ValidationConfiguration vconf, ValidatorTestcase tmd) { - try { - //vconf.setBuildValidate(false); - vconf.passivate(); - JDTUtility.setAutoBuild(false); - - // Construct the input - TaskListUtility.removeAllTasks(project); - IResource[] changedResources = tmd.getResources(project); - TestOpConstrInputOperation.touch(project, changedResources); - try { - project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor); - IMarker[] messagesAfterBuild = TaskListUtility.getValidationTasks(project, IMessage.ALL_MESSAGES); - - // Pass in an empty list because validation isn't supposed to run. - return BVTRunner.singleton().compare(getBuffer(), getName(), tmd.getName(), Collections.EMPTY_LIST, messagesAfterBuild); - } - catch(CoreException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - } - return false; - } - } - catch(InvocationTargetException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - if(exc.getTargetException() != null) { - logger.write(Level.SEVERE, exc.getTargetException()); - } - } - return false; - } - } - - private boolean maxMessagesReported(IProgressMonitor monitor, IProject project, ValidationConfiguration vconf) { - EnabledValidatorsOperation validOp = null; - try { - validOp = new EnabledValidatorsOperation(project,false); - ResourcesPlugin.getWorkspace().run(validOp, monitor); - } - catch(CoreException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - } - return false; - } - - return false; - } - -} - - diff --git a/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/validator/FwkNoBuildTestHelper.java b/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/validator/FwkNoBuildTestHelper.java deleted file mode 100644 index 9ad3df87..00000000 --- a/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/validator/FwkNoBuildTestHelper.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 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.jst.validation.test.fwk.validator; - -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceVisitor; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jem.java.JavaHelpers; -import org.eclipse.jst.j2ee.internal.validation.AWorkbenchMOFHelper; -import org.eclipse.wst.validation.internal.core.IFileDelta; -import org.eclipse.wst.validation.internal.operations.WorkbenchFileDelta; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; - -public class FwkNoBuildTestHelper extends AWorkbenchMOFHelper { - - public FwkNoBuildTestHelper() { - super(); - - registerModel(FwkTestValidator.ALL_FILES, "loadAllFiles"); //$NON-NLS-1$ - registerModel(FwkTestValidator.JAVAHELPERS, "loadJavaHelpers", new Class[]{IFileDelta.class}); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see com.ibm.etools.validate.IWorkbenchHelper#getTargetObjectName(java.lang.Object) - */ - public String getTargetObjectName(Object arg0) { - // No target objects outside of an IResource are used, therefore no target object names are needed. - return null; - } - - public IFileDelta[] loadAllFiles() { - IProject project = getProject(); - - final Set files = new HashSet(); - IResourceVisitor visitor = new IResourceVisitor() { - public boolean visit(IResource res) throws CoreException { - if(!res.isAccessible()) { - return false; // if the resource isn't accessible then neither are its children - } - - if((res instanceof IFile) && ("java".equals(res.getFileExtension()))) { //$NON-NLS-1$ - WorkbenchFileDelta newFileDelta = new WorkbenchFileDelta(res.getFullPath().toString(), IFileDelta.CHANGED, res); - files.add(newFileDelta); - } - - return true; // visit the resource's children as well - } - }; - - try { - project.accept(visitor, IResource.DEPTH_INFINITE, true); // true means include phantom resources - } - catch(CoreException exc) { - exc.printStackTrace(); - } - - IFileDelta[] result = new IFileDelta[files.size()]; - files.toArray(result); - return result; - } - - public JavaHelpers loadJavaHelpers(IFileDelta delta) { - WorkbenchFileDelta fd = (WorkbenchFileDelta)delta; - IResource result = fd.getResource(); - if(result != null){ - if(result instanceof IFile) { - return JDTUtility.getJavaHelpers((IFile)result); - } - else { - return null; - } - } - else { - // This validator validates only .java files, so this - // must be an instanceof JavaClass. - return (JavaHelpers)fd.getObject(); - } - } - - /* (non-Javadoc) - * @see com.ibm.etools.validate.IWorkbenchHelper#getResource(java.lang.Object) - */ - public IResource getResource(Object object) { - IResource result = super.getResource(object); - if((result != null) && (result.exists())) { - return result; - } - - if (object == null) { - return null; - } - - if(object instanceof JavaHelpers) { - // If the message was added to a JavaHelpers, this method will be called. - return JDTUtility.getResource(getProject(), (JavaHelpers) object); - } - else if(object instanceof WorkbenchFileDelta) { - // If the workbench is removing messages from files, and the object is set - // instead of the IResource, need to process the delta's object instead of - // its resource. - return JDTUtility.getResource(getProject(), (JavaHelpers)((WorkbenchFileDelta)object).getObject()); - } - return null; - } - - /* (non-Javadoc) - * @see com.ibm.etools.validate.AWorkbenchHelper#getLineNo(java.lang.Object) - */ - public int getLineNo(Object object) { - int lineNo = super.getLineNo(object); - if(lineNo == IMessage.LINENO_UNSET) { - // No adapters, so fudge the line number by adding the message to the first line in the file. - return 1; - } - return lineNo; - } - -} diff --git a/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/validator/FwkNoBuildTestValidator.java b/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/validator/FwkNoBuildTestValidator.java deleted file mode 100644 index 18242f04..00000000 --- a/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/validator/FwkNoBuildTestValidator.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.eclipse.jst.validation.test.fwk.validator; - -import org.eclipse.jem.java.JavaHelpers; -import org.eclipse.wst.validation.internal.core.IFileDelta; -import org.eclipse.wst.validation.internal.core.ValidationException; -import org.eclipse.wst.validation.internal.operations.LocalizedMessage; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; -import org.eclipse.wst.validation.internal.provisional.core.IValidationContext; -import org.eclipse.wst.validation.internal.provisional.core.IValidator; - -public class FwkNoBuildTestValidator implements IValidator { - public static final String ALL_FILES = "ALL_FILES"; // Load all IFileDeltas for the entire contents of the current project. //$NON-NLS-1$ - public static final String JAVAHELPERS = "JAVAHELPERS"; // The JavaClass that the IFileDelta maps to. //$NON-NLS-1$ - - /* (non-Javadoc) - * @see com.ibm.etools.validation.IValidator#cleanup(com.ibm.etools.validation.IReporter) - */ - public void cleanup(IReporter reporter) { - // Nothing is cached, so nothing to do. - } - - /* (non-Javadoc) - * @see com.ibm.etools.validation.IValidator#validate(com.ibm.etools.validation.IHelper, com.ibm.etools.validation.IReporter, com.ibm.etools.validation.IFileDelta[]) - */ - public void validate(IValidationContext helper, IReporter reporter) throws ValidationException { - IFileDelta[] delta = null ; - if((delta == null) || (delta.length ==0)) { - // Full Validate - delta = (IFileDelta[])helper.loadModel(ALL_FILES); - } - - if(delta == null) { - // Problem loading the files - return; - } - - for(int i=0; i<delta.length; i++) { - JavaHelpers target = (JavaHelpers)helper.loadModel(JAVAHELPERS, new Object[]{delta[i]}); - LocalizedMessage message = new LocalizedMessage(IMessage.LOW_SEVERITY, "This is a test message for the validation framework, reported by VF NoBuild Test Validator. Please ignore.", target); //$NON-NLS-1$ - reporter.addMessage(this, message); - } - } - -} diff --git a/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/validator/FwkTestHelper.java b/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/validator/FwkTestHelper.java deleted file mode 100644 index 4274e551..00000000 --- a/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/validator/FwkTestHelper.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.eclipse.jst.validation.test.fwk.validator; - -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceVisitor; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jem.java.JavaHelpers; -import org.eclipse.jst.j2ee.internal.validation.AWorkbenchMOFHelper; -import org.eclipse.wst.validation.internal.core.IFileDelta; -import org.eclipse.wst.validation.internal.operations.WorkbenchFileDelta; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; - -public class FwkTestHelper extends AWorkbenchMOFHelper { - - public FwkTestHelper() { - super(); - - registerModel(FwkTestValidator.ALL_FILES, "loadAllFiles"); //$NON-NLS-1$ - registerModel(FwkTestValidator.JAVAHELPERS, "loadJavaHelpers", new Class[]{IFileDelta.class}); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see com.ibm.etools.validate.IWorkbenchHelper#getTargetObjectName(java.lang.Object) - */ - public String getTargetObjectName(Object arg0) { - // No target objects outside of an IResource are used, therefore no target object names are needed. - return null; - } - - public IFileDelta[] loadAllFiles() { - IProject project = getProject(); - - final Set files = new HashSet(); - IResourceVisitor visitor = new IResourceVisitor() { - public boolean visit(IResource res) throws CoreException { - if(!res.isAccessible()) { - return false; // if the resource isn't accessible then neither are its children - } - - if((res instanceof IFile) && ( (res.getFileExtension() != null) && res.getFileExtension().equals("java"))) { //$NON-NLS-1$ - WorkbenchFileDelta newFileDelta = new WorkbenchFileDelta(res.getFullPath().toString(), IFileDelta.CHANGED, res); - files.add(newFileDelta); - } - - return true; // visit the resource's children as well - } - }; - - try { - project.accept(visitor, IResource.DEPTH_INFINITE, true); // true means include phantom resources - } - catch(CoreException exc) { - exc.printStackTrace(); - } - - IFileDelta[] result = new IFileDelta[files.size()]; - files.toArray(result); - return result; - } - - public JavaHelpers loadJavaHelpers(IFileDelta delta) { - WorkbenchFileDelta fd = (WorkbenchFileDelta)delta; - IResource result = fd.getResource(); - if(result != null){ - if(result instanceof IFile) { - return JDTUtility.getJavaHelpers((IFile)result); - } - else { - return null; - } - } - else { - // This validator validates only .java files, so this - // must be an instanceof JavaClass. - return (JavaHelpers)fd.getObject(); - } - } - - /* (non-Javadoc) - * @see com.ibm.etools.validate.IWorkbenchHelper#getResource(java.lang.Object) - */ - public IResource getResource(Object object) { - IResource result = super.getResource(object); - if((result != null) && (result.exists())) { - return result; - } - - if (object == null) { - return null; - } - - if(object instanceof JavaHelpers) { - // If the message was added to a JavaHelpers, this method will be called. - return JDTUtility.getResource(getProject(), (JavaHelpers) object); - } - else if(object instanceof WorkbenchFileDelta) { - // If the workbench is removing messages from files, and the object is set - // instead of the IResource, need to process the delta's object instead of - // its resource. - return JDTUtility.getResource(getProject(), (JavaHelpers)((WorkbenchFileDelta)object).getObject()); - } - return null; - } - - /* (non-Javadoc) - * @see com.ibm.etools.validate.AWorkbenchHelper#getLineNo(java.lang.Object) - */ - public int getLineNo(Object object) { - int lineNo = super.getLineNo(object); - if(lineNo == IMessage.LINENO_UNSET) { - // No adapters, so fudge the line number by adding the message to the first line in the file. - return 1; - } - return lineNo; - } - -} diff --git a/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/validator/FwkTestValidator.java b/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/validator/FwkTestValidator.java deleted file mode 100644 index 6d1fabd2..00000000 --- a/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/validator/FwkTestValidator.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.eclipse.jst.validation.test.fwk.validator; - -import org.eclipse.jem.java.JavaHelpers; -import org.eclipse.wst.validation.internal.core.IFileDelta; -import org.eclipse.wst.validation.internal.core.ValidationException; -import org.eclipse.wst.validation.internal.operations.LocalizedMessage; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; -import org.eclipse.wst.validation.internal.provisional.core.IValidationContext; -import org.eclipse.wst.validation.internal.provisional.core.IValidator; - -public class FwkTestValidator implements IValidator { - public static final String ALL_FILES = "ALL_FILES"; // Load all IFileDeltas for the entire contents of the current project. //$NON-NLS-1$ - public static final String JAVAHELPERS = "JAVAHELPERS"; // The JavaClass that the IFileDelta maps to. //$NON-NLS-1$ - - /* (non-Javadoc) - * @see com.ibm.etools.validation.IValidator#cleanup(com.ibm.etools.validation.IReporter) - */ - public void cleanup(IReporter reporter) { - // Nothing is cached, so nothing to do. - } - - /* (non-Javadoc) - * @see com.ibm.etools.validation.IValidator#validate(com.ibm.etools.validation.IHelper, com.ibm.etools.validation.IReporter, com.ibm.etools.validation.IFileDelta[]) - */ - public void validate(IValidationContext helper, IReporter reporter) throws ValidationException { - IFileDelta[] delta = null; - if((delta == null) || (delta.length ==0)) { - // Full Validate - delta = (IFileDelta[])helper.loadModel(ALL_FILES); - } - - if(delta == null) { - // Problem loading the files - return; - } - - for(int i=0; i<delta.length; i++) { - JavaHelpers target = (JavaHelpers)helper.loadModel(JAVAHELPERS, new Object[]{delta[i]}); - LocalizedMessage message = new LocalizedMessage(IMessage.LOW_SEVERITY, "This is a test message for the validation framework, reported by VF Test Validator. Please ignore.", target); //$NON-NLS-1$ - reporter.addMessage(this, message); - } - } - -} diff --git a/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/validator/JDTUtility.java b/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/validator/JDTUtility.java deleted file mode 100644 index 7396f1c0..00000000 --- a/tests/org.eclipse.jst.validation.test/testFwk/org/eclipse/jst/validation/test/fwk/validator/JDTUtility.java +++ /dev/null @@ -1,318 +0,0 @@ -package org.eclipse.jst.validation.test.fwk.validator; - -import java.util.logging.Level; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceDescription; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jem.internal.plugin.JavaEMFNature; -import org.eclipse.jem.java.JavaHelpers; -import org.eclipse.jem.java.JavaRefFactory; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.validation.test.BVTValidationPlugin; -import org.eclipse.jst.validation.test.fwk.TestOpConstrInputOperation; -import org.eclipse.jst.validation.test.internal.registry.BVTValidationRegistryReader; -import org.eclipse.jst.validation.test.internal.registry.ValidatorTestcase; - - -/** - * This class contains some utility methods used to - * access, manipulate, etc. jdt types. - */ -public final class JDTUtility { - private JDTUtility() { - // Do not need any instances of this class. - } - - /** - * Return the containers in the given project that contain either - * .java source files or .class binary files. - */ - public static IContainer[] getJavaContainers(IJavaProject jp) { - if (jp == null) { - return null; - } - - IProject project = jp.getProject(); - IClasspathEntry[] classpath = null; - try { - classpath = jp.getResolvedClasspath(true); // true means ignore unresolved (missing) variables, instead of throwing an exception - } - catch (JavaModelException exc) { - exc.printStackTrace(); - return null; - } - - if (classpath == null) { - return null; - } - - // Traverse the classpath, and calculate a list of just the - // IFolders and IProjects (i.e., IContainers) that contain source - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IContainer[] icontainers = new IContainer[classpath.length]; - int validCount = 0; - for (int i = 0; i < classpath.length; i++) { - IClasspathEntry entry = classpath[i]; - if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { - IResource res = root.findMember(entry.getPath()); - if(res == null) { - // not in the workspace - continue; - } - - if(!res.getProject().equals(project)) { - // in a different project - continue; - } - - if (res instanceof IContainer) { - icontainers[validCount++] = (IContainer) res; - } - } - } - - try { - IContainer outputContainer = (IContainer)root.findMember(jp.getOutputLocation()); - IContainer[] containers = null; - if(outputContainer == null) { - containers = new IContainer[validCount]; - } - else if(outputContainer.getProject().equals(project)) { - containers = new IContainer[validCount+1]; - containers[validCount] = outputContainer; - } - else { - containers = new IContainer[validCount]; - } - System.arraycopy(icontainers, 0, containers, 0, validCount); - return containers; - } - catch(JavaModelException exc) { - exc.printStackTrace(); - return null; - } - } - - /** - * Return the IType that represents this file, or null if none exists. - */ - public static IType getType(IContainer[] javaContainers, IFile file) { - if(file == null) { - return null; - } - - String fileExtension = file.getFileExtension(); - if(fileExtension == null) { - // not a .java or a .class file - return null; - } - - if(!(fileExtension.equals("java") || fileExtension.equals("class"))) { //$NON-NLS-1$ //$NON-NLS-2$ - return null; - } - - IProject project = file.getProject(); - IJavaProject jp = JavaCore.create(project); - if(jp == null) { - return null; - } - - try { - IPath relativePath = getRelativePath(javaContainers, file); - if(relativePath == null) { - // Not a member of a source or output container - return null; - } - - IPath packagePath = relativePath.removeLastSegments(1); - String packageName = packagePath.toString().replace(IPath.SEPARATOR, '.'); - String typeName = relativePath.lastSegment(); - typeName = typeName.substring(0, typeName.length() - fileExtension.length() - 1); - String qualifiedName = null; - if (packageName.length() > 0) { - qualifiedName = packageName + "." + typeName; //$NON-NLS-1$ - } else { - qualifiedName = typeName; - } - return jp.findType(qualifiedName); - } - catch(JavaModelException exc) { - exc.printStackTrace(); - return null; - } - } - - /** - * Return the IPath of the resource relative to the first container that the - * resource is found in. If the resource is contained in more than one container - * in the array, return the first IPath found. If the resource is not a member - * of any of the containers, return null. - */ - public static IPath getRelativePath(IContainer[] containers, IResource resource) { - for(int i=0; i<containers.length; i++) { - IPath path = getRelativePath(containers[i], resource); - if(path != null) { - return path; - } - } - return null; - } - - /** - * Returns the IPath of a resource relative to the container. - * If the IResource is not a member of the container, return null. - */ - public static IPath getRelativePath(IContainer container, IResource resource) { - if ((resource == null) || (container == null)) { - return null; - } - - // Is the path part of the IContainer? - int matchingFirstSegments = container.getFullPath().matchingFirstSegments(resource.getFullPath()); - if(matchingFirstSegments == 0) { - return null; - } - return resource.getFullPath().removeFirstSegments(matchingFirstSegments); - } - - public static JavaHelpers getJavaHelpers(IFile file) { - IType type = getType(file); - if(type == null) { - return null; - } - - return getJavaHelpers(type); - } - - public static IType getType(IFile file) { - IJavaProject jp = JavaCore.create(file.getProject()); - IContainer[] javaContainers = (jp == null) ? null : JDTUtility.getJavaContainers(jp); - if(javaContainers != null) { - return JDTUtility.getType(javaContainers, file); - } - return null; - } - - public static JavaHelpers getJavaHelpers(IType type) { - ResourceSet resourceSet = getResourceSet(type); - if(resourceSet == null) { - return null; - } - return JavaRefFactory.eINSTANCE.reflectType(type.getFullyQualifiedName(), resourceSet); - } - - public static ResourceSet getResourceSet(IType type) { - JavaEMFNature nature = getNature(type); - if(nature == null) { - return null; - } - return nature.getResourceSet(); - } - - public static JavaEMFNature getNature(IType type) { - IJavaProject jp = type.getJavaProject(); - IProject project = jp.getProject(); - - try { - JavaEMFNature nature = JavaEMFNature.createRuntime(project); - return nature; - } - catch(CoreException exc) { - exc.printStackTrace(); - return null; - } - } - - public static IResource getResource(IProject project, JavaHelpers clazz) { - IType type = getType(project, clazz); - return type.getResource(); - } - - public static IType getType(IProject project, JavaHelpers clazz) { - if(clazz == null) { - return null; - } - - String fullyQualifiedName = clazz.getJavaName(); - IJavaProject jp = JavaCore.create(project); - try { - return jp.findType(fullyQualifiedName); - } - catch(JavaModelException exc) { - exc.printStackTrace(); - return null; - } - } - - /** - * Return the three validator test cases used to test the validation framework. - */ - public static ValidatorTestcase[] getVFTests(IProgressMonitor monitor, IProject project) { - ValidatorTestcase[] tmds = BVTValidationRegistryReader.getReader().getAllValidatorTests(monitor, project); - if((tmds == null) || (tmds.length == 0)) { - return new ValidatorTestcase[0]; - } - - ValidatorTestcase fwkNobuildTestTMD = null; - ValidatorTestcase fwkTestTMD = null; - ValidatorTestcase propTMD = null; - ValidatorTestcase[] result = new ValidatorTestcase[3]; - int count = 0; - for(int i=0; i<tmds.length; i++) { - ValidatorTestcase tmd = tmds[i]; - if(tmd.getValidatorClass().equals(TestOpConstrInputOperation.FWK_TEST_VALIDATOR_CLASS)) { - fwkTestTMD = tmd; - result[count++] = tmd; - } - else if(tmd.getValidatorClass().equals(TestOpConstrInputOperation.PROPERTIES_VALIDATOR_CLASS)) { - propTMD = tmd; - result[count++] = tmd; - } - else if(tmd.getValidatorClass().equals(TestOpConstrInputOperation.FWK_NOBUILD_TEST_VALIDATOR_CLASS)) { - fwkNobuildTestTMD = tmd; - result[count++] = tmd; - } - - if((fwkTestTMD != null) && (propTMD != null) && (fwkNobuildTestTMD != null)) { - break; - } - } - - if(count != result.length) { - // On this project, not all of the test validators are used. - ValidatorTestcase[] r = new ValidatorTestcase[count]; - System.arraycopy(result, 0, r, 0, count); - return r; - } - - return result; - } - - public static void setAutoBuild(boolean autoBuildEnabled) { - try { - IWorkspaceDescription desc = ResourcesPlugin.getWorkspace().getDescription(); - desc.setAutoBuilding(autoBuildEnabled); - ResourcesPlugin.getWorkspace().setDescription(desc); - } - catch(CoreException exc) { - Logger logger = BVTValidationPlugin.getPlugin().getMsgLogger(); - if(logger.isLoggingLevel(Level.SEVERE)) { - logger.write(Level.SEVERE, exc); - } - } - } -} |