1 package org.codehaus.plexus.compiler;
2
3 import java.util.Iterator;
4 import java.util.Map;
5
6 import org.junit.jupiter.api.BeforeEach;
7 import org.junit.jupiter.api.Test;
8
9 import static org.hamcrest.MatcherAssert.assertThat;
10 import static org.hamcrest.Matchers.is;
11
12 public class CompilerConfigurationTest {
13 private CompilerConfiguration configuration;
14
15 @BeforeEach
16 protected void setUp() throws Exception {
17 configuration = new CompilerConfiguration();
18 }
19
20 @Test
21 public void testCustomArguments() {
22 configuration.addCompilerCustomArgument("--add-exports", "FROM-MOD/package1=OTHER-MOD");
23 configuration.addCompilerCustomArgument("--add-exports", "FROM-MOD/package2=OTHER-MOD");
24
25 assertThat(configuration.getCustomCompilerArgumentsAsMap().size(), is(1));
26 assertThat(
27 configuration.getCustomCompilerArgumentsAsMap().get("--add-exports"),
28 is("FROM-MOD/package2=OTHER-MOD"));
29
30 assertThat(configuration.getCustomCompilerArgumentsEntries().size(), is(2));
31 Iterator<Map.Entry<String, String>> entries =
32 configuration.getCustomCompilerArgumentsEntries().iterator();
33 Map.Entry<String, String> entry;
34
35 entry = entries.next();
36 assertThat(entry.getKey(), is("--add-exports"));
37 assertThat(entry.getValue(), is("FROM-MOD/package1=OTHER-MOD"));
38 entry = entries.next();
39 assertThat(entry.getKey(), is("--add-exports"));
40 assertThat(entry.getValue(), is("FROM-MOD/package2=OTHER-MOD"));
41 }
42 }