FSRegisteredPackage implements RegisteredPackage { @NotNull @Override public VaultPackage getPackage() throws IOException { if (this.vltPkg == null) { this.vltPkg = registry.openPackageFile(getId()); } return this.vltPkg; } FSRegisteredPackage(FSPackageRegistry registry, FSInstallState installState); @NotNull @Override PackageId getId(); @NotNull @Override VaultPackage getPackage(); @Override boolean isInstalled(); @Override long getSize(); @Nullable @Override Calendar getInstallationTime(); @Override void close(); @Override int compareTo(RegisteredPackage o); @Override Dependency[] getDependencies(); @Override WorkspaceFilter getWorkspaceFilter(); @Override PackageProperties getPackageProperties();  }
@Test public void testGetPackageFromNonTruncatedFile() throws IOException { File packageFile = getTempFile("test-package.zip"); try (RegisteredPackage regPack = new FSRegisteredPackage(newRegistry(packageFile), newInstallState(packageFile)); VaultPackage vltPack = regPack.getPackage()) { assertNotNull(vltPack); assertNotNull(vltPack.getArchive()); } catch (IOException e) { fail("should not throw any exception, but thrown: " + e.getMessage()); } finally { packageFile.delete(); } }
@Test public void testGetPackageFromTruncatedFile() throws IOException { File packageFile = getTempFile("test-package-truncated.zip"); try (RegisteredPackage regPack = new FSRegisteredPackage(newRegistry(packageFile), newInstallState(packageFile)); VaultPackage vltPack = regPack.getPackage()) { assertNotNull(vltPack); assertNull(vltPack.getArchive()); } catch (IOException e) { fail("should not throw any exception, but thrown: " + e.getMessage()); } finally { packageFile.delete(); } }