Search in sources :

Example 31 with FlagParser

use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.

the class ValidateBundleCommandTest method corruptedBundleFile_throws.

@Test
public void corruptedBundleFile_throws() throws Exception {
    ParsedFlags flags = new FlagParser().parse("--bundle=" + bundlePath);
    ValidateBundleCommand command = ValidateBundleCommand.fromFlags(flags);
    assertThrows(UncheckedIOException.class, () -> command.execute());
}
Also used : ParsedFlags(com.android.tools.build.bundletool.flags.ParsedFlags) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 32 with FlagParser

use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.

the class ValidateBundleCommandTest method bundleNotSet_throws.

@Test
public void bundleNotSet_throws() throws Exception {
    expectMissingRequiredBuilderPropertyException("bundlePath", () -> ValidateBundleCommand.builder().build());
    expectMissingRequiredFlagException("bundle", () -> ValidateBundleCommand.fromFlags(new FlagParser().parse()));
}
Also used : FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 33 with FlagParser

use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.

the class ValidateBundleCommandTest method missingBundleFile_throws.

@Test
public void missingBundleFile_throws() throws Exception {
    ParsedFlags flags = new FlagParser().parse("--bundle=doesnt-exist");
    ValidateBundleCommand command = ValidateBundleCommand.fromFlags(flags);
    IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> command.execute());
    assertThat(exception.getMessage()).matches("File '.*' was not found.");
}
Also used : ParsedFlags(com.android.tools.build.bundletool.flags.ParsedFlags) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 34 with FlagParser

use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.

the class CheckTransparencyCommandTest method buildingCommandViaFlags_apkMode_unknownFlagSet.

@Test
public void buildingCommandViaFlags_apkMode_unknownFlagSet() {
    Throwable e = assertThrows(UnknownFlagsException.class, () -> CheckTransparencyCommand.fromFlags(new FlagParser().parse("--mode=APK", "--apk-zip=" + bundlePath, "--unknownFlag=hello"), systemEnvironmentProvider, fakeAdbServer));
    assertThat(e).hasMessageThat().contains("Unrecognized flags");
}
Also used : FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 35 with FlagParser

use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.

the class CheckTransparencyCommandTest method buildingCommandViaFlags_connectedDeviceMode_bundleFlagSet.

@Test
public void buildingCommandViaFlags_connectedDeviceMode_bundleFlagSet() {
    Throwable e = assertThrows(UnknownFlagsException.class, () -> CheckTransparencyCommand.fromFlags(new FlagParser().parse("--mode=CONNECTED_DEVICE", "--adb=" + ADB_PATH, "--package-name=" + PACKAGE_NAME, "--bundle=" + bundlePath), systemEnvironmentProvider, fakeAdbServer));
    assertThat(e).hasMessageThat().contains("Unrecognized flags");
}
Also used : FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Aggregations

FlagParser (com.android.tools.build.bundletool.flags.FlagParser)138 Test (org.junit.Test)137 Path (java.nio.file.Path)63 ZipPath (com.android.tools.build.bundletool.model.ZipPath)55 ByteArrayOutputStream (java.io.ByteArrayOutputStream)29 PrintStream (java.io.PrintStream)29 BuildApksResult (com.android.bundle.Commands.BuildApksResult)22 InvalidCommandException (com.android.tools.build.bundletool.model.exceptions.InvalidCommandException)20 DeviceSpec (com.android.bundle.Devices.DeviceSpec)13 ParsedFlags (com.android.tools.build.bundletool.flags.ParsedFlags)12 ApksigSigningConfiguration (com.android.tools.build.bundletool.model.ApksigSigningConfiguration)10 SigningConfiguration (com.android.tools.build.bundletool.model.SigningConfiguration)10 FlagParseException (com.android.tools.build.bundletool.flags.FlagParser.FlagParseException)8 CommandExecutionException (com.android.tools.build.bundletool.model.exceptions.CommandExecutionException)8 InvalidBundleException (com.android.tools.build.bundletool.model.exceptions.InvalidBundleException)8 TestUtils.expectMissingRequiredBuilderPropertyException (com.android.tools.build.bundletool.testing.TestUtils.expectMissingRequiredBuilderPropertyException)8 TestUtils.expectMissingRequiredFlagException (com.android.tools.build.bundletool.testing.TestUtils.expectMissingRequiredFlagException)8 IOException (java.io.IOException)8 JoseException (org.jose4j.lang.JoseException)7 FakeSystemEnvironmentProvider (com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider)6