Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCurtis D'Entremont2006-10-12 23:32:29 +0000
committerCurtis D'Entremont2006-10-12 23:32:29 +0000
commit8086790b674c974c31df4b5b3f4cf3daa5370f96 (patch)
tree973aa5945a1d937a41f1f43bdf4a9fc4bfe33533 /org.eclipse.ua.tests/base/org/eclipse/ua/tests/util
parentfd2e96ad8dd417c3c1edb4e655e3d380c26e4779 (diff)
downloadeclipse.platform.ua-8086790b674c974c31df4b5b3f4cf3daa5370f96.tar.gz
eclipse.platform.ua-8086790b674c974c31df4b5b3f4cf3daa5370f96.tar.xz
eclipse.platform.ua-8086790b674c974c31df4b5b3f4cf3daa5370f96.zip
refactoring; rewrote dynamic content processing
Diffstat (limited to 'org.eclipse.ua.tests/base/org/eclipse/ua/tests/util')
-rw-r--r--org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/ResourceFinder.java18
-rw-r--r--org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/XMLUtil.java38
2 files changed, 56 insertions, 0 deletions
diff --git a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/ResourceFinder.java b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/ResourceFinder.java
index 9a4569b3b..f3bb73d29 100644
--- a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/ResourceFinder.java
+++ b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/ResourceFinder.java
@@ -15,12 +15,14 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Enumeration;
import java.util.List;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.Bundle;
/*
* Utility methods for finding resources.
@@ -105,4 +107,20 @@ public class ResourceFinder {
list.toArray(array);
return array;
}
+
+ /*
+ * Finds all files in the given bundle under the given path that end with
+ * the given suffix. Returns bundle-relative paths.
+ */
+ public static String[] findFiles(Bundle bundle, String path, String suffix) {
+ List list = new ArrayList();
+ Enumeration e = bundle.getEntryPaths(path);
+ while (e.hasMoreElements()) {
+ String entry = (String)e.nextElement();
+ if (entry.endsWith(suffix)) {
+ list.add(entry);
+ }
+ }
+ return (String[])list.toArray(new String[list.size()]);
+ }
}
diff --git a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/XMLUtil.java b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/XMLUtil.java
new file mode 100644
index 000000000..19d2bfb7b
--- /dev/null
+++ b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/XMLUtil.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ua.tests.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import junit.framework.Assert;
+
+import org.eclipse.help.internal.dynamic.DOMProcessorHandler;
+import org.eclipse.help.internal.dynamic.XMLProcessor;
+
+/**
+ * A utility class for working with XML.
+ */
+public class XMLUtil extends Assert {
+
+ public static void assertXMLEquals(String msg, String s1, String s2) throws Exception {
+ InputStream in1 = new ByteArrayInputStream(s1.getBytes("UTF-8"));
+ InputStream in2 = new ByteArrayInputStream(s2.getBytes("UTF-8"));
+ assertXMLEquals(msg, in1, in2);
+ }
+
+ public static void assertXMLEquals(String msg, InputStream in1, InputStream in2) throws Exception {
+ XMLProcessor processor = new XMLProcessor(new DOMProcessorHandler[0]);
+ String s1 = FileUtil.readString(processor.process(in1, null));
+ String s2 = FileUtil.readString(processor.process(in2, null));
+ assertEquals(msg, s1, s2);
+ }
+}

Back to the top