01: // Copyright 2006, 2007 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.integration.pagelevel;
16:
17: import java.util.Map;
18:
19: import org.apache.tapestry.dom.Document;
20: import org.apache.tapestry.dom.Element;
21: import org.apache.tapestry.ioc.internal.util.CollectionFactory;
22: import org.apache.tapestry.test.PageTester;
23: import org.testng.Assert;
24: import org.testng.annotations.AfterMethod;
25: import org.testng.annotations.Test;
26:
27: public class FormTest extends Assert {
28: private PageTester _tester;
29:
30: @Test
31: public void submit_form() {
32: String appPackage = "org.apache.tapestry.integration.app2";
33: String appName = "";
34: _tester = new PageTester(appPackage, appName);
35: Document doc = _tester.renderPage("TestPageForForm");
36: Element form = doc.getElementById("form1");
37: Map<String, String> fieldValues = CollectionFactory.newMap();
38: fieldValues.put("t1", "hello");
39: doc = _tester.submitForm(form, fieldValues);
40: assertTrue(doc.toString().contains("You entered: hello"));
41: }
42:
43: @AfterMethod
44: public void after() {
45: if (_tester != null) {
46: _tester.shutdown();
47: }
48: }
49: }
|