1   /*
2    * Copyright (C) The MetaClass Group. All rights reserved.
3    *
4    * This software is published under the terms of the Spice
5    * Software License version 1.1, a copy of which has been included
6    * with this distribution in the LICENSE.txt file.
7    */
8   package org.codehaus.metaclass.tools.tasks;
9   
10  import junit.framework.TestCase;
11  import org.apache.tools.ant.BuildException;
12  
13  /***
14   * @author Peter Donald
15   * @version $Revision: 1.3 $ $Date: 2003/11/28 11:14:55 $
16   */
17  public class FormatEnumTestCase
18      extends TestCase
19  {
20      public void testBinaryFormat()
21          throws Exception
22      {
23          final FormatEnum enum = new FormatEnum();
24          enum.setValue( "binary" );
25          assertEquals( GenerateClassDescriptorsTask.BINARY_TYPE,
26                        enum.getTypeCode() );
27      }
28  
29      public void testXMLFormat()
30          throws Exception
31      {
32          final FormatEnum enum = new FormatEnum();
33          enum.setValue( "xml" );
34          assertEquals( GenerateClassDescriptorsTask.XML_TYPE,
35                        enum.getTypeCode() );
36      }
37  
38      public void testUnknownFormat()
39          throws Exception
40      {
41          final FormatEnum enum = new FormatEnum();
42          try
43          {
44              enum.setValue( "unknown" );
45          }
46          catch( BuildException e )
47          {
48              return;
49          }
50          fail( "Expected to fail to set unknown type" );
51      }
52  }