package org.kohsuke.args4j;

import org.kohsuke.args4j.EnumAttribute.Animal;

import junit.framework.Assert;


public class EnumArgumentTest extends Args4JTestBase<EnumArgument> {

	@Override
	public EnumArgument getTestObject() {
		return new EnumArgument();
	}

	public void testSetEnum() throws CmdLineException {
		args = new String[]{"HORSE"};
		assertEquals(null, testObject.myAnimal);
		parser.parseArgument(args);
		assertEquals(Animal.HORSE, testObject.myAnimal);
	}

	public void testSetEnumCaseInsensitive() throws CmdLineException {
		args = new String[]{"horse"};
		assertEquals(null, testObject.myAnimal);
		parser.parseArgument(args);
		assertEquals(Animal.HORSE, testObject.myAnimal);
	}

	public void testIllegalArgumentOption() {
		String[] args = new String[] { "ILLEGAL_ANIMAL" };
		parseParameter(args, new EnumArgument());
	}

	private void parseParameter(String[] args, Object bean) {
		CmdLineParser parser = new CmdLineParser(bean);
		try {
			parser.parseArgument(args);
			Assert.fail();
		} catch (CmdLineException e) {
			if (args.length > 0) {
				Assert.assertTrue(
						"Illegal exception message: " + e.getMessage(),
						e.getMessage().startsWith(
								String.format("\"%s\" is not a valid value for \"", args[args.length - 1])
						));
			} else {
				Assert.assertEquals(
						"Illegal exception message: " + e.getMessage(),
						"Argument \"ANIMAL\" is required",
						e.getMessage());
			}
		}
	}

}

@@ -743,25 +743,16 @@
 n() %7B%0A%09%09
-String%5B%5D 
 args = n
@@ -789,165 +789,8 @@
  %7D;%0A
-%09%09parseParameter(args, new EnumArgument());%0A%09%7D%0A%0A%09private void parseParameter(String%5B%5D args, Object bean) %7B%0A%09%09CmdLineParser parser = new CmdLineParser(bean);%0A
 %09%09tr
@@ -879,35 +879,8 @@
 ) %7B%0A
-%09%09%09if (args.length %3E 0) %7B%0A%09
 %09%09%09A
@@ -897,17 +897,16 @@
 rtTrue(%0A
-%09
 %09%09%09%09%09%22Il
@@ -951,25 +951,24 @@
 age(),%0A%09%09%09%09%09
-%09
 e.getMessage
@@ -982,17 +982,16 @@
 tsWith(%0A
-%09
 %09%09%09%09%09%09%09S
@@ -1064,17 +1064,16 @@
 h - 1%5D)%0A
-%09
 %09%09%09%09%09));
@@ -1077,168 +1077,8 @@
 ));%0A
-%09%09%09%7D else %7B%0A%09%09%09%09Assert.assertEquals(%0A%09%09%09%09%09%09%22Illegal exception message: %22 + e.getMessage(),%0A%09%09%09%09%09%09%22Argument %5C%22ANIMAL%5C%22 is required%22,%0A%09%09%09%09%09%09e.getMessage());%0A%09%09%09%7D%0A
 %09%09%7D%0A

remove unnecessary lines. sorry.