-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure the content copy file is always removed
- Loading branch information
1 parent
3b42171
commit 5b6b397
Showing
4 changed files
with
150 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...t/java/internal/org/springframework/content/commons/repository/factory/StoreImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package internal.org.springframework.content.commons.repository.factory; | ||
|
||
import static com.github.paulcwarren.ginkgo4j.Ginkgo4jDSL.BeforeEach; | ||
import static com.github.paulcwarren.ginkgo4j.Ginkgo4jDSL.Context; | ||
import static com.github.paulcwarren.ginkgo4j.Ginkgo4jDSL.Describe; | ||
import static com.github.paulcwarren.ginkgo4j.Ginkgo4jDSL.It; | ||
import static com.github.paulcwarren.ginkgo4j.Ginkgo4jDSL.JustBeforeEach; | ||
import static org.junit.Assert.fail; | ||
import static org.mockito.Mockito.mock; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.File; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
import org.junit.runner.RunWith; | ||
import org.springframework.content.commons.repository.ContentStore; | ||
import org.springframework.context.ApplicationEventPublisher; | ||
|
||
import com.github.paulcwarren.ginkgo4j.Ginkgo4jRunner; | ||
|
||
@RunWith(Ginkgo4jRunner.class) | ||
public class StoreImplTest { | ||
|
||
private StoreImpl stores; | ||
|
||
private ContentStore store; | ||
private ApplicationEventPublisher publisher; | ||
private String tmpDir; | ||
private Path contentCopyPathRoot; | ||
|
||
{ | ||
Describe("StoreImpl", () -> { | ||
|
||
BeforeEach(() -> { | ||
store = mock(ContentStore.class); | ||
publisher = mock(ApplicationEventPublisher.class); | ||
|
||
}); | ||
JustBeforeEach(() -> { | ||
contentCopyPathRoot = Files.createTempDirectory("storeimpltest"); | ||
|
||
for (File f : contentCopyPathRoot.toFile().listFiles()) { | ||
if (f.getName().endsWith(".tmp")) { | ||
f.delete(); // may fail mysteriously - returns boolean you may want to check | ||
} | ||
} | ||
|
||
stores = new StoreImpl(store, publisher, contentCopyPathRoot); | ||
}); | ||
|
||
Context("#setContent - inputstream", () -> { | ||
|
||
JustBeforeEach(() -> { | ||
stores.setContent(new Object(), new ByteArrayInputStream("foo".getBytes())); | ||
}); | ||
|
||
It("should delete the content copy file", () -> { | ||
for (File f : contentCopyPathRoot.toFile().listFiles()) { | ||
if (f.getName().endsWith(".tmp")) { | ||
fail("Found orphaned content copy path"); | ||
} | ||
} | ||
}); | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters