Search in sources :

Example 6 with CommandExecutionException

use of com.android.tools.build.bundletool.model.exceptions.CommandExecutionException in project bundletool by google.

the class FusingAndroidManifestMergerTest method noBaseManifest_throws.

@Test
public void noBaseManifest_throws() {
    SetMultimap<BundleModuleName, AndroidManifest> manifests = ImmutableSetMultimap.of(BundleModuleName.create("feature"), AndroidManifest.create(androidManifest("com.testapp")));
    CommandExecutionException exception = assertThrows(CommandExecutionException.class, () -> createMerger(Mode.REPLACE).merge(manifests));
    assertThat(exception).hasMessageThat().isEqualTo("Expected to have base module.");
}
Also used : BundleModuleName(com.android.tools.build.bundletool.model.BundleModuleName) AndroidManifest(com.android.tools.build.bundletool.model.AndroidManifest) CommandExecutionException(com.android.tools.build.bundletool.model.exceptions.CommandExecutionException) Test(org.junit.Test)

Example 7 with CommandExecutionException

use of com.android.tools.build.bundletool.model.exceptions.CommandExecutionException in project bundletool by google.

the class KeystorePropertiesTest method readFromFile_missingKeystorePath.

@Test
public void readFromFile_missingKeystorePath() throws Exception {
    Path keystorePropertiesPath = createPropertiesFile(null, KEY_ALIAS, null, null);
    CommandExecutionException e = assertThrows(CommandExecutionException.class, () -> KeystoreProperties.readFromFile(keystorePropertiesPath));
    assertThat(e).hasMessageThat().contains(String.format("No value was given for property 'ks' in %s.", keystorePropertiesPath));
}
Also used : Path(java.nio.file.Path) CommandExecutionException(com.android.tools.build.bundletool.model.exceptions.CommandExecutionException) Test(org.junit.Test)

Example 8 with CommandExecutionException

use of com.android.tools.build.bundletool.model.exceptions.CommandExecutionException in project bundletool by google.

the class SigningConfigurationTest method extractFromKeystore_wrongKeyPassword.

@Test
public void extractFromKeystore_wrongKeyPassword() throws Exception {
    Path keystorePath = createKeystore();
    CommandExecutionException e = assertThrows(CommandExecutionException.class, () -> SigningConfiguration.extractFromKeystore(keystorePath, KEY_ALIAS, Optional.of(Password.createForTest(KEYSTORE_PASSWORD)), Optional.of(Password.createForTest("WrongPassword"))));
    assertThat(e).hasMessageThat().contains("Incorrect key password");
}
Also used : Path(java.nio.file.Path) CommandExecutionException(com.android.tools.build.bundletool.model.exceptions.CommandExecutionException) Test(org.junit.Test)

Example 9 with CommandExecutionException

use of com.android.tools.build.bundletool.model.exceptions.CommandExecutionException in project bundletool by google.

the class SigningConfigurationTest method extractFromKeystore_keyAliasDoesNotExist.

@Test
public void extractFromKeystore_keyAliasDoesNotExist() throws Exception {
    Path keystorePath = createKeystore();
    CommandExecutionException e = assertThrows(CommandExecutionException.class, () -> SigningConfiguration.extractFromKeystore(keystorePath, "BadKeyAlias", Optional.of(Password.createForTest(KEYSTORE_PASSWORD)), Optional.of(Password.createForTest(KEY_PASSWORD))));
    assertThat(e).hasMessageThat().contains("No key found with alias 'BadKeyAlias'");
}
Also used : Path(java.nio.file.Path) CommandExecutionException(com.android.tools.build.bundletool.model.exceptions.CommandExecutionException) Test(org.junit.Test)

Example 10 with CommandExecutionException

use of com.android.tools.build.bundletool.model.exceptions.CommandExecutionException in project bundletool by google.

the class KeystorePropertiesTest method readFromFile_missingKeyAlias.

@Test
public void readFromFile_missingKeyAlias() throws Exception {
    Path keystorePropertiesPath = createPropertiesFile(KEYSTORE_PATH, null, null, null);
    CommandExecutionException e = assertThrows(CommandExecutionException.class, () -> KeystoreProperties.readFromFile(keystorePropertiesPath));
    assertThat(e).hasMessageThat().contains(String.format("No value was given for property 'ks-key-alias' in %s.", keystorePropertiesPath));
}
Also used : Path(java.nio.file.Path) CommandExecutionException(com.android.tools.build.bundletool.model.exceptions.CommandExecutionException) Test(org.junit.Test)

Aggregations

CommandExecutionException (com.android.tools.build.bundletool.model.exceptions.CommandExecutionException)16 Test (org.junit.Test)16 Path (java.nio.file.Path)6 AndroidManifest (com.android.tools.build.bundletool.model.AndroidManifest)3 BundleModuleName (com.android.tools.build.bundletool.model.BundleModuleName)3 ApkTargeting (com.android.bundle.Targeting.ApkTargeting)2 BundleModule (com.android.tools.build.bundletool.model.BundleModule)2 BundleModuleBuilder (com.android.tools.build.bundletool.testing.BundleModuleBuilder)2 TargetingUtils.mergeApkTargeting (com.android.tools.build.bundletool.testing.TargetingUtils.mergeApkTargeting)2 FlagParser (com.android.tools.build.bundletool.flags.FlagParser)1