01: // Copyright 2006 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.internal.test;
16:
17: import org.testng.Assert;
18: import org.testng.annotations.DataProvider;
19: import org.testng.annotations.Test;
20:
21: public class CodeEqTest extends Assert {
22: @Test(enabled=false,dataProvider="stripValues")
23: public void strip(String input, String expected) {
24: assertEquals(CodeEq.strip(input), expected);
25: }
26:
27: @DataProvider(name="stripValues")
28: public Object[][] stripValues() {
29: return new Object[][] {
30: { "foo", "foo" },
31: { " foo\n", "foo" },
32: { " foo \nbar\n\n \tbaz", "foo bar baz" },
33: {
34: "{\n bar();\n baz();\n if (gnip())\n {\n gnop();\n }\n}\n",
35: "{bar(); baz(); if (gnip()){gnop();}}" } };
36: }
37:
38: @Test(enabled=false)
39: public void to_string() {
40: CodeEq eq = new CodeEq("{ foo(); bar(); baz(); }");
41:
42: StringBuffer buffer = new StringBuffer();
43:
44: eq.appendTo(buffer);
45:
46: assertEquals(buffer.toString(),
47: "codeEq({foo(); bar(); baz();})");
48: }
49:
50: @Test(enabled=false,dataProvider="matchValues")
51: public void matches(String pattern, String parameter,
52: boolean matches) {
53: CodeEq ceq = new CodeEq(pattern);
54:
55: assertEquals(ceq.matches(parameter), matches);
56: }
57:
58: @DataProvider(name="matchValues")
59: public Object[][] matchValues() {
60: return new Object[][] {
61: { "{ foo(); }", "{\n foo();\n}", true },
62: { " foo();", "foo ();", false }, };
63: }
64: }
|