StroomZipRepository { StroomZipOutputStream getStroomZipOutputStream() throws IOException { return getStroomZipOutputStream(null); } StroomZipRepository(final String dir, final boolean readOnly);   StroomZipRepository(final String dir,
                        final String repositoryFormat,
                        final boolean lock,
                        final int lockDeleteAgeMs,
                        final int cleanDelayMs,
                        final boolean readOnly);   StroomZipRepository(final String dir,
                        final String repositoryFormat,
                        final boolean lock,
                        final int lockDeleteAgeMs,
                        final boolean readOnly,
                        final LinkedBlockingDeque<StroomZipRepository> rolledRepositoryQueue);   StroomZipRepository(final String dir,
                        final String repositoryFormat,
                        final boolean lock,
                        final int lockDeleteAgeMs,
                        final int cleanDelayMs,
                        final boolean readOnly,
                        final LinkedBlockingDeque<StroomZipRepository> rolledRepositoryQueue); Path getRootDir(); final static String ZIP_EXTENSION; }
@Test void testTemplatedFilenameWithDate() throws IOException { final String repositoryFormat = "${year}-${month}-${day}/${feed}/${id}"; final String FEED_NAME = "myFeed"; final String repoDir = FileUtil.getCanonicalPath(Files.createTempDirectory("stroom").resolve("repo3")); StroomZipRepository stroomZipRepository = new StroomZipRepository(repoDir, repositoryFormat, false, 10000, 0, false); AttributeMap attributeMap = new AttributeMap(); attributeMap.put("feed", FEED_NAME); StroomZipOutputStreamImpl out1; try (final StroomZipOutputStreamImpl out = (StroomZipOutputStreamImpl) stroomZipRepository.getStroomZipOutputStream(attributeMap)) { StroomZipOutputStreamUtil.addSimpleEntry(out, new StroomZipEntry(null, "file", StroomZipFileType.Data), "SOME_DATA".getBytes(CharsetConstants.DEFAULT_CHARSET)); assertThat(Files.isRegularFile(out.getFile())).isFalse(); out1 = out; } Path zipFile = out1.getFile(); Path feedDir = zipFile.getParent(); Path dateDir = feedDir.getParent(); String dateDirStr = dateDir.getFileName().toString(); assertThat(Files.isRegularFile(zipFile)).isTrue(); assertThat(feedDir.getFileName().toString()).isEqualTo(FEED_NAME); String pattern = "yyyy-MM-dd"; SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); String nowStr = simpleDateFormat.format(new Date()); assertThat(dateDirStr).isEqualTo(nowStr); }
@Test void testInvalidDelimiter() throws IOException { final AttributeMap attributeMap = new AttributeMap(); attributeMap.put("feed", "myFeed"); attributeMap.put("key1", "myKey1"); final String repositoryFormat = "%{id}_${id}_${FEED}_${kEy1}"; final String repoDir = FileUtil.getCanonicalPath(Files.createTempDirectory("stroom").resolve("repo3")); final StroomZipRepository stroomZipRepository = new StroomZipRepository(repoDir, repositoryFormat, false, 10000, 0, false); StroomZipOutputStreamImpl out1; try (final StroomZipOutputStreamImpl out = (StroomZipOutputStreamImpl) stroomZipRepository.getStroomZipOutputStream(attributeMap)) { StroomZipOutputStreamUtil.addSimpleEntry(out, new StroomZipEntry(null, "file", StroomZipFileType.Data), "SOME_DATA".getBytes(CharsetConstants.DEFAULT_CHARSET)); assertThat(Files.isRegularFile(out.getFile())).isFalse(); out1 = out; } Path zipFile = out1.getFile(); assertThat(Files.isRegularFile(zipFile)).isTrue(); final String expectedFilename = "__id__001_myFeed_myKey1.zip"; assertThat(zipFile.getFileName().toString()).isEqualTo(expectedFilename); }