/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* See LICENSE.txt included in this distribution for the specific
* language governing permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at LICENSE.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Portions Copyright 2012 Jens Elkner.
*/
/**
* Test of the methods in <code>org.opensolaris.opengrok.web.Util</code>.
*/
public class UtilTest {
@SuppressWarnings("javadoc")
public static void setUpClass() {
// Some of the methods have different results in different locales.
// Set locale to en_US for these tests.
}
@SuppressWarnings("javadoc")
public static void tearDownClass() {
savedLocale = null;
}
@Test
public void htmlize() {
String[][] input_output = {
{"Newline\nshould become <br/>",
"Newline<br/>should become <br/>" },
{"This is a test", "This is a test" },
{"Open & Grok", "Open & Grok" },
{"&<>", "&amp;&lt;&gt;" },
};
if (i == 0) {
} else {
}
// 2 args
}
}
@Test
public void breadcrumbPath() {
assertEquals("<a href=\"/root/x\">x</a>",
assertEquals("<a href=\"/root/xx\">xx</a>",
// parent directories have a trailing slash in href
assertEquals("<a href=\"/r/a/\">a</a>/<a href=\"/r/a/b\">b</a>",
// if basename is a dir (ends with file seperator), href link also
// ends with a '/'
assertEquals("<a href=\"/r/a/\">a</a>/<a href=\"/r/a/b/\">b</a>/",
// should work the same way with a '.' as file separator
assertEquals("<a href=\"/r/java/\">java</a>." +
// suffix added to the link?
assertEquals("<a href=\"/root/xx&project=y\">xx</a>",
// compact: path needs to be resolved to /xx and no link is added
// for the virtual root directory (parent) but emitted as plain text.
// Prefix gets just prefixed as is and not mangled wrt. path -> "//"
assertEquals("/<a href=\"/root//xx&project=y\">xx</a>",
// relative pathes are resolved wrt. / , so path resolves to /a/c/d
assertEquals("/<a href=\"/r//a/\">a</a>/" +
"<a href=\"/r//a/c/\">c</a>/" +
"<a href=\"/r//a/c/d\">d</a>",
}
@Test
public void redableSize() {
assertEquals("<b>8,796,093,022,208 MiB</b>",
}
@Test
public void path2uid() {
assertEquals("\u0000etc\u0000passwd\u0000date",
}
@Test
public void uid2url() {
}
@Test
public void uriEncodeURL() {
// important to escape ", since it may terminate an attr value ...
// & handling
// as intended: encoder is not perfect - stops at 1st entity encountered
}
@Test
"foo::bar::test.js", "bl\u00E5b\u00E6rsyltet\u00F8y"
};
// Assuming this test will not be run in a sandbox and URI's internal
// decoder does the right thing. URI assumes UTF-8 encoding, what we
// use as well.
decoder.setAccessible(true);
}
}
@Test
public void formQuoteEscape() {
}
@Test
public void diffline() {
{
"\"(ses_id, mer_id, pass_id, \" + refCol +\" , mer_ref, amnt, "
+ "cur, ps_id, ret_url, d_req_time, d_req_mil, h_resp_time, "
+ "h_resp_mil) \"",
"\"(ses_id, mer_id, pass_id, \" + refCol +\" , mer_ref, amnt, "
+ "cur, ps_id, ret_url, exp_url, d_req_time, d_req_mil, "
+ "h_resp_time, h_resp_mil) \"",
"\"(ses_id, mer_id, pass_id, \" + refCol +\" , mer_ref, amnt, "
+ "cur, ps_id, ret_url, <span class=\"p\">exp_url, "
+ "</span>d_req_time, d_req_mil, h_resp_time, h_resp_mil) \""
},
{
"\"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\", values);",
"\"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\", values);",
"\"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?<span "
+ "class=\"p\">, ?</span>)\", values);"
},
{
"char *config_list = NULL;",
"char **config_list = NULL;",
"char *<span class=\"p\">*</span>config_list = NULL;"
},
{
"* An error occured or there is non-numeric stuff at the end",
"* An error occurred or there is non-numeric stuff at the end",
"* An error occur<span class=\"p\">r</span>ed or there is "
+ "non-numeric stuff at the end"
}
};
}
}
@Test
// Verify that we got a table.
// Verify that the output is well-formed.
}
@Test
public void jsStringLiteral() {
assertEquals("\"abc\\n\\r\\\"'\\\\\"",
}
}