/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.wicket.markup.html.border;
import org.apache.wicket.WicketTestCase;
import org.apache.wicket.markup.MarkupException;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.protocol.http.MockHttpServletRequest;
/**
* Test the component: PageView
*
* @author Juergen Donnerstag
*/
public class BoxBorderTest extends WicketTestCase
{
// private static final Log log = LogFactory.getLog(BoxBorderTest.class);
/**
* Create the test.
*
* @param name
* The test name
*/
public BoxBorderTest(String name)
{
super(name);
}
/**
* Test a simply page containing the debug component
*
* @throws Exception
*/
public void test1() throws Exception
{
executeTest(BoxBorderTestPage_1.class, "BoxBorderTestPage_ExpectedResult_1.html");
}
/**
* Test a simply page containing the debug component
*
* @throws Exception
*/
public void test2() throws Exception
{
executeTest(BoxBorderTestPage_2.class, "BoxBorderTestPage_ExpectedResult_2.html");
}
/**
* Test a simply page containing the debug component
*
* @throws Exception
*/
public void test3() throws Exception
{
executeTest(BoxBorderTestPage_3.class, "BoxBorderTestPage_ExpectedResult_3.html");
Border border = (Border)tester.getLastRenderedPage().get("border");
Form form = (Form)tester.getLastRenderedPage().get("border:myForm");
TextField input = (TextField)tester.getLastRenderedPage().get("border:name");
assertEquals("", input.getModelObjectAsString());
tester.setupRequestAndResponse();
MockHttpServletRequest mockRequest = tester.getServletRequest();
mockRequest.setRequestToComponent(form);
mockRequest.setParameter(input.getInputName(), "jdo");
tester.processRequestCycle();
input = (TextField)tester.getLastRenderedPage().get("border:name");
assertEquals("jdo", input.getModelObjectAsString());
}
/**
* Test to ensure MarkupException is thrown when Markup and Object hierarchy
* does not match with a Border involved.
*
* @throws Exception
*/
public void test4() throws Exception
{
Class pageClass = BorderTestHierarchyPage_4.class;
System.out.println("=== " + pageClass.getName() + " ===");
MarkupException markupException = null;
try
{
tester.startPage(pageClass);
}
catch (MarkupException e)
{
markupException = e;
}
assertNotNull("Markup does not match component hierarchy, but exception not thrown.",
markupException);
}
/**
* Test to ensure border render wrapped settings functions properly.
*
* @throws Exception
*/
public void testRenderWrapped() throws Exception
{
executeTest(BorderRenderWrappedTestPage_1.class,
"BorderRenderWrappedTestPage_ExpectedResult_1.html");
}
/**
* Test a simply page containing the debug component
*
* @throws Exception
*/
public void test5() throws Exception
{
executeTest(BoxBorderTestPage_5.class, "BoxBorderTestPage_ExpectedResult_5.html");
}
/**
* Test a simply page containing the debug component
*
* @throws Exception
*/
public void test6() throws Exception
{
executeTest(BoxBorderTestPage_6.class, "BoxBorderTestPage_ExpectedResult_6.html");
}
}