function Archiver() { var temperature = null; var archive = []; Object.defineProperty(this, 'temperature', { get: function() { console.log('get!'); return temperature; }, set: function(value) { temperature = value; archive.push({ val: temperature }); } }); this.getArchive = function() { return archive; }; } var arc = new Archiver(); arc.temperature; // 'get!' arc.temperature = 11; arc.temperature = 13; arc.getArchive(); // [{ val: 11 }, { val: 13 }]
archiver.archive(outputStream, uri);
private void addFile(final Path subPath) throws IOException { zipWriter.addFile(getZipEntry(subPath), ioService.newInputStream(subPath)); }
archiver.archive(outputStream, uri);
private void addFile(final Path subPath) throws IOException { zipWriter.addFile(getZipEntry(subPath), ioService.newInputStream(subPath)); }
@Test public void testZipRepository() throws Exception { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); archiver.archive(outputStream, this.getClass().getResource("testRepository").toURI().toString()); assertZipContains(outputStream, "project1/file1.txt", "project2/file2.txt"); }
function Archiver() { var temperature = null; var archive = []; Object.defineProperty(this, 'temperature', { get: function () { console.log('get!'); return temperature; }, set: function (value) { temperature = value; archive.push({ val: temperature }); } }); this.getArchive = function () { return archive; }; } var arc = new Archiver(); arc.temperature; // 'get!' arc.temperature = 11; arc.temperature = 13; arc.getArchive(); // [{ val: 11 }, { val: 13 }]
@Test public void testZipRepository() throws Exception { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); archiver.archive(outputStream, this.getClass().getResource("testRepository").toURI().toString()); assertZipContains(outputStream, "testRepository/project1/file1.txt", "testRepository/project2/file2.txt"); }
function Archiver() { var temperature = null; var archive = []; Object.defineProperty(this, 'temperature', { get: function() { console.log('get!'); return temperature; }, set: function(value) { console.log("set:"+value); temperature = value; archive.push({ val: temperature }); } }); this.getArchive = function() { return archive; }; } var arc = new Archiver(); arc.temperature; // 'get!' arc.temperature = 11; arc.temperature = 13; arc.getArchive(); // [{ val: 11 }, { val: 13 }]
@Test public void testZipProject() throws Exception { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); archiver.archive(outputStream, this.getClass().getResource("testRepository/project1").toURI().toString()); assertZipContains(outputStream, "project1/file1.txt"); }
@Test public void testZipRepository() throws Exception { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); archiver.archive(outputStream, this.getClass().getResource("testRepository").toURI().toString()); assertZipContains(outputStream, "testRepository/project1/file1.txt", "testRepository/project2/file2.txt"); }
@Before public void setUp() throws Exception { final SimpleFileSystemProvider simpleFileSystemProvider = new SimpleFileSystemProvider(); simpleFileSystemProvider.forceAsDefault(); ioService = spy(new MockIOService() { @Override public Path get(URI uri) throws IllegalArgumentException, FileSystemNotFoundException, SecurityException { return simpleFileSystemProvider.getPath(uri); } @Override public InputStream newInputStream(Path path, OpenOption... openOptions) throws IllegalArgumentException, NoSuchFileException, UnsupportedOperationException, IOException, SecurityException { return getClass().getResourceAsStream( path.toString().substring(path.toString().indexOf("test-classes") + "test-classes".length())); } }); archiver = new Archiver(ioService); }
@Test public void testZipProject() throws Exception { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); archiver.archive(outputStream, this.getClass().getResource("testRepository/project1").toURI().toString()); assertZipContains(outputStream, "file1.txt"); }