/** * Tests all options, checks if their default values are correct. * * @throws Exception */ public void testDefaultConfig() throws Exception { ZipalignMojo mojo = createMojo("zipalign-config-project0"); final ConfigHandler cfh = new ConfigHandler(mojo); cfh.parseConfiguration(); Boolean skip = Whitebox.getInternalState(mojo, "parsedSkip"); assertTrue("zipalign 'skip' parameter should be true", skip); Boolean verbose = Whitebox.getInternalState(mojo, "parsedVerbose"); assertFalse("zipalign 'verbose' parameter should be false", verbose); MavenProject project = Whitebox.getInternalState(mojo, "project"); String inputApk = Whitebox.getInternalState(mojo, "parsedInputApk"); File inputApkFile = new File(project.getBuild().getDirectory(), project.getBuild().getFinalName() + ".apk"); assertEquals( "zipalign 'inputApk' parameter should be equal", inputApkFile.getAbsolutePath(), inputApk); String outputApk = Whitebox.getInternalState(mojo, "parsedOutputApk"); File outputApkFile = new File( project.getBuild().getDirectory(), project.getBuild().getFinalName() + "-aligned.apk"); assertEquals( "zipalign 'outputApk' parameter should be equal", outputApkFile.getAbsolutePath(), outputApk); }
/** * Tests all parameters parsing * * <p>Probably not needed since it is like testing maven itself * * @throws Exception */ public void testConfigParse() throws Exception { ZipalignMojo mojo = createMojo("zipalign-config-project1"); final ConfigHandler cfh = new ConfigHandler(mojo); cfh.parseConfiguration(); Boolean skip = Whitebox.getInternalState(mojo, "parsedSkip"); assertFalse("zipalign 'skip' parameter should be false", skip); Boolean verbose = Whitebox.getInternalState(mojo, "parsedVerbose"); assertTrue("zipalign 'verbose' parameter should be true", verbose); String inputApk = Whitebox.getInternalState(mojo, "parsedInputApk"); assertEquals("zipalign 'inputApk' parameter should be equal", "app.apk", inputApk); String outputApk = Whitebox.getInternalState(mojo, "parsedOutputApk"); assertEquals("zipalign 'outputApk' parameter should be equal", "app-updated.apk", outputApk); }