All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.shale.test.base.AbstractViewControllerTestCase Maven / Gradle / Ivy

/*
 * 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.shale.test.base;

import java.util.Iterator;

/**
 * 

Abstract base class for testing ViewController * implementations.

* *

WARNING - If you choose to subclass this class, be sure * your setUp() and tearDown() methods call * super.setUp() and super.tearDown() respectively, * and that you implement your own suite() method that exposes * the test methods for your test case.

*/ public abstract class AbstractViewControllerTestCase extends AbstractJsfTestCase { // ------------------------------------------------------------ Constructors /** *

Construct a new instance of this test case.

* * @param name Test case name */ public AbstractViewControllerTestCase(String name) { super(name); } // ---------------------------------------------------- Overall Test Methods // ------------------------------------------------------ Instance Variables // ------------------------------------------------------- Protected Methods /** *

Test that the specified number of messages have been queued on the * FacesContext instance, without regard to matching a * particular client identifier.

* * @param expected The expected number of messages */ protected void checkMessageCount(int expected) { int actual = 0; Iterator messages = facesContext.getMessages(); while (messages.hasNext()) { messages.next(); actual++; } assertEquals("Complete message count", expected, actual); } /** *

Test that the specified number of messages have been queued on the * FacesContext instance, for the specified client id.

* * @param clientId Client identifier of the component for which to * count queued messages * @param expected The expected number of messages */ protected void checkMessageCount(String clientId, int expected) { int actual = 0; Iterator messages = facesContext.getMessages(clientId); while (messages.hasNext()) { messages.next(); actual++; } assertEquals("Complete message count", expected, actual); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy