1+ #! /bin/bash
2+ set -e
3+ echo " Running NPE fix test for jdeploy init in $( pwd) "
4+ echo " This tests that 'jdeploy init' doesn't throw NullPointerException with relative package.json path"
5+
6+ if [ -z " $JDEPLOY " ]; then
7+ echo " JDEPLOY environment variable must be set"
8+ exit 1
9+ fi
10+
11+ # Create a clean test environment
12+ rm -f package.json
13+ rm -rf dist jdeploy-bundle
14+
15+ # Create a minimal Java project structure that jdeploy can recognize
16+ mkdir -p dist
17+
18+ # Copy an existing JAR file from another test project to avoid ZipException
19+ cp ../TextEditor2/TextEditor-1.0-SNAPSHOT.jar dist/app.jar
20+
21+ # Create a minimal pom.xml to help jdeploy detect the project
22+ cat > pom.xml << 'EOF '
23+ <?xml version="1.0" encoding="UTF-8"?>
24+ <project xmlns="http://maven.apache.org/POM/4.0.0">
25+ <modelVersion>4.0.0</modelVersion>
26+ <groupId>com.test</groupId>
27+ <artifactId>npe-test-app</artifactId>
28+ <version>1.0.0</version>
29+ <name>NPE Test App</name>
30+ <build>
31+ <finalName>app</finalName>
32+ </build>
33+ </project>
34+ EOF
35+
36+ echo " Created test project structure"
37+ echo " Running 'jdeploy init --no-prompt --no-workflow'"
38+
39+ # This is the critical test: run jdeploy init
40+ # Before the fix, this would throw:
41+ # Exception in thread "main" java.lang.RuntimeException: java.lang.NullPointerException
42+ # at ca.weblite.jdeploy.JDeploy.main(JDeploy.java:714)
43+ # Caused by: java.lang.NullPointerException
44+ # at ca.weblite.jdeploy.JDeploy.init(JDeploy.java:197)
45+
46+ java -jar " $JDEPLOY " init --no-prompt --no-workflow
47+
48+ # If we get here without an exception, the NPE fix is working
49+ echo " jdeploy init completed successfully (no NPE thrown)"
50+
51+ # Verify that package.json was created
52+ if [ ! -f " package.json" ]; then
53+ echo " ERROR: package.json was not created by jdeploy init"
54+ exit 1
55+ fi
56+
57+ echo " package.json was created successfully"
58+
59+ # Verify the package.json has expected content
60+ if ! grep -q " jdeploy" package.json; then
61+ echo " ERROR: package.json does not contain jdeploy configuration"
62+ exit 1
63+ fi
64+
65+ echo " package.json contains jdeploy configuration"
66+
67+ # Clean up
68+ rm -f package.json pom.xml
69+ rm -rf dist
70+
71+ echo " InitNPETest passed: jdeploy init works without NullPointerException"
0 commit comments