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
path: root/tests
diff options
context:
space:
mode:
authornitind2011-02-02 20:41:36 +0000
committernitind2011-02-02 20:41:36 +0000
commit3a451db34c8ace9405dcd37fb6aa23da0fbe6e7c (patch)
tree21ae26e2cecd6680da42621f232d4d052b51c8b2 /tests
parent43af6662a1db4be0ae874a9506158efd40a91e88 (diff)
downloadwebtools.sourceediting.tests-3a451db34c8ace9405dcd37fb6aa23da0fbe6e7c.tar.gz
webtools.sourceediting.tests-3a451db34c8ace9405dcd37fb6aa23da0fbe6e7c.tar.xz
webtools.sourceediting.tests-3a451db34c8ace9405dcd37fb6aa23da0fbe6e7c.zip
[333901] Need to update JS include path after module core nature installed
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.wst.jsdt.web.core.tests/src/org/eclipse/wst/jsdt/web/core/tests/AllWebCoreTests.java12
-rw-r--r--tests/org.eclipse.wst.jsdt.web.core.tests/src/org/eclipse/wst/jsdt/web/core/tests/PathUtilsTests.java310
2 files changed, 322 insertions, 0 deletions
diff --git a/tests/org.eclipse.wst.jsdt.web.core.tests/src/org/eclipse/wst/jsdt/web/core/tests/AllWebCoreTests.java b/tests/org.eclipse.wst.jsdt.web.core.tests/src/org/eclipse/wst/jsdt/web/core/tests/AllWebCoreTests.java
index 4d4c6eb5a..b223909c0 100644
--- a/tests/org.eclipse.wst.jsdt.web.core.tests/src/org/eclipse/wst/jsdt/web/core/tests/AllWebCoreTests.java
+++ b/tests/org.eclipse.wst.jsdt.web.core.tests/src/org/eclipse/wst/jsdt/web/core/tests/AllWebCoreTests.java
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2011 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.jsdt.web.core.tests;
import junit.framework.Test;
@@ -16,6 +27,7 @@ public class AllWebCoreTests extends TestSuite {
//$JUnit-END$
suite.addTestSuite(TestHtmlTranslation.class);
+ suite.addTestSuite(PathUtilsTests.class);
return suite;
}
diff --git a/tests/org.eclipse.wst.jsdt.web.core.tests/src/org/eclipse/wst/jsdt/web/core/tests/PathUtilsTests.java b/tests/org.eclipse.wst.jsdt.web.core.tests/src/org/eclipse/wst/jsdt/web/core/tests/PathUtilsTests.java
new file mode 100644
index 000000000..8426b42c0
--- /dev/null
+++ b/tests/org.eclipse.wst.jsdt.web.core.tests/src/org/eclipse/wst/jsdt/web/core/tests/PathUtilsTests.java
@@ -0,0 +1,310 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.jsdt.web.core.tests;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.jsdt.web.core.internal.PathUtils;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/**
+ * <p>Unit tests for the {@link PathUtils} class.</p>
+ *
+ */
+public class PathUtilsTests extends TestCase {
+
+ /**
+ * <p>Default constructor</p>
+ */
+ public PathUtilsTests() {
+ super("Path Utils Tests");
+ }
+
+ public void testOneSegmentParentWithOneSegmentPattern_SegmentCountTest_0() {
+ runCountPatternSegmentsThatMatchParentTest("foo", "foo", 1);
+ }
+
+ public void testOneSegmentParentWithOneSegmentPattern_SegmentCountTest_1() {
+ runCountPatternSegmentsThatMatchParentTest("/foo", "foo", 1);
+ }
+
+ public void testOneSegmentParentWithOneSegmentPattern_SegmentCountTest_2() {
+ runCountPatternSegmentsThatMatchParentTest("/foo", "foo", 1);
+ }
+
+ public void testOneSegmentParentWithOneSegmentPattern_SegmentCountTest_3() {
+ runCountPatternSegmentsThatMatchParentTest("foo", "/foo", 1);
+ }
+
+ public void testOneSegmentParentWithOneSegmentPattern_SegmentCountTest_4() {
+ runCountPatternSegmentsThatMatchParentTest("/foo", "/foo", 1);
+ }
+
+ public void testOneSegmentParentWithTwoSegmentPattern_SegmentCountTest_0() {
+ runCountPatternSegmentsThatMatchParentTest("foo/bar", "foo", 1);
+ }
+
+ public void testOneSegmentParentWithTwoSegmentPattern_SegmentCountTest_1() {
+ runCountPatternSegmentsThatMatchParentTest("/foo/bar", "foo", 1);
+ }
+
+ public void testOneSegmentParentWithTwoSegmentPattern_SegmentCountTest_2() {
+ runCountPatternSegmentsThatMatchParentTest("/foo/bar", "foo", 1);
+ }
+
+ public void testOneSegmentParentWithTwoSegmentPattern_SegmentCountTest_3() {
+ runCountPatternSegmentsThatMatchParentTest("foo/bar", "/foo", 1);
+ }
+
+ public void testOneSegmentParentWithTwoSegmentPattern_SegmentCountTest_4() {
+ runCountPatternSegmentsThatMatchParentTest("/foo/bar", "/foo", 1);
+ }
+
+ public void testOneSegmentParentWithTwoSegmentPattern_SegmentCountTest_5() {
+ runCountPatternSegmentsThatMatchParentTest("foo/bar/", "foo", 1);
+ }
+
+ public void testOneSegmentParentWithTwoSegmentPattern_SegmentCountTest_6() {
+ runCountPatternSegmentsThatMatchParentTest("/foo/bar/", "foo", 1);
+ }
+
+ public void testOneSegmentParentWithTwoSegmentPattern_SegmentCountTest_7() {
+ runCountPatternSegmentsThatMatchParentTest("/foo/bar/", "foo", 1);
+ }
+
+ public void testOneSegmentParentWithTwoSegmentPattern_SegmentCountTest_8() {
+ runCountPatternSegmentsThatMatchParentTest("foo/bar/", "/foo", 1);
+ }
+
+ public void testOneSegmentParentWithTwoSegmentPattern_SegmentCountTest_9() {
+ runCountPatternSegmentsThatMatchParentTest("/foo/bar/", "/foo", 1);
+ }
+
+ public void testOneSegmentParentWithTwoSegmentPattern_SegmentCountTest_10() {
+ runCountPatternSegmentsThatMatchParentTest("/foo/bar/", "/boo", 0);
+ }
+
+ public void testTwoSegmentParentWithThreeSegmentPattern_SegmentCountTest_0() {
+ runCountPatternSegmentsThatMatchParentTest("/foo/bar/blarg", "/foo/bar", 2);
+ }
+
+ public void testStar_SegmentCountTest_0() {
+ runCountPatternSegmentsThatMatchParentTest("/foo/*/blarg", "foo/bar", 2);
+ }
+
+ public void testStar_SegmentCountTest_1() {
+ runCountPatternSegmentsThatMatchParentTest("/foo/*", "foo", 1);
+ }
+
+ public void testStar_SegmentCountTest_2() {
+ runCountPatternSegmentsThatMatchParentTest("/foo/*", "foo/blarg", 2);
+ }
+
+ public void testStar_SegmentCountTest_3() {
+ runCountPatternSegmentsThatMatchParentTest("/foo/*", "foo", 1);
+ }
+
+ public void testStarStar_SegmentCountTest_0() {
+ runCountPatternSegmentsThatMatchParentTest("/foo/**", "foo", 1);
+ }
+
+ public void testStarStar_SegmentCountTest_1() {
+ runCountPatternSegmentsThatMatchParentTest("/foo/**", "foo/bar", 2);
+ }
+
+ public void testStarStar_SegmentCountTest_2() {
+ runCountPatternSegmentsThatMatchParentTest("/foo/**", "foo/bar/blarg", 3);
+ }
+
+ public void testStarStar_SegmentCountTest_3() {
+ runCountPatternSegmentsThatMatchParentTest("/foo/**/blarg", "foo/bar/blarg", 3);
+ }
+
+ public void testStarStar_SegmentCountTest_4() {
+ runCountPatternSegmentsThatMatchParentTest("/foo/**/blarg", "foo/bar/boo/blarg", 3);
+ }
+
+ public void testStarStar_SegmentCountTest_5() {
+ runCountPatternSegmentsThatMatchParentTest("/foo/**/blarg/nerg", "foo/bar/boo/blarg", 3);
+ }
+
+ public void testQuestionMark_SegmentCountTest_0() {
+ runCountPatternSegmentsThatMatchParentTest("foo?bar", "/fooZbar", 1);
+ }
+
+ public void testQuestionMark_SegmentCountTest_1() {
+ runCountPatternSegmentsThatMatchParentTest("foo?bar", "/foobar", 0);
+ }
+
+ public void testOneSegmentParentWithOneSegmentPattern_TransformPatternTest_0() {
+ runMakePatternRelativeToParentTest("foo", "foo", null);
+ }
+
+ public void testOneSegmentParentWithOneSegmentPattern_TransformPatternTest_1() {
+ runMakePatternRelativeToParentTest("/foo", "foo", null);
+ }
+
+ public void testOneSegmentParentWithOneSegmentPattern_TransformPatternTest_2() {
+ runMakePatternRelativeToParentTest("/foo", "foo", null);
+ }
+
+ public void testOneSegmentParentWithOneSegmentPattern_TransformPatternTest_3() {
+ runMakePatternRelativeToParentTest("foo", "foo", null);
+ }
+
+ public void testOneSegmentParentWithOneSegmentPattern_TransformPatternTest_4() {
+ runMakePatternRelativeToParentTest("/foo", "foo", null);
+ }
+
+ public void testOneSegmentParentWithTwoSegmentPattern_TransformPatternTest_0() {
+ runMakePatternRelativeToParentTest("foo/bar", "foo", "bar/");
+ }
+
+ public void testOneSegmentParentWithTwoSegmentPattern_TransformPatternTest_1() {
+ runMakePatternRelativeToParentTest("/foo/bar", "foo", "bar/");
+ }
+
+ public void testOneSegmentParentWithTwoSegmentPattern_TransformPatternTest_2() {
+ runMakePatternRelativeToParentTest("/foo/bar", "foo", "bar/");
+ }
+
+ public void testOneSegmentParentWithTwoSegmentPattern_TransformPatternTest_3() {
+ runMakePatternRelativeToParentTest("foo/bar", "/foo", "bar/");
+ }
+
+ public void testOneSegmentParentWithTwoSegmentPattern_TransformPatternTest_4() {
+ runMakePatternRelativeToParentTest("/foo/bar", "/foo", "bar/");
+ }
+
+ public void testOneSegmentParentWithTwoSegmentPattern_TransformPatternTest_5() {
+ runMakePatternRelativeToParentTest("foo/bar/", "foo", "bar/");
+ }
+
+ public void testOneSegmentParentWithTwoSegmentPattern_TransformPatternTest_6() {
+ runMakePatternRelativeToParentTest("/foo/bar/", "foo", "bar/");
+ }
+
+ public void testOneSegmentParentWithTwoSegmentPattern_TransformPatternTest_7() {
+ runMakePatternRelativeToParentTest("/foo/bar/", "foo", "bar/");
+ }
+
+ public void testOneSegmentParentWithTwoSegmentPattern_TransformPatternTest_8() {
+ runMakePatternRelativeToParentTest("foo/bar/", "/foo", "bar/");
+ }
+
+ public void testOneSegmentParentWithTwoSegmentPattern_TransformPatternTest_9() {
+ runMakePatternRelativeToParentTest("/foo/bar/", "/foo", "bar/");
+ }
+
+ public void testOneSegmentParentWithTwoSegmentPattern_TransformPatternTest_10() {
+ runMakePatternRelativeToParentTest("/foo/bar/", "/boo", null);
+ }
+
+ public void testTwoSegmentParentWithThreeSegmentPattern_TransformPatternTest_0() {
+ runMakePatternRelativeToParentTest("/foo/bar/blarg", "/foo/bar", "blarg/");
+ }
+
+ public void testStar_TransformPatternTest_0() {
+ runMakePatternRelativeToParentTest("/foo/*/blarg", "foo/bar", "blarg/");
+ }
+
+ public void testStar_TransformPatternTest_1() {
+ runMakePatternRelativeToParentTest("/foo/*", "foo", "*/");
+ }
+
+ public void testStar_TransformPatternTest_2() {
+ runMakePatternRelativeToParentTest("/foo/*", "foo/blarg/", null);
+ }
+
+ public void testStar_TransformPatternTest_3() {
+ runMakePatternRelativeToParentTest("/foo/*", "foo", "*/");
+ }
+
+ public void testStarStar_TransformPatternTest_0() {
+ runMakePatternRelativeToParentTest("/foo/**", "foo", "**/");
+ }
+
+ public void testStarStar_TransformPatternTest_1() {
+ runMakePatternRelativeToParentTest("/foo/**", "foo/bar/", null);
+ }
+
+ public void testStarStar_TransformPatternTest_2() {
+ runMakePatternRelativeToParentTest("/foo/**", "foo/bar/blarg/", null);
+ }
+
+ public void testStarStar_TransformPatternTest_3() {
+ runMakePatternRelativeToParentTest("/foo/**/blarg", "foo/bar/blarg/", null);
+ }
+
+ public void testStarStar_TransformPatternTest_4() {
+ runMakePatternRelativeToParentTest("/foo/**/blarg", "foo/bar/boo/blarg/", null);
+ }
+
+ public void testStarStar_TransformPatternTest_5() {
+ runMakePatternRelativeToParentTest("/foo/**/blarg/nerg", "foo/bar/boo/blarg", "nerg/");
+ }
+
+ public void testQuestionMark_TransformPatternTest_0() {
+ runMakePatternRelativeToParentTest("foo?bar", "/fooZbar", null);
+ }
+
+ public void testQuestionMark_TransformPatternTest_1() {
+ runMakePatternRelativeToParentTest("foo?bar", "/foobar", null);
+ }
+
+ public void testQuestionMark_TransformPatternTest_2() {
+ runMakePatternRelativeToParentTest("foo?bar/awesome", "/fooZbar", "awesome/");
+ }
+
+ public void testQuestionMark_TransformPatternTest_3() {
+ runMakePatternRelativeToParentTest("foo?bar/awesome", "/foobar", null);
+ }
+
+ /**
+ * <p>Runs a test on {@link PathUtils#countPatternSegmentsThatMatchParent(IPath, IPath)}</p>
+ *
+ * @param pattern the pattern path to test
+ * @param parentPath the parent path to test
+ * @param expectedMatchedSegments the expected number of segments in the pattern that match the parent
+ */
+ private static void runCountPatternSegmentsThatMatchParentTest(String pattern, String parentPath,
+ int expectedMatchedSegments) {
+ int matchedSegments = PathUtils.countPatternSegmentsThatMatchParent(
+ new Path(pattern), new Path(parentPath));
+
+ Assert.assertEquals("Number of matched path segments does not equal expected.", //$NON-NLS-1$
+ expectedMatchedSegments, matchedSegments);
+ }
+
+ /**
+ *
+ * <p>Runs a test on {@link PathUtils#makePatternRelativeToParent(IPath, IPath)}</p>
+ *
+ * @param pattern the pattern path to test
+ * @param parent the parent path to test
+ * @param expected the expected pattern path made relative to the parent path
+ */
+ private static void runMakePatternRelativeToParentTest(String pattern, String parent, String expected) {
+ IPath transformedPattern = PathUtils.makePatternRelativeToParent(
+ new Path(pattern), new Path(parent));
+
+ IPath expectedPath = null;
+ if(expected != null) {
+ expectedPath = new Path(expected);
+ }
+
+ Assert.assertEquals("Transformed pattern does not match expected.",
+ expectedPath, transformedPattern);
+ }
+} \ No newline at end of file

Back to the top