summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2006-08-16 09:53:44 (EDT)
committer pelder2006-08-16 09:53:44 (EDT)
commit25f2d56bb46008abde9c774f7e429c5e4edda869 (patch)
tree65b86e6c43a3ec86fc03cd3809497bc9a3c3c08d
parent1843312d6ccaba52252e6e497bf450694468672c (diff)
downloadorg.eclipse.jet-25f2d56bb46008abde9c774f7e429c5e4edda869.zip
org.eclipse.jet-25f2d56bb46008abde9c774f7e429c5e4edda869.tar.gz
org.eclipse.jet-25f2d56bb46008abde9c774f7e429c5e4edda869.tar.bz2
[153930] Add JUnits for ActionsUtil to verify correct handling of Unicode files and their BOMs.
-rw-r--r--tests/org.eclipse.jet.tests/data/ActionsUtil/MANIFEST.MF17
-rw-r--r--tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf16be.xmlbin0 -> 150 bytes
-rw-r--r--tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf16le.xmlbin0 -> 150 bytes
-rw-r--r--tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf8_bom.xml4
-rw-r--r--tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf8_no_bom.xml4
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/AllTests.java1
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/java/JavaActionsUtilTests.java70
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/workspace/ActionsUtilTests.java115
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/workspace/AllTests.java17
9 files changed, 228 insertions, 0 deletions
diff --git a/tests/org.eclipse.jet.tests/data/ActionsUtil/MANIFEST.MF b/tests/org.eclipse.jet.tests/data/ActionsUtil/MANIFEST.MF
new file mode 100644
index 0000000..ff8d913
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/ActionsUtil/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.jet.tests;singleton:=true
+Bundle-Version: 0.7.0.qualifier
+Bundle-ClassPath: tests.jar
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.jet,
+ org.junit,
+ org.eclipse.emf.codegen,
+ org.eclipse.core.runtime,
+ org.eclipse.emf.ecore,
+ org.eclipse.emf.ecore.xmi,
+ org.eclipse.xsd,
+ org.eclipse.core.filebuffers,
+ org.eclipse.core.resources
+Bundle-Vendor: %providerName
diff --git a/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf16be.xml b/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf16be.xml
new file mode 100644
index 0000000..368bb8c
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf16be.xml
Binary files differ
diff --git a/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf16le.xml b/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf16le.xml
new file mode 100644
index 0000000..a167ef1
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf16le.xml
Binary files differ
diff --git a/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf8_bom.xml b/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf8_bom.xml
new file mode 100644
index 0000000..59bda64
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf8_bom.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<root>
+ <a attr="b"/>
+</root>
diff --git a/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf8_no_bom.xml b/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf8_no_bom.xml
new file mode 100644
index 0000000..e93c6a2
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf8_no_bom.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<root>
+ <a attr="b"/>
+</root>
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/AllTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/AllTests.java
index 4b2fe16..fd2efbb 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/AllTests.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/AllTests.java
@@ -14,6 +14,7 @@ public class AllTests {
suite.addTest(org.eclipse.jet.tests.model.load.AllTests.suite());
suite.addTest(org.eclipse.jet.tests.taglib.AllTests.suite());
suite.addTest(org.eclipse.jet.tests.taglib.control.AllTests.suite());
+ suite.addTest(org.eclipse.jet.tests.taglib.workspace.AllTests.suite());
suite.addTest(org.eclipse.jet.tests.taglib.java.AllTests.suite());
suite.addTest(org.eclipse.jet.tests.taglib.format.AllTests.suite());
suite.addTest(org.eclipse.jet.tests.runtime.AllTests.suite());
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/java/JavaActionsUtilTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/java/JavaActionsUtilTests.java
new file mode 100644
index 0000000..4304f79
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/java/JavaActionsUtilTests.java
@@ -0,0 +1,70 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id$
+ */
+
+package org.eclipse.jet.tests.taglib.java;
+
+import junit.framework.TestCase;
+
+/**
+ * @author pelder
+ *
+ */
+public class JavaActionsUtilTests extends TestCase {
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.taglib.java.JavaActionsUtil#getContainerForPackage(org.eclipse.core.runtime.IPath, java.lang.String)}.
+ */
+ public void testGetContainerForPackage() {
+ fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.taglib.java.JavaActionsUtil#getImportManager(org.eclipse.jet.JET2Writer)}.
+ */
+ public void testGetImportManager() {
+ fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.taglib.java.JavaActionsUtil#findContainingJavaPackageTag(org.eclipse.jet.taglib.CustomTag)}.
+ */
+ public void testFindContainingJavaPackageTag() {
+ fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.taglib.java.JavaActionsUtil#getResourceForJavaResource(org.eclipse.core.runtime.IPath, java.lang.String, java.lang.String)}.
+ */
+ public void testGetResourceForJavaResource() {
+ fail("Not yet implemented");
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/workspace/ActionsUtilTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/workspace/ActionsUtilTests.java
new file mode 100644
index 0000000..88a1779
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/workspace/ActionsUtilTests.java
@@ -0,0 +1,115 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id$
+ */
+
+package org.eclipse.jet.tests.taglib.workspace;
+
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jet.taglib.workspace.ActionsUtil;
+
+/**
+ * JUnit tests for {@link ActionsUtil}.
+ *
+ */
+public class ActionsUtilTests extends TestCase {
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.taglib.workspace.ActionsUtil#readTextFile(java.net.URL, java.lang.String)}.
+ * @throws Exception
+ */
+ public void testReadTextFile_Manifest_MF() throws Exception {
+ URL url = new URL("platform:/plugin/org.eclipse.jet.tests/data/ActionsUtil/MANIFEST.MF");
+ final String correctText = ActionsUtil.readTextFile(url, "UTF-8");
+
+ final String rawText = ActionsUtil.readTextFile(url, null);
+
+ assertTrue("raw text", rawText.startsWith("Manifest-Version: 1.0"));
+ assertTrue("correct text", correctText.startsWith("Manifest-Version: 1.0"));
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.taglib.workspace.ActionsUtil#readTextFile(java.net.URL, java.lang.String)}.
+ * @throws Exception
+ */
+ public void testReadTextFile_utf8_no_bom_xml() throws Exception {
+ URL url = new URL("platform:/plugin/org.eclipse.jet.tests/data/ActionsUtil/sample_utf8_no_bom.xml");
+ final String correctText = ActionsUtil.readTextFile(url, "UTF-8");
+
+ final String rawText = ActionsUtil.readTextFile(url, null);
+
+ assertTrue("correct text", correctText.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
+ assertTrue("raw text", rawText.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.taglib.workspace.ActionsUtil#readTextFile(java.net.URL, java.lang.String)}.
+ * @throws Exception
+ */
+ public void testReadTextFile_utf8_bom_xml() throws Exception {
+ URL url = new URL("platform:/plugin/org.eclipse.jet.tests/data/ActionsUtil/sample_utf8_bom.xml");
+ final String correctText = ActionsUtil.readTextFile(url, "UTF-8");
+
+ final String rawText = ActionsUtil.readTextFile(url, null);
+
+ assertTrue("correct text", correctText.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
+ assertTrue("raw text", rawText.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.taglib.workspace.ActionsUtil#readTextFile(java.net.URL, java.lang.String)}.
+ * @throws Exception
+ */
+ public void testReadTextFile_utf16_le_xml() throws Exception {
+ URL url = new URL("platform:/plugin/org.eclipse.jet.tests/data/ActionsUtil/sample_utf16le.xml");
+ final String correctText = ActionsUtil.readTextFile(url, "UTF-16");
+
+ final String rawText = ActionsUtil.readTextFile(url, null);
+
+ assertTrue("correct text", correctText.startsWith("<?xml version=\"1.0\" encoding=\"UTF-16\"?>"));
+ assertTrue("raw text", rawText.startsWith("\u00FF\u00FE")); // Little Endian BOM is FF FE
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.taglib.workspace.ActionsUtil#readTextFile(java.net.URL, java.lang.String)}.
+ * @throws Exception
+ */
+ public void testReadTextFile_utf16_be_xml() throws Exception {
+ URL url = new URL("platform:/plugin/org.eclipse.jet.tests/data/ActionsUtil/sample_utf16be.xml");
+ final String correctText = ActionsUtil.readTextFile(url, "UTF-16");
+
+ final String rawText = ActionsUtil.readTextFile(url, null);
+
+ assertTrue("correct text", correctText.startsWith("<?xml version=\"1.0\" encoding=\"UTF-16\"?>"));
+ assertTrue("raw text", rawText.startsWith("\u00FE\u00FF")); // big endian BOM is FE FF
+ }
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/workspace/AllTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/workspace/AllTests.java
new file mode 100644
index 0000000..1088325
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/workspace/AllTests.java
@@ -0,0 +1,17 @@
+package org.eclipse.jet.tests.taglib.workspace;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(
+ "Test for org.eclipse.jet.tests.taglib.workspace");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(ActionsUtilTests.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}