-
Notifications
You must be signed in to change notification settings - Fork 72
JCRVLT-851: Remove package tmp files through closewatcher #434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
420b8da
bb574f1
e9557ca
87f4eb2
ae5cce2
0833309
126eaec
4a46951
e9c4be2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.jackrabbit.vault.fs.io; | ||
|
|
||
| import java.io.IOException; | ||
| import java.net.URISyntaxException; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.nio.file.Paths; | ||
|
|
||
| import org.junit.Rule; | ||
| import org.junit.Test; | ||
| import org.junit.rules.TemporaryFolder; | ||
|
|
||
| import static org.junit.Assert.*; | ||
|
|
||
| /** | ||
| * Most tests in {@link ArchiveTest} are also applicable to {@link ZipNioArchive}. | ||
| * This class contains additional tests specific to {@link ZipNioArchive}. | ||
| */ | ||
| public class ZipNioArchiveTest { | ||
|
|
||
| @Rule | ||
| public TemporaryFolder tempFolder = new TemporaryFolder(); | ||
|
|
||
| @Test | ||
| public void testDumpUnclosedArchivesClosesTmpFile() throws IOException, InterruptedException, URISyntaxException { | ||
| Path tmpFile = createTempPackage(); | ||
| new ZipNioArchive(tmpFile, true); | ||
| System.gc(); | ||
| Thread.sleep(100); | ||
|
Check warning on line 47 in vault-core/src/test/java/org/apache/jackrabbit/vault/fs/io/ZipNioArchiveTest.java
|
||
| // Now dump unclosed archives | ||
| assertTrue("Couldn't find unclosed archives", AbstractArchive.dumpUnclosedArchives()); | ||
| assertFalse("Temp file should have been deleted but still exists", Files.exists(tmpFile)); | ||
|
Comment on lines
+45
to
+50
|
||
| } | ||
|
Comment on lines
+43
to
+51
|
||
|
|
||
| @Test | ||
| public void testDumpUnclosedArchivesClosesTmpFileAfterOpen() | ||
| throws IOException, InterruptedException, URISyntaxException { | ||
| Path tmpFile = createTempPackage(); | ||
| new ZipNioArchive(tmpFile, true).open(true); | ||
| System.gc(); | ||
| Thread.sleep(100); | ||
|
Check warning on line 59 in vault-core/src/test/java/org/apache/jackrabbit/vault/fs/io/ZipNioArchiveTest.java
|
||
| // Now dump unclosed archives | ||
| assertTrue("Couldn't find unclosed archives", AbstractArchive.dumpUnclosedArchives()); | ||
| assertFalse("Temp file should have been deleted but still exists", Files.exists(tmpFile)); | ||
| } | ||
|
|
||
| private Path createTempPackage() throws URISyntaxException, IOException { | ||
| Path zipFile = Paths.get(ZipNioArchiveTest.class | ||
| .getResource("/test-packages/atomic-counter-test.zip") | ||
| .toURI()); | ||
| // copy to tmpFile | ||
| Path tmpFile = tempFolder.newFile().toPath(); | ||
| Files.copy(zipFile, tmpFile, java.nio.file.StandardCopyOption.REPLACE_EXISTING); | ||
| return tmpFile; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.