title: Junit testing for a class with strings
body: <pre><code>//DOC Datatype Constants
  public enum DocDatatype {
  
      PROFILE("Profile"),
  
      SUPPORT_DETAIL("SupportDetail"),
  
      MISC_PAGE("MiscPage"),
  
  String name;
  
      DocDatatype(String name) {
          this.name = name;
      }
  
      public String getName() {
          return name;
      }
  
      // the identifierMethod
      public String toString() {
          return name;
      }
  
      // the valueOfMethod
      public static DocDatatype fromString(String value) {
          for (DocDatatype type : DocDatatype.values()) {
              if (type.getName().equals(value))
                  return type;
          }
  
          throw new java.lang.IllegalArgumentException(value
                  + " is Not valid dmDataType");
      }
  }
  </code></pre>
  
  <p>I have written the junit test case in this way. Whether it is right way to write or wrong way...?</p>
  
  <pre><code>public class DocDatatypeTest {
  
      private static final Log logger = LogFactory
              .getLog(TreeConstantTest.class);
  
      @Test
      public void testDocDatatypeFromName()
      {
          DocDatatype d= DocDatatype.fromString("Profile");
  
          assertTrue((d.toString().compareToIgnoreCase("PROFILE") == 0));
  
      }
  
      @Test
      public void testDocDatatypeFromName1()
      {
          DocDatatype d = DocDatatype.fromString("SupportDetail");
          assertTrue((d.toString().compareToIgnoreCase("SUPPORT_DETAIL") == 0 ));
      }
  
      }
  }
  </code></pre>