Java Code Examples for org.apache.tika.io.IOUtils#toString()
The following examples show how to use
org.apache.tika.io.IOUtils#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RepositoryRefactor.java From urule with Apache License 2.0 | 6 votes |
public List<String> getReferenceFiles(Node rootNode,String path,String searchText) throws Exception{ List<String> referenceFiles=new ArrayList<String>(); List<String> files=getFiles(rootNode, path); for(String nodePath:files){ InputStream inputStream=repositoryService.readFile(nodePath,null); try { String content = IOUtils.toString(inputStream); inputStream.close(); boolean containPath=content.contains(path); boolean containText=content.contains(searchText); if(containPath && containText){ referenceFiles.add(nodePath); } } catch (IOException e) { throw new RuleException(e); } } return referenceFiles; }
Example 2
Source File: TestPackageInstall.java From jackrabbit-filevault with Apache License 2.0 | 6 votes |
/** * Installs a binary properties. */ @Test public void testBinaryProperties() throws RepositoryException, IOException, PackageException { JcrPackage pack = packMgr.upload(getStream("/test-packages/tmp_binary.zip"), false); assertNotNull(pack); pack.install(getDefaultOptions()); Property p = admin.getProperty("/tmp/binary/test/jcr:data"); assertEquals(PropertyType.BINARY, p.getType()); StringBuilder buffer = new StringBuilder(8192); while (buffer.length() < 8192) { buffer.append("0123456789abcdef"); } String result = IOUtils.toString(p.getBinary().getStream()); assertEquals(buffer.toString(), result); }
Example 3
Source File: TestPackageInstall.java From jackrabbit-filevault with Apache License 2.0 | 5 votes |
/** * Installs a binary properties twice to check if it doesn't report an update. * TODO: this is not implemented yet. see JCRVLT-110 */ @Test @Ignore public void testBinaryPropertyTwice() throws RepositoryException, IOException, PackageException { JcrPackage pack = packMgr.upload(getStream("/test-packages/tmp_binary.zip"), false); assertNotNull(pack); pack.install(getDefaultOptions()); Property p = admin.getProperty("/tmp/binary/test/jcr:data"); assertEquals(PropertyType.BINARY, p.getType()); StringBuilder buffer = new StringBuilder(8192); while (buffer.length() < 8192) { buffer.append("0123456789abcdef"); } String result = IOUtils.toString(p.getBinary().getStream()); assertEquals(buffer.toString(), result); // install again to check if binary data is not updated ImportOptions opts = getDefaultOptions(); TrackingListener listener = new TrackingListener(opts.getListener()); opts.setListener(listener); pack.install(opts); //TODO: assertEquals("-", listener.getActions().get("/tmp/binary/test")); assertEquals("U", listener.getActions().get("/tmp/binary/test")); }
Example 4
Source File: SAML2SPMetadataTest.java From syncope with Apache License 2.0 | 5 votes |
private SAML2SPMetadata create(final String owner) throws Exception { SAML2SPMetadata saml2SPMetadata = entityFactory.newEntity(SAML2SPMetadata.class); saml2SPMetadata.setOwner(owner); String metadata = IOUtils.toString(new ClassPathResource("sp-metadata.xml").getInputStream()); saml2SPMetadata.setMetadata(metadata); saml2SPMetadataDAO.save(saml2SPMetadata); assertNotNull(saml2SPMetadata); assertNotNull(saml2SPMetadata.getKey()); assertNotNull(saml2SPMetadataDAO.findByOwner(saml2SPMetadata.getOwner())); return saml2SPMetadata; }
Example 5
Source File: HelmITSupport.java From nexus-repository-helm with Eclipse Public License 1.0 | 4 votes |
protected void checkYamlIncludesContent(InputStream is, String expectedContent) throws Exception { String downloadedPackageData = IOUtils.toString(is); assertThat(downloadedPackageData, containsString(expectedContent)); }
Example 6
Source File: RITSupport.java From nexus-repository-r with Eclipse Public License 1.0 | 4 votes |
protected void verifyTextGzipContent(Matcher<String> expectedContent, InputStream is) throws Exception { try (InputStream cin = new CompressorStreamFactory().createCompressorInputStream(GZIP, is)) { final String downloadedPackageData = IOUtils.toString(cin); assertThat(downloadedPackageData, expectedContent); } }
Example 7
Source File: TestSubPackages.java From jackrabbit-filevault with Apache License 2.0 | 4 votes |
/** * Test if installing and re-creating a package with sub-packages on an alternative path results in the same package again. */ @Test public void testRoundTrip() throws IOException, RepositoryException, PackageException { JcrPackage pack = packMgr.upload(getStream("/test-packages/subtest.zip"), false); assertNotNull(pack); // install ImportOptions opts = getDefaultOptions(); opts.setNonRecursive(true); pack.install(opts); // create new package JcrPackage pkg = packMgr.open(PACKAGE_ID_SUB_TEST); packMgr.assemble(pkg, new DefaultProgressListener()); try (ZipInputStream in = new ZipInputStream(pkg.getData().getBinary().getStream())) { ZipEntry e; List<String> entries = new ArrayList<>(); String filter = ""; while ((e = in.getNextEntry()) != null) { entries.add(e.getName()); if ("META-INF/vault/filter.xml".equals(e.getName())) { filter = IOUtils.toString(in, "utf-8"); } } Collections.sort(entries); StringBuffer result = new StringBuffer(); for (String name: entries) { // exclude some of the entries that depend on the repository setup if ("jcr_root/etc/.content.xml".equals(name) || "jcr_root/etc/packages/my_packages/.content.xml".equals(name) || "jcr_root/etc/packages/.content.xml".equals(name)) { continue; } result.append(name).append("\n"); } assertEquals("Filter must be correct", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<workspaceFilter version=\"1.0\">\n" + " <filter root=\"/etc/packages/my_packages/sub_a.zip\"/>\n" + " <filter root=\"/etc/packages/my_packages/sub_b.zip\"/>\n" + "</workspaceFilter>\n", filter); assertEquals("Package must contain proper entries.", "META-INF/\n" + "META-INF/MANIFEST.MF\n" + "META-INF/vault/\n" + "META-INF/vault/config.xml\n" + "META-INF/vault/definition/\n" + "META-INF/vault/definition/.content.xml\n" + "META-INF/vault/filter.xml\n" + "META-INF/vault/nodetypes.cnd\n" + "META-INF/vault/properties.xml\n" + "jcr_root/.content.xml\n" + "jcr_root/etc/\n" + "jcr_root/etc/packages/\n" + "jcr_root/etc/packages/my_packages/\n" + "jcr_root/etc/packages/my_packages/sub_a.zip\n" + "jcr_root/etc/packages/my_packages/sub_a.zip.dir/\n" + "jcr_root/etc/packages/my_packages/sub_a.zip.dir/.content.xml\n" + "jcr_root/etc/packages/my_packages/sub_a.zip.dir/_jcr_content/\n" + "jcr_root/etc/packages/my_packages/sub_a.zip.dir/_jcr_content/_vlt_definition/\n" + "jcr_root/etc/packages/my_packages/sub_a.zip.dir/_jcr_content/_vlt_definition/.content.xml\n" + "jcr_root/etc/packages/my_packages/sub_b.zip\n" + "jcr_root/etc/packages/my_packages/sub_b.zip.dir/\n" + "jcr_root/etc/packages/my_packages/sub_b.zip.dir/.content.xml\n" + "jcr_root/etc/packages/my_packages/sub_b.zip.dir/_jcr_content/\n" + "jcr_root/etc/packages/my_packages/sub_b.zip.dir/_jcr_content/_vlt_definition/\n" + "jcr_root/etc/packages/my_packages/sub_b.zip.dir/_jcr_content/_vlt_definition/.content.xml\n", result.toString()); } }