Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/org.eclipse.wst.xml.tests.encoding/src/org')
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/CreateCodedReaderTester.java253
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/EncodingTestSuite.java66
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/FileUtil.java55
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/GenerateFiles.java30
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/GenerateXMLFiles.java409
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/ListCharsets.java84
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/TestsPlugin.java150
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/pref/TestPreferences.java109
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/properties/TestCommonNames.java73
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/properties/TestDisplayNames.java28
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/properties/TestOverrides.java44
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestCodedReader.java614
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestCodedReaderOnGennedFiles.java717
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestContentDescription.java536
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestContentTypeDescriptionOnGennedFiles.java711
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestContentTypeDetection.java210
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestContentTypeDetectionForXML.java203
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestContentTypes.java50
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/util/ProjectUnzipUtility.java337
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/util/WorkspaceProgressMonitor.java54
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/write/TestCodedWrite.java127
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/xml/XMLEncodingTests.java192
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/xml/XMLHeadTokenizerTester.java380
-rw-r--r--tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/xml/XMLMalformedInputTests.java275
24 files changed, 0 insertions, 5707 deletions
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/CreateCodedReaderTester.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/CreateCodedReaderTester.java
deleted file mode 100644
index fe5cf3e9b..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/CreateCodedReaderTester.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.xml.tests.encoding;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.nio.charset.IllegalCharsetNameException;
-import java.nio.charset.MalformedInputException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.sse.core.internal.encoding.CodedReaderCreator;
-import org.eclipse.wst.sse.core.internal.encoding.NonContentBasedEncodingRules;
-import org.eclipse.wst.sse.core.internal.exceptions.UnsupportedCharsetExceptionWithDetail;
-import org.eclipse.wst.xml.tests.encoding.util.ProjectUnzipUtility;
-
-/**
- * This class is intended to be executed only at development time, and it
- * creates the class to JUnit test all the files found in the testfiles
- * directory.
- */
-public class CreateCodedReaderTester extends TestCase {
- // private final String fileDir = "html/";
- // private final String fileRoot =
- // "/builds/Workspaces/HeadWorkspace/org.eclipse.wst.xml.tests.encoding/";
- // private final String fileLocation = fileRoot + fileDir;
- private static final String TESTFILES_ZIPFILE_NAME = "testfiles.zip"; //$NON-NLS-1$
- private static final boolean DEBUG = false;
- private static final String TEST_FILE_DIR = "testfiles"; //$NON-NLS-1$
- // needs to be static, since JUnit creates difference instances for each
- // test
- private static boolean fTestProjectInitialized;
- private static final String TEST_PROJECT_NAME = "org.eclipse.wst.xml.tests.encoding"; //$NON-NLS-1$
- static IProject fTestProject;
- private static int nSetups = 0;
- private static final String currentPlatformCharset = getPlatformDefault();
- private boolean RECREATE_FILES = false;
-
- /**
- *
- */
- public CreateCodedReaderTester() {
- super();
- //System.out.println(currentPlatformCharset);
- }
-
- /**
- * @return
- */
- private static String getPlatformDefault() {
- String platformDefault = NonContentBasedEncodingRules.useDefaultNameRules(null);
- return platformDefault;
- }
-
- public static void main(String[] args) {
- // try {
- // new CreateCodedReaderTester().doCreateAllFiles();
- // } catch (CoreException e) {
- // e.printStackTrace();
- // } catch (IOException e) {
- // e.printStackTrace();
- // }
- }
-
- private static void createProject(IProject project, IPath locationPath, IProgressMonitor monitor) throws CoreException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.beginTask("creating test project", 10);
- // create the project
- try {
- if (!project.exists()) {
- IProjectDescription desc = project.getWorkspace().newProjectDescription(project.getName());
- if (Platform.getLocation().equals(locationPath)) {
- locationPath = null;
- }
- desc.setLocation(locationPath);
- project.create(desc, monitor);
- monitor = null;
- }
- if (!project.isOpen()) {
- project.open(monitor);
- monitor = null;
- }
- }
- finally {
- if (monitor != null) {
- monitor.done();
- }
- }
- }
-
- private static void getAndCreateProject() throws CoreException {
- //TestsPlugin testsPlugin = (TestsPlugin)
- // Platform.getPlugin("org.eclipse.wst.xml.tests.encoding");
- IWorkspace workspace = TestsPlugin.getWorkspace();
- IWorkspaceRoot root = workspace.getRoot();
- fTestProject = root.getProject(TEST_PROJECT_NAME);
- // this form creates project as "linked" back to 'fileRoot'
- //createProject(testProject, new Path(fileRoot), null);
- createProject(fTestProject, null, null);
- fTestProject.refreshLocal(IResource.DEPTH_INFINITE, null);
- assertTrue(fTestProject.exists());
- // IContainer testFiles = testProject.getFolder("testfiles");
- // assertTrue(testFiles.exists());
- // IResource[] allFolders = testFiles.members();
- // assertNotNull(allFolders);
- }
-
- private void createTestMethodSource(int count, String filePathAndName, String detectedCharsetName, String javaCharsetName, String expectedException) {
- String javaCharsetNameOrKey = javaCharsetName;
- if (null != javaCharsetNameOrKey && javaCharsetNameOrKey.equals(currentPlatformCharset))
- javaCharsetNameOrKey = "expectPlatformCharset";
- System.out.println("public void testFile" + count + " () throws CoreException, IOException {" + " doTest( \"" + javaCharsetNameOrKey + "\", \"" + detectedCharsetName + "\", \"" + filePathAndName + "\", " + expectedException + "); }");
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- nSetups++;
- if (!fTestProjectInitialized) {
- getAndCreateProject();
- // unzip files to the root of workspace directory
- String destinationProjectString = fTestProject.getLocation().toOSString();
- String destinationFolder = destinationProjectString + "/";
- // this zip file is sitting in the "root" of test plugin
- File zipFile = TestsPlugin.getTestFile("testfiles.zip");
- ProjectUnzipUtility projUtil = new ProjectUnzipUtility();
- projUtil.unzipAndImport(zipFile, destinationFolder);
- projUtil.initJavaProject(TEST_PROJECT_NAME);
- fTestProject.refreshLocal(IResource.DEPTH_INFINITE, null);
- fTestProjectInitialized = true;
- }
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- nSetups--;
- if (nSetups == 0) {
- if (!DEBUG) {
- // Display display = PlatformUI.getWorkbench().getDisplay();
- // display.asyncExec(new Runnable() {
- // public void run() {
- // ProjectUnzipUtility projUtil = new ProjectUnzipUtility();
- // IProject proj = fTestProject;
- // fTestProject = null;
- // try {
- // projUtil.deleteProject(proj);
- // } catch (Exception e) {
- // e.printStackTrace();
- // }
- // }
- // });
- }
- }
- }
-
- public void testCreateAllFiles() throws CoreException, IOException {
- if (RECREATE_FILES) {
- List allFiles = TestsPlugin.getAllTestFiles(TEST_FILE_DIR);
- URL outputDirURL = TestsPlugin.getInstallLocation();
- File zipoutFile = new File(outputDirURL.getPath(), TESTFILES_ZIPFILE_NAME);
- java.io.FileOutputStream zipOut = new FileOutputStream(zipoutFile);
- ZipOutputStream zipOutputStream = new ZipOutputStream(zipOut);
- int count = 1;
- for (Iterator iter = allFiles.iterator(); iter.hasNext();) {
- File file = (File) iter.next();
- createZipEntry(zipOutputStream, file);
- CodedReaderCreator codedReaderCreator = new CodedReaderCreator();
- codedReaderCreator.set(file.getName(), new FileInputStream(file));
- String detectedCharsetName = null;
- String javaCharsetName = null;
- String expectedException = null;
- try {
- // just used for debug info, but can throw exception
- javaCharsetName = codedReaderCreator.getEncodingMemento().getJavaCharsetName();
- detectedCharsetName = codedReaderCreator.getEncodingMemento().getDetectedCharsetName();
- }
- catch (UnsupportedCharsetExceptionWithDetail e) {
- // ignore for simply creating tests
- expectedException = e.getClass().getName() + ".class";
- }
- catch (MalformedInputException e) {
- // ignore for simply creating tests
- expectedException = e.getClass().getName() + ".class";
- }
- catch (IllegalCharsetNameException e) {
- // ignore for simply creating tests
- expectedException = e.getClass().getName() + ".class";
- }
- String subpath = getSubPathName(file);
- createTestMethodSource(count, subpath, detectedCharsetName, javaCharsetName, expectedException);
- count++;
- }
- zipOutputStream.close();
- zipOut.close();
- assertTrue(true);
- }
- }
-
- private String getSubPathName(File file) {
- String path = file.getPath();
- int lastIndex = path.lastIndexOf(TEST_FILE_DIR);
- String subpath = path.substring(lastIndex);
- subpath = subpath.replace('\\', '/');
- return subpath;
- }
-
- /**
- * @param zipOutputStream
- * @param element
- */
- private void createZipEntry(ZipOutputStream zipOutputStream, File file) throws IOException {
- String subPathName = getSubPathName(file);
- ZipEntry zipEntry = new ZipEntry(subPathName);
- zipOutputStream.putNextEntry(zipEntry);
- InputStream inputStream = new FileInputStream(file);
- int nRead = 0;
- byte[] buffer = new byte[1024 * 8];
- while (nRead != -1) {
- nRead = inputStream.read(buffer);
- if (nRead > 0) {
- zipOutputStream.write(buffer, 0, nRead);
- }
- }
- zipOutputStream.flush();
- }
-}
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/EncodingTestSuite.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/EncodingTestSuite.java
deleted file mode 100644
index f77bac93a..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/EncodingTestSuite.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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.xml.tests.encoding;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.wst.xml.tests.encoding.properties.TestCommonNames;
-import org.eclipse.wst.xml.tests.encoding.properties.TestOverrides;
-import org.eclipse.wst.xml.tests.encoding.read.TestCodedReader;
-import org.eclipse.wst.xml.tests.encoding.read.TestCodedReaderOnGennedFiles;
-import org.eclipse.wst.xml.tests.encoding.read.TestContentDescription;
-import org.eclipse.wst.xml.tests.encoding.read.TestContentTypeDescriptionOnGennedFiles;
-import org.eclipse.wst.xml.tests.encoding.read.TestContentTypeDetectionForXML;
-import org.eclipse.wst.xml.tests.encoding.read.TestContentTypes;
-import org.eclipse.wst.xml.tests.encoding.write.TestCodedWrite;
-import org.eclipse.wst.xml.tests.encoding.xml.XMLEncodingTests;
-import org.eclipse.wst.xml.tests.encoding.xml.XMLHeadTokenizerTester;
-
-
-public class EncodingTestSuite extends TestSuite {
-
- // FIXME: commented out lang. spec. tests, until all migrated to org.eclipse
- private static Class[] classes = new Class[]{TestOverrides.class, TestCodedReader.class, TestCodedWrite.class, XMLEncodingTests.class, XMLHeadTokenizerTester.class, TestContentTypeDescriptionOnGennedFiles.class, TestCodedReaderOnGennedFiles.class, TestContentDescription.class, TestContentTypes.class, TestCommonNames.class, TestContentTypeDetectionForXML.class};
- //private static Class[] classes = new Class[]{TestOverrides.class, CSSEncodingTester.class, CSSHeadTokenizerTester.class, HTMLEncodingTests.class, HTMLHeadTokenizerTester.class, JSPEncodingTests.class, JSPHeadTokenizerTester.class, TestCodedReader.class, TestCodedWrite.class, XMLEncodingTests.class, XMLHeadTokenizerTester.class, XMLMalformedInputTests.class, TestContentTypeDescriptionOnGennedFiles.class, TestCodedReaderOnGennedFiles.class, TestContentTypeDetection.class, TestContentDescription.class, TestContentTypes.class, TestCommonNames.class};
- public EncodingTestSuite() {
- super("Encoding Test Suite");
- for (int i = 0; i < classes.length; i++) {
- addTest(new TestSuite(classes[i], classes[i].getName()));
- }
- }
-
- /**
- * @param theClass
- * @param name
- */
- public EncodingTestSuite(Class theClass, String name) {
- super(theClass, name);
- }
-
- /**
- * @param theClass
- */
- public EncodingTestSuite(Class theClass) {
- super(theClass);
- }
-
- /**
- * @param name
- */
- public EncodingTestSuite(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new EncodingTestSuite();
- }
-}
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/FileUtil.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/FileUtil.java
deleted file mode 100644
index 1ad29480b..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/FileUtil.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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.xml.tests.encoding;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-
-import org.eclipse.core.runtime.FileLocator;
-
-/**
- * @author davidw
- *
- * To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates. To enable and disable the creation of
- * type comments go to Window>Preferences>Java>Code Generation.
- */
-class FileUtil {
- private static String currentWorkspace = "dev0725";
- private static boolean printedOnce = false;
- public static String fLineSeparator = System.getProperty("line.separator");
- public static String fPathSeparator = System.getProperty("path.separator");
- public static String fFileSeparator = System.getProperty("file.separator");
-
- public static File makeFileFor(String directory, String filename, String testResultsDirectoryPrefix) throws IOException {
- String installPath = "/builds/Workspaces/" + currentWorkspace + "/org.eclipse.wst.xml.tests.encoding/";
- URL url = new URL("file://" + installPath);
- String totalDirectory = installPath + directory;
- String totalPath = totalDirectory + "/" + filename;
- URL totalURL = new URL(url, totalPath);
- URL finalurl = FileLocator.toFileURL(totalURL);
- String finalFile = finalurl.getFile();
- File file = new File(finalFile);
- String finalPath = file.getParent();
- File dir = new File(finalPath);
- if (!printedOnce) {
- System.out.println("Output written to " + dir.getAbsolutePath());
- printedOnce = true;
- }
-
- if (!dir.exists()) {
- dir.mkdirs();
- }
- return file;
- }
-
-}
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/GenerateFiles.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/GenerateFiles.java
deleted file mode 100644
index 327f4e6ae..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/GenerateFiles.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.xml.tests.encoding;
-
-
-public class GenerateFiles {
-
- public static final String getMainDirectoryBasedOnVMName() {
- String mainDirectory = "testfiles/genedFiles-" + getJavaVersion();
- return mainDirectory;
- }
-
- private static final String getJavaVersion() {
- String name = null; //System.getProperty("java.fullversion");
- if (name == null) {
- name = System.getProperty("java.version") + " (" + System.getProperty("java.runtime.version") + ")";
- }
- return name;
- }
-
-}
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/GenerateXMLFiles.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/GenerateXMLFiles.java
deleted file mode 100644
index 4dd0e75fc..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/GenerateXMLFiles.java
+++ /dev/null
@@ -1,409 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.xml.tests.encoding;
-
-import java.io.BufferedWriter;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintStream;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetEncoder;
-import java.nio.charset.CodingErrorAction;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.runtime.content.IContentDescription;
-
-/**
- * The purpose and logic of this class is to create small "XML files" of
- * various, known encodings, write them to files, and in later tests, be sure
- * appropriate encoding can be detected, and read in and intact characters.
- */
-public class GenerateXMLFiles extends GenerateFiles {
- private String LF = "\n";
- private String CR = "\r";
- private String CRLF = CR + LF;
- // different text strings for comparisons
- private String textUS_ASCII_LF = "abcdefghijklmnopqrstuvwxyz\n1234567890\nABCDEFGHIJKLMNOPQRSTUVWXYZ";
- private String textUS_ASCII_CRLF = "abcdefghijklmnopqrstuvwxyz\r\n1234567890\r\nABCDEFGHIJKLMNOPQRSTUVWXYZ";
- private boolean DEBUG = true;
- private boolean DEBUGCRLF = false;
- private boolean DEBUGINFO = true;
-
-
- public GenerateXMLFiles() {
- super();
- }
-
- public static void main(String[] args) {
- //junit.textui.TestRunner.run(GenerateXMLFiles.class);
- GenerateXMLFiles thisApp = new GenerateXMLFiles();
- try {
- //thisApp.generateOriginalFiles();
- thisApp.generateAllFilesForCurrentVM();
- }
- catch (IOException e) {
-
- e.printStackTrace();
- }
- }
-
- private void generateAllFilesForCurrentVM() throws IOException {
- Map allCharsetMap = Charset.availableCharsets();
- Set allKeys = allCharsetMap.keySet();
- Object[] allcharsets = allKeys.toArray();
- String[] allcharsetNames = new String[allcharsets.length];
- for (int i = 0; i < allcharsets.length; i++) {
- allcharsetNames[i] = allcharsets[i].toString();
-
- }
- //createFiles(allcharsetNames, false);
- createFiles(allcharsetNames, true);
-
- }
-
- private void createFiles(String[] charsetnames, boolean useCRLF) throws FileNotFoundException, IOException {
-
- String charsetName = null;
- Writer out = null;
- String mainDirectory = getMainDirectoryBasedOnVMNameAndFileExtension();
- List charsetFilesWritten = new ArrayList();
- for (int i = 0; i < charsetnames.length; i++) {
- try {
-
-
- charsetName = charsetnames[i];
-
- Charset charset = Charset.forName(charsetName);
- CharsetEncoder charsetEncoder = charset.newEncoder();
- charsetEncoder.onMalformedInput(CodingErrorAction.REPORT);
- charsetEncoder.onUnmappableCharacter(CodingErrorAction.REPORT);
-
- String header = getHeaderStart() + charsetName + getHeaderEnd();
- String fulltext = null;
- if (useCRLF) {
- fulltext = header + textUS_ASCII_CRLF;
- }
- else {
- fulltext = header + textUS_ASCII_LF;
- }
-
- if (!isEbcidic(charsetName, charsetEncoder)) {
- if (charsetEncoder.canEncode(fulltext)) {
- // if (canEncodeCRLF(charsetName, charsetEncoder)
- // &&
- // canEncodeSimpleString(charsetName,
- // charsetEncoder, "<?") &&
- // charsetEncoder.canEncode(fulltext)) {
- String outputfilename = "test-" + charsetName + ".xml";
- File outFile = FileUtil.makeFileFor(mainDirectory, outputfilename, null);
- //System.out.println(outFile.getAbsolutePath());
- OutputStream outputStream = new FileOutputStream(outFile);
- ByteArrayOutputStream bytesout = new ByteArrayOutputStream();
-
- Writer fileWriter = new OutputStreamWriter(outputStream, charsetEncoder);
- // this byte writer is created just to be able to
- // count precise bytes.
- Writer byteWriter = new OutputStreamWriter(bytesout, charsetEncoder);
-
- supplyBOMs(charsetName, outputStream, bytesout);
-
- out = new BufferedWriter(fileWriter);
-
-
- out.write(fulltext);
- byteWriter.write(fulltext);
- out.close();
- byteWriter.flush();
- // if we made is this far, with no exceptions,
- // etc.,
- // then
- // must have been
- // really written.
- String writtenRecord = charsetName;
- charsetFilesWritten.add(writtenRecord);
- if (DEBUG) {
- printDebugInfo(useCRLF, header, outputfilename, bytesout);
- }
- }
- else {
- if (DEBUGINFO) {
- System.out.println(" *** could not convert sample ascii text for " + charsetName);
- }
- }
- }
- }
-
- catch (IOException e) {
- if (DEBUGINFO) {
- System.out.println(" ***** could not generate for " + charsetName);
- String msg = e.getMessage();
- if (msg == null)
- msg = "";
- System.out.println(" due to " + e.getClass().getName() + " " + msg);
- }
- }
- catch (Exception e) {
- if (DEBUGINFO) {
- System.out.println(" ***** could not generate for " + charsetName);
- String msg = e.getMessage();
- if (msg == null)
- msg = "";
- System.out.println(" due to " + e.getClass().getName() + " " + msg);
- }
- }
- finally {
- if (out != null) {
- out.close();
- }
- }
- }
-
-
- // now create file that summarizes what was written
- // suitable to paste as method in test class
- File outFile = FileUtil.makeFileFor(mainDirectory, "testMethods.text", null);
- FileWriter outproperties = new FileWriter(outFile);
- outproperties.write(charsetFilesWritten.size() + CRLF);
- Iterator items = charsetFilesWritten.iterator();
- int n = 0;
- while (items.hasNext()) {
- String itemCreated = (String) items.next();
- String testMethod = createMethod(n++, itemCreated);
- outproperties.write(testMethod + CRLF);
- }
- outproperties.close();
-
- }
-
- /**
- * I thought this used to be automatic, but doesn't seem to be now?!
- */
- private void supplyBOMs(String charsetName, OutputStream outputStream, ByteArrayOutputStream bytesout) throws IOException {
- byte[] nullBytes = new byte[]{0x00, 0x00};
- if (charsetName.equals("UTF-16")) {
- outputStream.write(IContentDescription.BOM_UTF_16LE);
- bytesout.write(IContentDescription.BOM_UTF_16LE);
- }
- if (charsetName.equals("UTF-16LE")) {
- outputStream.write(IContentDescription.BOM_UTF_16LE);
- bytesout.write(IContentDescription.BOM_UTF_16LE);
- }
- if (charsetName.equals("X-UnicodeLittle")) {
- outputStream.write(IContentDescription.BOM_UTF_16LE);
- bytesout.write(IContentDescription.BOM_UTF_16LE);
- }
- if (charsetName.equals("UTF-16BE")) {
- outputStream.write(IContentDescription.BOM_UTF_16BE);
- bytesout.write(IContentDescription.BOM_UTF_16BE);
- }
- if (charsetName.equals("X-UnicodeBig")) {
- outputStream.write(IContentDescription.BOM_UTF_16BE);
- bytesout.write(IContentDescription.BOM_UTF_16BE);
- }
- if (charsetName.equals("UTF-32")) {
- outputStream.write(nullBytes);
- outputStream.write(IContentDescription.BOM_UTF_16LE);
- bytesout.write(nullBytes);
- bytesout.write(IContentDescription.BOM_UTF_16LE);
- }
- if (charsetName.equals("UTF-32LE")) {
- outputStream.write(nullBytes);
- outputStream.write(IContentDescription.BOM_UTF_16LE);
- bytesout.write(nullBytes);
- bytesout.write(IContentDescription.BOM_UTF_16LE);
- }
- if (charsetName.equals("UTF-32BE")) {
- outputStream.write(nullBytes);
- outputStream.write(IContentDescription.BOM_UTF_16BE);
- bytesout.write(nullBytes);
- bytesout.write(IContentDescription.BOM_UTF_16BE);
- }
- }
-
- /**
- * @param i
- * @param itemCreated
- */
- private String createMethod(int i, String itemCreated) {
- String template = " public void testFile" + i + "() throws CoreException, IOException {\r\n" + " String charsetName = \"" + itemCreated + "\";\r\n" + " doGenTest(charsetName);\r\n" + " }";
- return template;
- }
-
- private void printDebugInfo(boolean useCRLF, String header, String outputfilename, ByteArrayOutputStream bytesout) {
- byte[] bytes = bytesout.toByteArray();
- int nBytes = bytes.length;
- int nChars = 0;
- if (useCRLF) {
- nChars = header.length() + textUS_ASCII_CRLF.length();
- }
- else {
- nChars = header.length() + textUS_ASCII_LF.length();
- }
-
- System.out.println("Wrote " + nChars + " characters and " + nBytes + " bytes to " + outputfilename);
- }
-
- // TODO: never used
- boolean canEncodeSimpleString(String charsetName, CharsetEncoder charsetEncocder, String simpleString) {
- // this method added since some encoders don't report that they can't
- // encode something, but they obviously
- // can't, at least in the normal meaning of the word.
- // This seems to mostly apply to some IBM varieties where, apparently,
- // the input can't be interpreted at all without knowing encoding
- // (that is
- // could not be used for content based encoding).
- boolean result = false;
-
- String newAsciiString = null;
- byte[] translatedBytes = null;
- try {
- translatedBytes = simpleString.getBytes(charsetName);
- newAsciiString = new String(translatedBytes, "ascii");
- }
- catch (UnsupportedEncodingException e) {
- // impossible, since checked already
- throw new Error(e);
- }
- result = simpleString.equals(newAsciiString);
- if (!result) {
- if (charsetEncocder.maxBytesPerChar() != 1) {
- // don't check mulitbyte encoders, just assume true (for now).
- result = true;
- if (charsetEncocder.maxBytesPerChar() == 4) {
- //except, let's just exclude four byte streams, for now.
- result = false;
- if (charsetEncocder.averageBytesPerChar() == 2) {
- // except, for some reason UTF has max bytes of 4
- // (average bytes of 2).
- result = false;
- }
- }
- }
- }
-
- return result;
- }
-
- /**
- * A very heuristic method. Should have table, someday.
- */
- private boolean isEbcidic(String charsetName, CharsetEncoder charsetEncocder) {
- boolean result = false;
- String simpleString = "<?";
- String newAsciiString = null;
- byte[] translatedBytes = null;
- try {
- translatedBytes = simpleString.getBytes(charsetName);
- newAsciiString = new String(translatedBytes, "ascii");
- }
- catch (UnsupportedEncodingException e) {
- // impossible, since checked already
- throw new Error(e);
- }
- // experimenting/debugging showed the known ebcidic onces always
- // "mis" tranlated to characters L and o.
- result = "Lo".equals(newAsciiString);
- if (result) {
- System.out.println(charsetName + " assumed to be Edcidic");
- }
- return result;
- }
-
- /**
- * @param charset
- */
- boolean canEncodeCRLF(String charsetName, CharsetEncoder charsetEncoder) {
- boolean result = true;
- //String charsetCononicalName = charsetEncoder.charset().name();
- if (!charsetEncoder.canEncode(LF)) {
- if (DEBUGCRLF) {
- String stringName = "LF";
- String testString = LF;
- exploreConversion(charsetName, stringName, testString);
- System.out.println("can not encode LF for " + charsetEncoder.charset().name());
- }
- result = false;
- }
- if (!charsetEncoder.canEncode(CR)) {
- if (DEBUGCRLF) {
- String stringName = "CR";
- String testString = CR;
- exploreConversion(charsetName, stringName, testString);
- System.out.println("can not encode CR for " + charsetEncoder.charset().name());
- }
- result = false;
- }
- if (!charsetEncoder.canEncode(CRLF)) {
- if (DEBUGCRLF) {
- String stringName = "CRLF";
- String testString = CRLF;
- exploreConversion(charsetName, stringName, testString);
- System.out.println("can not encode CRLF for " + charsetEncoder.charset().name());
- }
- result = false;
- }
- return result;
-
- }
-
- private void exploreConversion(String charsetName, String stringName, String testString) throws Error {
- try {
- String newLF = new String(testString.getBytes(charsetName));
- System.out.print("old " + stringName + " (dec): ");
- dumpString(System.out, testString);
- System.out.println();
- System.out.print("new " + stringName + " (dec): ");
- dumpString(System.out, newLF);
- System.out.println();
- }
- catch (UnsupportedEncodingException e) {
- //should never happen, already checked
- throw new Error(e);
- }
- }
-
- /**
- * @param out
- * @param lf2
- */
- private void dumpString(PrintStream out, String lf2) {
- for (int i = 0; i < lf2.length(); i++) {
- out.print((int) lf2.charAt(i) + " ");
- }
-
- }
-
- public final static String getMainDirectoryBasedOnVMNameAndFileExtension() {
- String mainDirectory = getMainDirectoryBasedOnVMName() + "/xml";
- return mainDirectory;
- }
-
- private String getHeaderStart() {
- return "<?xml version=\"1.0\" encoding=\"";
- }
-
- private String getHeaderEnd() {
- return "\"?>";
- }
-
-}
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/ListCharsets.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/ListCharsets.java
deleted file mode 100644
index eef0edd6b..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/ListCharsets.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.xml.tests.encoding;
-
-import java.nio.charset.Charset;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Small class to list charset detected for a particular VM. Simple run as Java
- * Applications to get output to standard out.
- */
-public class ListCharsets {
- private final String tab = "\t";
-
- public static void main(String[] args) {
-
- ListCharsets thisApp = new ListCharsets();
-
- System.out.println();
-
- System.out.println("Current Locale: " + Locale.getDefault());
-
- System.out.println();
-
- String name = System.getProperty("java.fullversion");
- if (name == null) {
- name = System.getProperty("java.version") + " (" + System.getProperty("java.runtime.version") + ")";
- }
- System.out.println("JRE version: " + name);
-
- System.getProperties().list(System.out);
-
- thisApp.listOfLocales();
-
- System.out.println("file.encoding.pkg: " + System.getProperty("file.encoding.pkg"));
- System.out.println("file.encoding: " + System.getProperty("file.encoding"));
- System.out.println();
-
- for (int i = 0; i < args.length; i++) {
- System.out.println(args[i]);
- }
- System.out.println();
- thisApp.listOfCharsets();
- }
-
- private void listOfLocales() {
- System.out.println("Available Locales");
- Locale[] locales = Locale.getAvailableLocales();
- for (int i = 0; i < locales.length; i++) {
- System.out.println(locales[i]);
-
- }
-
- }
-
- private void listOfCharsets() {
- System.out.println("Available Charsets");
- int count = 0;
- Map map = Charset.availableCharsets();
- Iterator it = map.keySet().iterator();
- while (it.hasNext()) {
- count++;
- // Get charset name
- String charsetName = (String) it.next();
- System.out.println(count + ". " + " Charsetname: " + charsetName);
- // Get charset
- Charset charset = Charset.forName(charsetName);
- System.out.println(tab + "displayName: " + charset.displayName(Locale.getDefault()));
- Set set = charset.aliases();
- System.out.println(tab + "aliases: " + set);
- }
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/TestsPlugin.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/TestsPlugin.java
deleted file mode 100644
index ef9c6174a..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/TestsPlugin.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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.xml.tests.encoding;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.wst.xml.core.internal.contenttype.ByteReader;
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class TestsPlugin extends Plugin {
- // The shared instance.
- private static TestsPlugin plugin;
-
- /**
- * The constructor.
- */
- public TestsPlugin() {
- super();
- plugin = this;
- }
-
- /**
- * Returns the shared instance.
- */
- public static TestsPlugin getDefault() {
- return plugin;
- }
-
- /**
- * Returns the workspace instance.
- */
- public static IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
- /**
- * Returns the string from the plugin's resource bundle, or 'key' if not
- * found.
- */
- public static String getResourceString(String key) {
- return key;
- }
-
- /**
- * Returns the plugin's resource bundle,
- */
- public ResourceBundle getResourceBundle() {
- return null;
- }
-
- public static URL getInstallLocation() {
- URL installLocation = Platform.getBundle("org.eclipse.wst.xml.tests.encoding").getEntry("/");
- URL resolvedLocation = null;
- try {
- resolvedLocation = FileLocator.resolve(installLocation);
- }
- catch (IOException e) {
- // impossible
- throw new Error(e);
- }
- return resolvedLocation;
- }
-
- public static File getTestFile(String filepath) {
- URL installURL = getInstallLocation();
- // String scheme = installURL.getProtocol();
- String path = installURL.getPath();
- String location = path + filepath;
- File result = new File(location);
- return result;
- }
-
- public static List getAllTestFiles(String topDirName) {
- List result = null;
- URL installURL = getInstallLocation();
- // String scheme = installURL.getProtocol();
- String path = installURL.getPath();
- String location = path + topDirName;
- File topDir = new File(location);
- if (!topDir.isDirectory()) {
- throw new IllegalArgumentException(topDirName + " is not a directory");
- }
- result = getFilesInDir(topDir);
- return result;
- }
-
- /**
- * @param topDir
- * @return
- */
- private static List getFilesInDir(File topDir) {
- List files = new ArrayList();
- File[] topFiles = topDir.listFiles();
- for (int i = 0; i < topFiles.length; i++) {
- File file = topFiles[i];
- if (file.isFile()) {
- files.add(file);
- }
- else if (file.isDirectory() && !file.getName().endsWith("CVS")) {
- List innerFiles = getFilesInDir(file);
- files.addAll(innerFiles);
- }
- }
- return files;
- }
-
- public static Reader getTestReader(String filepath) throws FileNotFoundException {
- URL installURL = getInstallLocation();
- // String scheme = installURL.getProtocol();
- String path = installURL.getPath();
- String location = path + filepath;
- Reader result = new FileReader(location);
- return result;
- }
-
- public static Reader getByteReader(String filepath) throws FileNotFoundException {
- URL installURL = getInstallLocation();
- // String scheme = installURL.getProtocol();
- String path = installURL.getPath();
- String location = path + filepath;
- Reader result = new ByteReader(new BufferedInputStream(new FileInputStream(location)));
- return result;
- }
-
-}
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/pref/TestPreferences.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/pref/TestPreferences.java
deleted file mode 100644
index 4fc24b386..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/pref/TestPreferences.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.xml.tests.encoding.pref;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.wst.sse.core.internal.encoding.ContentBasedPreferenceGateway;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
-
-
-public class TestPreferences extends TestCase {
-
- /**
- * @param preferences
- * @throws BackingStoreException
- */
- private static void printChildren(Preferences preferences) throws BackingStoreException {
- System.out.println("\t" + preferences.absolutePath());
- String [] keys = preferences.keys();
- printKeys(keys);
- String[] children = preferences.childrenNames();
- printChildren(children);
- for (int i = 0; i < children.length; i++) {
- String child = children[i];
- Preferences subPreferences = preferences.node(child);
- String [] subkeys = subPreferences.keys();
- System.out.println();
- System.out.println(child);
- System.out.println();
- printKeys(subkeys);
- }
- }
- static private void printChildren(String[] children) {
- printStringArray(children, "\t");
- }
-
- /**
- * @param keys
- */
- private static void printKeys(String[] keys) {
- printStringArray(keys, "\t\t");
-
- }
-
- static private void printStringArray(String[] array, String tabChars) {
- for (int i = 0; i < array.length; i++) {
- String string = array[i];
- System.out.println(tabChars + string);
- }
- }
-
- private boolean DEBUG = true;
-
- private void displayPreferenceTree() {
- IEclipsePreferences eclipsePreferences = Platform.getPreferencesService().getRootNode();
-
-
- try {
- String[] children = eclipsePreferences.childrenNames();
- System.out.println(eclipsePreferences.absolutePath());
- printChildren(children);
-
- for (int i = 0; i < children.length; i++) {
- String string = children[i];
- Preferences preferences = eclipsePreferences.node(string);
- printChildren(preferences);
-
-
- }
-
- }
- catch (BackingStoreException e) {
- e.printStackTrace();
- }
-
- }
-
- public void testAccess() {
- if (DEBUG) {
- displayPreferenceTree();
- }
- // always ok if no exceptions thrown
- assertTrue(true);
- }
-
- public void testContentBasedPrefHTML() {
- IContentType contentType = Platform.getContentTypeManager().findContentTypeFor("test.html");
- Preferences preferences = ContentBasedPreferenceGateway.getPreferences(contentType);
- assertNotNull(preferences);
- }
-
- public void testContentBasedPrefXML() {
- IContentType contentType = Platform.getContentTypeManager().findContentTypeFor("test.xml");
- Preferences preferences = ContentBasedPreferenceGateway.getPreferences(contentType);
- assertNotNull(preferences);
- }
-}
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/properties/TestCommonNames.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/properties/TestCommonNames.java
deleted file mode 100644
index 1ff78d499..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/properties/TestCommonNames.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.xml.tests.encoding.properties;
-
-import junit.framework.TestCase;
-
-import org.eclipse.wst.sse.core.internal.encoding.CommonCharsetNames;
-
-public class TestCommonNames extends TestCase {
-
- private static final boolean DEBUG = false;
-
- public void testCommonNames() {
- String[] names = CommonCharsetNames.getCommonCharsetNames();
- assertTrue("common charset names could not be loaded", names != null && names.length > 0);
- if (DEBUG) {
- for (int i = 0; i < names.length; i++) {
- String name = names[i];
- String displayName = CommonCharsetNames.getDisplayString(name);
- System.out.println( name + " " + displayName);
- }
- }
- }
-
- public void doTestDefaultIanaNames(String stringToCheck, String defaultName, String expected) {
- String actual = CommonCharsetNames.getPreferredDefaultIanaName(stringToCheck, defaultName);
- assertEquals("default IANA name test failed for " + stringToCheck, expected, actual);
- }
-
- public void testASCII() {
- doTestDefaultIanaNames("ASCII", "UTF-8", "US-ASCII");
- }
-
- public void testCp1252() {
- doTestDefaultIanaNames("Cp1252", "UTF-8", "ISO-8859-1");
- }
-
- public void testMS950() {
- doTestDefaultIanaNames("MS950", "UTF-8", "BIG5");
- }
-
- public void testCp1256() {
- doTestDefaultIanaNames("Cp1256", "UTF-8", "windows-1256");
- }
-
- public void testMS949() {
- doTestDefaultIanaNames("MS949", "UTF-8", "EUC-KR");
- }
-
- public void testEUC_JP() {
- doTestDefaultIanaNames("EUC-JP", "UTF-8", "EUC-JP");
- }
-
- public void testTotallyFake() {
- doTestDefaultIanaNames("totallyFake", "UTF-8", "UTF-8");
- }
-
- public void testSystemEncoding() {
- String systemEnc = System.getProperty("file.encoding");
- if (systemEnc != null) {
- String actual = CommonCharsetNames.getPreferredDefaultIanaName(systemEnc, "UTF-8");
- assertNotNull("default IANA name test failed for system encoding " + systemEnc, actual);
- }
- }
-}
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/properties/TestDisplayNames.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/properties/TestDisplayNames.java
deleted file mode 100644
index 7d8423bd2..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/properties/TestDisplayNames.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.xml.tests.encoding.properties;
-
-import junit.framework.TestCase;
-
-import org.eclipse.wst.sse.core.internal.encoding.CommonCharsetNames;
-
-
-public class TestDisplayNames extends TestCase {
- private static final boolean DEBUG = false;
-
- public void testCommonName() {
- String displayName = CommonCharsetNames.getDisplayString("ISO-8859-2");
- assertNotNull("display name for charset could not be retrieved", displayName);
- if (DEBUG) {
- System.out.println(displayName);
- }
- }
-}
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/properties/TestOverrides.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/properties/TestOverrides.java
deleted file mode 100644
index c5400a806..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/properties/TestOverrides.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.xml.tests.encoding.properties;
-
-import junit.framework.TestCase;
-
-import org.eclipse.wst.sse.core.internal.encoding.CodedIO;
-
-public class TestOverrides extends TestCase {
-
- private static final boolean DEBUG = false;
-
- public String doTestOverride(String stringToCheck) {
-
- String charset = CodedIO.getAppropriateJavaCharset(stringToCheck);
- assertNotNull("override test failed for " + stringToCheck, charset);
- return charset;
- }
-
- public void testISO88598I() {
- String result = doTestOverride("ISO-8859-8-I");
- assertEquals("mapping override not correct for ISO-8859-8-I", "ISO-8859-8", result);
- if (DEBUG) {
- System.out.println(result);
- }
- }
-
- public void testXSJIS() {
- String result = doTestOverride("X-SJIS");
- assertEquals("mapping override not correct for X-SJIS", "Shift_JIS", result);
- if (DEBUG) {
- System.out.println(result);
- }
- }
-
-}
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestCodedReader.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestCodedReader.java
deleted file mode 100644
index f436de3c9..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestCodedReader.java
+++ /dev/null
@@ -1,614 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.xml.tests.encoding.read;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.Reader;
-
-import junit.framework.TestCase;
-
-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.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.wst.sse.core.internal.encoding.CodedReaderCreator;
-import org.eclipse.wst.sse.core.internal.encoding.IContentDescriptionExtended;
-import org.eclipse.wst.sse.core.internal.encoding.NonContentBasedEncodingRules;
-import org.eclipse.wst.xml.tests.encoding.TestsPlugin;
-import org.eclipse.wst.xml.tests.encoding.util.ProjectUnzipUtility;
-
-
-public class TestCodedReader extends TestCase {
- // private final String fileDir = "html/";
- // private final String fileRoot =
- // "/builds/Workspaces/HeadWorkspace/org.eclipse.wst.xml.tests.encoding/";
- // private final String fileLocation = fileRoot + fileDir;
- private static final boolean DEBUG = false;
- private static final boolean DEBUG_TEST_DETAIL = false;
- // needs to be static, since JUnit creates difference instances for each
- // test
- private static boolean fTestProjectInitialized;
- private static final String TEST_PROJECT_NAME = "org.eclipse.encoding.resource.newtests";
- static IProject fTestProject;
- protected static int nSetups = 0;
-
- private String massageCharset(String foundCharset) {
- String result = foundCharset;
- if ("UTF-16LE".equals(foundCharset)) {
- result = "UTF-16";
- } else if ("X-UnicodeLittle".equals(foundCharset)) {
- result = "UTF-16";
- } else if ("X-UnicodeBig".equals(foundCharset)) {
- result = "UTF-16BE";
- }
-
- return result;
- }
-
- /**
- *
- */
- public TestCodedReader() {
- super();
- // System.out.println(currentPlatformCharset);
- }
-
- public static void main(String[] args) {
- // try {
- // new TestCodedReader().doAllFiles();
- // } catch (CoreException e) {
- // e.printStackTrace();
- // } catch (IOException e) {
- // e.printStackTrace();
- // }
- }
-
- private static void createProject(IProject project, IPath locationPath, IProgressMonitor monitor) throws CoreException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.beginTask("creating test project", 10);
- // create the project
- try {
- if (!project.exists()) {
- IProjectDescription desc = project.getWorkspace().newProjectDescription(project.getName());
- if (Platform.getLocation().equals(locationPath)) {
- locationPath = null;
- }
- desc.setLocation(locationPath);
- project.create(desc, monitor);
- monitor = null;
- }
- if (!project.isOpen()) {
- project.open(monitor);
- monitor = null;
- }
- } finally {
- if (monitor != null) {
- monitor.done();
- }
- }
- }
-
- private static void getAndCreateProject() throws CoreException {
- // TestsPlugin testsPlugin = (TestsPlugin)
- // Platform.getPlugin("org.eclipse.wst.xml.tests.encoding");
- IWorkspace workspace = TestsPlugin.getWorkspace();
- IWorkspaceRoot root = workspace.getRoot();
- fTestProject = root.getProject(TEST_PROJECT_NAME);
- // this form creates project as "linked" back to 'fileRoot'
- // createProject(testProject, new Path(fileRoot), null);
- createProject(fTestProject, null, null);
- fTestProject.refreshLocal(IResource.DEPTH_INFINITE, null);
- assertTrue(fTestProject.exists());
- // IContainer dotestFiles = testProject.getFolder("dotestFiles");
- // assertTrue(dotestFiles.exists());
- // IResource[] allFolders = dotestFiles.members();
- // assertNotNull(allFolders);
- }
-
- private StringBuffer readInputStream(Reader reader) throws IOException {
- StringBuffer buffer = new StringBuffer();
- int numRead = 0;
- char tBuff[] = new char[4000];
- while ((numRead = reader.read(tBuff, 0, tBuff.length)) != -1) {
- buffer.append(tBuff, 0, numRead);
- }
- return buffer;
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- nSetups++;
- if (!fTestProjectInitialized) {
- getAndCreateProject();
- // unzip files to the root of workspace directory
- String destinationProjectString = fTestProject.getLocation().toOSString();
- String destinationFolder = destinationProjectString + "/";
- // this zip file is sitting in the "root" of test plugin
- File zipFile = TestsPlugin.getTestFile("testfiles.zip");
- ProjectUnzipUtility projUtil = new ProjectUnzipUtility();
- projUtil.unzipAndImport(zipFile, destinationFolder);
- projUtil.initJavaProject(TEST_PROJECT_NAME);
- fTestProject.refreshLocal(IResource.DEPTH_INFINITE, null);
- fTestProjectInitialized = true;
- }
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- nSetups--;
- if (nSetups == 0) {
- if (!DEBUG) {
- // Display display = PlatformUI.getWorkbench().getDisplay();
- // display.asyncExec(new Runnable() {
- // public void run() {
- // ProjectUnzipUtility projUtil = new ProjectUnzipUtility();
- // IProject proj = fTestProject;
- // fTestProject = null;
- // try {
- // projUtil.deleteProject(proj);
- // } catch (Exception e) {
- // e.printStackTrace();
- // }
- // }
- // });
- }
- }
- }
-
- protected void doTest(String expectedJavaCharset, String expectedDetectedCharset, String filePath, Class expectedException) throws CoreException, IOException {
- Reader reader = null;
- IFile file = (IFile) fTestProject.findMember(filePath);
- assertNotNull(file);
- expectedJavaCharset = massageCharset(expectedJavaCharset);
- expectedDetectedCharset = massageCharset(expectedDetectedCharset);
-
- // note: eventually, I should change calling methods so if detected
- // charset is expected to be same
- // as the 'used' java charset, then simply pass in null, but for now,
- // we'll "force" that here in this
- // method.
- if (expectedJavaCharset.equals(expectedDetectedCharset)) {
- expectedDetectedCharset = null;
- }
-
- try {
- reader = doCoreTest(expectedJavaCharset, expectedDetectedCharset, file);
- } catch (Exception e) {
- if (expectedException != null) {
- boolean result = expectedException.isInstance(e);
- assertTrue("Unexpected Exception: " + getGoodFullMsg(e), result);
- } else {
- // will alway assert if gets to here
- String msg = getGoodFullMsg(e);
- assertNull("Unexpected Exception: " + msg, e);
- }
- } finally {
- if (reader != null) {
- reader.close();
- }
-
- }
- }
-
- protected Reader doCoreTest(String expectedJavaCharset, String expectedDetectedCharset, IFile file) throws CoreException, IOException {
- Reader reader;
- // create these first, to test exception being thrown correctly
- CodedReaderCreator codedReaderCreator = new CodedReaderCreator();
- codedReaderCreator.set(file);
- reader = codedReaderCreator.getCodedReader();
-
- String javaCharsetName = file.getCharset();
- IContentDescription description = file.getContentDescription();
- javaCharsetName = massageCharset(javaCharsetName);
- // codedReaderCreator.getEncodingMemento().getJavaCharsetName();
- if (expectedJavaCharset.equals("expectPlatformCharset")) {
- String platformDefault = NonContentBasedEncodingRules.useDefaultNameRules(null);
- assertTrue(javaCharsetName.equals(platformDefault));
- } else {
- boolean asExpected = javaCharsetName.equals(expectedJavaCharset);
- assertTrue(javaCharsetName + " did not equal the expected " + expectedJavaCharset + " (this is a VM dependent test)", asExpected);
- }
- String javaCharsetNameProperty = (String) description.getProperty(IContentDescription.CHARSET);
- String detectedCharsetNameProperty = getDetectedCharsetName(description);
- detectedCharsetNameProperty = massageCharset(detectedCharsetNameProperty);
- // if (detectedCharsetName == null) {
- // detectedCharsetName = javaCharsetNameProperty;
- // }
- if (!expectedJavaCharset.equals("expectPlatformCharset")) {
- boolean expecedResult = expectedJavaCharset.equals(javaCharsetNameProperty);
- assertTrue("java based charset name was not as expected", expecedResult);
- } else {
- String expectedDefault = NonContentBasedEncodingRules.useDefaultNameRules(null);
- boolean ExpectedResult = expectedDefault.equals(javaCharsetNameProperty);
- assertTrue("java based charset name not as expected when platform default expected", ExpectedResult);
- }
-
- if (expectedDetectedCharset != null) {
- boolean expectedResult = expectedDetectedCharset.equals(detectedCharsetNameProperty);
- assertTrue("detected charset name was not as expected", expectedResult);
- }
- // test if can read/write file
- StringBuffer buffer = readInputStream(reader);
- if (DEBUG_TEST_DETAIL) {
- System.out.print(buffer);
- }
- return reader;
- }
-
- /**
- * This method is just to help handle transition from using
- * EncodingMemtento to not using encodingMemento.
- */
- private String getDetectedCharsetName(IContentDescription description) {
- String result = null;
- result = (String) description.getProperty(IContentDescriptionExtended.DETECTED_CHARSET);
- return result;
- }
-
- /**
- * @param e
- * @return
- */
- private String getGoodFullMsg(Exception e) {
- String msg = e.getClass().getName() + ": " + e.getMessage();
- return msg;
- }
-
- public void testFile1() throws CoreException, IOException {
- doTest("expectPlatformCharset", null, "testfiles/css/emptyFile.css", null);
- }
-
- public void testFile2() throws CoreException, IOException {
- doTest("EUC-JP", "EUC-JP", "testfiles/css/encoding_test_eucjp.css", null);
- }
-
- public void testFile3() throws CoreException, IOException {
- doTest("ISO-2022-JP", "ISO-2022-JP", "testfiles/css/encoding_test_jis.css", null);
- }
-
- public void testFile4() throws CoreException, IOException {
- doTest("Shift_JIS", "SHIFT_JIS", "testfiles/css/encoding_test_sjis.css", null);
- }
-
- public void testFile5() throws CoreException, IOException {
- doTest("expectPlatformCharset", null, "testfiles/css/noEncoding.css", null);
- }
-
- public void testFile6() throws CoreException, IOException {
- doTest("ISO-8859-6", "ISO-8859-6", "testfiles/css/nonStandard.css", null);
- }
-
- public void testFile7() throws CoreException, IOException {
- doTest("ISO-8859-6", "ISO-8859-6", "testfiles/css/nonStandardIllFormed.css", null);
- }
-
- public void testFile8() throws CoreException, IOException {
- doTest("ISO-8859-6", "ISO-8859-6", "testfiles/css/nonStandardIllFormed2.css", null);
- }
-
-
- public void testFile57() throws CoreException, IOException {
- doTest("expectPlatformCharset", null, "testfiles/html/EmptyFile.html", null);
- }
-
- public void testFile58() throws CoreException, IOException {
- doTest("UTF-8", "UTF-8", "testfiles/html/IllformedNormalNonDefault.html", null);
- }
-
- public void testFile59() throws CoreException, IOException {
- doTest("expectPlatformCharset", null, "testfiles/html/LargeNoEncoding.html", null);
- }
-
- public void testFile60() throws CoreException, IOException {
- doTest("ISO-8859-1", "iso-8859-1", "testfiles/html/LargeNonDefault.html", null);
- }
-
- public void testFile61() throws CoreException, IOException {
- doTest("ISO-8859-6", "ISO-8859-6", "testfiles/html/MultiNonDefault.html", null);
- }
-
- public void testFile62() throws CoreException, IOException {
- doTest("expectPlatformCharset", null, "testfiles/html/NoEncoding.html", null);
- }
-
- public void testFile63() throws CoreException, IOException {
- doTest("UTF-8", "UTF-8", "testfiles/html/noquotes.html", null);
- }
-
- public void testFile64() throws CoreException, IOException {
- doTest("UTF-8", "UTF-8", "testfiles/html/NormalNonDefault.html", null);
- }
-
- public void testFile65() throws CoreException, IOException {
- doTest("ISO-8859-1", "ISO-8859-1", "testfiles/jsp/EmptyFile.jsp", null);
- }
-
- public void testFile66() throws CoreException, IOException {
- doTest("ISO-8859-8", null, "testfiles/jsp/IllformedNormalNonDefault.jsp", null);
- }
-
- public void testFile67() throws CoreException, IOException {
- doTest("null", "null", "testfiles/jsp/inValidEncodingValue.jsp", org.eclipse.wst.sse.core.internal.exceptions.UnsupportedCharsetExceptionWithDetail.class);
- }
-
- public void testFile68() throws CoreException, IOException {
- doTest("windows-1252", "Cp1252", "testfiles/jsp/javaEncodingValue.jsp", null);
- }
-
- public void testFile69() throws CoreException, IOException {
- doTest("ISO-8859-1", "ISO-8859-1", "testfiles/jsp/MalformedNoEncoding.jsp", null);
- }
-
- public void testFile70() throws CoreException, IOException {
- doTest("ISO-8859-1", "ISO-8859-1", "testfiles/jsp/MalformedNoEncodingXSL.jsp", null);
- }
-
- public void testFile71() throws CoreException, IOException {
- doTest("ISO-8859-1", "ISO-8859-1", "testfiles/jsp/noEncoding.jsp", null);
- }
-
- public void testFile72() throws CoreException, IOException {
- doTest("ISO-8859-1", "ISO-8859-1", "testfiles/jsp/NoEncodinginXMLDecl.jsp", null);
- }
-
- public void testFile73() throws CoreException, IOException {
- doTest("ISO-8859-2", "ISO-8859-2", "testfiles/jsp/nomalDirectiveCase.jsp", null);
- }
-
- public void testFile74() throws CoreException, IOException {
- doTest("ISO-8859-1", "ISO-8859-1", "testfiles/jsp/nomalDirectiveCaseNoEncoding.jsp", null);
- }
-
- public void testFile75() throws CoreException, IOException {
- doTest("ISO-8859-3", "ISO-8859-3", "testfiles/jsp/nomalDirectiveCaseUsingCharset.jsp", null);
- }
-
- public void testFile76() throws CoreException, IOException {
- doTest("ISO-8859-2", "ISO-8859-2", "testfiles/jsp/nomalDirectiveCaseUsingXMLSyntax.jsp", null);
- }
-
- public void testFile77() throws CoreException, IOException {
- doTest("ISO-8859-8", null, "testfiles/jsp/NormalNonDefault.jsp", null);
- }
-
- public void testFile78() throws CoreException, IOException {
- doTest("ISO-8859-8", "ISO-8859-8", "testfiles/jsp/NormalNonDefaultWithXMLDecl.jsp", null);
- }
-
- public void testFile79() throws CoreException, IOException {
- doTest("ISO-8859-7", "ISO-8859-7", "testfiles/jsp/NormalPageCaseNonDefault.jsp", null);
- }
-
- public void testFile80() throws CoreException, IOException {
- doTest("Shift_JIS", "SHIFT_JIS", "testfiles/jsp/SelColBeanRow12ResultsForm.jsp", null);
- }
-
- public void testFile81() throws CoreException, IOException {
- doTest("ISO-8859-3", "ISO-8859-3", "testfiles/jsp/testBrokenLine.jsp", null);
- }
-
- public void testFile82() throws CoreException, IOException {
- doTest("null", "null", "testfiles/jsp/testDefaultEncoding.jsp", org.eclipse.wst.sse.core.internal.exceptions.UnsupportedCharsetExceptionWithDetail.class);
- }
-
- public void testFile83() throws CoreException, IOException {
- doTest("null", "null", "testfiles/jsp/testDefaultEncodingWithJunk.jsp", org.eclipse.wst.sse.core.internal.exceptions.UnsupportedCharsetExceptionWithDetail.class);
- }
-
- public void testFile84() throws CoreException, IOException {
- doTest("ISO-8859-1", "ISO-8859-1", "testfiles/jsp/testExtraJunk.jsp", null);
- }
-
- public void testFile85() throws CoreException, IOException {
- doTest("UTF-8", "UTF-8", "testfiles/jsp/testExtraValidStuff.jsp", null);
- }
-
- public void testFile86() throws CoreException, IOException {
- doTest("ISO-8859-1", null, "testfiles/jsp/testIllFormed.jsp", null);
- }
-
- public void testFile87() throws CoreException, IOException {
- doTest("UTF-8", "UTF-8", "testfiles/jsp/testIllFormed2.jsp", null);
- }
-
- public void testFile88() throws CoreException, IOException {
- doTest("ISO-8859-1", "ISO-8859-1", "testfiles/jsp/testNoEncodingValue.jsp", null);
- }
-
- public void testFile89() throws CoreException, IOException {
- doTest("ISO-8859-1", "ISO-8859-1", "testfiles/jsp/testNoPageDirective.jsp", null);
- }
-
- public void testFile90() throws CoreException, IOException {
- doTest("ISO-8859-2", "ISO-8859-2", "testfiles/jsp/testNoPageDirectiveAtFirst.jsp", null);
- }
-
- public void testFile91() throws CoreException, IOException {
- doTest("ISO-8859-1", "ISO-8859-1", "testfiles/jsp/testNoPageDirectiveInLargeFile.jsp", null);
- }
-
- public void testFile92() throws CoreException, IOException {
- doTest("UTF-8", "UTF-8", "testfiles/jsp/testNormalCase.jsp", null);
- }
-
- public void testFile93() throws CoreException, IOException {
- doTest("UTF-16", "UTF-16", "testfiles/jsp/testUTF16.jsp", null);
- }
-
- public void testFile94() throws CoreException, IOException {
- doTest("UTF-16LE", "UTF-16LE", "testfiles/jsp/utf16UnicodeStreamWithNoEncodingInHeader2.jsp", null);
- }
-
- public void testFile95() throws CoreException, IOException {
- doTest("UTF-16", "UTF-16", "testfiles/jsp/utf16UnicodeStreamWithNoEncodingInHeaderBE.jsp", null);
- }
-
- public void testFile96() throws CoreException, IOException {
- doTest("UTF-16", "UTF-16", "testfiles/jsp/utf16WithJapaneseChars.jsp", null);
- }
-
- public void testFile97() throws CoreException, IOException {
- doTest("UTF-8", "UTF-8", "testfiles/jsp/UTF8With3ByteBOM.jsp", null);
- }
-
- public void testFile98() throws CoreException, IOException {
- doTest("ISO-8859-8", "ISO-8859-8", "testfiles/jsp/WellFormedNormalNonDefault.jsp", null);
- }
-
- public void testFile99() throws CoreException, IOException {
- doTest("Shift_JIS", "SHIFT_JIS", "testfiles/regressionTestFiles/defect223365/SelColBeanRow12ResultsForm.jsp", null);
- }
-
- public void testFile100() throws CoreException, IOException {
- doTest("Shift_JIS", "SHIFT_JIS", "testfiles/regressionTestFiles/defect223365/SelColBeanRow12ResultsFormB.jsp", null);
- }
-
- public void testFile101() throws CoreException, IOException {
- doTest("Shift_JIS", "SHIFT_JIS", "testfiles/regressionTestFiles/defect224293/testshiftjisXmlSyntax.jsp", null);
- }
-
- public void testFile102() throws CoreException, IOException {
- doTest("Shift_JIS", "Shift_JIS", "testfiles/regressionTestFiles/defect229667/audi.jsp", null);
- }
-
- public void testFile103() throws CoreException, IOException {
- doTest("UTF-8", "UTF-8", "testfiles/xml/EmptyFile.xml", null);
- }
-
- public void testFile104() throws CoreException, IOException {
- doTest("EUC-JP", "EUC-JP", "testfiles/xml/eucjp.xml", null);
- }
-
- // public void testFile105() throws CoreException, IOException {
- // doTest("ISO-8859-1", "ISO-8859-1",
- // "testfiles/xml/IllformedNormalNonDefault.xml", null);
- // }
-
- // public void testFile106() throws CoreException, IOException {
- // doTest("UTF-8", "UTF-8", "testfiles/xml/MalformedNoEncoding.xml",
- // CharacterCodingException.class);
- // }
-
- // public void testFile107() throws CoreException, IOException {
- // doTest("UTF-8", "UTF-8", "testfiles/xml/MalformedNoEncoding.xsl",
- // CharacterCodingException.class);
- // }
-
- public void testFile108() throws CoreException, IOException {
- doTest("UTF-8", "UTF-8", "testfiles/xml/NoEncoding.xml", null);
- }
-
- public void testFile109() throws CoreException, IOException {
- doTest("ISO-8859-1", "ISO-8859-1", "testfiles/xml/NormalNonDefault.xml", null);
- }
-
- public void testFile110() throws CoreException, IOException {
- doTest("Shift_JIS", "Shift_JIS", "testfiles/xml/shiftjis.xml", null);
- }
-
- public void testFile111() throws CoreException, IOException {
- doTest("ISO-8859-1", "ISO-8859-1", "testfiles/xml/testExtraJunk.xml", null);
- }
-
- public void testFile112() throws CoreException, IOException {
- doTest("UTF-8", "UTF-8", "testfiles/xml/testExtraValidStuff.xml", null);
- }
-
- // public void testFile113() throws CoreException, IOException {
- // doTest("UTF-8", "UTF-8", "testfiles/xml/testIllFormed.xml", null);
- // }
-
- public void testFile114() throws CoreException, IOException {
- doTest("UTF-8", "UTF-8", "testfiles/xml/testIllFormed2.xml", null);
- }
-
- // public void testFile115() throws CoreException, IOException {
- // doTest("null", "null", "testfiles/xml/testIllFormed3.xml",
- // UnsupportedCharsetExceptionWithDetail.class);
- // }
-
- public void testFile116() throws CoreException, IOException {
- doTest("UTF-8", "UTF-8", "testfiles/xml/testIllFormed4.xml", null);
- }
-
- public void testFile117() throws CoreException, IOException {
- doTest("ISO-8859-1", "ISO-8859-1", "testfiles/xml/testMultiLine.xml", null);
- }
-
- public void testFile118() throws CoreException, IOException {
- doTest("UTF-8", "UTF-8", "testfiles/xml/testNoEncodingValue.xml", null);
- }
-
- public void testFile119() throws CoreException, IOException {
- doTest("UTF-8", "UTF-8", "testfiles/xml/testNormalCase.xml", null);
- }
-
- public void testFile120() throws CoreException, IOException {
- doTest("UTF-8", "UTF-8", "testfiles/xml/testNoXMLDecl.xml", null);
- }
-
- public void testFile121() throws CoreException, IOException {
- doTest("UTF-8", "UTF-8", "testfiles/xml/testNoXMLDeclAtFirst.xml", null);
- }
-
- public void testFile122() throws CoreException, IOException {
- doTest("UTF-8", "UTF-8", "testfiles/xml/testNoXMLDeclInLargeFile.xml", null);
- }
-
- // public void testFile123() throws CoreException, IOException {
- // doTest("UTF-16BE", "UTF-16BE", "testfiles/xml/testUTF16.xml",
- // CharacterCodingException.class);
- // }
-
- // public void testFile124() throws CoreException, IOException {
- // doTest("UTF-16LE", "UTF-16LE",
- // "testfiles/xml/UTF16LEAtStartOfLargeFile.xml", null);
- // }
-
- // public void testFile125() throws CoreException, IOException {
- // doTest("UTF-16LE", "UTF-16LE",
- // "testfiles/xml/utf16UnicodeStreamWithNoEncodingInHeader2.xml", null);
- // }
-
- // public void testFile126() throws CoreException, IOException {
- // doTest("UTF-16BE", "UTF-16BE",
- // "testfiles/xml/utf16UnicodeStreamWithNoEncodingInHeaderBE.xml",
- // CharacterCodingException.class);
- // }
-
- // public void testFile127() throws CoreException, IOException {
- // doTest("UTF-16BE", "UTF-16BE",
- // "testfiles/xml/utf16WithJapaneseChars.xml", null);
- // }
-
- public void testFile128() throws CoreException, IOException {
- doTest("UTF-8", "UTF-8", "testfiles/xml/UTF8With3ByteBOM.xml", null);
- }
-
- public void testDocumentStreamCaseHTML() throws CoreException, IOException {
- doTest("Shift_JIS", "SHIFT_JIS", "testfiles/DocumentStreamTestCase/kaeru5.htm", null);
- }
-
- public void testDocumentStreamCaseJSP() throws CoreException, IOException {
- doTest("Shift_JIS", "SHIFT_JIS", "testfiles/DocumentStreamTestCase/kaeru5.jsp", null);
- }
-}
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestCodedReaderOnGennedFiles.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestCodedReaderOnGennedFiles.java
deleted file mode 100644
index 7978943cc..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestCodedReaderOnGennedFiles.java
+++ /dev/null
@@ -1,717 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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.xml.tests.encoding.read;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.xml.tests.encoding.GenerateFiles;
-
-
-/**
- * This class should contain a "master list" of all filenames generated by
- * various VM's ... then the test ingores it if the filename's not found due
- * to the VM not supporting it.
- *
- */
-public class TestCodedReaderOnGennedFiles extends TestCodedReader {
- private static int notRan = 0;
- private static final boolean DEBUG = false;
-
- protected void doGenTest(String charsetName) throws CoreException, IOException {
- doTest(charsetName, charsetName, GenerateFiles.getMainDirectoryBasedOnVMName() + "/xml/test-" + charsetName + ".xml", null);
- }
-
- protected void doTest(String expectedJavaCharset, String expectedDetectedCharset, String filePath, Class expectedException) throws CoreException, IOException {
- if (expectedJavaCharset != null && expectedJavaCharset.indexOf("UTF-32") > -1) {
- return; //won't try 32 bit right now
- }
- IFile file = (IFile) fTestProject.findMember(filePath);
-
- // if there no file, just assume that its due to which VM is
- // bring used. (Could be improved in future to avoid counting as a
- // test) - this check in here for initial debugging only
- if (file == null) {
- notRan++;
- if (DEBUG) {
- System.out.println();
- System.out.println("test not ran since charset not supported by VM: " + filePath);
- }
- return;
- }
- super.doTest(expectedJavaCharset, expectedDetectedCharset, filePath, expectedException);
- }
-
- public void testFile0() throws CoreException, IOException {
- String charsetName = "Big5";
- doGenTest(charsetName);
- }
-
- public void testFile1() throws CoreException, IOException {
- String charsetName = "CESU-8";
- doGenTest(charsetName);
- }
-
- public void testFile2() throws CoreException, IOException {
- String charsetName = "COMPOUND_TEXT";
- doGenTest(charsetName);
- }
-
- public void testFile3() throws CoreException, IOException {
- String charsetName = "EUC-CN";
- doGenTest(charsetName);
- }
-
- public void testFile4() throws CoreException, IOException {
- String charsetName = "EUC-JP";
- doGenTest(charsetName);
- }
-
- public void testFile5() throws CoreException, IOException {
- String charsetName = "EUC-KR";
- doGenTest(charsetName);
- }
-
- public void testFile6() throws CoreException, IOException {
- String charsetName = "GB18030";
- doGenTest(charsetName);
- }
-
- public void testFile7() throws CoreException, IOException {
- String charsetName = "GB2312";
- doGenTest(charsetName);
- }
-
- public void testFile8() throws CoreException, IOException {
- String charsetName = "GBK";
- doGenTest(charsetName);
- }
-
- public void testFile9() throws CoreException, IOException {
- String charsetName = "hp-roman8";
- doGenTest(charsetName);
- }
-
- public void testFile10() throws CoreException, IOException {
- String charsetName = "IBM-1006";
- doGenTest(charsetName);
- }
-
- public void testFile11() throws CoreException, IOException {
- String charsetName = "IBM-1041";
- doGenTest(charsetName);
- }
-
- public void testFile12() throws CoreException, IOException {
- String charsetName = "IBM-1043";
- doGenTest(charsetName);
- }
-
- public void testFile13() throws CoreException, IOException {
- String charsetName = "IBM-1046";
- doGenTest(charsetName);
- }
-
- public void testFile14() throws CoreException, IOException {
- String charsetName = "IBM-1046S";
- doGenTest(charsetName);
- }
-
- public void testFile15() throws CoreException, IOException {
- String charsetName = "IBM-1088";
- doGenTest(charsetName);
- }
-
- public void testFile16() throws CoreException, IOException {
- String charsetName = "IBM-1098";
- doGenTest(charsetName);
- }
-
- public void testFile17() throws CoreException, IOException {
- String charsetName = "IBM-1114";
- doGenTest(charsetName);
- }
-
- public void testFile18() throws CoreException, IOException {
- String charsetName = "IBM-1115";
- doGenTest(charsetName);
- }
-
- public void testFile19() throws CoreException, IOException {
- String charsetName = "IBM-1124";
- doGenTest(charsetName);
- }
-
- public void testFile20() throws CoreException, IOException {
- String charsetName = "IBM-1363";
- doGenTest(charsetName);
- }
-
- public void testFile21() throws CoreException, IOException {
- String charsetName = "IBM-1363C";
- doGenTest(charsetName);
- }
-
- public void testFile22() throws CoreException, IOException {
- String charsetName = "IBM-1370";
- doGenTest(charsetName);
- }
-
- public void testFile23() throws CoreException, IOException {
- String charsetName = "IBM-1381";
- doGenTest(charsetName);
- }
-
- public void testFile24() throws CoreException, IOException {
- String charsetName = "IBM-1383";
- doGenTest(charsetName);
- }
-
- public void testFile25() throws CoreException, IOException {
- String charsetName = "IBM-1386";
- doGenTest(charsetName);
- }
-
- public void testFile26() throws CoreException, IOException {
- String charsetName = "IBM-33722C";
- doGenTest(charsetName);
- }
-
- public void testFile27() throws CoreException, IOException {
- String charsetName = "IBM-437";
- doGenTest(charsetName);
- }
-
- public void testFile28() throws CoreException, IOException {
- String charsetName = "IBM-737";
- doGenTest(charsetName);
- }
-
- public void testFile29() throws CoreException, IOException {
- String charsetName = "IBM-775";
- doGenTest(charsetName);
- }
-
- public void testFile30() throws CoreException, IOException {
- String charsetName = "IBM-808";
- doGenTest(charsetName);
- }
-
- public void testFile31() throws CoreException, IOException {
- String charsetName = "IBM-850";
- doGenTest(charsetName);
- }
-
- public void testFile32() throws CoreException, IOException {
- String charsetName = "IBM-852";
- doGenTest(charsetName);
- }
-
- public void testFile33() throws CoreException, IOException {
- String charsetName = "IBM-855";
- doGenTest(charsetName);
- }
-
- public void testFile34() throws CoreException, IOException {
- String charsetName = "IBM-856";
- doGenTest(charsetName);
- }
-
- public void testFile35() throws CoreException, IOException {
- String charsetName = "IBM-857";
- doGenTest(charsetName);
- }
-
- public void testFile36() throws CoreException, IOException {
- String charsetName = "IBM-858";
- doGenTest(charsetName);
- }
-
- public void testFile37() throws CoreException, IOException {
- String charsetName = "IBM-859";
- doGenTest(charsetName);
- }
-
- public void testFile38() throws CoreException, IOException {
- String charsetName = "IBM-860";
- doGenTest(charsetName);
- }
-
- public void testFile39() throws CoreException, IOException {
- String charsetName = "IBM-861";
- doGenTest(charsetName);
- }
-
- public void testFile40() throws CoreException, IOException {
- String charsetName = "IBM-862";
- doGenTest(charsetName);
- }
-
- public void testFile41() throws CoreException, IOException {
- String charsetName = "IBM-863";
- doGenTest(charsetName);
- }
-
- public void testFile42() throws CoreException, IOException {
- String charsetName = "IBM-864";
- doGenTest(charsetName);
- }
-
- public void testFile43() throws CoreException, IOException {
- String charsetName = "IBM-864S";
- doGenTest(charsetName);
- }
-
- public void testFile44() throws CoreException, IOException {
- String charsetName = "IBM-865";
- doGenTest(charsetName);
- }
-
- public void testFile45() throws CoreException, IOException {
- String charsetName = "IBM-866";
- doGenTest(charsetName);
- }
-
- public void testFile46() throws CoreException, IOException {
- String charsetName = "IBM-867";
- doGenTest(charsetName);
- }
-
- public void testFile47() throws CoreException, IOException {
- String charsetName = "IBM-868";
- doGenTest(charsetName);
- }
-
- public void testFile48() throws CoreException, IOException {
- String charsetName = "IBM-869";
- doGenTest(charsetName);
- }
-
- public void testFile49() throws CoreException, IOException {
- String charsetName = "IBM-874";
- doGenTest(charsetName);
- }
-
- public void testFile50() throws CoreException, IOException {
- String charsetName = "IBM-897";
- doGenTest(charsetName);
- }
-
- public void testFile51() throws CoreException, IOException {
- String charsetName = "IBM-921";
- doGenTest(charsetName);
- }
-
- public void testFile52() throws CoreException, IOException {
- String charsetName = "IBM-922";
- doGenTest(charsetName);
- }
-
- public void testFile53() throws CoreException, IOException {
- String charsetName = "IBM-932";
- doGenTest(charsetName);
- }
-
- public void testFile54() throws CoreException, IOException {
- String charsetName = "IBM-942";
- doGenTest(charsetName);
- }
-
- public void testFile55() throws CoreException, IOException {
- String charsetName = "IBM-942C";
- doGenTest(charsetName);
- }
-
- public void testFile56() throws CoreException, IOException {
- String charsetName = "IBM-943";
- doGenTest(charsetName);
- }
-
- public void testFile57() throws CoreException, IOException {
- String charsetName = "IBM-943C";
- doGenTest(charsetName);
- }
-
- public void testFile58() throws CoreException, IOException {
- String charsetName = "IBM-948";
- doGenTest(charsetName);
- }
-
- public void testFile59() throws CoreException, IOException {
- String charsetName = "IBM-949";
- doGenTest(charsetName);
- }
-
- public void testFile60() throws CoreException, IOException {
- String charsetName = "IBM-949C";
- doGenTest(charsetName);
- }
-
- public void testFile61() throws CoreException, IOException {
- String charsetName = "IBM-950";
- doGenTest(charsetName);
- }
-
- public void testFile62() throws CoreException, IOException {
- String charsetName = "IBM-954C";
- doGenTest(charsetName);
- }
-
- public void testFile63() throws CoreException, IOException {
- String charsetName = "ISO-2022-CN";
- doGenTest(charsetName);
- }
-
- public void testFile64() throws CoreException, IOException {
- String charsetName = "ISO-2022-CN-GB";
- doGenTest(charsetName);
- }
-
- public void testFile65() throws CoreException, IOException {
- String charsetName = "ISO-2022-JP";
- doGenTest(charsetName);
- }
-
- public void testFile66() throws CoreException, IOException {
- String charsetName = "ISO-2022-KR";
- doGenTest(charsetName);
- }
-
- public void testFile67() throws CoreException, IOException {
- String charsetName = "ISO-8859-1";
- doGenTest(charsetName);
- }
-
- public void testFile68() throws CoreException, IOException {
- String charsetName = "ISO-8859-10";
- doGenTest(charsetName);
- }
-
- public void testFile69() throws CoreException, IOException {
- String charsetName = "ISO-8859-13";
- doGenTest(charsetName);
- }
-
- public void testFile70() throws CoreException, IOException {
- String charsetName = "ISO-8859-14";
- doGenTest(charsetName);
- }
-
- public void testFile71() throws CoreException, IOException {
- String charsetName = "ISO-8859-15";
- doGenTest(charsetName);
- }
-
- public void testFile72() throws CoreException, IOException {
- String charsetName = "ISO-8859-16";
- doGenTest(charsetName);
- }
-
- public void testFile73() throws CoreException, IOException {
- String charsetName = "ISO-8859-2";
- doGenTest(charsetName);
- }
-
- public void testFile74() throws CoreException, IOException {
- String charsetName = "ISO-8859-3";
- doGenTest(charsetName);
- }
-
- public void testFile75() throws CoreException, IOException {
- String charsetName = "ISO-8859-4";
- doGenTest(charsetName);
- }
-
- public void testFile76() throws CoreException, IOException {
- String charsetName = "ISO-8859-5";
- doGenTest(charsetName);
- }
-
- public void testFile77() throws CoreException, IOException {
- String charsetName = "ISO-8859-6";
- doGenTest(charsetName);
- }
-
- public void testFile78() throws CoreException, IOException {
- String charsetName = "ISO-8859-6S";
- doGenTest(charsetName);
- }
-
- public void testFile79() throws CoreException, IOException {
- String charsetName = "ISO-8859-7";
- doGenTest(charsetName);
- }
-
- public void testFile80() throws CoreException, IOException {
- String charsetName = "ISO-8859-8";
- doGenTest(charsetName);
- }
-
- public void testFile81() throws CoreException, IOException {
- String charsetName = "ISO-8859-9";
- doGenTest(charsetName);
- }
-
- public void testFile82() throws CoreException, IOException {
- String charsetName = "JIS0201";
- doGenTest(charsetName);
- }
-
- public void testFile83() throws CoreException, IOException {
- String charsetName = "JIS0208";
- doGenTest(charsetName);
- }
-
- public void testFile84() throws CoreException, IOException {
- String charsetName = "JIS0212";
- doGenTest(charsetName);
- }
-
- public void testFile85() throws CoreException, IOException {
- String charsetName = "Johab";
- doGenTest(charsetName);
- }
-
- public void testFile86() throws CoreException, IOException {
- String charsetName = "KOI8-R";
- doGenTest(charsetName);
- }
-
- public void testFile87() throws CoreException, IOException {
- String charsetName = "KOI8-RU";
- doGenTest(charsetName);
- }
-
- public void testFile88() throws CoreException, IOException {
- String charsetName = "KOI8-U";
- doGenTest(charsetName);
- }
-
- public void testFile89() throws CoreException, IOException {
- String charsetName = "KSC5601";
- doGenTest(charsetName);
- }
-
- public void testFile90() throws CoreException, IOException {
- String charsetName = "MacArabic";
- doGenTest(charsetName);
- }
-
- public void testFile91() throws CoreException, IOException {
- String charsetName = "MacCentralEurope";
- doGenTest(charsetName);
- }
-
- public void testFile92() throws CoreException, IOException {
- String charsetName = "MacCroatian";
- doGenTest(charsetName);
- }
-
- public void testFile93() throws CoreException, IOException {
- String charsetName = "MacCyrillic";
- doGenTest(charsetName);
- }
-
- public void testFile94() throws CoreException, IOException {
- String charsetName = "MacGreek";
- doGenTest(charsetName);
- }
-
- public void testFile95() throws CoreException, IOException {
- String charsetName = "MacHebrew";
- doGenTest(charsetName);
- }
-
- public void testFile96() throws CoreException, IOException {
- String charsetName = "MacIceland";
- doGenTest(charsetName);
- }
-
- public void testFile97() throws CoreException, IOException {
- String charsetName = "MacRoman";
- doGenTest(charsetName);
- }
-
- public void testFile98() throws CoreException, IOException {
- String charsetName = "MacRomania";
- doGenTest(charsetName);
- }
-
- public void testFile99() throws CoreException, IOException {
- String charsetName = "MacThai";
- doGenTest(charsetName);
- }
-
- public void testFile100() throws CoreException, IOException {
- String charsetName = "MacTurkish";
- doGenTest(charsetName);
- }
-
- public void testFile101() throws CoreException, IOException {
- String charsetName = "MacUkraine";
- doGenTest(charsetName);
- }
-
- public void testFile102() throws CoreException, IOException {
- String charsetName = "PTCP154";
- doGenTest(charsetName);
- }
-
- public void testFile103() throws CoreException, IOException {
- String charsetName = "Shift_JIS";
- doGenTest(charsetName);
- }
-
- public void testFile104() throws CoreException, IOException {
- String charsetName = "TIS-620";
- doGenTest(charsetName);
- }
-
- public void testFile105() throws CoreException, IOException {
- String charsetName = "US-ASCII";
- doGenTest(charsetName);
- }
-
-// public void testFile106() throws CoreException, IOException {
-// String charsetName = "UTF-16";
-// doGenTest(charsetName);
-// }
-
-// public void testFile107() throws CoreException, IOException {
-// String charsetName = "UTF-16BE";
-// doGenTest(charsetName);
-// }
-
-// public void testFile108() throws CoreException, IOException {
-// String charsetName = "UTF-16LE";
-// doGenTest(charsetName);
-// }
-
- public void testFile109() throws CoreException, IOException {
- String charsetName = "UTF-32";
- doGenTest(charsetName);
- }
-
- public void testFile110() throws CoreException, IOException {
- String charsetName = "UTF-32BE";
- doGenTest(charsetName);
- }
-
- public void testFile111() throws CoreException, IOException {
- String charsetName = "UTF-32LE";
- doGenTest(charsetName);
- }
-
- public void testFile112() throws CoreException, IOException {
- String charsetName = "UTF-8";
- doGenTest(charsetName);
- }
-
- public void testFile113() throws CoreException, IOException {
- String charsetName = "UTF-8J";
- doGenTest(charsetName);
- }
-
- public void testFile114() throws CoreException, IOException {
- String charsetName = "windows-1250";
- doGenTest(charsetName);
- }
-
- public void testFile115() throws CoreException, IOException {
- String charsetName = "windows-1251";
- doGenTest(charsetName);
- }
-
- public void testFile116() throws CoreException, IOException {
- String charsetName = "windows-1252";
- doGenTest(charsetName);
- }
-
- public void testFile117() throws CoreException, IOException {
- String charsetName = "windows-1253";
- doGenTest(charsetName);
- }
-
- public void testFile118() throws CoreException, IOException {
- String charsetName = "windows-1254";
- doGenTest(charsetName);
- }
-
- public void testFile119() throws CoreException, IOException {
- String charsetName = "windows-1255";
- doGenTest(charsetName);
- }
-
- public void testFile120() throws CoreException, IOException {
- String charsetName = "windows-1256";
- doGenTest(charsetName);
- }
-
- public void testFile121() throws CoreException, IOException {
- String charsetName = "windows-1256S";
- doGenTest(charsetName);
- }
-
- public void testFile122() throws CoreException, IOException {
- String charsetName = "windows-1257";
- doGenTest(charsetName);
- }
-
- public void testFile123() throws CoreException, IOException {
- String charsetName = "windows-1258";
- doGenTest(charsetName);
- }
-
- public void testFile124() throws CoreException, IOException {
- String charsetName = "windows-874";
- doGenTest(charsetName);
- }
-
- public void testFile125() throws CoreException, IOException {
- String charsetName = "windows-932";
- doGenTest(charsetName);
- }
-
- public void testFile126() throws CoreException, IOException {
- String charsetName = "windows-936";
- doGenTest(charsetName);
- }
-
- public void testFile127() throws CoreException, IOException {
- String charsetName = "windows-949";
- doGenTest(charsetName);
- }
-
-
- public void testFile128() throws CoreException, IOException {
- String charsetName = "windows-950";
- doGenTest(charsetName);
- }
-
-/*
-removed for PPC machine with IBM VM
-https://bugs.eclipse.org/bugs/show_bug.cgi?id=126503
-*/
-// public void testFile129() throws CoreException, IOException {
-// String charsetName = "X-UnicodeBig";
-// doGenTest(charsetName);
-// }
-
-/*
-removed for PPC machine with IBM VM
-https://bugs.eclipse.org/bugs/show_bug.cgi?id=126503
-*/
-// public void testFile130() throws CoreException, IOException {
-// String charsetName = "X-UnicodeLittle";
-// doGenTest(charsetName);
-// }
-}
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestContentDescription.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestContentDescription.java
deleted file mode 100644
index 76ebccb69..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestContentDescription.java
+++ /dev/null
@@ -1,536 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.xml.tests.encoding.read;
-
-import java.io.File;
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-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.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.wst.sse.core.internal.encoding.NonContentBasedEncodingRules;
-import org.eclipse.wst.xml.tests.encoding.TestsPlugin;
-import org.eclipse.wst.xml.tests.encoding.util.ProjectUnzipUtility;
-
-
-public class TestContentDescription extends TestCase {
- // private final String fileDir = "html/";
- // private final String fileRoot =
- // "/builds/Workspaces/HeadWorkspace/org.eclipse.wst.xml.tests.encoding/";
- // private final String fileLocation = fileRoot + fileDir;
- private static final boolean DEBUG = true;
- //private static final boolean DEBUG_TEST_DETAIL = false;
- // needs to be static, since JUnit creates difference instances for each
- // test
- private static boolean fTestProjectInitialized;
- private static final String TEST_PROJECT_NAME = "org.eclipse.encoding.resource.newtests";
- static IProject fTestProject;
- private static int nSetups = 0;
-
- /**
- *
- */
- public TestContentDescription() {
- super();
- //System.out.println(currentPlatformCharset);
- }
-
- public static void main(String[] args) {
- // try {
- // new TestCodedReader().doAllFiles();
- // } catch (CoreException e) {
- // e.printStackTrace();
- // } catch (IOException e) {
- // e.printStackTrace();
- // }
- }
-
- private static void createProject(IProject project, IPath locationPath, IProgressMonitor monitor) throws CoreException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.beginTask("creating test project", 10);
- // create the project
- try {
- if (!project.exists()) {
- IProjectDescription desc = project.getWorkspace().newProjectDescription(project.getName());
- if (Platform.getLocation().equals(locationPath)) {
- locationPath = null;
- }
- desc.setLocation(locationPath);
- project.create(desc, monitor);
- monitor = null;
- }
- if (!project.isOpen()) {
- project.open(monitor);
- monitor = null;
- }
- }
- finally {
- if (monitor != null) {
- monitor.done();
- }
- }
- }
-
- private static void getAndCreateProject() throws CoreException {
- //TestsPlugin testsPlugin = (TestsPlugin)
- // Platform.getPlugin("org.eclipse.wst.xml.tests.encoding");
- IWorkspace workspace = TestsPlugin.getWorkspace();
- IWorkspaceRoot root = workspace.getRoot();
- fTestProject = root.getProject(TEST_PROJECT_NAME);
- // this form creates project as "linked" back to 'fileRoot'
- //createProject(testProject, new Path(fileRoot), null);
- createProject(fTestProject, null, null);
- fTestProject.refreshLocal(IResource.DEPTH_INFINITE, null);
- assertTrue(fTestProject.exists());
- // IContainer dotestFiles = testProject.getFolder("dotestFiles");
- // assertTrue(dotestFiles.exists());
- // IResource[] allFolders = dotestFiles.members();
- // assertNotNull(allFolders);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- nSetups++;
- if (!fTestProjectInitialized) {
- getAndCreateProject();
- // unzip files to the root of workspace directory
- String destinationProjectString = fTestProject.getLocation().toOSString();
- String destinationFolder = destinationProjectString + "/";
- // this zip file is sitting in the "root" of test plugin
- File zipFile = TestsPlugin.getTestFile("testfiles.zip");
- ProjectUnzipUtility projUtil = new ProjectUnzipUtility();
- projUtil.unzipAndImport(zipFile, destinationFolder);
- projUtil.initJavaProject(TEST_PROJECT_NAME);
- fTestProject.refreshLocal(IResource.DEPTH_INFINITE, null);
- fTestProjectInitialized = true;
- }
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- nSetups--;
- if (nSetups == 0) {
- if (!DEBUG) {
- // Display display = PlatformUI.getWorkbench().getDisplay();
- // display.asyncExec(new Runnable() {
- // public void run() {
- // ProjectUnzipUtility projUtil = new ProjectUnzipUtility();
- // IProject proj = fTestProject;
- // fTestProject = null;
- // try {
- // projUtil.deleteProject(proj);
- // } catch (Exception e) {
- // e.printStackTrace();
- // }
- // }
- // });
- }
- }
- }
-
- protected void doTest(String expectedJavaCharset, String filePath, Class expectedException) throws CoreException, IOException {
- if (expectedJavaCharset != null && expectedJavaCharset.indexOf("UTF-32") > -1) {
- return; //won't try 32 bit right now
- }
- expectedJavaCharset = massageCharset(expectedJavaCharset);
- IFile file = (IFile) fTestProject.findMember(filePath);
- assertNotNull("Error in test case: file not found: " + filePath, file);
-
- IContentDescription fileContentDescription = file.getContentDescription();
- // IContentDescription streamContentDescription = Platform.getContentTypeManager().getDescriptionFor(file.getContents(), file.getName(), IContentDescription.ALL);
- // assertEquals("comparing file and stream contentDescription", fileContentDescription, streamContentDescription);
-
- assertNotNull("Null content description", fileContentDescription);
- String foundCharset = fileContentDescription.getCharset();
- foundCharset = massageCharset(foundCharset);
-
- if (expectedJavaCharset == null || expectedJavaCharset.equals("expectPlatformCharset")) {
- String platformDefault = NonContentBasedEncodingRules.useDefaultNameRules(null);
- assertTrue(foundCharset.equals(platformDefault));
- }
- else {
- boolean asExpected = foundCharset.equals(expectedJavaCharset);
- assertTrue(foundCharset + " did not equal the expected " + expectedJavaCharset + " (this is a VM dependent test)", asExpected);
- }
-
-
- }
-
- /**
- * @param foundCharset
- * @return
- */
- private String massageCharset(String foundCharset) {
- String result = foundCharset;
- if ("UTF-16LE".equals(foundCharset)) {
- result = "UTF-16";
- }
- else if ("X-UnicodeLittle".equals(foundCharset)) {
- result = "UTF-16";
- }
- else if ("X-UnicodeBig".equals(foundCharset)) {
- result = "UTF-16BE";
- }
-
- return result;
- }
-
- public void testFile1() throws CoreException, IOException {
- doTest("expectPlatformCharset", "testfiles/css/emptyFile.css", null);
- }
-
- public void testFile2() throws CoreException, IOException {
- doTest("EUC-JP", "testfiles/css/encoding_test_eucjp.css", null);
- }
-
- public void testFile3() throws CoreException, IOException {
- doTest("ISO-2022-JP", "testfiles/css/encoding_test_jis.css", null);
- }
-
- public void testFile4() throws CoreException, IOException {
- doTest("Shift_JIS", "testfiles/css/encoding_test_sjis.css", null);
- }
-
- public void testFile5() throws CoreException, IOException {
- doTest("expectPlatformCharset", "testfiles/css/noEncoding.css", null);
- }
-
- public void testFile6() throws CoreException, IOException {
- doTest("ISO-8859-6", "testfiles/css/nonStandard.css", null);
- }
-
- public void testFile7() throws CoreException, IOException {
- doTest("ISO-8859-6", "testfiles/css/nonStandardIllFormed.css", null);
- }
-
- public void testFile8() throws CoreException, IOException {
- doTest("ISO-8859-6", "testfiles/css/nonStandardIllFormed2.css", null);
- }
-
-
- public void testFile57() throws CoreException, IOException {
- doTest("expectPlatformCharset", "testfiles/html/EmptyFile.html", null);
- }
-
- public void testFile58() throws CoreException, IOException {
- doTest("UTF-8", "testfiles/html/IllformedNormalNonDefault.html", null);
- }
-
- public void testFile59() throws CoreException, IOException {
- doTest("expectPlatformCharset", "testfiles/html/LargeNoEncoding.html", null);
- }
-
- public void testFile60() throws CoreException, IOException {
- doTest("ISO-8859-1", "testfiles/html/LargeNonDefault.html", null);
- }
-
- public void testFile61() throws CoreException, IOException {
- doTest("ISO-8859-6", "testfiles/html/MultiNonDefault.html", null);
- }
-
- public void testFile62() throws CoreException, IOException {
- doTest("expectPlatformCharset", "testfiles/html/NoEncoding.html", null);
- }
-
- public void testFile63() throws CoreException, IOException {
- doTest("UTF-8", "testfiles/html/noquotes.html", null);
- }
-
- public void testFile64() throws CoreException, IOException {
- doTest("UTF-8", "testfiles/html/NormalNonDefault.html", null);
- }
-
- public void testFile65() throws CoreException, IOException {
- doTest("ISO-8859-1", "testfiles/jsp/EmptyFile.jsp", null);
- }
-
- public void testFile66() throws CoreException, IOException {
- doTest("ISO-8859-8", "testfiles/jsp/IllformedNormalNonDefault.jsp", null);
- }
-
- public void testFile67() throws CoreException, IOException {
- doTest("abc", "testfiles/jsp/inValidEncodingValue.jsp", org.eclipse.wst.sse.core.internal.exceptions.UnsupportedCharsetExceptionWithDetail.class);
- }
-
- public void testFile68() throws CoreException, IOException {
- doTest("windows-1252", "testfiles/jsp/javaEncodingValue.jsp", null);
- }
-
- public void testFile69() throws CoreException, IOException {
- doTest("ISO-8859-1", "testfiles/jsp/MalformedNoEncoding.jsp", null);
- }
-
- public void testFile70() throws CoreException, IOException {
- doTest("ISO-8859-1", "testfiles/jsp/MalformedNoEncodingXSL.jsp", null);
- }
-
- public void testFile71() throws CoreException, IOException {
- doTest("ISO-8859-1", "testfiles/jsp/noEncoding.jsp", null);
- }
-
- public void testFile72() throws CoreException, IOException {
- doTest("ISO-8859-1", "testfiles/jsp/NoEncodinginXMLDecl.jsp", null);
- }
-
- public void testFile73() throws CoreException, IOException {
- doTest("ISO-8859-2", "testfiles/jsp/nomalDirectiveCase.jsp", null);
- }
-
- public void testFile74() throws CoreException, IOException {
- doTest("ISO-8859-1", "testfiles/jsp/nomalDirectiveCaseNoEncoding.jsp", null);
- }
-
- public void testFile75() throws CoreException, IOException {
- doTest("ISO-8859-3", "testfiles/jsp/nomalDirectiveCaseUsingCharset.jsp", null);
- }
-
- public void testFile76() throws CoreException, IOException {
- doTest("ISO-8859-2", "testfiles/jsp/nomalDirectiveCaseUsingXMLSyntax.jsp", null);
- }
-
- public void testFile77() throws CoreException, IOException {
- doTest("ISO-8859-8", "testfiles/jsp/NormalNonDefault.jsp", null);
- }
-
- public void testFile78() throws CoreException, IOException {
- doTest("ISO-8859-8", "testfiles/jsp/NormalNonDefaultWithXMLDecl.jsp", null);
- }
-
- public void testFile79() throws CoreException, IOException {
- doTest("ISO-8859-7", "testfiles/jsp/NormalPageCaseNonDefault.jsp", null);
- }
-
- public void testFile80() throws CoreException, IOException {
- doTest("Shift_JIS", "testfiles/jsp/SelColBeanRow12ResultsForm.jsp", null);
- }
-
- public void testFile81() throws CoreException, IOException {
- doTest("ISO-8859-3", "testfiles/jsp/testBrokenLine.jsp", null);
- }
-
- public void testFile82() throws CoreException, IOException {
- doTest("testjunk", "testfiles/jsp/testDefaultEncoding.jsp", org.eclipse.wst.sse.core.internal.exceptions.UnsupportedCharsetExceptionWithDetail.class);
- }
-
- public void testFile83() throws CoreException, IOException {
- doTest("testjunk", "testfiles/jsp/testDefaultEncodingWithJunk.jsp", org.eclipse.wst.sse.core.internal.exceptions.UnsupportedCharsetExceptionWithDetail.class);
- }
-
- public void testFile84() throws CoreException, IOException {
- doTest("ISO-8859-1", "testfiles/jsp/testExtraJunk.jsp", null);
- }
-
- public void testFile85() throws CoreException, IOException {
- doTest("UTF-8", "testfiles/jsp/testExtraValidStuff.jsp", null);
- }
-
- public void testFile86() throws CoreException, IOException {
- doTest("ISO-8859-1", "testfiles/jsp/testIllFormed.jsp", null);
- }
-
- public void testFile87() throws CoreException, IOException {
- doTest("UTF-8", "testfiles/jsp/testIllFormed2.jsp", null);
- }
-
- public void testFile88() throws CoreException, IOException {
- doTest("ISO-8859-1", "testfiles/jsp/testNoEncodingValue.jsp", null);
- }
-
- public void testFile89() throws CoreException, IOException {
- doTest("ISO-8859-1", "testfiles/jsp/testNoPageDirective.jsp", null);
- }
-
- public void testFile90() throws CoreException, IOException {
- doTest("ISO-8859-2", "testfiles/jsp/testNoPageDirectiveAtFirst.jsp", null);
- }
-
- public void testFile91() throws CoreException, IOException {
- doTest("ISO-8859-1", "testfiles/jsp/testNoPageDirectiveInLargeFile.jsp", null);
- }
-
- public void testFile92() throws CoreException, IOException {
- doTest("UTF-8", "testfiles/jsp/testNormalCase.jsp", null);
- }
-
- public void testFile93() throws CoreException, IOException {
- doTest("UTF-16", "testfiles/jsp/testUTF16.jsp", null);
- }
-
- public void testFile94() throws CoreException, IOException {
- doTest("UTF-16LE", "testfiles/jsp/utf16UnicodeStreamWithNoEncodingInHeader2.jsp", null);
- }
-
- public void testFile95() throws CoreException, IOException {
- doTest("UTF-16", "testfiles/jsp/utf16UnicodeStreamWithNoEncodingInHeaderBE.jsp", null);
- }
-
- public void testFile96() throws CoreException, IOException {
- doTest("UTF-16", "testfiles/jsp/utf16WithJapaneseChars.jsp", null);
- }
-
- public void testFile97() throws CoreException, IOException {
- doTest("UTF-8", "testfiles/jsp/UTF8With3ByteBOM.jsp", null);
- }
-
- public void testFile98() throws CoreException, IOException {
- doTest("ISO-8859-8", "testfiles/jsp/WellFormedNormalNonDefault.jsp", null);
- }
-
- public void testFile99() throws CoreException, IOException {
- doTest("Shift_JIS", "testfiles/regressionTestFiles/defect223365/SelColBeanRow12ResultsForm.jsp", null);
- }
-
- public void testFile100() throws CoreException, IOException {
- doTest("Shift_JIS", "testfiles/regressionTestFiles/defect223365/SelColBeanRow12ResultsFormB.jsp", null);
- }
-
- public void testFile101() throws CoreException, IOException {
- doTest("Shift_JIS", "testfiles/regressionTestFiles/defect224293/testshiftjisXmlSyntax.jsp", null);
- }
-
- public void testFile102() throws CoreException, IOException {
- doTest("Shift_JIS", "testfiles/regressionTestFiles/defect229667/audi.jsp", null);
- }
-
- public void testFile103() throws CoreException, IOException {
- doTest("UTF-8", "testfiles/xml/EmptyFile.xml", null);
- }
-
- public void testFile104() throws CoreException, IOException {
- doTest("EUC-JP", "testfiles/xml/eucjp.xml", null);
- }
-
-// public void testFile105() throws CoreException, IOException {
-// doTest("ISO-8859-1", "testfiles/xml/IllformedNormalNonDefault.xml", null);
-// }
-//
-// public void testFile106() throws CoreException, IOException {
-// doTest("UTF-8", "testfiles/xml/MalformedNoEncoding.xml", null);
-// }
-//
-// public void testFile107() throws CoreException, IOException {
-// doTest("UTF-8", "testfiles/xml/MalformedNoEncoding.xsl", null);
-// }
-
- public void testFile108() throws CoreException, IOException {
- doTest("UTF-8", "testfiles/xml/NoEncoding.xml", null);
- }
-
- public void testFile109() throws CoreException, IOException {
- doTest("ISO-8859-1", "testfiles/xml/NormalNonDefault.xml", null);
- }
-
- public void testFile110() throws CoreException, IOException {
- doTest("Shift_JIS", "testfiles/xml/shiftjis.xml", null);
- }
-
- public void testFile111() throws CoreException, IOException {
- doTest("ISO-8859-1", "testfiles/xml/testExtraJunk.xml", null);
- }
-
- public void testFile112() throws CoreException, IOException {
- doTest("UTF-8", "testfiles/xml/testExtraValidStuff.xml", null);
- }
-
-// public void testFile113() throws CoreException, IOException {
-// doTest("UTF-8", "testfiles/xml/testIllFormed.xml", null);
-// }
-
- public void testFile114() throws CoreException, IOException {
- doTest("UTF-8", "testfiles/xml/testIllFormed2.xml", null);
- }
-
- public void testFile115() throws CoreException, IOException {
- doTest("UTF-8 standalone=", "testfiles/xml/testIllFormed3.xml", java.nio.charset.IllegalCharsetNameException.class);
- }
-
- public void testFile116() throws CoreException, IOException {
- doTest("UTF-8", "testfiles/xml/testIllFormed4.xml", null);
- }
-
- public void testFile117() throws CoreException, IOException {
- doTest("ISO-8859-1", "testfiles/xml/testMultiLine.xml", null);
- }
-
- public void testFile118() throws CoreException, IOException {
- doTest("UTF-8", "testfiles/xml/testNoEncodingValue.xml", null);
- }
-
- public void testFile119() throws CoreException, IOException {
- doTest("UTF-8", "testfiles/xml/testNormalCase.xml", null);
- }
-
- public void testFile120() throws CoreException, IOException {
- doTest("UTF-8", "testfiles/xml/testNoXMLDecl.xml", null);
- }
-
- public void testFile121() throws CoreException, IOException {
- doTest("UTF-8", "testfiles/xml/testNoXMLDeclAtFirst.xml", null);
- }
-
- public void testFile122() throws CoreException, IOException {
- doTest("UTF-8", "testfiles/xml/testNoXMLDeclInLargeFile.xml", null);
- }
-
-// public void testFile123() throws CoreException, IOException {
-// doTest("UTF-16BE", "testfiles/xml/testUTF16.xml", null);
-// }
-
- public void testFile124() throws CoreException, IOException {
- doTest("UTF-16LE", "testfiles/xml/UTF16LEAtStartOfLargeFile.xml", null);
- }
-
- public void testFile125() throws CoreException, IOException {
- doTest("UTF-16LE", "testfiles/xml/utf16UnicodeStreamWithNoEncodingInHeader2.xml", null);
- }
-
-// public void testFile126() throws CoreException, IOException {
-// doTest("UTF-16BE", "testfiles/xml/utf16UnicodeStreamWithNoEncodingInHeaderBE.xml", null);
-// }
-
-// public void testFile127() throws CoreException, IOException {
-// doTest("UTF-16BE", "testfiles/xml/utf16WithJapaneseChars.xml", null);
-// }
-
- public void testFile129() throws CoreException, IOException {
- doTest("UTF-8", "testfiles/xml/UTF8With3ByteBOM.xml", null);
- }
-
- public void testFile130() throws CoreException, IOException {
- doTest("UTF-16BE", "testfiles/xml/utf16be.xml", null);
- }
-
- public void testFile131() throws CoreException, IOException {
- doTest("UTF-16LE", "testfiles/xml/utf16le.xml", null);
- }
-
- public void testFile132() throws CoreException, IOException {
- doTest("UTF-16LE", "testfiles/xml/utf16leMalformed.xml", null);
- }
-
- public void testFile133() throws CoreException, IOException {
- doTest("UTF-16BE", "testfiles/xml/utf16beMalformed.xml", null);
- }
-
-}
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestContentTypeDescriptionOnGennedFiles.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestContentTypeDescriptionOnGennedFiles.java
deleted file mode 100644
index ea8d990b1..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestContentTypeDescriptionOnGennedFiles.java
+++ /dev/null
@@ -1,711 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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.xml.tests.encoding.read;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.xml.tests.encoding.GenerateFiles;
-
-
-
-public class TestContentTypeDescriptionOnGennedFiles extends TestContentDescription {
- private static int notRan = 0;
- private static final boolean DEBUG = false;
-
- protected void doGenTest(String charsetName) throws CoreException, IOException {
- String filename = GenerateFiles.getMainDirectoryBasedOnVMName() + "/xml/test-" + charsetName + ".xml";
- doTest(charsetName, filename, null);
- }
-
- protected void doTest(String expectedJavaCharset, String filePath, Class expectedException) throws CoreException, IOException {
- if (expectedJavaCharset != null && expectedJavaCharset.indexOf("UTF-32") > -1) {
- return; //won't try 32 bit right now
- }
- IFile file = (IFile) fTestProject.findMember(filePath);
-
- // if there no file, just assume that its due to which VM is
- // bring used. (Could be improved in future to avoid counting as a
- // test) - this check in here for initial debugging only
- if (file == null) {
- notRan++;
- if (DEBUG) {
- System.out.println();
- System.out.println("test not ran since charset not supported by VM: " + filePath);
- }
- return;
- }
- super.doTest(expectedJavaCharset, filePath, expectedException);
- }
-
-
- public void testFile0() throws CoreException, IOException {
- String charsetName = "Big5";
- doGenTest(charsetName);
- }
-
- public void testFile1() throws CoreException, IOException {
- String charsetName = "CESU-8";
- doGenTest(charsetName);
- }
-
- public void testFile2() throws CoreException, IOException {
- String charsetName = "COMPOUND_TEXT";
- doGenTest(charsetName);
- }
-
- public void testFile3() throws CoreException, IOException {
- String charsetName = "EUC-CN";
- doGenTest(charsetName);
- }
-
- public void testFile4() throws CoreException, IOException {
- String charsetName = "EUC-JP";
- doGenTest(charsetName);
- }
-
- public void testFile5() throws CoreException, IOException {
- String charsetName = "EUC-KR";
- doGenTest(charsetName);
- }
-
- public void testFile6() throws CoreException, IOException {
- String charsetName = "GB18030";
- doGenTest(charsetName);
- }
-
- public void testFile7() throws CoreException, IOException {
- String charsetName = "GB2312";
- doGenTest(charsetName);
- }
-
- public void testFile8() throws CoreException, IOException {
- String charsetName = "GBK";
- doGenTest(charsetName);
- }
-
- public void testFile9() throws CoreException, IOException {
- String charsetName = "hp-roman8";
- doGenTest(charsetName);
- }
-
- public void testFile10() throws CoreException, IOException {
- String charsetName = "IBM-1006";
- doGenTest(charsetName);
- }
-
- public void testFile11() throws CoreException, IOException {
- String charsetName = "IBM-1041";
- doGenTest(charsetName);
- }
-
- public void testFile12() throws CoreException, IOException {
- String charsetName = "IBM-1043";
- doGenTest(charsetName);
- }
-
- public void testFile13() throws CoreException, IOException {
- String charsetName = "IBM-1046";
- doGenTest(charsetName);
- }
-
- public void testFile14() throws CoreException, IOException {
- String charsetName = "IBM-1046S";
- doGenTest(charsetName);
- }
-
- public void testFile15() throws CoreException, IOException {
- String charsetName = "IBM-1088";
- doGenTest(charsetName);
- }
-
- public void testFile16() throws CoreException, IOException {
- String charsetName = "IBM-1098";
- doGenTest(charsetName);
- }
-
- public void testFile17() throws CoreException, IOException {
- String charsetName = "IBM-1114";
- doGenTest(charsetName);
- }
-
- public void testFile18() throws CoreException, IOException {
- String charsetName = "IBM-1115";
- doGenTest(charsetName);
- }
-
- public void testFile19() throws CoreException, IOException {
- String charsetName = "IBM-1124";
- doGenTest(charsetName);
- }
-
- public void testFile20() throws CoreException, IOException {
- String charsetName = "IBM-1363";
- doGenTest(charsetName);
- }
-
- public void testFile21() throws CoreException, IOException {
- String charsetName = "IBM-1363C";
- doGenTest(charsetName);
- }
-
- public void testFile22() throws CoreException, IOException {
- String charsetName = "IBM-1370";
- doGenTest(charsetName);
- }
-
- public void testFile23() throws CoreException, IOException {
- String charsetName = "IBM-1381";
- doGenTest(charsetName);
- }
-
- public void testFile24() throws CoreException, IOException {
- String charsetName = "IBM-1383";
- doGenTest(charsetName);
- }
-
- public void testFile25() throws CoreException, IOException {
- String charsetName = "IBM-1386";
- doGenTest(charsetName);
- }
-
- public void testFile26() throws CoreException, IOException {
- String charsetName = "IBM-33722C";
- doGenTest(charsetName);
- }
-
- public void testFile27() throws CoreException, IOException {
- String charsetName = "IBM-437";
- doGenTest(charsetName);
- }
-
- public void testFile28() throws CoreException, IOException {
- String charsetName = "IBM-737";
- doGenTest(charsetName);
- }
-
- public void testFile29() throws CoreException, IOException {
- String charsetName = "IBM-775";
- doGenTest(charsetName);
- }
-
- public void testFile30() throws CoreException, IOException {
- String charsetName = "IBM-808";
- doGenTest(charsetName);
- }
-
- public void testFile31() throws CoreException, IOException {
- String charsetName = "IBM-850";
- doGenTest(charsetName);
- }
-
- public void testFile32() throws CoreException, IOException {
- String charsetName = "IBM-852";
- doGenTest(charsetName);
- }
-
- public void testFile33() throws CoreException, IOException {
- String charsetName = "IBM-855";
- doGenTest(charsetName);
- }
-
- public void testFile34() throws CoreException, IOException {
- String charsetName = "IBM-856";
- doGenTest(charsetName);
- }
-
- public void testFile35() throws CoreException, IOException {
- String charsetName = "IBM-857";
- doGenTest(charsetName);
- }
-
- public void testFile36() throws CoreException, IOException {
- String charsetName = "IBM-858";
- doGenTest(charsetName);
- }
-
- public void testFile37() throws CoreException, IOException {
- String charsetName = "IBM-859";
- doGenTest(charsetName);
- }
-
- public void testFile38() throws CoreException, IOException {
- String charsetName = "IBM-860";
- doGenTest(charsetName);
- }
-
- public void testFile39() throws CoreException, IOException {
- String charsetName = "IBM-861";
- doGenTest(charsetName);
- }
-
- public void testFile40() throws CoreException, IOException {
- String charsetName = "IBM-862";
- doGenTest(charsetName);
- }
-
- public void testFile41() throws CoreException, IOException {
- String charsetName = "IBM-863";
- doGenTest(charsetName);
- }
-
- public void testFile42() throws CoreException, IOException {
- String charsetName = "IBM-864";
- doGenTest(charsetName);
- }
-
- public void testFile43() throws CoreException, IOException {
- String charsetName = "IBM-864S";
- doGenTest(charsetName);
- }
-
- public void testFile44() throws CoreException, IOException {
- String charsetName = "IBM-865";
- doGenTest(charsetName);
- }
-
- public void testFile45() throws CoreException, IOException {
- String charsetName = "IBM-866";
- doGenTest(charsetName);
- }
-
- public void testFile46() throws CoreException, IOException {
- String charsetName = "IBM-867";
- doGenTest(charsetName);
- }
-
- public void testFile47() throws CoreException, IOException {
- String charsetName = "IBM-868";
- doGenTest(charsetName);
- }
-
- public void testFile48() throws CoreException, IOException {
- String charsetName = "IBM-869";
- doGenTest(charsetName);
- }
-
- public void testFile49() throws CoreException, IOException {
- String charsetName = "IBM-874";
- doGenTest(charsetName);
- }
-
- public void testFile50() throws CoreException, IOException {
- String charsetName = "IBM-897";
- doGenTest(charsetName);
- }
-
- public void testFile51() throws CoreException, IOException {
- String charsetName = "IBM-921";
- doGenTest(charsetName);
- }
-
- public void testFile52() throws CoreException, IOException {
- String charsetName = "IBM-922";
- doGenTest(charsetName);
- }
-
- public void testFile53() throws CoreException, IOException {
- String charsetName = "IBM-932";
- doGenTest(charsetName);
- }
-
- public void testFile54() throws CoreException, IOException {
- String charsetName = "IBM-942";
- doGenTest(charsetName);
- }
-
- public void testFile55() throws CoreException, IOException {
- String charsetName = "IBM-942C";
- doGenTest(charsetName);
- }
-
- public void testFile56() throws CoreException, IOException {
- String charsetName = "IBM-943";
- doGenTest(charsetName);
- }
-
- public void testFile57() throws CoreException, IOException {
- String charsetName = "IBM-943C";
- doGenTest(charsetName);
- }
-
- public void testFile58() throws CoreException, IOException {
- String charsetName = "IBM-948";
- doGenTest(charsetName);
- }
-
- public void testFile59() throws CoreException, IOException {
- String charsetName = "IBM-949";
- doGenTest(charsetName);
- }
-
- public void testFile60() throws CoreException, IOException {
- String charsetName = "IBM-949C";
- doGenTest(charsetName);
- }
-
- public void testFile61() throws CoreException, IOException {
- String charsetName = "IBM-950";
- doGenTest(charsetName);
- }
-
- public void testFile62() throws CoreException, IOException {
- String charsetName = "IBM-954C";
- doGenTest(charsetName);
- }
-
- public void testFile63() throws CoreException, IOException {
- String charsetName = "ISO-2022-CN";
- doGenTest(charsetName);
- }
-
- public void testFile64() throws CoreException, IOException {
- String charsetName = "ISO-2022-CN-GB";
- doGenTest(charsetName);
- }
-
- public void testFile65() throws CoreException, IOException {
- String charsetName = "ISO-2022-JP";
- doGenTest(charsetName);
- }
-
- public void testFile66() throws CoreException, IOException {
- String charsetName = "ISO-2022-KR";
- doGenTest(charsetName);
- }
-
- public void testFile67() throws CoreException, IOException {
- String charsetName = "ISO-8859-1";
- doGenTest(charsetName);
- }
-
- public void testFile68() throws CoreException, IOException {
- String charsetName = "ISO-8859-10";
- doGenTest(charsetName);
- }
-
- public void testFile69() throws CoreException, IOException {
- String charsetName = "ISO-8859-13";
- doGenTest(charsetName);
- }
-
- public void testFile70() throws CoreException, IOException {
- String charsetName = "ISO-8859-14";
- doGenTest(charsetName);
- }
-
- public void testFile71() throws CoreException, IOException {
- String charsetName = "ISO-8859-15";
- doGenTest(charsetName);
- }
-
- public void testFile72() throws CoreException, IOException {
- String charsetName = "ISO-8859-16";
- doGenTest(charsetName);
- }
-
- public void testFile73() throws CoreException, IOException {
- String charsetName = "ISO-8859-2";
- doGenTest(charsetName);
- }
-
- public void testFile74() throws CoreException, IOException {
- String charsetName = "ISO-8859-3";
- doGenTest(charsetName);
- }
-
- public void testFile75() throws CoreException, IOException {
- String charsetName = "ISO-8859-4";
- doGenTest(charsetName);
- }
-
- public void testFile76() throws CoreException, IOException {
- String charsetName = "ISO-8859-5";
- doGenTest(charsetName);
- }
-
- public void testFile77() throws CoreException, IOException {
- String charsetName = "ISO-8859-6";
- doGenTest(charsetName);
- }
-
- public void testFile78() throws CoreException, IOException {
- String charsetName = "ISO-8859-6S";
- doGenTest(charsetName);
- }
-
- public void testFile79() throws CoreException, IOException {
- String charsetName = "ISO-8859-7";
- doGenTest(charsetName);
- }
-
- public void testFile80() throws CoreException, IOException {
- String charsetName = "ISO-8859-8";
- doGenTest(charsetName);
- }
-
- public void testFile81() throws CoreException, IOException {
- String charsetName = "ISO-8859-9";
- doGenTest(charsetName);
- }
-
- public void testFile82() throws CoreException, IOException {
- String charsetName = "JIS0201";
- doGenTest(charsetName);
- }
-
- public void testFile83() throws CoreException, IOException {
- String charsetName = "JIS0208";
- doGenTest(charsetName);
- }
-
- public void testFile84() throws CoreException, IOException {
- String charsetName = "JIS0212";
- doGenTest(charsetName);
- }
-
- public void testFile85() throws CoreException, IOException {
- String charsetName = "Johab";
- doGenTest(charsetName);
- }
-
- public void testFile86() throws CoreException, IOException {
- String charsetName = "KOI8-R";
- doGenTest(charsetName);
- }
-
- public void testFile87() throws CoreException, IOException {
- String charsetName = "KOI8-RU";
- doGenTest(charsetName);
- }
-
- public void testFile88() throws CoreException, IOException {
- String charsetName = "KOI8-U";
- doGenTest(charsetName);
- }
-
- public void testFile89() throws CoreException, IOException {
- String charsetName = "KSC5601";
- doGenTest(charsetName);
- }
-
- public void testFile90() throws CoreException, IOException {
- String charsetName = "MacArabic";
- doGenTest(charsetName);
- }
-
- public void testFile91() throws CoreException, IOException {
- String charsetName = "MacCentralEurope";
- doGenTest(charsetName);
- }
-
- public void testFile92() throws CoreException, IOException {
- String charsetName = "MacCroatian";
- doGenTest(charsetName);
- }
-
- public void testFile93() throws CoreException, IOException {
- String charsetName = "MacCyrillic";
- doGenTest(charsetName);
- }
-
- public void testFile94() throws CoreException, IOException {
- String charsetName = "MacGreek";
- doGenTest(charsetName);
- }
-
- public void testFile95() throws CoreException, IOException {
- String charsetName = "MacHebrew";
- doGenTest(charsetName);
- }
-
- public void testFile96() throws CoreException, IOException {
- String charsetName = "MacIceland";
- doGenTest(charsetName);
- }
-
- public void testFile97() throws CoreException, IOException {
- String charsetName = "MacRoman";
- doGenTest(charsetName);
- }
-
- public void testFile98() throws CoreException, IOException {
- String charsetName = "MacRomania";
- doGenTest(charsetName);
- }
-
- public void testFile99() throws CoreException, IOException {
- String charsetName = "MacThai";
- doGenTest(charsetName);
- }
-
- public void testFile100() throws CoreException, IOException {
- String charsetName = "MacTurkish";
- doGenTest(charsetName);
- }
-
- public void testFile101() throws CoreException, IOException {
- String charsetName = "MacUkraine";
- doGenTest(charsetName);
- }
-
- public void testFile102() throws CoreException, IOException {
- String charsetName = "PTCP154";
- doGenTest(charsetName);
- }
-
- public void testFile103() throws CoreException, IOException {
- String charsetName = "Shift_JIS";
- doGenTest(charsetName);
- }
-
- public void testFile104() throws CoreException, IOException {
- String charsetName = "TIS-620";
- doGenTest(charsetName);
- }
-
- public void testFile105() throws CoreException, IOException {
- String charsetName = "US-ASCII";
- doGenTest(charsetName);
- }
-
- public void testFile106() throws CoreException, IOException {
- String charsetName = "UTF-16";
- doGenTest(charsetName);
- }
-
-// public void testFile107() throws CoreException, IOException {
-// String charsetName = "UTF-16BE";
-// doGenTest(charsetName);
-// }
-
- public void testFile108() throws CoreException, IOException {
- String charsetName = "UTF-16LE";
- doGenTest(charsetName);
- }
-
- public void testFile109() throws CoreException, IOException {
- String charsetName = "UTF-32";
- doGenTest(charsetName);
- }
-
- public void testFile110() throws CoreException, IOException {
- String charsetName = "UTF-32BE";
- doGenTest(charsetName);
- }
-
- public void testFile111() throws CoreException, IOException {
- String charsetName = "UTF-32LE";
- doGenTest(charsetName);
- }
-
- public void testFile112() throws CoreException, IOException {
- String charsetName = "UTF-8";
- doGenTest(charsetName);
- }
-
- public void testFile113() throws CoreException, IOException {
- String charsetName = "UTF-8J";
- doGenTest(charsetName);
- }
-
- public void testFile114() throws CoreException, IOException {
- String charsetName = "windows-1250";
- doGenTest(charsetName);
- }
-
- public void testFile115() throws CoreException, IOException {
- String charsetName = "windows-1251";
- doGenTest(charsetName);
- }
-
- public void testFile116() throws CoreException, IOException {
- String charsetName = "windows-1252";
- doGenTest(charsetName);
- }
-
- public void testFile117() throws CoreException, IOException {
- String charsetName = "windows-1253";
- doGenTest(charsetName);
- }
-
- public void testFile118() throws CoreException, IOException {
- String charsetName = "windows-1254";
- doGenTest(charsetName);
- }
-
- public void testFile119() throws CoreException, IOException {
- String charsetName = "windows-1255";
- doGenTest(charsetName);
- }
-
- public void testFile120() throws CoreException, IOException {
- String charsetName = "windows-1256";
- doGenTest(charsetName);
- }
-
- public void testFile121() throws CoreException, IOException {
- String charsetName = "windows-1256S";
- doGenTest(charsetName);
- }
-
- public void testFile122() throws CoreException, IOException {
- String charsetName = "windows-1257";
- doGenTest(charsetName);
- }
-
- public void testFile123() throws CoreException, IOException {
- String charsetName = "windows-1258";
- doGenTest(charsetName);
- }
-
- public void testFile124() throws CoreException, IOException {
- String charsetName = "windows-874";
- doGenTest(charsetName);
- }
-
- public void testFile125() throws CoreException, IOException {
- String charsetName = "windows-932";
- doGenTest(charsetName);
- }
-
- public void testFile126() throws CoreException, IOException {
- String charsetName = "windows-936";
- doGenTest(charsetName);
- }
-
- public void testFile127() throws CoreException, IOException {
- String charsetName = "windows-949";
- doGenTest(charsetName);
- }
-
- public void testFile128() throws CoreException, IOException {
- String charsetName = "windows-950";
- doGenTest(charsetName);
- }
-/*
-removed for PPC machine with IBM VM
-https://bugs.eclipse.org/bugs/show_bug.cgi?id=126503
-*/
-// public void testFile129() throws CoreException, IOException {
-// String charsetName = "X-UnicodeBig";
-// doGenTest(charsetName);
-// }
-
- public void testFile130() throws CoreException, IOException {
- String charsetName = "X-UnicodeLittle";
- doGenTest(charsetName);
- }
-
-
-
-}
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestContentTypeDetection.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestContentTypeDetection.java
deleted file mode 100644
index 6b20edaa5..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestContentTypeDetection.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.xml.tests.encoding.read;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-
-import junit.framework.TestCase;
-
-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.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.wst.xml.tests.encoding.TestsPlugin;
-import org.eclipse.wst.xml.tests.encoding.util.ProjectUnzipUtility;
-
-
-public class TestContentTypeDetection extends TestCase {
- private static final boolean DEBUG = false;
- static IProject fTestProject;
- // needs to be static, since JUnit creates difference instances for each
- // test
- private static boolean fTestProjectInitialized;
- private static int nSetups = 0;
- private static final String TEST_PROJECT_NAME = "org.eclipse.wst.xml.temp.tests.encoding.resource.newtests";
-
- private static void createProject(IProject project, IPath locationPath, IProgressMonitor monitor) throws CoreException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.beginTask("creating test project", 10);
- // create the project
- try {
- if (!project.exists()) {
- IProjectDescription desc = project.getWorkspace().newProjectDescription(project.getName());
- if (Platform.getLocation().equals(locationPath)) {
- locationPath = null;
- }
- desc.setLocation(locationPath);
- project.create(desc, monitor);
- monitor = null;
- }
- if (!project.isOpen()) {
- project.open(monitor);
- monitor = null;
- }
- }
- finally {
- if (monitor != null) {
- monitor.done();
- }
- }
- }
-
- private static void getAndCreateProject() throws CoreException {
- IWorkspace workspace = TestsPlugin.getWorkspace();
- IWorkspaceRoot root = workspace.getRoot();
- fTestProject = root.getProject(TEST_PROJECT_NAME);
- // this form creates project as "linked" back to 'fileRoot'
- // createProject(testProject, new Path(fileRoot), null);
- createProject(fTestProject, null, null);
- fTestProject.refreshLocal(IResource.DEPTH_INFINITE, null);
- assertTrue(fTestProject.exists());
- }
-
- /**
- *
- */
- public TestContentTypeDetection() {
- super();
- // System.out.println(currentPlatformCharset);
- }
-
- protected void doTest(String expectedContentType, String filePath, Class expectedException) throws CoreException, IOException {
- IFile file = (IFile) fTestProject.findMember(filePath);
- assertNotNull("Error in test case: file not found: " + filePath, file);
-
-
- IContentDescription streamContentDescription = doGetContentTypeBasedOnStream(file);
- IContentDescription fileContentDescription = doGetContentTypeBasedOnFile(file);
-
- IContentType fileContentType = fileContentDescription.getContentType();
- assertNotNull("file content type was null", fileContentType);
-
- IContentType streamContentType = streamContentDescription.getContentType();
- assertNotNull("stream content type was null", streamContentType);
-
- assertEquals("comparing content type based on file and stream: ", fileContentType, streamContentType);
-
- // if equal, above, as expected, then only need to check one.
- assertEquals("compareing with expected content type id", expectedContentType, fileContentType.getId());
-
- }
-
- protected IContentDescription doGetContentTypeBasedOnStream(IFile file) throws CoreException, IOException {
- IContentDescription streamContentDescription = null;
- InputStream inputStream = null;
- try {
- inputStream = file.getContents();
- streamContentDescription = Platform.getContentTypeManager().getDescriptionFor(inputStream, file.getName(), IContentDescription.ALL);
- }
- finally {
- if (inputStream != null) {
- inputStream.close();
- }
- }
- assertNotNull("content description was null", streamContentDescription);
- return streamContentDescription;
- }
-
- protected IContentDescription doGetContentTypeBasedOnFile(IFile file) throws CoreException {
- IContentDescription fileContentDescription = file.getContentDescription();
- assertNotNull("file content description was null", fileContentDescription);
- return fileContentDescription;
- }
-
- protected void doTestForParent(String expectedContentType, String filePath, Class expectedException) throws CoreException, IOException {
- IFile file = (IFile) fTestProject.findMember(filePath);
- assertNotNull("Error in test case: file not found: " + filePath, file);
-
- IContentDescription contentDescription = file.getContentDescription();
- if (contentDescription == null) {
- InputStream inputStream = null;
- try {
- inputStream = file.getContents();
- contentDescription = Platform.getContentTypeManager().getDescriptionFor(inputStream, file.getName(), IContentDescription.ALL);
- }
- finally {
- if (inputStream != null) {
- inputStream.close();
- }
- }
- }
- assertNotNull("content description was null", contentDescription);
- IContentType contentType = contentDescription.getContentType();
- assertNotNull("content type was null", contentType);
-
- IContentType parentContentType = contentType;
- boolean found = false;
- while (parentContentType != null && !found) {
- found = expectedContentType.equals(parentContentType.getId());
- parentContentType = parentContentType.getBaseType();
- }
- assertTrue("did not find '" + expectedContentType + "' in parent chain of base types", found);
-
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- nSetups++;
- if (!fTestProjectInitialized) {
- getAndCreateProject();
- // unzip files to the root of workspace directory
- String destinationProjectString = fTestProject.getLocation().toOSString();
- String destinationFolder = destinationProjectString + "/";
- // this zip file is sitting in the "root" of test plugin
- File zipFile = TestsPlugin.getTestFile("testfiles.zip");
- ProjectUnzipUtility projUtil = new ProjectUnzipUtility();
- projUtil.unzipAndImport(zipFile, destinationFolder);
- projUtil.initJavaProject(TEST_PROJECT_NAME);
- fTestProject.refreshLocal(IResource.DEPTH_INFINITE, null);
- fTestProjectInitialized = true;
- }
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- nSetups--;
- if (nSetups == 0) {
- if (!DEBUG) {
-// Display display = PlatformUI.getWorkbench().getDisplay();
-// display.asyncExec(new Runnable() {
-// public void run() {
-// ProjectUnzipUtility projUtil = new ProjectUnzipUtility();
-// IProject proj = fTestProject;
-// fTestProject = null;
-// try {
-// projUtil.deleteProject(proj);
-// }
-// catch (Exception e) {
-// e.printStackTrace();
-// }
-// }
-// });
- }
- }
- }
-
- protected static IProject getTestProject() {
- return fTestProject;
- }
-}
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestContentTypeDetectionForXML.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestContentTypeDetectionForXML.java
deleted file mode 100644
index 8ce009c25..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestContentTypeDetectionForXML.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.xml.tests.encoding.read;
-
-import java.io.IOException;
-
-import org.eclipse.core.runtime.CoreException;
-
-public class TestContentTypeDetectionForXML extends TestContentTypeDetection {
- private static final String expectedCustomXMLContentType = "org.eclipse.wst.xml.core.xmlsource";
-
- private static final String expectedXSLContentType = "org.eclipse.wst.xml.core.xslsource";
-
- private static final String expectedXMLContentType = "org.eclipse.core.runtime.xml";
-
- public void testFile103() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/EmptyFile.xml", null);
- }
-
- public void testFile103P() throws CoreException, IOException {
- doTestForParent(expectedXMLContentType, "testfiles/xml/EmptyFile.xml", null);
- }
-
- public void testFile104() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/eucjp.xml", null);
- }
-
- public void testFile104b() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/eucjp.xml", null);
- }
-
- public void testFile105() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/IllformedNormalNonDefault.xml", null);
- }
-
- public void testFile106() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/MalformedNoEncoding.xml", null);
- }
-
- /**
- * This file is illformed in its specified charset
- * and characters.
- * @throws CoreException
- * @throws IOException
- */
- public void testFile107() throws CoreException, IOException {
- doTest(expectedXSLContentType, "testfiles/xml/MalformedNoEncoding.xsl", null);
- }
-
- public void testFile107P() throws CoreException, IOException {
- doTestForParent(expectedXMLContentType, "testfiles/xml/MalformedNoEncoding.xsl", null);
- }
-
- public void testFile108() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/NoEncoding.xml", null);
- }
-
- public void testFile109() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/NormalNonDefault.xml", null);
- }
-
-
- public void testFile110() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/shiftjis.xml", null);
- }
-
- public void testFile111() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/testExtraJunk.xml", null);
- }
-
- public void testFile112() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/testExtraValidStuff.xml", null);
- }
-
- public void testFile113() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/testIllFormed.xml", null);
- }
-
- public void testFile114() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/testIllFormed2.xml", null);
- }
-
- public void testFile115() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/testIllFormed3.xml", java.nio.charset.IllegalCharsetNameException.class);
- }
-
- public void testFile116() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/testIllFormed4.xml", null);
- }
-
- public void testFile117() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/testMultiLine.xml", null);
- }
-
- public void testFile118() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/testNoEncodingValue.xml", null);
- }
-
- public void testFile119() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/testNormalCase.xml", null);
- }
-
- public void testFile120() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/testNoXMLDecl.xml", null);
- }
-
- public void testFile120WS() throws CoreException, IOException {
- // whitespace (CRLF) before xml declaration
- doTest(expectedCustomXMLContentType, "testfiles/xml/testWSBeforeXMLDecl.xml", null);
- }
-
- public void testFile120WS2() throws CoreException, IOException {
- // whitespace (space only) before xml declaration
- doTest(expectedCustomXMLContentType, "testfiles/xml/testWSBeforeXMLDecl2.xml", null);
- }
-
- public void testFile120WS3() throws CoreException, IOException {
- // whitespace (space, tabs, and CR only) before xml declaration
- doTest(expectedCustomXMLContentType, "testfiles/xml/testWSBeforeXMLDecl3.xml", null);
- }
-
- public void testFile120P() throws CoreException, IOException {
- doTestForParent(expectedXMLContentType, "testfiles/xml/testNoXMLDecl.xml", null);
- }
-
- public void testFile121() throws CoreException, IOException {
- // tag (not just white space) before xml declaration.
- doTest(expectedXMLContentType, "testfiles/xml/testNoXMLDeclAtFirst.xml", null);
- }
-
- public void testFile121P() throws CoreException, IOException {
- doTestForParent(expectedXMLContentType, "testfiles/xml/testNoXMLDeclAtFirst.xml", null);
- }
-
- public void testFile122() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/testNoXMLDeclInLargeFile.xml", null);
- }
-
- public void testFile122P() throws CoreException, IOException {
- doTestForParent(expectedXMLContentType, "testfiles/xml/testNoXMLDeclInLargeFile.xml", null);
- }
-
- public void testFile123() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/testUTF16.xml", null);
- }
-
- public void testFile124() throws CoreException, IOException {
- // large, utf16, but no xmlDecl
- doTest(expectedXMLContentType, "testfiles/xml/UTF16LEAtStartOfLargeFile.xml", null);
- }
-
- public void testFile124P() throws CoreException, IOException {
- doTestForParent(expectedXMLContentType, "testfiles/xml/UTF16LEAtStartOfLargeFile.xml", null);
- }
-
- public void testFile125() throws CoreException, IOException {
- // illformed, is in utf16, but not in header, not in encoding= spec.
- doTest(expectedXMLContentType, "testfiles/xml/utf16UnicodeStreamWithNoEncodingInHeader2.xml", null);
- }
-
- public void testFile125P() throws CoreException, IOException {
- doTestForParent(expectedXMLContentType, "testfiles/xml/utf16UnicodeStreamWithNoEncodingInHeader2.xml", null);
- }
-
- public void testFile126() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/utf16UnicodeStreamWithNoEncodingInHeaderBE.xml", null);
- }
-
- public void testFile127() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/utf16WithJapaneseChars.xml", null);
- }
-
- public void testFile128() throws CoreException, IOException {
- doTest(expectedXMLContentType, "testfiles/xml/UTF8With3ByteBOM.xml", null);
- }
-
- public void testFile129() throws CoreException, IOException {
- doTest(expectedCustomXMLContentType, "testfiles/xml/utf16be.xml", null);
- }
-
- public void testFile130() throws CoreException, IOException {
- doTest(expectedCustomXMLContentType, "testfiles/xml/utf16le.xml", null);
- }
-
- public void testFile131() throws CoreException, IOException {
- doTest(expectedCustomXMLContentType, "testfiles/xml/utf16beMalformed.xml", null);
- }
-
- public void testFile132() throws CoreException, IOException {
- doTest(expectedCustomXMLContentType, "testfiles/xml/utf16leMalformed.xml", null);
- }
-
-}
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestContentTypes.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestContentTypes.java
deleted file mode 100644
index b5a6167fc..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/read/TestContentTypes.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.xml.tests.encoding.read;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.core.runtime.content.IContentTypeManager;
-
-
-public class TestContentTypes extends TestCase {
- private static final boolean DEBUG = false;
-
- public void testCreation() {
- IContentTypeManager registry = Platform.getContentTypeManager();
- assertTrue("content type identifer registry must exist", registry != null);
- IContentType[] allTypes = registry.getAllContentTypes();
- for (int i = 0; i < allTypes.length; i++) {
- IContentType contentType = allTypes[i];
- IContentType parentType = contentType.getBaseType();
- if (DEBUG) {
- System.out.print(contentType);
-
- if (parentType != null) {
- System.out.println(" (extends " + parentType + ")");
- }
- else {
- System.out.println();
- }
- System.out.println(" " + contentType.getName());
- }
- String[] filespecs = contentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC | IContentType.FILE_NAME_SPEC);
- if (DEBUG) {
- for (int j = 0; j < filespecs.length; j++) {
- String filespec = filespecs[j];
- System.out.println(" " + filespec);
- }
- }
- }
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/util/ProjectUnzipUtility.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/util/ProjectUnzipUtility.java
deleted file mode 100644
index 8dad58201..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/util/ProjectUnzipUtility.java
+++ /dev/null
@@ -1,337 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.xml.tests.encoding.util;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-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.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-import org.eclipse.ui.dialogs.IOverwriteQuery;
-import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
-import org.eclipse.ui.wizards.datatransfer.IImportStructureProvider;
-import org.eclipse.ui.wizards.datatransfer.ImportOperation;
-
-/**
- * Imports zipped files into the test workspace. Deletes all projects in
- * workspace.
- *
- * @author pavery
- */
-public class ProjectUnzipUtility {
- class MyOverwriteQuery implements IOverwriteQuery {
- public String queryOverwrite(String pathString) {
- return ALL;
- }
- }
-
- public final static String PROJECT_ZIPS_FOLDER = "ProjectTestFiles";
- private List fCreatedProjects = null;
-
- public ProjectUnzipUtility() {
- // for deletion later
- fCreatedProjects = new ArrayList();
- }
-
- /**
- * @param fileToImport
- * the file you wish to import
- * @param folderPath
- * the container path within the workspace
- */
- public void importFile(File fileToImport, String folderPath) {
- WorkspaceProgressMonitor importProgress = new WorkspaceProgressMonitor();
- try {
- if (fileToImport.exists()) {
- IPath containerPath = new Path(folderPath);
- //fCreatedProjects.add(folderPath);
- IImportStructureProvider provider = FileSystemStructureProvider.INSTANCE;
- IOverwriteQuery overwriteImplementor = new MyOverwriteQuery();
- File[] filesToImport = {fileToImport};
- ImportOperation importOp = new ImportOperation(containerPath, null, provider, overwriteImplementor, Arrays.asList(filesToImport));
- importOp.setCreateContainerStructure(false);
- importOp.setOverwriteResources(true);
- importOp.run(importProgress);
- }
- else {
- System.out.println("handle source doesn't exist");
- }
- }
- catch (Exception ex) {
- ex.printStackTrace();
- }
- finally {
- importProgress.done();
- }
- }
-
- /**
- * the following is logic from
- * http://www.devshed.com/c/a/Java/Zip-Meets-Java/2/
- */
- // specify buffer size for extraction
- static final int BUFFER = 2048;
-
- public void unzipAndImport(File inFile, String destinationDirectory) {
- try {
- // Specify file to decompress
- String inFileName = inFile.getAbsolutePath(); //"c:/example.zip";
- // Specify destination where file will be unzipped
- //String destinationDirectory =
- // "d:/eclipsedev/M5_SSE_TESTS_WORKSPACE/"; //"c:/temp/";
- File sourceZipFile = new File(inFileName);
- File unzipDestinationDirectory = new File(destinationDirectory);
- // Open Zip file for reading
- ZipFile zipFile = new ZipFile(sourceZipFile, ZipFile.OPEN_READ);
- // Create an enumeration of the entries in the zip file
- Enumeration zipFileEntries = zipFile.entries();
- String projectFolderName = null;
- IProject currentProject = null;
- // Process each entry
- while (zipFileEntries.hasMoreElements()) {
- // grab a zip file entry
- ZipEntry entry = (ZipEntry) zipFileEntries.nextElement();
- String currentEntry = entry.getName();
- //System.out.println("Extracting: " + entry);
- File destFile = new File(unzipDestinationDirectory, currentEntry);
- // grab file's parent directory structure
- File destinationParent = destFile.getParentFile();
- // create the parent directory structure if needed
- destinationParent.mkdirs();
- // extract file if not a directory
- if (!entry.isDirectory()) {
- BufferedInputStream is = new BufferedInputStream(zipFile.getInputStream(entry));
- // establish buffer for writing file
- byte data[] = new byte[BUFFER];
- // write the current file to disk
- FileOutputStream fileOutputStream = new FileOutputStream(destFile);
- ByteArrayOutputStream dest = new ByteArrayOutputStream(BUFFER);
- // read and write until last byte is encountered
- boolean eof = false;
- int nBytes = 0;
- while (!eof) {
- nBytes = is.read(data, 0, BUFFER);
- if (nBytes != -1) {
- dest.write(data, 0, nBytes);
- }
- else {
- eof = true;
- }
- }
- dest.flush();
- dest.close();
- fileOutputStream.write(dest.toByteArray());
- fileOutputStream.close();
- is.close();
- if (projectFolderName != null)
- importFile(destFile, projectFolderName);
- }
- else {
- // need handle to the main project folder to create
- // containerPath
- // unlike version in sse.tests, we don't create project
- // for
- // every directory
- // if(projectFolderName == null) {
- // projectFolderName = destFile.getName();
- // fCreatedProjects.add(projectFolderName);
- //
- // currentProject =
- // ResourcesPlugin.getWorkspace().getRoot().getProject(projectFolderName);
- // }
- }
- }
- zipFile.close();
- // fixes workspace metadata for the project
- // for clean startup next run
- if (currentProject != null) {
- try {
- Path projectLocation = new Path(Platform.getLocation().toOSString());
- createProject(currentProject, projectLocation, new WorkspaceProgressMonitor());
- }
- catch (CoreException cex) {
- cex.printStackTrace();
- }
- }
- }
- catch (IOException ioe) {
- ioe.printStackTrace();
- }
- }
-
- /**
- *
- */
- public void refreshWorkspace() throws CoreException {
- IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
- IProject[] projects = wsRoot.getProjects();
- for (int i = 0; i < projects.length; i++) {
- projects[i].refreshLocal(IResource.DEPTH_INFINITE, null);
- }
- wsRoot.refreshLocal(IResource.DEPTH_INFINITE, null);
- }
-
- /**
- * Delete projects created (unzipped and imported) by this utility
- *
- * @throws Exception
- */
- public void deleteProjects() throws Exception {
- final IProject[] projects = getCreatedProjects();
- WorkspaceModifyOperation deleteOp = new WorkspaceModifyOperation() {
- protected void execute(IProgressMonitor monitor) throws CoreException {
- for (int i = 0; i < projects.length; i++) {
- projects[i].clearHistory(null);
- projects[i].close(null);
- projects[i].delete(true, true, null);
- }
- refreshWorkspace();
- }
- };
- WorkspaceProgressMonitor progress = new WorkspaceProgressMonitor();
- deleteOp.run(progress);
- // saves the new workspace metadata
- ResourcesPlugin.getWorkspace().save(true, null);
- }
-
- public void deleteProject(String projectName) throws Exception {
- final String name = projectName;
- IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
- final IProject proj = wsRoot.getProject(name);
- WorkspaceModifyOperation deleteOp = new WorkspaceModifyOperation(proj) {
- protected void execute(IProgressMonitor monitor) throws CoreException {
- // IWorkspaceRoot wsRoot =
- // ResourcesPlugin.getWorkspace().getRoot();
- // IProject proj = wsRoot.getProject(name);
- if (proj != null && proj.exists()) {
- proj.clearHistory(null);
- //proj.close(null);
- proj.refreshLocal(IResource.DEPTH_INFINITE, null);
- try {
- proj.delete(true, true, null);
- }
- catch (Exception e) {
- // just try again (not sure why they are not being
- // deleted)
- proj.refreshLocal(IResource.DEPTH_INFINITE, null);
- proj.delete(true, true, null);
- }
- //proj = null;
- }
- refreshWorkspace();
- }
- };
- WorkspaceProgressMonitor progress = new WorkspaceProgressMonitor();
- deleteOp.run(progress);
- // saves the new workspace metadata
- ResourcesPlugin.getWorkspace().save(true, null);
- }
-
- /**
- * @return IProjects that were unzipped and imported into the workspace by
- * this utility
- */
- public IProject[] getCreatedProjects() {
- IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
- String[] projectNames = (String[]) fCreatedProjects.toArray(new String[fCreatedProjects.size()]);
- IProject[] projects = new IProject[projectNames.length];
- for (int i = 0; i < projectNames.length; i++) {
- projects[i] = wsRoot.getProject(projectNames[i]);
- }
- return projects;
- }
-
- public void initJavaProject(String projName) throws CoreException {
- // resynch
- refreshWorkspace();
- //change prereqs to get this functionality back in
- IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject(projName);
- // need to add java nature, or else project won't "exist()" in the
- // java element sense
- String[] natureIds = {"org.eclipse.jdt.core.javanature"};
- if (!proj.isOpen()) {
- proj.open(null);
- }
- IProjectDescription desc = proj.getDescription();
- desc.setNatureIds(natureIds);
- proj.setDescription(desc, null);
- }
-
- private void createProject(IProject project, IPath locationPath, IProgressMonitor monitor) throws CoreException {
- if (monitor == null) {
- monitor = new WorkspaceProgressMonitor();
- }
- monitor.beginTask("creating test project", 10);
- // create the project
- try {
- if (!project.exists()) {
- IProjectDescription desc = project.getWorkspace().newProjectDescription(project.getName());
- if (Platform.getLocation().equals(locationPath)) {
- locationPath = null;
- }
- desc.setLocation(locationPath);
- project.create(desc, monitor);
- monitor = null;
- }
- if (!project.isOpen()) {
- project.open(monitor);
- monitor = null;
- }
- }
- finally {
- if (monitor != null) {
- monitor.done();
- }
- }
- }
-
- public void deleteProject(IProject fProject) throws InvocationTargetException, InterruptedException {
- final IProject proj = fProject;
- WorkspaceModifyOperation deleteOp = new WorkspaceModifyOperation(proj) {
- protected void execute(IProgressMonitor monitor) throws CoreException {
- // IWorkspaceRoot wsRoot =
- // ResourcesPlugin.getWorkspace().getRoot();
- // IProject proj = wsRoot.getProject(name);
- if (proj != null && proj.exists()) {
- proj.clearHistory(null);
- //proj.close(null);
- proj.refreshLocal(IResource.DEPTH_INFINITE, null);
- proj.delete(true, true, null);
- //proj = null;
- }
- refreshWorkspace();
- }
- };
- //WorkspaceProgressMonitor progress = new WorkspaceProgressMonitor();
- deleteOp.run(null);
- // saves the new workspace metadata
- //ResourcesPlugin.getWorkspace().save(true, null);
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/util/WorkspaceProgressMonitor.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/util/WorkspaceProgressMonitor.java
deleted file mode 100644
index 7d7f7d36c..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/util/WorkspaceProgressMonitor.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.xml.tests.encoding.util;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-class WorkspaceProgressMonitor implements IProgressMonitor {
- private boolean finished = false;
-
- public void beginTask(String name, int totalWork) {
- // noop
- }
-
- public void done() {
- finished = true;
- }
-
- public boolean isFinished() {
- return finished;
- }
-
- public void internalWorked(double work) {
- // noop
- }
-
- public boolean isCanceled() {
- return finished;
- }
-
- public void setCanceled(boolean value) {
- if (value == true)
- finished = true;
- }
-
- public void setTaskName(String name) {
- // noop
- }
-
- public void subTask(String name) {
- // noop
- }
-
- public void worked(int work) {
- // noop
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/write/TestCodedWrite.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/write/TestCodedWrite.java
deleted file mode 100644
index 112521f63..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/write/TestCodedWrite.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.xml.tests.encoding.write;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.sse.core.internal.encoding.CodedStreamCreator;
-import org.eclipse.wst.sse.core.internal.encoding.EncodingRule;
-
-public class TestCodedWrite extends TestCase {
- /** A table of hex digits */
- private static final char[] hexDigit = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
- private static StringBuffer sBuff = new StringBuffer(2);
-
- private static String byteToHex(byte bytechar) {
- sBuff.setLength(0);
- int low = bytechar & 0xF;
- int hi = (bytechar >> 4) & 0xF;
- sBuff.append(toHex(hi));
- sBuff.append(toHex(low));
- return sBuff.toString();
- }
-
- /**
- * Convert a nibble to a hex character
- *
- * @param nibble
- * the nibble to convert.
- */
- private static char toHex(int nibble) {
- return hexDigit[(nibble & 0xF)];
- }
-
- private boolean DEBUG = false;
-
- /**
- *
- */
- public TestCodedWrite() {
- super();
- }
-
- /**
- * @param name
- */
- public TestCodedWrite(String name) {
- super(name);
- }
-
- public void testSimple() throws UnsupportedEncodingException, CoreException, IOException {
- String jsp = "<%@ page contentType=\"text/html; charset=ISO-8859-3\"%>";
- CodedStreamCreator codedStreamCreator = new CodedStreamCreator();
- codedStreamCreator.set("dummy.jsp", jsp);
- ByteArrayOutputStream outputStream = codedStreamCreator.getCodedByteArrayOutputStream(EncodingRule.CONTENT_BASED);
- if (DEBUG) {
- debugPrint("testSimple", jsp, "ISO-8859-3", outputStream);
- }
- assertNotNull(outputStream);
-
- }
-
- private void debugPrint(String testname, String originalString, String encoding, ByteArrayOutputStream outputStream) throws UnsupportedEncodingException {
- System.out.println();
- System.out.println(testname);
- byte[] bytes = outputStream.toByteArray();
- for (int i = 0; i < bytes.length; i++) {
- System.out.print(byteToHex(bytes[i]));
- }
- System.out.println();
- if (encoding == null) {
- System.out.println(new String(bytes));
-
- }
- else {
- System.out.println(new String(bytes, encoding));
- }
- }
-
- public void testSimpleUTF16BE() throws UnsupportedEncodingException, CoreException, IOException {
- String jsp = "<%@ page contentType=\"text/html; charset=UTF-16BE\"%>";
- CodedStreamCreator codedStreamCreator = new CodedStreamCreator();
- codedStreamCreator.set("dummy.jsp", jsp);
- ByteArrayOutputStream outputStream = codedStreamCreator.getCodedByteArrayOutputStream(EncodingRule.CONTENT_BASED);
- if (DEBUG) {
- debugPrint("testSimpleUTF16BE", jsp, "UTF-16BE", outputStream);
- }
- assertNotNull(outputStream);
-
- }
-
- public void testSimpler() throws UnsupportedEncodingException, CoreException, IOException {
- CodedStreamCreator codedStreamCreator = new CodedStreamCreator();
- String xmlString = "<?xml version=\"1.0\" encoding=\"UTF-16\"?><tag>test text</tag>";
- codedStreamCreator.set("dummy.xml", xmlString);
- ByteArrayOutputStream outputStream = codedStreamCreator.getCodedByteArrayOutputStream(EncodingRule.CONTENT_BASED);
- if (DEBUG) {
- debugPrint("testSimpler", xmlString, "UTF-16", outputStream);
- }
- assertNotNull(outputStream);
-
- }
-
- public void testSimplest() throws UnsupportedEncodingException, CoreException, IOException {
- CodedStreamCreator codedStreamCreator = new CodedStreamCreator();
- String text = "test text";
- codedStreamCreator.set("dummy.xml", text);
- ByteArrayOutputStream outputStream = codedStreamCreator.getCodedByteArrayOutputStream(EncodingRule.CONTENT_BASED);
- if (DEBUG) {
- debugPrint("testSimplest", text, null, outputStream);
- }
- assertNotNull(outputStream);
-
- }
-}
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/xml/XMLEncodingTests.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/xml/XMLEncodingTests.java
deleted file mode 100644
index 0ab1c8e4f..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/xml/XMLEncodingTests.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.xml.tests.encoding.xml;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CodingErrorAction;
-
-import junit.framework.TestCase;
-
-import org.eclipse.wst.sse.core.internal.encoding.EncodingMemento;
-import org.eclipse.wst.sse.core.internal.encoding.IResourceCharsetDetector;
-import org.eclipse.wst.xml.core.internal.contenttype.XMLResourceEncodingDetector;
-import org.eclipse.wst.xml.tests.encoding.TestsPlugin;
-
-
-public class XMLEncodingTests extends TestCase {
- private int READ_BUFFER_SIZE = 8000;
- private boolean DEBUG = false;
- private final String fileRoot = "testfiles/";
- private final String fileDir = "xml/";
- private final String fileLocation = fileRoot + fileDir;
-
- public XMLEncodingTests(String name) {
- super(name);
- }
-
- private void doTestFileStream(String filename, String expectedIANAEncoding, IResourceCharsetDetector detector) throws IOException {
- File file = TestsPlugin.getTestFile(filename);
- if (!file.exists())
- throw new IllegalArgumentException(filename + " was not found");
- InputStream inputStream = new FileInputStream(file);
- //InputStream inStream = getClass().getResourceAsStream(filename);
- InputStream istream = getMarkSupportedStream(inputStream);
- try {
- detector.set(istream);
- EncodingMemento encodingMemento = ((XMLResourceEncodingDetector)detector).getEncodingMemento();
- String foundIANAEncoding = encodingMemento.getJavaCharsetName();
- // I changed many "equals" to "equalsIgnoreCase" on 11/4/2002,
- // since
- // some issues with SHIFT_JIS vs. Shift_JIS were causing failures.
- // We do want to be tolerant on input, and accept either, but I
- // think
- // that SupportedJavaEncodings needs to be changed to "recommend"
- // Shift_JIS.
- boolean expectedIANAResult = false;
- expectedIANAResult = expectedIANAEncoding.equalsIgnoreCase(foundIANAEncoding);
-
- assertTrue("encoding test file " + filename + " expected: " + expectedIANAEncoding + " found: " + foundIANAEncoding, expectedIANAResult);
- // a very simple read test ... will cause JUnit error (not fail) if throws exception.
- ensureCanRead(filename, foundIANAEncoding, istream);
- }
- finally {
- if (istream != null) {
- istream.close();
- }
- if (inputStream != null) {
- inputStream.close();
- }
- }
- }
-
- public void testXMLEmptyFile() throws IOException {
- String filename = fileLocation + "EmptyFile.xml";
- doTestFileStream(filename, "UTF-8", new XMLResourceEncodingDetector());
- }
-
- public void testXMLIllformedNormalNonDefault() throws IOException {
- String filename = fileLocation + "IllformedNormalNonDefault.xml";
- String ianaInFile = "ISO-8859-1";
- doTestFileStream(filename, ianaInFile, new XMLResourceEncodingDetector());
- }
-
- public void testXMLNormalNonDefault() throws IOException {
- String filename = fileLocation + "NormalNonDefault.xml";
- String ianaInFile = "ISO-8859-1";
- doTestFileStream(filename, ianaInFile, new XMLResourceEncodingDetector());
- }
-
- public void testXMLNoEncoding() throws IOException {
- String filename = fileLocation + "NoEncoding.xml";
- doTestFileStream(filename, "UTF-8", new XMLResourceEncodingDetector());
- }
-
- /**
- * Caution, when this file prints out in console (when debug set to true, it appears
- * incorrect (due to font problems in console).
- */
- public void testUTF16() throws IOException {
- String filename = fileLocation + "utf16WithJapaneseChars.xml";
- doTestFileStream(filename, "UTF-16", new XMLResourceEncodingDetector());
- }
-
- /**
- * This test shows unicode BOM should take priority over settings/defaults
- */
- public void testUtf16UnicodeStreamWithNoEncodingInHeader() throws IOException {
- String filename = fileLocation + "utf16UnicodeStreamWithNoEncodingInHeader2.xml";
- doTestFileStream(filename, "UTF-16", new XMLResourceEncodingDetector());
- }
-
- /**
- * This test shows unicode BOM should take priority over settings/defaults
- * Note: UTF-16 == UTF-16BE
- */
- public void testUtf16UnicodeStreamWithNoEncodingInHeaderBE() throws IOException {
- String filename = fileLocation + "utf16UnicodeStreamWithNoEncodingInHeaderBE.xml";
- doTestFileStream(filename, "UTF-16", new XMLResourceEncodingDetector());
- }
-
- public void testUTF83ByteBOM() throws IOException {
- String filename = fileLocation + "UTF8With3ByteBOM.xml";
- doTestFileStream(filename, "UTF-8", new XMLResourceEncodingDetector());
- }
-
- public void testUTF16BE() throws IOException {
- String filename = fileLocation + "utf16be.xml";
- doTestFileStream(filename, "UTF-16BE", new XMLResourceEncodingDetector());
- }
-
- public void testUTF16LE() throws IOException {
- String filename = fileLocation + "utf16le.xml";
- doTestFileStream(filename, "UTF-16LE", new XMLResourceEncodingDetector());
- }
-
- public void testUTF16LEMalformed() throws IOException {
- String filename = fileLocation + "utf16leMalformed.xml";
- doTestFileStream(filename, "UTF-16LE", new XMLResourceEncodingDetector());
- }
-
- public void testUTF16BEMalformed() throws IOException {
- String filename = fileLocation + "utf16beMalformed.xml";
- doTestFileStream(filename, "UTF-16BE", new XMLResourceEncodingDetector());
- }
-
- /**
- * Ensures that an InputStream has mark/reset support.
- */
- private static InputStream getMarkSupportedStream(InputStream original) {
- if (original == null)
- return null;
- if (original.markSupported())
- return original;
- return new BufferedInputStream(original);
- }
-
- private StringBuffer readInputStream(Reader reader) throws IOException {
-
- StringBuffer buffer = new StringBuffer();
- int numRead = 0;
- char tBuff[] = new char[READ_BUFFER_SIZE];
- while ((numRead = reader.read(tBuff, 0, tBuff.length)) != -1) {
- buffer.append(tBuff, 0, numRead);
- }
- return buffer;
- }
-
- /**
- * This method just reads to stream, to be sure it can be read per
- * encoding, without exception.
- */
- private void ensureCanRead(String filename, String encoding, InputStream inStream) throws IOException {
- Charset charset = Charset.forName(encoding);
- CharsetDecoder charsetDecoder = charset.newDecoder();
- charsetDecoder.onMalformedInput(CodingErrorAction.REPORT);
- charsetDecoder.onUnmappableCharacter(CodingErrorAction.REPORT);
-
- InputStreamReader reader = new InputStreamReader(inStream, charsetDecoder);
- StringBuffer stringBuffer = readInputStream(reader);
- if (DEBUG) {
- System.out.println();
- System.out.println(filename);
- System.out.println(stringBuffer.toString());
- }
- }
-
-}
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/xml/XMLHeadTokenizerTester.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/xml/XMLHeadTokenizerTester.java
deleted file mode 100644
index d03c374f8..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/xml/XMLHeadTokenizerTester.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.xml.tests.encoding.xml;
-
-import java.io.IOException;
-import java.io.Reader;
-
-import junit.framework.TestCase;
-
-import org.eclipse.wst.xml.core.internal.contenttype.EncodingParserConstants;
-import org.eclipse.wst.xml.core.internal.contenttype.HeadParserToken;
-import org.eclipse.wst.xml.core.internal.contenttype.XMLHeadTokenizer;
-import org.eclipse.wst.xml.core.internal.contenttype.XMLHeadTokenizerConstants;
-import org.eclipse.wst.xml.tests.encoding.TestsPlugin;
-
-
-public class XMLHeadTokenizerTester extends TestCase {
-
- private boolean DEBUG = false;
- private final String fileDir = "xml/";
- private final String fileHome = "testfiles/";
- private final String fileLocation = fileHome + fileDir;
- private String fEncoding = null;
- private HeadParserToken fFinalToken;
-
- private void doTestFile(String filename, String expectedName) {
- doTestFile(filename, expectedName, null);
- }
-
- private void doTestFile(String filename, String expectedName, String expectedFinalTokenType) {
-
- XMLHeadTokenizer tokenizer = null;
- Reader fileReader = null;
- try {
- if (DEBUG) {
- System.out.println();
- System.out.println(" " + filename);
- System.out.println();
- }
- fileReader = TestsPlugin.getByteReader(filename);
- tokenizer = new XMLHeadTokenizer(fileReader);
- }
- catch (IOException e) {
- System.out.println("Error opening file \"" + filename + "\"");
- }
-
- String resultValue = null;
- try {
- parse(tokenizer);
- resultValue = fEncoding;
- if (DEBUG) {
- System.out.println("XML Head Tokenizer Found Encoding: " + resultValue);
- }
- fileReader.close();
- }
- catch (java.io.IOException e) {
- System.out.println("An I/O error occured while scanning :");
- System.out.println(e);
- }
-
- if (expectedFinalTokenType != null) {
- assertTrue("did not end as expected. found: " + fFinalToken.getType(), expectedFinalTokenType.equals(fFinalToken.getType()));
- }
- else {
- if (expectedName == null) {
- // TODO: this test branch needs to be improved ... doesn't
- // fail
- // as it should
- // (such as when tokenizer changed to return early when
- // Unicode
- // stream found).
- assertTrue("expected no encoding, but found: " + resultValue, resultValue == null);
- }
- else {
- assertTrue("expected " + expectedName + " but found " + resultValue, expectedName.equals(resultValue));
- }
- }
-
- }
-
- private void parse(XMLHeadTokenizer tokenizer) throws IOException {
- HeadParserToken token = null;
- String tokenType = null;
- do {
- token = tokenizer.getNextToken();
- tokenType = token.getType();
- // normally "parsing" the tokens should be done by parser
- // @see, XMLResourceEncodoingDetector
- // but we'll
- // do it here for a little
- // more independent test.
- if (tokenType == EncodingParserConstants.UTF16BE) {
- fEncoding = "UTF16BEInStream";
- }
- if (tokenType == EncodingParserConstants.UTF16LE) {
- fEncoding = "UTF16LEInStream";
- }
- if (tokenType == EncodingParserConstants.UTF83ByteBOM) {
- fEncoding = "UTF83ByteBOMInStream";
- }
- if (tokenType == XMLHeadTokenizerConstants.XMLDelEncoding) {
- if (tokenizer.hasMoreTokens()) {
- token = tokenizer.getNextToken();
- tokenType = token.getType();
- if (isLegalString(tokenType)) {
- fEncoding = token.getText();
- }
- }
- }
- }
- while (tokenizer.hasMoreTokens());
- // for testing
- fFinalToken = token;
- }
-
- private boolean isLegalString(String tokenType) {
- boolean result = false;
- if (tokenType != null) {
- result = tokenType.equals(EncodingParserConstants.StringValue) || tokenType.equals(EncodingParserConstants.UnDelimitedStringValue) || tokenType.equals(EncodingParserConstants.InvalidTerminatedStringValue) || tokenType.equals(EncodingParserConstants.InvalidTermintatedUnDelimitedStringValue);
- }
- return result;
- }
-
- /**
- * Normal XMLDeclaration with default encoding specified (UTF-8)
- *
- */
- public void testBestCase() {
- String filename = fileLocation + "testNormalCase.xml";
- doTestFile(filename, "UTF-8");
-
- }
-
- /**
- * This is a UTF-16 file (Unicode bytes in BOM). So, the tokenizer by
- * itself can't read correctly. Returns null in "pure" tokenizer test, but
- * encoding detector case should still handle since looks for bytes first.
- */
- public void testUTF16() {
- String filename = fileLocation + "testUTF16.xml";
- doTestFile(filename, "UTF16BEInStream");
- }
-
- /**
- * Just to make sure we don't choke on empty file.
- *
- */
- public void testEmptyFile() {
- String filename = fileLocation + "EmptyFile.xml";
- doTestFile(filename, null);
- }
-
- /**
- * Testing as a result of CMVC defect 217720
- */
- public void testEUCJP() {
- String filename = fileLocation + "eucjp.xml";
- doTestFile(filename, "EUC-JP");
- }
-
- /**
- * Extended XML Declaration that contains 'standalone' attribute
- *
- */
- public void testExtraAttrCase() {
- String filename = fileLocation + "testExtraValidStuff.xml";
- doTestFile(filename, "UTF-8");
-
- }
-
- /**
- * A case with a valid encoding, but extra attributes which are not
- * valid/meaningful.
- *
- */
- public void testExtraJunkCase() {
- String filename = fileLocation + "testExtraJunk.xml";
- doTestFile(filename, "ISO-8859-1");
- }
-
- /**
- * Missing 2 quotes, one and end of version value and one at beginning of
- * encoding value. In this case, tokenizer handles as undelimite string,
- * but if we ever modifiy to also look for 'version', then would not work
- * the same.
- *
- */
- public void testIllFormed() {
- String filename = fileLocation + "testIllFormed.xml";
- doTestFile(filename, null);
- }
-
- /**
- * Missing XMLDecl end tag ... we should be able to safely guess.
- *
- */
- public void testIllFormed2() {
- String filename = fileLocation + "testIllFormed2.xml";
- doTestFile(filename, "UTF-8");
- }
-
- /**
- * Missing end quote on UTF-8 attribute, so picks up following attribte
- * too.
- *
- */
- public void testIllFormed3() {
- String filename = fileLocation + "testIllFormed3.xml";
- doTestFile(filename, "UTF-8 standalone=");
- }
-
- /**
- * Missing end quote on UTF-8 attribute, but then XMLDeclEnds, so should
- * be able to handle
- *
- */
- public void testIllFormed4() {
- String filename = fileLocation + "testIllFormed4.xml";
- doTestFile(filename, "UTF-8");
- }
-
- /**
- * Test of missing end quote on encoding value.
- *
- */
- public void testIllformedNormalNonDefault() {
- String filename = fileLocation + "IllformedNormalNonDefault.xml";
- doTestFile(filename, "ISO-8859-1");
- }
-
- /**
- * Empty string as encoding value; (And, malformed input, for UTF-8 ...
- * should not effect results of this level of test).
- *
- */
- public void testMalformedNoEncoding() {
- String filename = fileLocation + "MalformedNoEncoding.xml";
- doTestFile(filename, "");
- }
-
- /**
- * Empty string as encoding value; (And, malformed input, for UTF-8 ...
- * should not effect results of this level of test).
- *
- */
- public void testMalformedNoEncodingXSL() {
- String filename = fileLocation + "MalformedNoEncoding.xsl";
- doTestFile(filename, "");
- }
-
- /**
- * XMLDeclaration not all on same line
- *
- */
- public void testMultiLineCase() {
- String filename = fileLocation + "testMultiLine.xml";
- doTestFile(filename, "ISO-8859-1");
-
- }
-
- /**
- * No encoding in XMLDeclaration
- *
- */
- public void testNoEncoding() {
- String filename = fileLocation + "NoEncoding.xml";
- doTestFile(filename, null);
- }
-
- /**
- * ?Is this a dup?
- *
- */
- public void testNoEncodingCase() {
- String filename = fileLocation + "testNoEncodingValue.xml";
- doTestFile(filename, null);
- }
-
- /**
- * Normal XMLDeclaration with ISO-1 specified
- *
- */
- public void testNormalNonDefault() {
- String filename = fileLocation + "NormalNonDefault.xml";
- doTestFile(filename, "ISO-8859-1");
- }
-
- /**
- * No XMLDeclaration at all. (Invalid, but should still be able to parse).
- *
- */
- public void testNoXMLDecl() {
- String filename = fileLocation + "testNoXMLDecl.xml";
- doTestFile(filename, null);
- }
-
- /**
- * Hard to handle safely (may appear in comment, for example).
- *
- */
- public void testNoXMLDeclAtFirst() {
- String filename = fileLocation + "testNoXMLDeclAtFirst.xml";
- doTestFile(filename, null);
- }
-
- /**
- * This test is just to make sure the scanning ends before end of file is
- * reached.
- *
- */
- public void testNoXMLDeclInLargeFile() {
- String filename = fileLocation + "testNoXMLDeclInLargeFile.xml";
- doTestFile(filename, null, EncodingParserConstants.MAX_CHARS_REACHED);
- }
-
- /**
- * Testing as a result of CMVC defect 217720
- */
- public void testshiftjis() {
- String filename = fileLocation + "shiftjis.xml";
- doTestFile(filename, "Shift_JIS");
- }
-
- /**
- * Testing as a result of CMVC defect 217720
- */
- public void testUTF16LEWithJapaneseChars() {
- String filename = fileLocation + "utf16UnicodeStreamWithNoEncodingInHeader2.xml";
- doTestFile(filename, "UTF16LEInStream");
- }
-
- /**
- * Testing as a result of CMVC defect 217720
- */
- public void testUTF16BEWithJapaneseChars() {
- String filename = fileLocation + "utf16UnicodeStreamWithNoEncodingInHeaderBE.xml";
- doTestFile(filename, "UTF16BEInStream");
- }
-
- /**
- * A common case.
- *
- */
- public void testUTF8With3ByteBOM() {
- String filename = fileLocation + "UTF8With3ByteBOM.xml";
- doTestFile(filename, "UTF83ByteBOMInStream");
- }
- public void UTF16LEAtStartOfLargeFile() {
- String filename = fileLocation + "UTF16LEAtStartOfLargeFile.xml";
- doTestFile(filename, "UTF16LEInStream");
- }
-
- public void testUTF16LE() {
- String filename = fileLocation + "utf16le.xml";
- doTestFile(filename, "UTF-16LE");
- }
-
- public void testUTF16BE() {
- String filename = fileLocation + "utf16be.xml";
- doTestFile(filename, "UTF-16BE");
- }
-
- public void testUTF16BEMalformed() {
- String filename = fileLocation + "utf16beMalformed.xml";
- doTestFile(filename, "UTF-16BE");
- }
-
- public void testUTF16LEMalformed() {
- String filename = fileLocation + "utf16leMalformed.xml";
- doTestFile(filename, "UTF-16LE");
- }
-}
diff --git a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/xml/XMLMalformedInputTests.java b/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/xml/XMLMalformedInputTests.java
deleted file mode 100644
index 8be099ae4..000000000
--- a/tests/org.eclipse.wst.xml.tests.encoding/src/org/eclipse/wst/xml/tests/encoding/xml/XMLMalformedInputTests.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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.xml.tests.encoding.xml;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CodingErrorAction;
-import java.nio.charset.MalformedInputException;
-
-import junit.framework.TestCase;
-
-import org.eclipse.wst.sse.core.internal.encoding.EncodingMemento;
-import org.eclipse.wst.sse.core.internal.encoding.IResourceCharsetDetector;
-import org.eclipse.wst.sse.core.internal.exceptions.MalformedInputExceptionWithDetail;
-import org.eclipse.wst.xml.core.internal.contenttype.XMLResourceEncodingDetector;
-import org.eclipse.wst.xml.tests.encoding.TestsPlugin;
-
-/**
- * FIXME: this might be a good starting point to create a "file peeker"? But,
- * its not otherwised used -- delete if not fixed/improved soon
- * XMLMalformedInputTests
- */
-
-public class XMLMalformedInputTests extends TestCase {
- private int READ_BUFFER_SIZE = 8000;
- private boolean DEBUG = false;
-
-
- public XMLMalformedInputTests(String name) {
- super(name);
- }
-
- /**
- * Tests for a file, filename that should throw a
- * MalformedInputExceptionWithDetail at character, expectedPosition. This
- * happens when no encoding is specified, so the default is used, but
- * there are characters that the default encoding does not recognize
- */
- void doTestMalformedInput(String filename, IResourceCharsetDetector detector, int expectedPosition) throws IOException {
- Exception foundException = null;
- int badCharPosition = -1;
- File file = TestsPlugin.getTestFile(filename);
- if (!file.exists())
- throw new IllegalArgumentException(filename + " was not found");
- InputStream inputStream = new FileInputStream(file);
- InputStream istream = getMarkSupportedStream(inputStream);
- detector.set(istream);
- // IEncodedDocument doc =
- // detector.createNewStructuredDocument(filename, istream);
- EncodingMemento encodingMemento = ((XMLResourceEncodingDetector) detector).getEncodingMemento();
- String foundIANAEncoding = encodingMemento.getJavaCharsetName();
-
- Charset charset = Charset.forName(foundIANAEncoding);
- CharsetDecoder charsetDecoder = charset.newDecoder();
- charsetDecoder.onMalformedInput(CodingErrorAction.REPORT);
- charsetDecoder.onUnmappableCharacter(CodingErrorAction.REPORT);
-
- istream.close();
- inputStream.close();
-
- // now, try reading as per encoding
- inputStream = new FileInputStream(file);
- // skip BOM for this case
- // System.out.println(inputStream.read());
- // System.out.println(inputStream.read());
- // System.out.println(inputStream.read());
- InputStreamReader reader = new InputStreamReader(inputStream, charsetDecoder);
-
- try {
- // just try reading ... should throw exception
- // exception)
- readInputStream(reader);
- }
- catch (MalformedInputException e) {
- // as expected, now do detailed checking.
- inputStream.close();
- istream.close();
- inputStream = new FileInputStream(file);
- charsetDecoder = charset.newDecoder();
- charsetDecoder.onMalformedInput(CodingErrorAction.REPORT);
- charsetDecoder.onUnmappableCharacter(CodingErrorAction.REPORT);
- reader = new InputStreamReader(inputStream, charsetDecoder);
- istream = getMarkSupportedStream(inputStream);
- try {
- handleMalFormedInput_DetailChecking(reader, foundIANAEncoding);
- }
- catch (MalformedInputExceptionWithDetail se) {
- foundException = se;
- badCharPosition = se.getCharPosition();
- }
-
- }
- finally {
- if (istream != null) {
- istream.close();
- }
- if (inputStream != null) {
- inputStream.close();
- }
-
- }
- // handle adjustments here for VM differnces:
- // for now its either 49 or 49 + 2 BOMs (51)
- // can be smarting later.
- assertTrue("MalformedInputException was not thrown as expected for filename: " + filename + " Exception thrown:" + foundException, foundException instanceof MalformedInputExceptionWithDetail);
- assertTrue("Wrong character position detected in MalformedInputException. Expected: " + expectedPosition + " Found: " + badCharPosition, (badCharPosition == expectedPosition) || badCharPosition == expectedPosition - 2);
- }
-
- // public void testXSLMalformedInput() throws IOException {
- // String filename = fileLocation + "MalformedNoEncoding.xsl";
- // doTestMalformedInput(filename, new XMLResourceEncodingDetector(), 211);
- // }
-
- /**
- * Ensures that an InputStream has mark/reset support.
- */
- private static InputStream getMarkSupportedStream(InputStream original) {
- if (original == null)
- return null;
- if (original.markSupported())
- return original;
- return new BufferedInputStream(original);
- }
-
- private StringBuffer readInputStream(Reader reader) throws IOException {
-
- StringBuffer buffer = new StringBuffer();
- int numRead = 0;
- char tBuff[] = new char[READ_BUFFER_SIZE];
- while ((numRead = reader.read(tBuff, 0, tBuff.length)) != -1) {
- if (DEBUG) {
- System.out.println(tBuff[0]);
- }
- buffer.append(tBuff, 0, numRead);
- }
- return buffer;
- }
-
- /*
- * removed for PPC machine with IBM VM
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=126503
- */
- // public void testXMLMalformedInput() throws IOException {
- // String filename = fileLocation + "MalformedNoEncoding.xml";
- // doTestMalformedInput(filename, new XMLResourceEncodingDetector(), 51);
- // }
- // since above test was only one im this class, put in this no op to avoid
- // a failure due to no tests in class!
- public void testNoOp() {
- assertTrue(true);
- }
-
- private void handleMalFormedInput_DetailChecking(Reader reader, String encodingName) throws IOException, MalformedInputExceptionWithDetail {
- int charPostion = -1;
- charPostion = getCharPostionOfFailure(reader);
- // all of that just to throw more accurate error
- // note: we do the conversion to ianaName, instead of using the local
- // variable,
- // because this is ultimately only for the user error message (that
- // is,
- // the error occurred
- // in context of javaEncodingName no matter what ianaEncodingName is
- throw new MalformedInputExceptionWithDetail(encodingName, charPostion);
- }
-
- private int getCharPostionOfFailure(Reader reader) throws IOException {
- int charPosition = 1;
- int charRead = -1;
- int result = -1;
- boolean errorFound = false;
- do {
- try {
- if (reader.ready()) {
- charRead = reader.read();
- }
- if (DEBUG) {
- System.out.println(charPosition + ": " + escape((char) charRead, true));
- }
- charPosition++;
- }
- catch (MalformedInputException e) {
- // this is expected, since we're expecting failure,
- // so no need to do anything.
- errorFound = true;
- break;
- }
- }
- while ((charRead != -1 && !errorFound) && reader.ready());
-
- if (errorFound)
- result = charPosition;
- else
- result = -1;
- return result;
- }
-
- private String escape(char aChar, boolean escapeSpace) {
-
- StringBuffer outBuffer = new StringBuffer();
- switch (aChar) {
- case ' ' :
- if (escapeSpace)
- outBuffer.append('\\');
-
- outBuffer.append(' ');
- break;
- case '\\' :
- outBuffer.append('\\');
- outBuffer.append('\\');
- break;
- case '\t' :
- outBuffer.append('\\');
- outBuffer.append('t');
- break;
- case '\n' :
- outBuffer.append('\\');
- outBuffer.append('n');
- break;
- case '\r' :
- outBuffer.append('\\');
- outBuffer.append('r');
- break;
- case '\f' :
- outBuffer.append('\\');
- outBuffer.append('f');
- break;
- default :
- if ((aChar < 0x0020) || (aChar > 0x007e)) {
- outBuffer.append('\\');
- outBuffer.append('u');
- outBuffer.append(toHex((aChar >> 12) & 0xF));
- outBuffer.append(toHex((aChar >> 8) & 0xF));
- outBuffer.append(toHex((aChar >> 4) & 0xF));
- outBuffer.append(toHex(aChar & 0xF));
- }
- else {
- if (specialSaveChars.indexOf(aChar) != -1)
- outBuffer.append('\\');
- outBuffer.append(aChar);
- }
- }
-
- return outBuffer.toString();
- }
-
- /**
- * Convert a nibble to a hex character
- *
- * @param nibble
- * the nibble to convert.
- */
- private static char toHex(int nibble) {
- return hexDigit[(nibble & 0xF)];
- }
-
- /** A table of hex digits */
- private static final char[] hexDigit = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
- private static final String specialSaveChars = "=: \t\r\n\f#!";
-
-}

Back to the top