diff options
Diffstat (limited to 'tests/org.eclipse.wst.wsdl.validation.tests/src/org/eclipse/wst/wsdl/validation/internal/ui')
7 files changed, 0 insertions, 899 deletions
diff --git a/tests/org.eclipse.wst.wsdl.validation.tests/src/org/eclipse/wst/wsdl/validation/internal/ui/ant/AntLoggerTest.java b/tests/org.eclipse.wst.wsdl.validation.tests/src/org/eclipse/wst/wsdl/validation/internal/ui/ant/AntLoggerTest.java deleted file mode 100644 index 4bbc75316..000000000 --- a/tests/org.eclipse.wst.wsdl.validation.tests/src/org/eclipse/wst/wsdl/validation/internal/ui/ant/AntLoggerTest.java +++ /dev/null @@ -1,187 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.wst.wsdl.validation.internal.ui.ant; - -import junit.framework.TestCase; - -import org.eclipse.wst.wsdl.validation.internal.logging.ILogger; - -/** - * Tests for the AntLogger. - */ -public class AntLoggerTest extends TestCase -{ - AntLoggerTestTask task = null; - - /* (non-Javadoc) - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception - { - task = new AntLoggerTestTask(); - } - - /* (non-Javadoc) - * @see junit.framework.TestCase#tearDown() - */ - protected void tearDown() throws Exception - { - task = null; - } - - /** - * Test that the log method: - * 1. logs errors correctly. - * 2. records the message correctly. - * 3. records the throwable correctly. - */ - public void testLogErrorWithThrowable() - { - AntLogger logger = new AntLogger(task); - logger.log("MESSAGE", ILogger.SEV_ERROR, new Throwable("THROWABLE")); - - assertTrue("Warnings were reported when only errors should have been reported.", task.getWarnings().isEmpty()); - assertTrue("Infos were reported when only errors should have been reported.", task.getInfos().isEmpty()); - assertTrue("Verboses were reported when only errors should have been reported.", task.getVerboses().isEmpty()); - assertEquals("2 errors were not reported.", 2, task.getErrors().size()); - assertEquals("The message was not MESSAGE.", "MESSAGE", task.getErrors().get(0)); - assertEquals("The throwable was not THROWABLE.", "java.lang.Throwable: THROWABLE", task.getErrors().get(1)); - } - - /** - * Test that the log method: - * 1. logs warnings correctly. - * 2. records the message correctly. - * 3. records the throwable correctly. - */ - public void testLogWarningWithThrowable() - { - AntLogger logger = new AntLogger(task); - logger.log("MESSAGE", ILogger.SEV_WARNING, new Throwable("THROWABLE")); - - assertTrue("Errors were reported when only warnings should have been reported.", task.getErrors().isEmpty()); - assertTrue("Infos were reported when only warnings should have been reported.", task.getInfos().isEmpty()); - assertTrue("Verboses were reported when only errors should have been reported.", task.getVerboses().isEmpty()); - assertEquals("2 warnings were not reported.", 2, task.getWarnings().size()); - assertEquals("The message was not MESSAGE.", "MESSAGE", task.getWarnings().get(0)); - assertEquals("The throwable was not THROWABLE.", "java.lang.Throwable: THROWABLE", task.getWarnings().get(1)); - } - - /** - * Test that the log method: - * 1. logs infos correctly. - * 2. records the message correctly. - * 3. records the throwable correctly. - */ - public void testLogInfoWithThrowable() - { - AntLogger logger = new AntLogger(task); - logger.log("MESSAGE", ILogger.SEV_INFO, new Throwable("THROWABLE")); - - assertTrue("Warnings were reported when only infos should have been reported.", task.getWarnings().isEmpty()); - assertTrue("Errors were reported when only infos should have been reported.", task.getErrors().isEmpty()); - assertTrue("Verboses were reported when only errors should have been reported.", task.getVerboses().isEmpty()); - assertEquals("2 infos were not reported.", 2, task.getInfos().size()); - assertEquals("The message was not MESSAGE.", "MESSAGE", task.getInfos().get(0)); - assertEquals("The throwable was not THROWABLE.", "java.lang.Throwable: THROWABLE", task.getInfos().get(1)); - } - - /** - * Test that the log method: - * 1. logs verboses correctly. - * 2. records the message correctly. - * 3. records the throwable correctly. - */ - public void testLogVerboseWithThrowable() - { - AntLogger logger = new AntLogger(task); - logger.log("MESSAGE", ILogger.SEV_VERBOSE, new Throwable("THROWABLE")); - - assertTrue("Warnings were reported when only verboses should have been reported.", task.getWarnings().isEmpty()); - assertTrue("Errors were reported when only verboses should have been reported.", task.getErrors().isEmpty()); - assertTrue("Infos were reported when only verboses should have been reported.", task.getInfos().isEmpty()); - assertEquals("2 verboses were not reported.", 2, task.getVerboses().size()); - assertEquals("The message was not MESSAGE.", "MESSAGE", task.getVerboses().get(0)); - assertEquals("The throwable was not THROWABLE.", "java.lang.Throwable: THROWABLE", task.getVerboses().get(1)); - } - - /** - * Test that the log method: - * 1. logs errors correctly. - * 2. records the message correctly. - * 3. records the throwable correctly. - */ - public void testLogErrorWithoutThrowable() - { - AntLogger logger = new AntLogger(task); - logger.log("MESSAGE", ILogger.SEV_ERROR); - - assertTrue("Warnings were reported when only errors should have been reported.", task.getWarnings().isEmpty()); - assertTrue("Infos were reported when only errors should have been reported.", task.getInfos().isEmpty()); - assertTrue("Verboses were reported when only errors should have been reported.", task.getVerboses().isEmpty()); - assertEquals("1 error was not reported.", 1, task.getErrors().size()); - assertEquals("The message was not MESSAGE.", "MESSAGE", task.getErrors().get(0)); - } - - /** - * Test that the log method: - * 1. logs warnings correctly. - * 2. records the message correctly. - * 3. records the throwable correctly. - */ - public void testLogWarningWithoutThrowable() - { - AntLogger logger = new AntLogger(task); - logger.log("MESSAGE", ILogger.SEV_WARNING); - - assertTrue("Errors were reported when only warnings should have been reported.", task.getErrors().isEmpty()); - assertTrue("Infos were reported when only warnings should have been reported.", task.getInfos().isEmpty()); - assertTrue("Verboses were reported when only errors should have been reported.", task.getVerboses().isEmpty()); - assertEquals("1 error was not reported.", 1, task.getWarnings().size()); - assertEquals("The message was not MESSAGE.", "MESSAGE", task.getWarnings().get(0)); - } - - /** - * Test that the log method: - * 1. logs infos correctly. - * 2. records the message correctly. - * 3. records the throwable correctly. - */ - public void testLogInfoWithoutThrowable() - { - AntLogger logger = new AntLogger(task); - logger.log("MESSAGE", ILogger.SEV_INFO); - - assertTrue("Warnings were reported when only infos should have been reported.", task.getWarnings().isEmpty()); - assertTrue("Errors were reported when only infos should have been reported.", task.getErrors().isEmpty()); - assertTrue("Verboses were reported when only errors should have been reported.", task.getVerboses().isEmpty()); - assertEquals("1 info was not reported.", 1, task.getInfos().size()); - assertEquals("The message was not MESSAGE.", "MESSAGE", task.getInfos().get(0)); - } - - /** - * Test that the log method: - * 1. logs verboses correctly. - * 2. records the message correctly. - * 3. records the throwable correctly. - */ - public void testLogVerboseWithoutThrowable() - { - AntLogger logger = new AntLogger(task); - logger.log("MESSAGE", ILogger.SEV_VERBOSE); - - assertTrue("Warnings were reported when only verboses should have been reported.", task.getWarnings().isEmpty()); - assertTrue("Errors were reported when only verboses should have been reported.", task.getErrors().isEmpty()); - assertTrue("Infos were reported when only verboses should have been reported.", task.getInfos().isEmpty()); - assertEquals("1 verbose was not reported.", 1, task.getVerboses().size()); - assertEquals("The message was not MESSAGE.", "MESSAGE", task.getVerboses().get(0)); - } -} diff --git a/tests/org.eclipse.wst.wsdl.validation.tests/src/org/eclipse/wst/wsdl/validation/internal/ui/ant/AntLoggerTestTask.java b/tests/org.eclipse.wst.wsdl.validation.tests/src/org/eclipse/wst/wsdl/validation/internal/ui/ant/AntLoggerTestTask.java deleted file mode 100644 index 7c2247a53..000000000 --- a/tests/org.eclipse.wst.wsdl.validation.tests/src/org/eclipse/wst/wsdl/validation/internal/ui/ant/AntLoggerTestTask.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.wst.wsdl.validation.internal.ui.ant; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; - -/** - * A dummy task that will allow testing of the and logger. - */ -public class AntLoggerTestTask extends Task -{ - protected List errors = new ArrayList(); - protected List warnings = new ArrayList(); - protected List infos = new ArrayList(); - protected List verboses = new ArrayList(); - - /* (non-Javadoc) - * @see org.apache.tools.ant.Task#log(java.lang.String, int) - */ - public void log(String msg, int msgLevel) - { - if(msgLevel == Project.MSG_ERR) - { - errors.add(msg); - } - else if(msgLevel == Project.MSG_WARN) - { - warnings.add(msg); - } - else if(msgLevel == Project.MSG_INFO) - { - infos.add(msg); - } - else if(msgLevel == Project.MSG_VERBOSE) - { - verboses.add(msg); - } - } - - /* (non-Javadoc) - * @see org.apache.tools.ant.Task#log(java.lang.String) - */ - public void log(String msg) - { - log(msg, Project.MSG_INFO); - } - - /** - * Get the errors that were logged. - * - * @return - * The errors that were logged. - */ - public List getErrors() - { - return errors; - } - - /** - * Get the warnings that were logged. - * - * @return - * The warnings that were logged. - */ - public List getWarnings() - { - return warnings; - } - - /** - * Get the infos that were logged. - * - * @return - * The infos that were logged. - */ - public List getInfos() - { - return infos; - } - - /** - * Get the verboses that were logged. - * - * @return - * The verboses that were logged. - */ - public List getVerboses() - { - return verboses; - } -} diff --git a/tests/org.eclipse.wst.wsdl.validation.tests/src/org/eclipse/wst/wsdl/validation/internal/ui/ant/WSDLValidateTask.java b/tests/org.eclipse.wst.wsdl.validation.tests/src/org/eclipse/wst/wsdl/validation/internal/ui/ant/WSDLValidateTask.java deleted file mode 100644 index 907875d96..000000000 --- a/tests/org.eclipse.wst.wsdl.validation.tests/src/org/eclipse/wst/wsdl/validation/internal/ui/ant/WSDLValidateTask.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 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.wst.wsdl.validation.internal.ui.ant; - -import java.util.List; - -/** - * This class is used to expose functionality from the WSDLValidate class for testing. - */ -public class WSDLValidateTask extends WSDLValidate -{ - - /** - * @see org.eclipse.wst.wsdl.validation.internal.ui.ant.WSDLValidate#getFileList() - */ - public List getFileList() - { - return super.getFileList(); - } - -} diff --git a/tests/org.eclipse.wst.wsdl.validation.tests/src/org/eclipse/wst/wsdl/validation/internal/ui/ant/WSDLValidateTest.java b/tests/org.eclipse.wst.wsdl.validation.tests/src/org/eclipse/wst/wsdl/validation/internal/ui/ant/WSDLValidateTest.java deleted file mode 100644 index 8b31f2d5a..000000000 --- a/tests/org.eclipse.wst.wsdl.validation.tests/src/org/eclipse/wst/wsdl/validation/internal/ui/ant/WSDLValidateTest.java +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 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.wst.wsdl.validation.internal.ui.ant; - -import java.io.File; -import java.util.List; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.FileSet; -import org.apache.tools.ant.types.selectors.FilenameSelector; -import org.eclipse.wst.wsdl.validation.tests.internal.BaseTestCase; - -/** - * WSDLValidate ant task tests. - */ -public class WSDLValidateTest extends BaseTestCase -{ - private String BASE_DIR;; - private Project project; - - /** - * Create a tests suite from this test class. - * - * @return A test suite containing this test class. - */ - public static Test suite() - { - return new TestSuite(WSDLValidateTest.class); - } - - /* (non-Javadoc) - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception - { - super.setUp(); - try - { - BASE_DIR = PLUGIN_ABSOLUTE_PATH; - BASE_DIR = BASE_DIR.replace('/', File.separatorChar); - if(BASE_DIR.startsWith("\\")) - { - BASE_DIR = BASE_DIR.substring(1); - } - } - catch(Exception e) - { - - } - project = new Project(); - project.setBaseDir(new File(BASE_DIR)); - } - - /** - * Test that a single file with a relative location is resolved properly. - */ - public void testRelativeSingleFileLocation() - { - String fileLoc = "file.wsdl"; - String resolvedLocation = ("file:///" + BASE_DIR + fileLoc).replace('\\','/'); - WSDLValidateTask wsdlValidateTask = new WSDLValidateTask(); - wsdlValidateTask.setProject(project); - wsdlValidateTask.setFile(fileLoc); - List fileList = wsdlValidateTask.getFileList(); - assertEquals("The file list does not contain only one file.", 1, fileList.size()); - // The file locations are converted to lower case to avoid drive letter case differences on windows. ie. C vs c. - assertEquals("The file location '" + fileList.get(0) + "' is not correctly resolved to the base location.", resolvedLocation.toLowerCase(), ((String)fileList.get(0)).toLowerCase()); - - } - - /** - * Test that a single file with an absolute location is resolved properly. - */ - public void testAbsoluteSingleFileLocation() - { - String fileLoc = BASE_DIR + "file.wsdl"; - String resolvedLocation = (FILE_PROTOCOL + fileLoc).replace('\\','/'); - WSDLValidateTask wsdlValidateTask = new WSDLValidateTask(); - wsdlValidateTask.setProject(project); - wsdlValidateTask.setFile(fileLoc); - List fileList = wsdlValidateTask.getFileList(); - assertEquals("The file list does not contain only one file.", 1, fileList.size()); - assertEquals("The file location '" + fileLoc + "' is modified.", resolvedLocation.toLowerCase(), ((String)fileList.get(0)).toLowerCase()); - - } - - /** - * Test that a single file with an absolute, remote location is resolved properly. - */ - public void testAbsoluteSingleFileRemoteLocation() - { - String resolvedLocation = "http://www.ws-i.org/SampleApplications/SupplyChainManagement/2003-07/Catalog.wsdl"; - String fileLoc = "http://www.ws-i.org/SampleApplications/SupplyChainManagement/2003-07/Catalog.wsdl"; - WSDLValidateTask wsdlValidateTask = new WSDLValidateTask(); - wsdlValidateTask.setProject(project); - wsdlValidateTask.setFile(fileLoc); - List fileList = wsdlValidateTask.getFileList(); - assertEquals("The file list does not contain only one file.", 1, fileList.size()); - assertEquals("The file location '" + fileLoc + "' is modified.", resolvedLocation.toLowerCase(), ((String)fileList.get(0)).toLowerCase()); - - } - -/** - * Test that a single file in a fileset with a relative location is resolved properly - * when no directory is specified. - */ - public void testRelativeSingleFileInFilesetNoDirSpecified() - { - String fileLoc = "Empty.wsdl"; - String base_dir = BASE_DIR + SAMPLES_DIR + "WSDL" + File.separator + "SelfContained"; - String resolvedLocation = ("file:///" + base_dir + "/" + fileLoc).replace('\\','/'); - base_dir = base_dir.replace('/', File.separatorChar); - - WSDLValidateTask wsdlValidateTask = new WSDLValidateTask(); - wsdlValidateTask.setProject(project); - - FileSet fileset = wsdlValidateTask.createFileset(); - fileset.setProject(project); - fileset.setDir(new File(base_dir)); - - FilenameSelector filenameSelector = new FilenameSelector(); - filenameSelector.setName(fileLoc); - fileset.addFilename(filenameSelector); - //fileset.setFile(new File(fileLoc)); - - List fileList = wsdlValidateTask.getFileList(); - assertEquals("The file list does not contain only one file.", 1, fileList.size()); - // The file locations are converted to lower case to avoid drive letter case differences on windows. ie. C vs c. - assertEquals("The file location '" + fileList.get(0) + "' is not correctly resolved to the base location.", resolvedLocation.toLowerCase(), ((String)fileList.get(0)).toLowerCase()); - - } -} diff --git a/tests/org.eclipse.wst.wsdl.validation.tests/src/org/eclipse/wst/wsdl/validation/internal/ui/text/WSDLValidateTest.java b/tests/org.eclipse.wst.wsdl.validation.tests/src/org/eclipse/wst/wsdl/validation/internal/ui/text/WSDLValidateTest.java deleted file mode 100644 index b6458f203..000000000 --- a/tests/org.eclipse.wst.wsdl.validation.tests/src/org/eclipse/wst/wsdl/validation/internal/ui/text/WSDLValidateTest.java +++ /dev/null @@ -1,221 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.wst.wsdl.validation.internal.ui.text; - -import java.text.MessageFormat; -import java.util.List; - -import org.eclipse.wst.wsdl.validation.internal.IValidationMessage; -import org.eclipse.wst.wsdl.validation.internal.IValidationReport; -import org.eclipse.wst.wsdl.validation.internal.ValidationMessageImpl; -import org.eclipse.wst.wsdl.validation.internal.ValidatorRegistry; -import org.eclipse.wst.wsdl.validation.internal.logging.ILogger; -import org.eclipse.wst.wsdl.validation.internal.logging.LoggerFactory; -import org.eclipse.wst.wsdl.validation.internal.logging.StandardLogger; -import org.eclipse.wst.wsdl.validation.tests.internal.BaseTestCase; - -public class WSDLValidateTest extends BaseTestCase -{ - WSDLValidateWrapper validate = null; - - /* (non-Javadoc) - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception - { - super.setUp(); - validate = new WSDLValidateWrapper(); - } - - /* (non-Javadoc) - * @see junit.framework.TestCase#tearDown() - */ - protected void tearDown() throws Exception - { - validate = null; - super.tearDown(); - } - - /** - * Test the validateFile method. - * 1. A valid file should report back that it's valid. - * 2. An invalid file should report back that it's invalid. - * 3. A file that can't be found should succeed and report that it's invalid. - */ - public void testValidateFile() - { - String validFile = FILE_PROTOCOL + PLUGIN_ABSOLUTE_PATH + SAMPLES_DIR + "Paths/AngleHat^InPath/AngleHatInPathValid.wsdl"; - if(PLUGIN_ABSOLUTE_PATH.startsWith("/")) - { - validFile = "file://" + PLUGIN_ABSOLUTE_PATH + SAMPLES_DIR + "Paths/AngleHat^InPath/AngleHatInPathValid.wsdl"; - } - String invalidFile = FILE_PROTOCOL + PLUGIN_ABSOLUTE_PATH + SAMPLES_DIR + "Paths/AngleHat^InPath/AngleHatInPathInvalid.wsdl"; - if(PLUGIN_ABSOLUTE_PATH.startsWith("/")) - { - invalidFile = "file://" + PLUGIN_ABSOLUTE_PATH + SAMPLES_DIR + "Paths/AngleHat^InPath/AngleHatInPathInvalid.wsdl"; - } - String nonexistantFile = "nonexistantfile.wsdl"; - // 1. A valid file should report back that it's valid. - IValidationReport report = validate.validateFile(validFile); - assertFalse("Errors were reported for a valid file.", report.hasErrors()); - - // 2. An invalid file should report back that it's invalid. - IValidationReport report2 = validate.validateFile(invalidFile); - assertTrue("Errors were not reported for an invalid file.", report2.hasErrors()); - - // 3. A file that can't be found should succeed and report that it's invalid. - IValidationReport report3 = validate.validateFile(nonexistantFile); - assertTrue("Errors were not reported for a nonexistant file.", report3.hasErrors()); - } - - /** - * Test the validate method. - * 1. The method should succeed with one file specified. - * 2. The method should succeed and validate 2 files when 2 are specified. - * 3. The method should output verbose information for valid files when verbose is enabled. - */ - public void testValidate() - { - String validFile = FILE_PROTOCOL + PLUGIN_ABSOLUTE_PATH + SAMPLES_DIR + "Paths/AngleHat^InPath/AngleHatInPathValid.wsdl"; - if(PLUGIN_ABSOLUTE_PATH.startsWith("/")) - { - validFile = "file://" + PLUGIN_ABSOLUTE_PATH + SAMPLES_DIR + "Paths/AngleHat^InPath/AngleHatInPathValid.wsdl"; - } - String validFile2 = FILE_PROTOCOL + PLUGIN_ABSOLUTE_PATH + SAMPLES_DIR + "Paths/AngleHatInFilename/AngleHat^InFilenameValid.wsdl"; - if(PLUGIN_ABSOLUTE_PATH.startsWith("/")) - { - validFile2 = "file://" + PLUGIN_ABSOLUTE_PATH + SAMPLES_DIR + "Paths/AngleHatInFilename/AngleHat^InFilenameValid.wsdl"; - } - ILogger currentLogger = LoggerFactory.getInstance().getLogger(); - WSDLValidateTestLogger logger = new WSDLValidateTestLogger(); - LoggerFactory.getInstance().setLogger(logger); - - // 1. The method should succeed with one file specified. - validate.getWSDLFiles().add(validFile); - validate.validate(); - assertEquals("Validating a single valid file failed.", MessageFormat.format(WSDLValidateTextUIMessages._UI_VALIDATION_SUMMARY, new Object[]{new Integer(1), new Integer(0)}), logger.getInfos().get(0)); - validate.getWSDLFiles().clear(); - logger.getInfos().clear(); - - // 2. The method should succeed and validate 2 files when 2 are specified. - validate.getWSDLFiles().add(validFile); - validate.getWSDLFiles().add(validFile2); - validate.validate(); - assertEquals("Validating two valid files failed.", MessageFormat.format(WSDLValidateTextUIMessages._UI_VALIDATION_SUMMARY, new Object[]{new Integer(2), new Integer(0)}), logger.getInfos().get(0)); - validate.getWSDLFiles().clear(); - logger.getInfos().clear(); - - // 3. The method should output verbose information for valid files when verbose is enabled. - validate.setVerbose(true); - validate.getWSDLFiles().add(validFile); - validate.validate(); - assertEquals("Validating a single valid file failed.", MessageFormat.format(WSDLValidateTextUIMessages._UI_FILE_VALID, new Object[]{validFile}), logger.getVerboses().get(0)); - assertEquals("Validating a single valid file failed.", MessageFormat.format(WSDLValidateTextUIMessages._UI_VALIDATION_SUMMARY, new Object[]{new Integer(1), new Integer(0)}), logger.getInfos().get(0)); - validate.getWSDLFiles().clear(); - validate.setVerbose(false); - logger.getInfos().clear(); - logger.getVerboses().clear(); - - LoggerFactory.getInstance().setLogger(currentLogger); - } - - /** - * Test the getMessages method. - * 1. The method should return a properly formatted string for a single error. - * 2. The method should return a properly formatted string for a single warning. - * 3. The method should return a properly fomatted string for 2 messages. - */ - public void testGetMessages() - { - IValidationMessage errorMessage = new ValidationMessageImpl("MESSAGE", 1, 2, IValidationMessage.SEV_ERROR, "URI"); - IValidationMessage warningMessage = new ValidationMessageImpl("MESSAGE", 1, 2, IValidationMessage.SEV_WARNING, "URI"); - // 1. The method should return a properly formatted string for a single error. - IValidationMessage[] errorMessages = new IValidationMessage[]{errorMessage}; - String message = validate.getMessages(errorMessages); - assertEquals("The error message was not correct.", WSDLValidateTextUIMessages._UI_ERROR_MARKER + " 1:2 MESSAGE", message); - - // 2. The method should return a properly formatted string for a single warning. - IValidationMessage[] warningMessages = new IValidationMessage[]{warningMessage}; - String message2 = validate.getMessages(warningMessages); - assertEquals("The warning message was not correct.", WSDLValidateTextUIMessages._UI_WARNING_MARKER + " 1:2 MESSAGE", message2); - - // 3. The method should return a properly fomatted string for 2 messages. - IValidationMessage[] twoMessages = new IValidationMessage[]{errorMessage, warningMessage}; - String message3 = validate.getMessages(twoMessages); - assertEquals("Two messages was not correct.", WSDLValidateTextUIMessages._UI_ERROR_MARKER + " 1:2 MESSAGE\n" + WSDLValidateTextUIMessages._UI_WARNING_MARKER + " 1:2 MESSAGE", message3); - } - - /** - * Test the parseArguments method. - * 1. -wsdl11v parsing succeeds and registers the validator with the WSDL validator. - * 2. -extv parsing succeeds and registers the validator with the WSDL validator. - * 3. Extension validator parsing where a param is omitted succeeds. - * 4. -logger parsing succeeds and sets the correct logger. - * 5. -D (property) parsing succeeds sets the property on the configuration. - * 6. -v, -verbose parsing succeeds and sets verbose correctly. - * 7. The specified WSDL files are read properly. - * - * Not currently tested: - * -schema - * -schemaDir - * -uriresolver - */ - public void testParseArguments() - { - // 1. -wsdl11v parsing succeeds and registers the validator with the WSDL validator. - String[] args1 = new String[]{WSDLValidateWrapper.PARAM_WSDL11VAL, "http://wsdl11validator", "org.eclipse.wst.wsdl.validation.internal.wsdl11.http.HTTPValidator"}; - validate.parseArguments(args1); - assertTrue("The WSDL 1.1 validator was not registered.", org.eclipse.wst.wsdl.validation.internal.wsdl11.ValidatorRegistry.getInstance().hasRegisteredValidator("http://wsdl11validator")); - - // 2. -extv parsing succeeds and registers the validator with the WSDL validator. - String[] args2 = new String[]{WSDLValidateWrapper.PARAM_EXTVAL, "http://extvalidator", "validatorclass"}; - validate.parseArguments(args2); - assertTrue("The WSDL extension validator was not registered.", ValidatorRegistry.getInstance().hasRegisteredValidator("http://extvalidator", ValidatorRegistry.EXT_VALIDATOR)); - - // 3. Extension validator parsing where a param is omitted succeeds. - String[] args3 = new String[]{WSDLValidateWrapper.PARAM_EXTVAL, "http://extvalidator2", "-dummyparam"}; - validate.parseArguments(args3); - assertFalse("The WSDL extension validator was registered without enough information.", ValidatorRegistry.getInstance().hasRegisteredValidator("http://extvalidator2", ValidatorRegistry.EXT_VALIDATOR)); - - // 4. -logger parsing succeeds and sets the correct logger. - ILogger currentLogger = LoggerFactory.getInstance().getLogger(); - String[] args4 = new String[]{WSDLValidateWrapper.PARAM_LOGGER, "org.eclipse.wst.wsdl.validation.internal.logging.StandardLogger"}; - validate.parseArguments(args4); - assertTrue("The registered logger is not a StandardLogger", LoggerFactory.getInstance().getLogger() instanceof StandardLogger); - assertFalse("The registered logger is the same as originally registered.", currentLogger.equals(LoggerFactory.getInstance().getLogger())); - LoggerFactory.getInstance().setLogger(currentLogger); - - // 5. -D (property) parsing succeeds sets the property on the configuration. - String[] args5 = new String[]{WSDLValidateWrapper.PARAM_PROPERTY + "SAMPLENAME=SAMPLEVALUE"}; - validate.parseArguments(args5); - assertEquals("The parameter was not set correctly.", "SAMPLEVALUE", validate.getConfiguration().getProperty("SAMPLENAME")); - - // 6. -v, -verbose parsing succeeds and sets verbose correctly. - String[] args6 = new String[]{WSDLValidateWrapper.PARAM_VERBOSE}; - validate.setVerbose(false); - validate.parseArguments(args6); - assertTrue("Verbose is not set to true.", validate.isVerbose()); - - String[] args6a = new String[]{WSDLValidateWrapper.PARAM_VERBOSE_SHORT}; - validate.setVerbose(false); - validate.parseArguments(args6a); - assertTrue("Verbose is not set to true.", validate.isVerbose()); - - // 7. The specified WSDL files are read properly. - String[] args7 = new String[]{"filename1.wsdl", "folder/filename2.wsdl", "folder\filename3.wsdl"}; - validate.parseArguments(args7); - List wsdlFiles = validate.getWSDLFiles(); - assertEquals("There were not 3 WSDL files listed to validate.", 3, wsdlFiles.size()); - assertTrue("The WSDL file list did not include filename1.wsdl", wsdlFiles.contains("filename1.wsdl")); - assertTrue("The WSDL file list did not include folder/filename2.wsdl", wsdlFiles.contains("folder/filename2.wsdl")); - assertTrue("The WSDL file list did not include folder\filename3.wsdl", wsdlFiles.contains("folder\filename3.wsdl")); - } -} diff --git a/tests/org.eclipse.wst.wsdl.validation.tests/src/org/eclipse/wst/wsdl/validation/internal/ui/text/WSDLValidateTestLogger.java b/tests/org.eclipse.wst.wsdl.validation.tests/src/org/eclipse/wst/wsdl/validation/internal/ui/text/WSDLValidateTestLogger.java deleted file mode 100644 index 1352a4baa..000000000 --- a/tests/org.eclipse.wst.wsdl.validation.tests/src/org/eclipse/wst/wsdl/validation/internal/ui/text/WSDLValidateTestLogger.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.wst.wsdl.validation.internal.ui.text; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.wst.wsdl.validation.internal.logging.ILogger; - -/** - * A helper class for testing that allows access to the messages logged. - */ -public class WSDLValidateTestLogger implements ILogger { - - protected List errors = new ArrayList(); - protected List warnings = new ArrayList(); - protected List infos = new ArrayList(); - protected List verboses = new ArrayList(); - - /* (non-Javadoc) - * @see org.eclipse.wst.wsdl.validation.internal.logging.ILogger#log(java.lang.String, int) - */ - public void log(String message, int severity) - { - if(severity == ILogger.SEV_ERROR) - { - errors.add(message); - } - else if(severity == ILogger.SEV_WARNING) - { - warnings.add(message); - } - else if(severity == ILogger.SEV_INFO) - { - infos.add(message); - } - else if(severity == ILogger.SEV_VERBOSE) - { - verboses.add(message); - } - } - - /* (non-Javadoc) - * @see org.eclipse.wst.wsdl.validation.internal.logging.ILogger#log(java.lang.String, int, java.lang.Throwable) - */ - public void log(String message, int severity, Throwable throwable) - { - log(message, severity); - log(throwable.toString(), severity); - } - - /** - * Get the error list. - * - * @return - * The error list. - */ - public List getErrors() - { - return errors; - } - - /** - * Get the warning list. - * - * @return - * The warning list. - */ - public List getWarnings() - { - return warnings; - } - - /** - * Get the info list. - * - * @return - * The info list. - */ - public List getInfos() - { - return infos; - } - - /** - * Get the verbose list. - * - * @return - * The verbose list. - */ - public List getVerboses() - { - return verboses; - } -} diff --git a/tests/org.eclipse.wst.wsdl.validation.tests/src/org/eclipse/wst/wsdl/validation/internal/ui/text/WSDLValidateWrapper.java b/tests/org.eclipse.wst.wsdl.validation.tests/src/org/eclipse/wst/wsdl/validation/internal/ui/text/WSDLValidateWrapper.java deleted file mode 100644 index 80407bd5e..000000000 --- a/tests/org.eclipse.wst.wsdl.validation.tests/src/org/eclipse/wst/wsdl/validation/internal/ui/text/WSDLValidateWrapper.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.wst.wsdl.validation.internal.ui.text; - -import java.util.List; - -import org.eclipse.wst.wsdl.validation.internal.IValidationMessage; -import org.eclipse.wst.wsdl.validation.internal.IValidationReport; -import org.eclipse.wst.wsdl.validation.internal.WSDLValidationConfiguration; -import org.eclipse.wst.wsdl.validation.internal.WSDLValidator; - -/** - * A wrapper class of WSDLValidate that exposes internals for testing. - */ -public class WSDLValidateWrapper extends WSDLValidate -{ - - /* (non-Javadoc) - * @see org.eclipse.wst.wsdl.validation.internal.ui.text.WSDLValidate#getMessages(org.eclipse.wst.wsdl.validation.internal.IValidationMessage[]) - */ - public String getMessages(IValidationMessage[] messages) - { - return super.getMessages(messages); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.wsdl.validation.internal.ui.text.WSDLValidate#parseArguments(java.lang.String[]) - */ - public void parseArguments(String[] args) - { - super.parseArguments(args); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.wsdl.validation.internal.ui.text.WSDLValidate#validate() - */ - public void validate() - { - super.validate(); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.wsdl.validation.internal.ui.text.WSDLValidate#validateFile(java.lang.String) - */ - public IValidationReport validateFile(String filename) - { - return super.validateFile(filename); - } - - /** - * Get the internal WSDL validator. - * - * @return - * The internal WSDL validator. - */ - public WSDLValidator getWSDLValidator() - { - return wsdlValidator; - } - - /** - * Get the WSDL validation configuration. - * - * @return - * The WSDL validation configuration. - */ - public WSDLValidationConfiguration getConfiguration() - { - return configuration; - } - - /** - * Get the list of WSDL files to validate. - * - * @return - * The list of WSDL files to validate. - */ - public List getWSDLFiles() - { - return wsdlFiles; - } - - /** - * Returns true if verbose is on, false otherwise. - * - * @return - * True if verbose is on, false otherwise. - */ - public boolean isVerbose() - { - return verbose; - } - - /** - * Set whether reporting should be done in a verbose way. - * - * @param verbose - * If true reporting will be done in a verbose way, otherwise it will not. - */ - public void setVerbose(boolean verbose) - { - this.verbose = verbose; - } - -} |