View Javadoc

1   package org.apache.maven.plugin.ear;
2   
3   import org.junit.Test;
4   
5   import static junit.framework.Assert.assertEquals;
6   import static junit.framework.Assert.assertNotNull;
7   
8   /**
9    * @author Stephane Nicoll
10   */
11  public class EnvEntryTest
12  {
13  
14      public static final String DESCRIPTION = "description";
15  
16      public static final String NAME = "name";
17  
18      public static final String TYPE = Integer.class.getName();
19  
20      public static final String VALUE = "34";
21  
22      @Test
23      public void createComplete()
24      {
25          final EnvEntry envEntry = new EnvEntry( DESCRIPTION, NAME, TYPE, VALUE );
26          assertEnvEntry( envEntry, DESCRIPTION, NAME, TYPE, VALUE );
27      }
28  
29      @Test
30      public void createWithoutTypeButValue()
31      {
32          final EnvEntry envEntry = new EnvEntry( null, NAME, null, VALUE );
33          assertEnvEntry( envEntry, null, NAME, null, VALUE );
34      }
35  
36      @Test( expected = IllegalArgumentException.class )
37      public void createWithoutName()
38      {
39          new EnvEntry( DESCRIPTION, null, TYPE, VALUE );
40  
41      }
42  
43      @Test( expected = IllegalArgumentException.class )
44      public void createWithEmptyName()
45      {
46          new EnvEntry( DESCRIPTION, "", TYPE, VALUE );
47      }
48  
49      @Test( expected = IllegalArgumentException.class )
50      public void createWithNullTypeAndNoValue()
51      {
52          new EnvEntry( DESCRIPTION, NAME, null, null );
53  
54      }
55  
56      @Test( expected = IllegalArgumentException.class )
57      public void createWithEmptyTypeAndNoValue()
58      {
59          new EnvEntry( DESCRIPTION, NAME, "", null );
60  
61      }
62  
63      private void assertEnvEntry( EnvEntry actual, String description, String name, String type, String value )
64      {
65          assertNotNull( "Env entry could not be null", actual );
66          assertNotNull( "ToString could not be null", actual.toString() );
67          assertEquals( "Wrong env entry description for [" + actual + "]", description, actual.getDescription() );
68          assertEquals( "Wrong env entry name for [" + actual + "]", name, actual.getName() );
69          assertEquals( "Wrong env entry type for [" + actual + "]", type, actual.getType() );
70          assertEquals( "Wrong env entry value for [" + actual + "]", value, actual.getValue() );
71  
72      }
73  }