174
175 Map<String, Object> bundleParams = new HashMap<>();
176
177 bundleParams.put(BUILD_ROOT.getID(), tmpBase);
178
179 bundleParams.put(APP_NAME.getID(), "Smoke Test");
180 bundleParams.put(MAIN_CLASS.getID(), "hello.HelloRectangle");
181 bundleParams.put(PREFERENCES_ID.getID(), "the/really/long/preferences/id");
182 bundleParams.put(MAIN_JAR.getID(),
183 new RelativeFileSet(fakeMainJar.getParentFile(),
184 new HashSet<>(Arrays.asList(fakeMainJar)))
185 );
186 bundleParams.put(MAC_CF_BUNDLE_VERSION.getID(), "1.0." + new SimpleDateFormat("YYYYMMddHHmm").format(new Date()));
187 bundleParams.put(CLASSPATH.getID(), "mainApp.jar");
188 bundleParams.put(IDENTIFIER.getID(), "com.example.javapackager.hello.TestPackager");
189 bundleParams.put(MacAppBundler.MAC_CATEGORY.getID(), "public.app-category.developer-tools");
190 bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
191 bundleParams.put(VERBOSE.getID(), true);
192
193 if (runtimeJdk != null) {
194 bundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
195 }
196
197 boolean valid = bundler.validate(bundleParams);
198 assertTrue(valid);
199
200 File result = bundler.execute(bundleParams, new File(workDir, "smoke"));
201 System.err.println("Bundle at - " + result);
202
203 checkFiles(result);
204 }
205
206 private void checkFiles(File result) throws IOException {
207 assertNotNull(result);
208 assertTrue(result.exists());
209 assertTrue(result.length() > MIN_SIZE);
210
211 ByteArrayOutputStream baos = new ByteArrayOutputStream();
212 PrintStream printStream = new PrintStream(baos, true);
213 IOUtils.exec(
214 new ProcessBuilder("pkgutil", "--payload-files", result.getCanonicalPath()),
226 @Test
227 public void configureEverything() throws Exception {
228 AbstractBundler bundler = new MacAppStoreBundler();
229 Collection<BundlerParamInfo<?>> parameters = bundler.getBundleParameters();
230
231 Map<String, Object> bundleParams = new HashMap<>();
232
233 bundleParams.put(APP_NAME.getID(), "Everything App Name");
234 bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
235 bundleParams.put(ARGUMENTS.getID(), Arrays.asList("He Said", "She Said"));
236 bundleParams.put(BUNDLE_ID_SIGNING_PREFIX.getID(), "everything.signing.prefix.");
237 bundleParams.put(CLASSPATH.getID(), "mainApp.jar");
238 bundleParams.put(ICON_ICNS.getID(), hdpiIcon);
239 bundleParams.put(INSTALLER_SUFFIX.getID(), "-MAS-TEST");
240 bundleParams.put(JVM_OPTIONS.getID(), "-Xms128M");
241 bundleParams.put(JVM_PROPERTIES.getID(), "everything.jvm.property=everything.jvm.property.value");
242 bundleParams.put(MAC_CATEGORY.getID(), "public.app-category.developer-tools");
243 bundleParams.put(MAC_CF_BUNDLE_IDENTIFIER.getID(), "com.example.everything.cf-bundle-identifier");
244 bundleParams.put(MAC_CF_BUNDLE_NAME.getID(), "Everything CF Bundle Name");
245 bundleParams.put(MAC_CF_BUNDLE_VERSION.getID(), "8.2.0");
246 bundleParams.put(MAC_RUNTIME.getID(), runtimeJdk == null ? System.getProperty("java.home") : runtimeJdk);
247 bundleParams.put(MAIN_CLASS.getID(), "hello.HelloRectangle");
248 bundleParams.put(MAIN_JAR.getID(), "mainApp.jar");
249 bundleParams.put(PREFERENCES_ID.getID(), "everything/preferences/id");
250 bundleParams.put(PRELOADER_CLASS.getID(), "hello.HelloPreloader");
251 bundleParams.put(SIGNING_KEYCHAIN.getID(), "");
252 bundleParams.put(USER_JVM_OPTIONS.getID(), "-Xmx=256M\n");
253 bundleParams.put(VERSION.getID(), "1.2.3.4");
254
255 bundleParams.put(MAC_APP_STORE_APP_SIGNING_KEY.getID(), "3rd Party Mac Developer Application");
256 bundleParams.put(MAC_APP_STORE_ENTITLEMENTS.getID(), null);
257 bundleParams.put(MAC_APP_STORE_PKG_SIGNING_KEY.getID(), "3rd Party Mac Developer Installer");
258
259 // assert they are set
260 for (BundlerParamInfo bi : parameters) {
261 assertNotNull("Bundle args Contains " + bi.getID(), bundleParams.containsKey(bi.getID()));
262 }
263
264 // and only those are set
265 bundleParamLoop:
266 for (String s : bundleParams.keySet()) {
307 assertNotNull(bundler.getName());
308 assertNotNull(bundler.getID());
309 assertNotNull(bundler.getDescription());
310
311 Map<String, Object> bundleParams = new HashMap<>();
312
313 bundleParams.put(BUILD_ROOT.getID(), tmpBase);
314
315 bundleParams.put(APP_NAME.getID(), "Smoke Test");
316 bundleParams.put(MAIN_CLASS.getID(), "hello.HelloRectangle");
317 bundleParams.put(PREFERENCES_ID.getID(), "the/really/long/preferences/id");
318 bundleParams.put(MAIN_JAR.getID(),
319 new RelativeFileSet(fakeMainJar.getParentFile(),
320 new HashSet<>(Arrays.asList(fakeMainJar)))
321 );
322 bundleParams.put(CLASSPATH.getID(), "mainApp.jar");
323 bundleParams.put(IDENTIFIER.getID(), "com.example.javapackager.hello.TestPackager");
324 bundleParams.put(MacAppBundler.MAC_CATEGORY.getID(), "public.app-category.developer-tools");
325 bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
326 bundleParams.put(VERBOSE.getID(), true);
327 bundleParams.put(MAC_RUNTIME.getID(), jre);
328
329 boolean valid = bundler.validate(bundleParams);
330 assertTrue(valid);
331
332 File result = bundler.execute(bundleParams, new File(workDir, "jre"));
333 System.err.println("Bundle at - " + result);
334
335 checkFiles(result);
336
337 }
338
339 /**
340 * Request no signature, should be a validaiton error
341 */
342 @Test(expected = ConfigException.class)
343 public void invalidDoNotSign() throws IOException, ConfigException, UnsupportedPlatformException {
344 AbstractBundler bundler = new MacAppStoreBundler();
345
346 Map<String, Object> bundleParams = new HashMap<>();
347
348 bundleParams.put(BUILD_ROOT.getID(), tmpBase);
349
350 bundleParams.put(APP_NAME.getID(), "Smoke Test");
351 bundleParams.put(MAIN_CLASS.getID(), "hello.HelloRectangle");
352 bundleParams.put(PREFERENCES_ID.getID(), "the/really/long/preferences/id");
353 bundleParams.put(MAIN_JAR.getID(),
354 new RelativeFileSet(fakeMainJar.getParentFile(),
355 new HashSet<>(Arrays.asList(fakeMainJar)))
356 );
357 bundleParams.put(CLASSPATH.getID(), "mainApp.jar");
358 bundleParams.put(IDENTIFIER.getID(), "com.example.javapackager.hello.TestPackager");
359 bundleParams.put(MacAppBundler.MAC_CATEGORY.getID(), "public.app-category.developer-tools");
360 bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
361 bundleParams.put(VERBOSE.getID(), true);
362
363 if (runtimeJdk != null) {
364 bundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
365 }
366
367 bundleParams.put(SIGN_BUNDLE.getID(), false);
368
369 bundler.validate(bundleParams);
370 }
371 }
|
174
175 Map<String, Object> bundleParams = new HashMap<>();
176
177 bundleParams.put(BUILD_ROOT.getID(), tmpBase);
178
179 bundleParams.put(APP_NAME.getID(), "Smoke Test");
180 bundleParams.put(MAIN_CLASS.getID(), "hello.HelloRectangle");
181 bundleParams.put(PREFERENCES_ID.getID(), "the/really/long/preferences/id");
182 bundleParams.put(MAIN_JAR.getID(),
183 new RelativeFileSet(fakeMainJar.getParentFile(),
184 new HashSet<>(Arrays.asList(fakeMainJar)))
185 );
186 bundleParams.put(MAC_CF_BUNDLE_VERSION.getID(), "1.0." + new SimpleDateFormat("YYYYMMddHHmm").format(new Date()));
187 bundleParams.put(CLASSPATH.getID(), "mainApp.jar");
188 bundleParams.put(IDENTIFIER.getID(), "com.example.javapackager.hello.TestPackager");
189 bundleParams.put(MacAppBundler.MAC_CATEGORY.getID(), "public.app-category.developer-tools");
190 bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
191 bundleParams.put(VERBOSE.getID(), true);
192
193 if (runtimeJdk != null) {
194 //FIXME bundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
195 }
196
197 boolean valid = bundler.validate(bundleParams);
198 assertTrue(valid);
199
200 File result = bundler.execute(bundleParams, new File(workDir, "smoke"));
201 System.err.println("Bundle at - " + result);
202
203 checkFiles(result);
204 }
205
206 private void checkFiles(File result) throws IOException {
207 assertNotNull(result);
208 assertTrue(result.exists());
209 assertTrue(result.length() > MIN_SIZE);
210
211 ByteArrayOutputStream baos = new ByteArrayOutputStream();
212 PrintStream printStream = new PrintStream(baos, true);
213 IOUtils.exec(
214 new ProcessBuilder("pkgutil", "--payload-files", result.getCanonicalPath()),
226 @Test
227 public void configureEverything() throws Exception {
228 AbstractBundler bundler = new MacAppStoreBundler();
229 Collection<BundlerParamInfo<?>> parameters = bundler.getBundleParameters();
230
231 Map<String, Object> bundleParams = new HashMap<>();
232
233 bundleParams.put(APP_NAME.getID(), "Everything App Name");
234 bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
235 bundleParams.put(ARGUMENTS.getID(), Arrays.asList("He Said", "She Said"));
236 bundleParams.put(BUNDLE_ID_SIGNING_PREFIX.getID(), "everything.signing.prefix.");
237 bundleParams.put(CLASSPATH.getID(), "mainApp.jar");
238 bundleParams.put(ICON_ICNS.getID(), hdpiIcon);
239 bundleParams.put(INSTALLER_SUFFIX.getID(), "-MAS-TEST");
240 bundleParams.put(JVM_OPTIONS.getID(), "-Xms128M");
241 bundleParams.put(JVM_PROPERTIES.getID(), "everything.jvm.property=everything.jvm.property.value");
242 bundleParams.put(MAC_CATEGORY.getID(), "public.app-category.developer-tools");
243 bundleParams.put(MAC_CF_BUNDLE_IDENTIFIER.getID(), "com.example.everything.cf-bundle-identifier");
244 bundleParams.put(MAC_CF_BUNDLE_NAME.getID(), "Everything CF Bundle Name");
245 bundleParams.put(MAC_CF_BUNDLE_VERSION.getID(), "8.2.0");
246 //FIXME bundleParams.put(MAC_RUNTIME.getID(), runtimeJdk == null ? System.getProperty("java.home") : runtimeJdk);
247 bundleParams.put(MAIN_CLASS.getID(), "hello.HelloRectangle");
248 bundleParams.put(MAIN_JAR.getID(), "mainApp.jar");
249 bundleParams.put(PREFERENCES_ID.getID(), "everything/preferences/id");
250 bundleParams.put(PRELOADER_CLASS.getID(), "hello.HelloPreloader");
251 bundleParams.put(SIGNING_KEYCHAIN.getID(), "");
252 bundleParams.put(USER_JVM_OPTIONS.getID(), "-Xmx=256M\n");
253 bundleParams.put(VERSION.getID(), "1.2.3.4");
254
255 bundleParams.put(MAC_APP_STORE_APP_SIGNING_KEY.getID(), "3rd Party Mac Developer Application");
256 bundleParams.put(MAC_APP_STORE_ENTITLEMENTS.getID(), null);
257 bundleParams.put(MAC_APP_STORE_PKG_SIGNING_KEY.getID(), "3rd Party Mac Developer Installer");
258
259 // assert they are set
260 for (BundlerParamInfo bi : parameters) {
261 assertNotNull("Bundle args Contains " + bi.getID(), bundleParams.containsKey(bi.getID()));
262 }
263
264 // and only those are set
265 bundleParamLoop:
266 for (String s : bundleParams.keySet()) {
307 assertNotNull(bundler.getName());
308 assertNotNull(bundler.getID());
309 assertNotNull(bundler.getDescription());
310
311 Map<String, Object> bundleParams = new HashMap<>();
312
313 bundleParams.put(BUILD_ROOT.getID(), tmpBase);
314
315 bundleParams.put(APP_NAME.getID(), "Smoke Test");
316 bundleParams.put(MAIN_CLASS.getID(), "hello.HelloRectangle");
317 bundleParams.put(PREFERENCES_ID.getID(), "the/really/long/preferences/id");
318 bundleParams.put(MAIN_JAR.getID(),
319 new RelativeFileSet(fakeMainJar.getParentFile(),
320 new HashSet<>(Arrays.asList(fakeMainJar)))
321 );
322 bundleParams.put(CLASSPATH.getID(), "mainApp.jar");
323 bundleParams.put(IDENTIFIER.getID(), "com.example.javapackager.hello.TestPackager");
324 bundleParams.put(MacAppBundler.MAC_CATEGORY.getID(), "public.app-category.developer-tools");
325 bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
326 bundleParams.put(VERBOSE.getID(), true);
327 //FIXME bundleParams.put(MAC_RUNTIME.getID(), jre);
328
329 boolean valid = bundler.validate(bundleParams);
330 assertTrue(valid);
331
332 File result = bundler.execute(bundleParams, new File(workDir, "jre"));
333 System.err.println("Bundle at - " + result);
334
335 checkFiles(result);
336
337 }
338
339 /**
340 * Request no signature, should be a validaiton error
341 */
342 @Test(expected = ConfigException.class)
343 public void invalidDoNotSign() throws IOException, ConfigException, UnsupportedPlatformException {
344 AbstractBundler bundler = new MacAppStoreBundler();
345
346 Map<String, Object> bundleParams = new HashMap<>();
347
348 bundleParams.put(BUILD_ROOT.getID(), tmpBase);
349
350 bundleParams.put(APP_NAME.getID(), "Smoke Test");
351 bundleParams.put(MAIN_CLASS.getID(), "hello.HelloRectangle");
352 bundleParams.put(PREFERENCES_ID.getID(), "the/really/long/preferences/id");
353 bundleParams.put(MAIN_JAR.getID(),
354 new RelativeFileSet(fakeMainJar.getParentFile(),
355 new HashSet<>(Arrays.asList(fakeMainJar)))
356 );
357 bundleParams.put(CLASSPATH.getID(), "mainApp.jar");
358 bundleParams.put(IDENTIFIER.getID(), "com.example.javapackager.hello.TestPackager");
359 bundleParams.put(MacAppBundler.MAC_CATEGORY.getID(), "public.app-category.developer-tools");
360 bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
361 bundleParams.put(VERBOSE.getID(), true);
362
363 if (runtimeJdk != null) {
364 //FIXME bundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
365 }
366
367 bundleParams.put(SIGN_BUNDLE.getID(), false);
368
369 bundler.validate(bundleParams);
370 }
371 }
|