Search in sources :

Example 1 with SdkBundleSerializer

use of com.android.tools.build.bundletool.io.SdkBundleSerializer in project bundletool by google.

the class BuildApksCommandTest method sdkBundleHasInvalidManifestEntry_sdkBundleValidationFails.

@Test
public void sdkBundleHasInvalidManifestEntry_sdkBundleValidationFails() throws Exception {
    new SdkBundleSerializer().writeToDisk(new SdkBundleBuilder().setModule(new BundleModuleBuilder("base").setManifest(androidManifest("package.name", withMinSdkVersion(32), // Major version must be a long.
    withSdkLibraryElement("MajorVersionNotLong"))).build()).build(), sdkBundlePath1);
    createAppBundle(bundlePath);
    BuildApksCommand command = BuildApksCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--sdk-bundles=" + sdkBundlePath1), fakeAdbServer);
    Exception e = assertThrows(InvalidBundleException.class, command::execute);
    assertThat(e).hasMessageThat().contains("SDK Major version in <" + SDK_LIBRARY_ELEMENT_NAME + "> cannot be parsed to a Long.");
}
Also used : BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) SdkBundleBuilder(com.android.tools.build.bundletool.testing.SdkBundleBuilder) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) FlagParseException(com.android.tools.build.bundletool.flags.FlagParser.FlagParseException) IOException(java.io.IOException) CommandExecutionException(com.android.tools.build.bundletool.model.exceptions.CommandExecutionException) JoseException(org.jose4j.lang.JoseException) TestUtils.expectMissingRequiredBuilderPropertyException(com.android.tools.build.bundletool.testing.TestUtils.expectMissingRequiredBuilderPropertyException) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) TestUtils.expectMissingRequiredFlagException(com.android.tools.build.bundletool.testing.TestUtils.expectMissingRequiredFlagException) InvalidCommandException(com.android.tools.build.bundletool.model.exceptions.InvalidCommandException) SdkBundleSerializer(com.android.tools.build.bundletool.io.SdkBundleSerializer) Test(org.junit.Test)

Aggregations

FlagParser (com.android.tools.build.bundletool.flags.FlagParser)1 FlagParseException (com.android.tools.build.bundletool.flags.FlagParser.FlagParseException)1 SdkBundleSerializer (com.android.tools.build.bundletool.io.SdkBundleSerializer)1 CommandExecutionException (com.android.tools.build.bundletool.model.exceptions.CommandExecutionException)1 InvalidBundleException (com.android.tools.build.bundletool.model.exceptions.InvalidBundleException)1 InvalidCommandException (com.android.tools.build.bundletool.model.exceptions.InvalidCommandException)1 BundleModuleBuilder (com.android.tools.build.bundletool.testing.BundleModuleBuilder)1 SdkBundleBuilder (com.android.tools.build.bundletool.testing.SdkBundleBuilder)1 TestUtils.expectMissingRequiredBuilderPropertyException (com.android.tools.build.bundletool.testing.TestUtils.expectMissingRequiredBuilderPropertyException)1 TestUtils.expectMissingRequiredFlagException (com.android.tools.build.bundletool.testing.TestUtils.expectMissingRequiredFlagException)1 IOException (java.io.IOException)1 JoseException (org.jose4j.lang.JoseException)1 Test (org.junit.Test)1