1 package org.apache.maven.plugins.ear;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.junit.Test;
23
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertNotNull;
26
27
28
29
30 public class EnvEntryTest
31 {
32
33 public static final String DESCRIPTION = "description";
34
35 public static final String NAME = "name";
36
37 public static final String TYPE = Integer.class.getName();
38
39 public static final String VALUE = "34";
40
41 public static final String LOOKUP_NAME = "lookupName";
42
43 @Test
44 public void createComplete()
45 {
46 final EnvEntry envEntry = new EnvEntry( DESCRIPTION, NAME, TYPE, VALUE, LOOKUP_NAME );
47 assertEnvEntry( envEntry, DESCRIPTION, NAME, TYPE, VALUE, LOOKUP_NAME );
48 }
49
50 @Test
51 public void createWithoutTypeButValue()
52 {
53 final EnvEntry envEntry = new EnvEntry( null, NAME, null, VALUE, LOOKUP_NAME );
54 assertEnvEntry( envEntry, null, NAME, null, VALUE, LOOKUP_NAME );
55 }
56
57 @Test( expected = IllegalArgumentException.class )
58 public void createWithoutName()
59 {
60 new EnvEntry( DESCRIPTION, null, TYPE, VALUE, LOOKUP_NAME );
61
62 }
63
64 @Test( expected = IllegalArgumentException.class )
65 public void createWithEmptyName()
66 {
67 new EnvEntry( DESCRIPTION, "", TYPE, VALUE, LOOKUP_NAME );
68 }
69
70 @Test( expected = IllegalArgumentException.class )
71 public void createWithNullTypeAndNoValue()
72 {
73 new EnvEntry( DESCRIPTION, NAME, null, null, LOOKUP_NAME );
74 }
75
76 @Test( expected = IllegalArgumentException.class )
77 public void createWithEmptyTypeAndNoValue()
78 {
79 new EnvEntry( DESCRIPTION, NAME, "", null, LOOKUP_NAME );
80 }
81
82 @Test
83 public void createWithEmptyLookupName()
84 {
85 new EnvEntry( DESCRIPTION, NAME, TYPE, VALUE, null );
86 }
87
88 private void assertEnvEntry( EnvEntry actual, String description, String name, String type, String value,
89 String lookupName )
90 {
91 assertNotNull( "Env entry could not be null", actual );
92 assertNotNull( "ToString could not be null", actual.toString() );
93 assertEquals( "Wrong env entry description for [" + actual + "]", description, actual.getDescription() );
94 assertEquals( "Wrong env entry name for [" + actual + "]", name, actual.getName() );
95 assertEquals( "Wrong env entry type for [" + actual + "]", type, actual.getType() );
96 assertEquals( "Wrong env entry value for [" + actual + "]", value, actual.getValue() );
97 assertEquals( "Wrong env entry value for [" + actual + "]", lookupName, actual.getLookupName() );
98
99 }
100 }