23 * questions.
24 */
25
26 package com.oracle.bundlers.mac;
27
28 import com.oracle.bundlers.*;
29 import com.oracle.bundlers.Bundler;
30 import com.sun.javafx.tools.packager.Log;
31 import com.sun.javafx.tools.packager.bundlers.*;
32 import org.junit.After;
33 import org.junit.Assume;
34 import org.junit.Before;
35 import org.junit.BeforeClass;
36 import org.junit.Test;
37
38 import java.io.File;
39 import java.io.IOException;
40 import java.nio.file.Files;
41 import java.util.*;
42
43 import static org.junit.Assert.assertNotNull;
44 import static org.junit.Assert.assertTrue;
45
46 public class MacPKGBundlerTest {
47
48 static File tmpBase;
49 static File workDir;
50 static File appResourcesDir;
51 static File fakeMainJar;
52 static Set<File> appResources;
53 static boolean retain = false;
54
55 @BeforeClass
56 public static void prepareApp() {
57 // only run on mac
58 Assume.assumeTrue(System.getProperty("os.name").toLowerCase().contains("os x"));
59
60 Log.setLogger(new Log.Logger(true));
61
62 retain = Boolean.parseBoolean(System.getProperty("RETAIN_PACKAGER_TESTS"));
94 }
95 }
96 }
97 boolean success;
98 try {
99 success = !tmpBase.exists() || tmpBase.delete();
100 } catch (SecurityException se) {
101 success = false;
102 }
103 if (!success) {
104 System.err.println("Could not clean up " + tmpBase.toString());
105 }
106 }
107
108 /**
109 * See if smoke comes out
110 */
111 @Test
112 public void smokeTest() throws IOException, ConfigException, UnsupportedPlatformException {
113 AbstractBundler bundler = new MacPKGBundler();
114 bundler.setVerbose(true);
115
116 assertNotNull(bundler.getName());
117 assertNotNull(bundler.getID());
118 assertNotNull(bundler.getDescription());
119 //assertNotNull(bundler.getBundleParameters());
120
121 Map<String, Object> bundleParams = new HashMap<>();
122
123 bundleParams.put(StandardBundlerParam.BUILD_ROOT.getID(), tmpBase);
124
125 bundleParams.put(StandardBundlerParam.NAME.getID(), "Smoke");
126 bundleParams.put(StandardBundlerParam.MAIN_CLASS.getID(), "hello.TestPackager");
127 bundleParams.put(StandardBundlerParam.APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
128
129 bundleParams.put(StandardBundlerParam.RUNTIME.getID(),
130 StandardBundlerParam.extractJreAsRelativeFileSet("~/tools/jdk1.8.0.jdk/Contents/Home/jre"));
131
132 bundler.execute(bundleParams, new File(workDir, "smoke"));
133 }
134
135 /**
136 * The bare minimum configuration needed to make it work
137 * <ul>
138 * <li>Where to build it</li>
139 * <li>The jar containing the application (with a main-class attribute)</li>
140 * </ul>
141 *
142 * All other values will be driven off of those two values.
143 */
144 @Test
145 public void minimumConfig() throws IOException, ConfigException, UnsupportedPlatformException {
146 Bundler bundler = new MacPKGBundler();
147 ((AbstractBundler)bundler).setVerbose(true);
148
149 Map<String, Object> bundleParams = new HashMap<>();
150
151 bundleParams.put(StandardBundlerParam.BUILD_ROOT.getID(), tmpBase);
152
153 bundleParams.put(StandardBundlerParam.NAME.getID(), "Smoke");
154 bundleParams.put(StandardBundlerParam.APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
155
156 File output = bundler.execute(bundleParams, new File(workDir, "BareMinimum"));
157 System.err.println(output);
158 assertTrue(output.isFile());
159 //TODO assert file name
160 }
161 }
|
23 * questions.
24 */
25
26 package com.oracle.bundlers.mac;
27
28 import com.oracle.bundlers.*;
29 import com.oracle.bundlers.Bundler;
30 import com.sun.javafx.tools.packager.Log;
31 import com.sun.javafx.tools.packager.bundlers.*;
32 import org.junit.After;
33 import org.junit.Assume;
34 import org.junit.Before;
35 import org.junit.BeforeClass;
36 import org.junit.Test;
37
38 import java.io.File;
39 import java.io.IOException;
40 import java.nio.file.Files;
41 import java.util.*;
42
43 import static com.oracle.bundlers.StandardBundlerParam.*;
44 import static org.junit.Assert.assertNotNull;
45 import static org.junit.Assert.assertTrue;
46
47 public class MacPKGBundlerTest {
48
49 static File tmpBase;
50 static File workDir;
51 static File appResourcesDir;
52 static File fakeMainJar;
53 static Set<File> appResources;
54 static boolean retain = false;
55
56 @BeforeClass
57 public static void prepareApp() {
58 // only run on mac
59 Assume.assumeTrue(System.getProperty("os.name").toLowerCase().contains("os x"));
60
61 Log.setLogger(new Log.Logger(true));
62
63 retain = Boolean.parseBoolean(System.getProperty("RETAIN_PACKAGER_TESTS"));
95 }
96 }
97 }
98 boolean success;
99 try {
100 success = !tmpBase.exists() || tmpBase.delete();
101 } catch (SecurityException se) {
102 success = false;
103 }
104 if (!success) {
105 System.err.println("Could not clean up " + tmpBase.toString());
106 }
107 }
108
109 /**
110 * See if smoke comes out
111 */
112 @Test
113 public void smokeTest() throws IOException, ConfigException, UnsupportedPlatformException {
114 AbstractBundler bundler = new MacPKGBundler();
115
116 assertNotNull(bundler.getName());
117 assertNotNull(bundler.getID());
118 assertNotNull(bundler.getDescription());
119 //assertNotNull(bundler.getBundleParameters());
120
121 Map<String, Object> bundleParams = new HashMap<>();
122
123 bundleParams.put(BUILD_ROOT.getID(), tmpBase);
124
125 bundleParams.put(APP_NAME.getID(), "Smoke");
126 bundleParams.put(MAIN_CLASS.getID(), "hello.TestPackager");
127 bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
128 bundleParams.put(VERBOSE.getID(), true);
129
130 // bundleParams.put(StandardBundlerParam.RUNTIME.getID(),
131 // JreUtils.extractJreAsRelativeFileSet(MacAppBundler.adjustMacRuntimePath(System.getProperty("java.home")),
132 // MacAppBundler.macJDKRules));
133
134 File result = bundler.execute(bundleParams, new File(workDir, "smoke"));
135 System.err.println("Bundle at - " + result);
136 assertNotNull(result);
137 assertTrue(result.exists());
138 }
139
140 /**
141 * The bare minimum configuration needed to make it work
142 * <ul>
143 * <li>Where to build it</li>
144 * <li>The jar containing the application (with a main-class attribute)</li>
145 * </ul>
146 *
147 * All other values will be driven off of those two values.
148 */
149 @Test
150 public void minimumConfig() throws IOException, ConfigException, UnsupportedPlatformException {
151 Bundler bundler = new MacPKGBundler();
152
153 Map<String, Object> bundleParams = new HashMap<>();
154
155 bundleParams.put(BUILD_ROOT.getID(), tmpBase);
156
157 bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
158
159 File output = bundler.execute(bundleParams, new File(workDir, "BareMinimum"));
160 System.err.println("Bundle at - " + output);
161 assertNotNull(output);
162 assertTrue(output.exists());
163 }
164 }
|