1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.codehaus.mojo.appassembler.daemon.generic;
22
23 import java.io.File;
24
25 import javax.xml.parsers.DocumentBuilder;
26 import javax.xml.parsers.DocumentBuilderFactory;
27
28 import org.codehaus.mojo.appassembler.daemon.AbstractDaemonGeneratorTest;
29 import org.w3c.dom.Document;
30
31
32
33
34
35 public class GenericDaemonGeneratorTest
36 extends AbstractDaemonGeneratorTest
37 {
38 public void testGenerationWithAllInfoInDescriptor()
39 throws Exception
40 {
41 runTest( "generic", "src/test/resources/project-1/pom.xml", "src/test/resources/project-1/descriptor.xml",
42 "target/output-1-generic" );
43
44 File actualAppXml = new File( getTestFile( "target/output-1-generic" ), "app.xml" );
45
46 assertTrue( "config file is missing: " + actualAppXml.getAbsolutePath(), actualAppXml.isFile() );
47
48 DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
49
50 builderFactory.setIgnoringComments( true );
51 builderFactory.setIgnoringElementContentWhitespace( true );
52 DocumentBuilder builder = builderFactory.newDocumentBuilder();
53
54 Document actual = builder.parse( actualAppXml );
55
56 assertNodeEquals( "com.westerngeco.example.App", "mainClass", actual );
57 assertNodeEquals( "org/codehaus/mojo/appassembler/project-1/1.0-SNAPSHOT/project-1-1.0-SNAPSHOT.jar",
58 "relativePath", actual );
59 assertNodeEquals( "345", "initialMemorySize", actual );
60 assertNodeEquals( "234", "maxMemorySize", actual );
61 assertNodeEquals( "321", "maxStackSize", actual );
62 assertNodeEquals( "foo=bar", "systemProperty", actual );
63 assertNodeEquals( "arg1=arg1-value", "commandLineArgument", actual );
64 assertNodeNull( "commandLineArgument", actual );
65
66 }
67
68
69
70 private void assertNodeEquals( String expected, String tagName, Document document )
71 {
72 assertEquals( "Node with tag name " + tagName + " does not match", expected,
73 document.getElementsByTagName( tagName ).item( 0 ).getFirstChild().getNodeValue() );
74 }
75
76 private void assertNodeNull( String tagName, Document document )
77 {
78 assertNull( document.getElementsByTagName( tagName ).item( 1 ).getFirstChild() );
79 }
80 }