1 package com.lexicalscope.jewel.cli.examples; 2 3 import static org.junit.Assert.*; 4 5 import org.junit.Test; 6 7 import com.lexicalscope.jewel.UtilitiesForTesting; 8 import com.lexicalscope.jewel.cli.Cli; 9 import com.lexicalscope.jewel.cli.CliFactory; 10 import com.lexicalscope.jewel.cli.ArgumentValidationException; 11 12 public class TestHelpExample { 13 private static final String HELP_MESSAGE = 14 UtilitiesForTesting 15 .joinLines( 16 "The options available are:", 17 "\t--count value", 18 "\t--email /^[^\\S@]+@[\\w.]+$/ : your email address", 19 "\t[--help -h] : display help", 20 "\t--location value : the location of something", 21 "\t--firstLongName --secondLongName -m -n value : many aliases", 22 "\t--pattern -p value : a pattern"); 23 24 @Test public void testHelpExample() { 25 final Cli<HelpExample> cli = CliFactory.createCli(HelpExample.class); 26 27 assertEquals(HELP_MESSAGE, cli.getHelpMessage()); 28 29 try { 30 cli.parseArguments("--help"); 31 fail("Help was requested"); 32 } catch (final ArgumentValidationException e) { 33 assertEquals(HELP_MESSAGE, e.getMessage()); 34 } 35 } 36 }