diff options
author | Curtis D'Entremont | 2006-03-28 00:04:08 +0000 |
---|---|---|
committer | Curtis D'Entremont | 2006-03-28 00:04:08 +0000 |
commit | 00f34df469506f27923247657278c2d14f4e83cf (patch) | |
tree | ea63653bd38a724a8cbefdc9a75dc574c457cb34 /org.eclipse.ua.tests/base | |
parent | 2d87dded5e13b9da3bbadcac10ecefa02ee59a94 (diff) | |
download | eclipse.platform.ua-00f34df469506f27923247657278c2d14f4e83cf.tar.gz eclipse.platform.ua-00f34df469506f27923247657278c2d14f4e83cf.tar.xz eclipse.platform.ua-00f34df469506f27923247657278c2d14f4e83cf.zip |
132251 New: NOT function on filters
Diffstat (limited to 'org.eclipse.ua.tests/base')
-rw-r--r-- | org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java | 88 | ||||
-rw-r--r-- | org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/XHTMLUtil.java | 39 |
2 files changed, 43 insertions, 84 deletions
diff --git a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java index a00f0336c..0d44496e5 100644 --- a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java +++ b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java @@ -16,7 +16,6 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; -import org.eclipse.core.runtime.Platform; import org.osgi.framework.Bundle; /* @@ -49,91 +48,10 @@ public class FileUtil { * for the intro xml referred to by the string. */ public static String getResultFile(String in) { - return getResultFile(in, false); + return in.substring(0, in.lastIndexOf('.')) + "_expected.txt"; } /** - * Same as above, but gives the option of appending os, ws, and arch. For example, - * myfile_serialized_macosx_carbon_ppc.txt. - */ - public static String getResultFile(String in, boolean env) { - StringBuffer buf = new StringBuffer(); - buf.append(in.substring(0, in.lastIndexOf('.')) + "_serialized"); - if (env) { - buf.append('_'); - buf.append(Platform.getOS()); - buf.append('_'); - buf.append(Platform.getWS()); - buf.append('_'); - buf.append(Platform.getOSArch()); - } - buf.append(".txt"); - return buf.toString(); - } - - /** - * Gets the contents of the result file with the given original relative path in - * the given bundle, as a String (file must be encoded as UTF-8). - */ - public static String getResultFileContents(Bundle bundle, String relative) throws IOException { - /* - * Try [filename]_serialized_os_ws_arch.txt. If it's not there, try - * [filename]_serialized.txt. - * - * We use different files for os/ws/arch combinations in order to test dynamic content, - * specifically filtering. Some of the files have filters by os, ws, and arch so the - * result is different on each combination. - */ - String contents = null; - try { - contents = getContents(bundle, getResultFile(relative, true)); - } - catch(Exception e) { - // didn't find the _serialized_os_ws_arch.txt file, try just _serialized.txt - } - if (contents == null) { - try { - contents = getContents(bundle, getResultFile(relative, false)); - } - catch(IOException e) { - throw e; - } - } - return contents; - } - - /** - * Gets the contents of the result file with the given original absolute path as - * a String (file must be encoded as UTF-8). - */ - public static String getResultFileContents(String absolutePath) throws IOException { - /* - * Try [filename]_serialized_os_ws_arch.txt. If it's not there, try - * [filename]_serialized.txt. - * - * We use different files for os/ws/arch combinations in order to test dynamic content, - * specifically filtering. Some of the files have filters by os, ws, and arch so the - * result is different on each combination. - */ - String contents = null; - try { - contents = getContents(getResultFile(absolutePath, true)); - } - catch(Exception e) { - // didn't find the _serialized_os_ws_arch.txt file, try just _serialized.txt - } - if (contents == null) { - try { - contents = getContents(getResultFile(absolutePath, false)); - } - catch(IOException e) { - throw e; - } - } - return contents; - } - - /** * Reads the contents of the input stream as UTF-8 and constructs and returns * as a String. */ @@ -146,8 +64,10 @@ public class FileUtil { } String result = new String(out.toByteArray(), "UTF-8"); if (result != null) { + // filter windows-specific newline result = result.replaceAll("\r", ""); } - return result; + // ignore whitespace at start or end + return result.trim(); } } diff --git a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/XHTMLUtil.java b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/XHTMLUtil.java new file mode 100644 index 000000000..b4dda1b26 --- /dev/null +++ b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/XHTMLUtil.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * 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; + +/** + * A utility class for working with XHTML. + */ +public class XHTMLUtil { + + /* + * Some of the XHTML content is environment-specific. This means it changes + * depending on the test machine, location on filesystem, etc. This content + * is not important for this test so just strip it out before comparing the + * serializations. + */ + public static String removeEnvironmentSpecificContent(String xhtml) { + /* + * The base tag is added before showing in browser. It contains an + * absolute path in filesystem. + */ + xhtml = xhtml.replaceAll("<base href=\".*\" />", ""); + + /* + * The order of the params for the meta tag comes out differently on + * different platforms. I'm not sure why, and why just this tag. We + * don't care about this one for our tests anyway, so just strip it. + */ + xhtml = xhtml.replaceAll("<meta .*/>", ""); + return xhtml; + } +} |