    001package org.apache.turbine.util;
    002
    003
    004/*
    005 * Licensed to the Apache Software Foundation (ASF) under one
    006 * or more contributor license agreements.  See the NOTICE file
    007 * distributed with this work for additional information
    008 * regarding copyright ownership.  The ASF licenses this file
    009 * to you under the Apache License, Version 2.0 (the
    010 * "License"); you may not use this file except in compliance
    011 * with the License.  You may obtain a copy of the License at
    012 *
    013 *   http://www.apache.org/licenses/LICENSE-2.0
    014 *
    015 * Unless required by applicable law or agreed to in writing,
    016 * software distributed under the License is distributed on an
    017 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    018 * KIND, either express or implied.  See the License for the
    019 * specific language governing permissions and limitations
    020 * under the License.
    021 */
    022
    023
    024import static org.junit.Assert.assertTrue;
    025
    026import org.apache.turbine.test.BaseTestCase;
    027import org.junit.Test;
    028
    029public class FormMessageTest
    030    extends BaseTestCase
    031{
    032
    033
    034    @Test public void testCreateFormMessage()
    035    {
    036        FormMessage fm = new FormMessage("mainForm","someField","A message!");
    037        String fmString = fm.toString();
    038        assertTrue("Make sure toString works",fmString.indexOf("someField")>-1);
    039        assertTrue("Make sure toString works",fmString.indexOf("A message")>-1);
    040        assertTrue("Make sure toString works",fmString.indexOf("mainForm")>-1);
    041    }
    042
    043    @Test public void testCreateFormMessageMultipleFields()
    044    {
    045        FormMessage fm = new FormMessage("mainForm","someField","A message!");
    046        fm.setFieldName("someOtherField");
    047        String fmString = fm.toString();
    048        assertTrue("Make sure toString works",fmString.indexOf("someField")>-1);
    049        assertTrue("Make sure toString works",fmString.indexOf("someOtherField")>-1);
    050        assertTrue("Make sure toString works",fmString.indexOf("A message")>-1);
    051        assertTrue("Make sure toString works",fmString.indexOf("mainForm")>-1);
    052    }
    053}