@Override @Nonnull public Optional<Resource> getContent() throws IOException { final Path absolutePath = normalizedPath(getAbsolutePath()); return Files.exists(absolutePath) ? Optional.of(new FileSystemResource(absolutePath.toFile())) : Optional.empty(); }
@Override @Nonnegative public long getSize() throws IOException { return Files.size(normalizedPath(getAbsolutePath())); }
/******************************************************************************************************************* * * * ******************************************************************************************************************/ public static void assertSameContents2 (final @Nonnull Path expectedPath, final @Nonnull Path actualPath) throws IOException { FileComparisonUtils.assertSameContents(toFileBMT46(normalizedPath(expectedPath.toAbsolutePath())), toFileBMT46(normalizedPath(actualPath.toAbsolutePath()))); } }
/******************************************************************************************************************* * * Queries the catalog for the whole data in various ways and dumps the results to check the consistency. * ******************************************************************************************************************/ @Test(dataProvider = "testSetNamesProvider") public void must_properly_query_the_whole_catalog_in_various_ways (final @Nonnull String testSetName, final @CheckForNull String otherTestSetName, final @Nonnull Id source, final @Nonnull Id fallbackSource) throws Exception { // given final Repository repository = context.getBean(Repository.class); if (otherTestSetName != null) { loadRepository(repository, PATH_TEST_SETS.resolve(otherTestSetName + ".n3")); } loadRepository(repository, PATH_TEST_SETS.resolve(testSetName + ".n3")); final RepositoryMediaCatalog underTest = context.getBean(RepositoryMediaCatalog.class); underTest.setSource(source); underTest.setFallback(fallbackSource); final Path expectedResult = PATH_EXPECTED_TEST_RESULTS.resolve(testSetName + "-dump.txt"); final Path actualResult = PATH_TEST_RESULTS.resolve(testSetName + "-dump.txt"); // when queryAndDump(underTest, actualResult); // then assertSameContents(normalizedPath(expectedResult).toFile(), normalizedPath(actualResult).toFile()); }
@Override public void received (final @Nonnull ActionInvocation actionInvocation, final @Nonnull DIDLContent didl) { try { log.info("received() - {}", actionInvocation); final String fileName = String.format("%s/%s/%s/%s-%03d.txt", clientDeviceName, testSetName, sequenceName, sequenceName, n.getAndIncrement()); final Path expectedFile = EXPECTED_PATH.resolve(fileName); final Path actualFile = ACTUAL_PATH.resolve(fileName); Files.createDirectories(actualFile.getParent()); final String header = String.format("%s(%s)", actionInvocation.getAction().getName(), actionInvocation.getInputMap()); final DIDLParser parser = new DIDLParser(); final String baseUrl = resourceServer.absoluteUrl(""); final String result = xmlPrettyPrinted(parser.generate(didl)).replaceAll(baseUrl, "http://<server>/"); final String queries = String.format("QUERY COUNT: %d", RepositoryTrackFinder.getQueryCount()); Files.write(actualFile, (header + "\n" + result + "\n" + queries).getBytes(UTF_8)); assertSameContents(normalizedPath(expectedFile), normalizedPath(actualFile)); } catch (Throwable e) { log.error("", e); error.set(e); } latch.countDown(); }
final Path normalizedPath = normalizedPath(path.toAbsolutePath()); log.debug("path: {}", normalizedPath); file = toFileBMT46(normalizedPath);