@Test
public void updateRunWithPinning() throws Exception {

    // Update from v2 to v3, whilst we are pinned to v2.
    Path working = dir.resolve("working");
    createDirectory(working);
    byte[] baseFile = new byte[2048];
    Arrays.fill(baseFile, (byte) 1);
    Path jar1 = working.resolve("1.jar");
    write(jar1, baseFile, CREATE_NEW);
    baseFile[0] = 2;
    Path baseJar = working.resolve("2.jar");
    write(baseJar, baseFile, CREATE_NEW);
    baseFile[0] = 3;
    Path jar3 = working.resolve("3.jar");
    write(jar3, baseFile, CREATE_NEW);
    DeltaCalculator.process(working.toAbsolutePath(), working.toAbsolutePath(), -1);
    Path bpatch2 = working.resolve("2.jar.bpatch");
    assertTrue(exists(bpatch2));
    Path bpatch3 = working.resolve("3.jar.bpatch");
    assertTrue(exists(bpatch3));
    byte[] bpatch1bits = readAllBytes(bpatch2);
    byte[] bpatch2bits = readAllBytes(bpatch3);
    paths.put("/2.jar.bpatch", bpatch1bits);
    paths.put("/3.jar.bpatch", bpatch2bits);
    configureIndex(sha256(readAllBytes(jar1)), sha256(bpatch1bits), sha256(readAllBytes(baseJar)),
            sha256(readAllBytes(baseJar)), sha256(bpatch2bits), sha256(readAllBytes(jar3)));
    UpdateFX.pinToVersion(dir, 2);
    UpdateFX.pinToVersion(dir, 1);
    updater = new TestUpdater(indexURL, "UnitTest", dir, baseJar);
    UpdateSummary summary = updater.call();
    byte[] bits3 = Files.readAllBytes(dir.resolve("3.jar"));
    assertArrayEquals(baseFile, bits3);
    assertEquals(3, summary.highestVersion);
    UpdateFX.unpin(dir);
}