1   package org.apache.turbine.util;
2   
3   /*
4    * Copyright 2001-2005 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License")
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import org.apache.turbine.test.BaseTestCase;
20  
21  public class FormMessageTest
22      extends BaseTestCase
23  {
24      public FormMessageTest(String name)
25              throws Exception
26      {
27          super(name);
28      }
29  
30      public void testCreateFormMessage()
31      {
32          FormMessage fm = new FormMessage("mainForm","someField","A message!");
33          String fmString = fm.toString();
34          assertTrue("Make sure toString works",fmString.indexOf("someField")>-1);
35          assertTrue("Make sure toString works",fmString.indexOf("A message")>-1);
36          assertTrue("Make sure toString works",fmString.indexOf("mainForm")>-1);
37      }
38  
39      public void testCreateFormMessageMultipleFields()
40      {
41          FormMessage fm = new FormMessage("mainForm","someField","A message!");
42          fm.setFieldName("someOtherField");
43          String fmString = fm.toString();
44          assertTrue("Make sure toString works",fmString.indexOf("someField")>-1);
45          assertTrue("Make sure toString works",fmString.indexOf("someOtherField")>-1);
46          assertTrue("Make sure toString works",fmString.indexOf("A message")>-1);
47          assertTrue("Make sure toString works",fmString.indexOf("mainForm")>-1);
48      }
49  }