Search in sources :

Example 6 with InvalidBundleException

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

the class ApexBundleValidatorTest method validateModule_missingPackageFromApexManifest_throws.

@Test
public void validateModule_missingPackageFromApexManifest_throws() throws Exception {
    BundleModule apexModule = new BundleModuleBuilder("apexTestModule").setManifest(androidManifest(PKG_NAME)).setApexConfig(APEX_CONFIG).addFile(APEX_MANIFEST_PATH, ApexManifest.getDefaultInstance().toByteArray()).addFile("apex/x86_64.img").addFile("apex/x86.img").addFile("apex/armeabi-v7a.img").addFile("apex/arm64-v8a.img").build();
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new ApexBundleValidator().validateModule(apexModule));
    assertThat(exception).hasMessageThat().contains("APEX manifest must have a package name");
}
Also used : BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 7 with InvalidBundleException

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

the class ApexBundleValidatorTest method validateAllModules_multipleApexModules_throws.

@Test
public void validateAllModules_multipleApexModules_throws() throws Exception {
    BundleModule apexModule = validApexModule();
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new ApexBundleValidator().validateAllModules(ImmutableList.of(apexModule, apexModule)));
    assertThat(exception).hasMessageThat().contains("Multiple APEX modules are not allowed, found 2.");
}
Also used : InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 8 with InvalidBundleException

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

the class ApexBundleValidatorTest method validateModule_untargetedImageFile_throws.

@Test
public void validateModule_untargetedImageFile_throws() throws Exception {
    BundleModule apexModule = new BundleModuleBuilder("apexTestModule").setManifest(androidManifest(PKG_NAME)).setApexConfig(APEX_CONFIG).addFile(APEX_MANIFEST_PATH, APEX_MANIFEST).addFile("apex/x86_64.img").addFile("apex/x86.img").addFile("apex/armeabi-v7a.img").addFile("apex/arm64-v8a.img").addFile("apex/x86_64.x86.img").build();
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new ApexBundleValidator().validateModule(apexModule));
    assertThat(exception).hasMessageThat().contains("Found APEX image files that are not targeted");
}
Also used : BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 9 with InvalidBundleException

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

the class AssetBundleValidatorTest method validateAllModules_assetOnlyWithInstallTime_throws.

@Test
public void validateAllModules_assetOnlyWithInstallTime_throws() throws Exception {
    ImmutableList<BundleModule> allModules = ImmutableList.of(assetOnlyModule("asset", androidManifestForAssetModule(PKG_NAME, withInstallTimeDelivery())));
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new AssetBundleValidator().validateAllModules(allModules));
    assertThat(exception).hasMessageThat().contains("Asset-only bundle contains an install-time asset module");
}
Also used : InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 10 with InvalidBundleException

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

the class AssetModuleFilesValidatorTest method moduleWithInvalidEntry_throws.

@Test
public void moduleWithInvalidEntry_throws() throws Exception {
    BundleModule module = new BundleModuleBuilder(MODULE_NAME).setManifest(androidManifestForAssetModule(PKG_NAME)).addFile("dex/classes.dex").build();
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new AssetModuleFilesValidator().validateModule(module));
    assertThat(exception).hasMessageThat().matches("Invalid entry found in asset pack 'assetmodule': 'dex/classes.dex'.");
}
Also used : BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Aggregations

InvalidBundleException (com.android.tools.build.bundletool.model.exceptions.InvalidBundleException)188 Test (org.junit.Test)188 BundleModule (com.android.tools.build.bundletool.model.BundleModule)106 BundleModuleBuilder (com.android.tools.build.bundletool.testing.BundleModuleBuilder)69 ZipPath (com.android.tools.build.bundletool.model.ZipPath)28 AppBundle (com.android.tools.build.bundletool.model.AppBundle)17 XmlNode (com.android.aapt.Resources.XmlNode)14 Path (java.nio.file.Path)14 ManifestProtoUtils.androidManifest (com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest)12 ResourceTableBuilder (com.android.tools.build.bundletool.testing.ResourceTableBuilder)10 ResourceTable (com.android.aapt.Resources.ResourceTable)9 ZipFile (java.util.zip.ZipFile)9 ZipBuilder (com.android.tools.build.bundletool.io.ZipBuilder)8 AppBundleBuilder (com.android.tools.build.bundletool.testing.AppBundleBuilder)8 ApexImages (com.android.bundle.Files.ApexImages)6 NativeLibraries (com.android.bundle.Files.NativeLibraries)6 BundleConfigBuilder (com.android.tools.build.bundletool.testing.BundleConfigBuilder)6 Truth.assertThat (com.google.common.truth.Truth.assertThat)6 IOException (java.io.IOException)6 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)6