use of com.android.tools.build.bundletool.model.exceptions.InvalidCommandException in project bundletool by google.
the class InstallMultiApksCommandTest method fromFlags_exclusiveApksOptions.
@Test
public void fromFlags_exclusiveApksOptions() {
Path apkDir = tmpDir.resolve("apk_dir");
Path apkFile1 = apkDir.resolve("file1.apks");
Path apkFile2 = apkDir.resolve("file2.apks");
Path zipFile = tmpDir.resolve("container.zip");
InvalidCommandException e = assertThrows(InvalidCommandException.class, () -> InstallMultiApksCommand.fromFlags(new FlagParser().parse(String.format("--apks=%s,%s", apkFile1, apkFile2), "--apks-zip=" + zipFile), systemEnvironmentProvider, fakeServerOneDevice(qDeviceWithLocales("en-US"))));
assertThat(e).hasMessageThat().contains("Exactly one of");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidCommandException in project bundletool by google.
the class ApkMatcherTest method apkMatch_withModuleNameFiltering_instantApks_checksModuleName_exists.
@Test
public void apkMatch_withModuleNameFiltering_instantApks_checksModuleName_exists() {
DeviceSpec device = deviceWithSdk(21);
ZipPath apk = ZipPath.create("master-de-fr.apk");
BuildApksResult buildApksResult = buildApksResult(createVariant(VariantTargeting.getDefaultInstance(), splitApkSet(/* moduleName= */
"base", instantApkDescription(ApkTargeting.getDefaultInstance(), apk))));
Optional<ImmutableSet<String>> allModules = Optional.empty();
assertThat(createInstantMatcher(device, allModules).getMatchingApks(buildApksResult)).containsExactly(baseMatchedApk(apk));
Optional<ImmutableSet<String>> baseModuleOnly = Optional.of(ImmutableSet.of("base"));
assertThat(createInstantMatcher(device, baseModuleOnly).getMatchingApks(buildApksResult)).containsExactly(baseMatchedApk(apk));
Optional<ImmutableSet<String>> unknownModuleOnly = Optional.of(ImmutableSet.of("unknown_module"));
InvalidCommandException exception = assertThrows(InvalidCommandException.class, () -> createInstantMatcher(device, unknownModuleOnly).getMatchingApks(buildApksResult));
assertThat(exception).hasMessageThat().contains("The APK Set archive does not contain the following modules: [unknown_module]");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidCommandException in project bundletool by google.
the class BuildApksCommandTest method oldestSignerFlag_noLineage_fails.
@Test
public void oldestSignerFlag_noLineage_fails() {
InvalidCommandException e = assertThrows(InvalidCommandException.class, () -> BuildApksCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--aapt2=" + AAPT2_PATH, "--ks=" + keystorePath, "--ks-key-alias=" + KEY_ALIAS, "--ks-pass=pass:" + KEYSTORE_PASSWORD, "--key-pass=pass:" + KEY_PASSWORD, "--oldest-signer=" + oldestSignerPropertiesPath), fakeAdbServer));
assertThat(e).hasMessageThat().isEqualTo("Flag 'lineage' is required when 'oldest-signer' is set.");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidCommandException in project bundletool by google.
the class BuildApksCommandTest method keystoreFlags_keystoreNotSet.
@Test
public void keystoreFlags_keystoreNotSet() {
InvalidCommandException e = assertThrows(InvalidCommandException.class, () -> BuildApksCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--aapt2=" + AAPT2_PATH, "--ks-key-alias=" + KEY_ALIAS), fakeAdbServer));
assertThat(e).hasMessageThat().isEqualTo("Flag --ks is required when --ks-key-alias is set.");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidCommandException in project bundletool by google.
the class BuildApksCommandTest method stampKeystoreFlags_noKeystore_fails.
@Test
public void stampKeystoreFlags_noKeystore_fails() throws Exception {
SystemEnvironmentProvider provider = new FakeSystemEnvironmentProvider(/* variables= */
ImmutableMap.of(ANDROID_HOME, "/android/home", ANDROID_SERIAL, DEVICE_ID), /* properties= */
ImmutableMap.of(USER_HOME.key(), "/"));
ByteArrayOutputStream output = new ByteArrayOutputStream();
InvalidCommandException e = assertThrows(InvalidCommandException.class, () -> BuildApksCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--aapt2=" + AAPT2_PATH, "--create-stamp=" + true), new PrintStream(output), provider, fakeAdbServer));
assertThat(e).hasMessageThat().isEqualTo("No key was found to sign the stamp.");
}
Aggregations