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