List of usage examples for java.net URI equals
public boolean equals(Object ob)
From source file:main.java.miro.validator.fetcher.RsyncFetcher.java
public boolean removeURI(URI pfUri) { List<URI> toBeRemoved = new ArrayList<URI>(); for (URI uri : prefetchURIs) { if (uri.equals(pfUri)) toBeRemoved.add(uri);/*from ww w . j a v a 2 s. co m*/ } prefetchURIs.removeAll(toBeRemoved); return !toBeRemoved.isEmpty(); }
From source file:org.akubraproject.mux.MuxBlob.java
@Override public Blob moveTo(URI blobId, Map<String, String> hints) throws IOException { MuxBlob dest = (MuxBlob) getConnection().getBlob(blobId, hints); URI thisStore = delegate.getConnection().getBlobStore().getId(); URI otherStore = dest.delegate.getConnection().getBlobStore().getId(); if (!thisStore.equals(otherStore)) moveByCopy(dest, thisStore, otherStore); else//from w ww . j a v a2s. co m delegate.moveTo(blobId, hints); return dest; }
From source file:org.apache.hadoop.hdfs.server.namenode.ha.TestFailureOfSharedDir.java
/** * Test that marking the shared edits dir as being "required" causes the NN to * fail if that dir can't be accessed.//from ww w . j a v a 2 s. co m */ @Test public void testFailureOfSharedDir() throws Exception { Configuration conf = new Configuration(); // The shared edits dir will automatically be marked required. MiniDFSCluster cluster = null; File sharedEditsDir = null; try { cluster = new MiniDFSCluster.Builder(conf).nnTopology(MiniDFSNNTopology.simpleHATopology()) .numDataNodes(0).build(); cluster.waitActive(); cluster.transitionToActive(0); FileSystem fs = HATestUtil.configureFailoverFs(cluster, conf); assertTrue(fs.mkdirs(new Path("/test1"))); // Blow away the shared edits dir. Runtime mockRuntime = Mockito.mock(Runtime.class); URI sharedEditsUri = cluster.getSharedEditsDir(0, 1); sharedEditsDir = new File(sharedEditsUri); assertEquals(0, FileUtil.chmod(sharedEditsDir.getAbsolutePath(), "-w", true)); NameNode nn0 = cluster.getNameNode(0); nn0.getNamesystem().getFSImage().getEditLog().getJournalSet().setRuntimeForTesting(mockRuntime); try { // Make sure that subsequent operations on the NN fail. nn0.getRpcServer().rollEditLog(); fail("Succeeded in rolling edit log despite shared dir being deleted"); } catch (IOException ioe) { GenericTestUtils.assertExceptionContains( "Unable to start log segment 4: too few journals successfully started", ioe); // By current policy the NN should exit upon this error. // exit() should be called once, but since it is mocked, exit gets // called once during FSEditsLog.endCurrentLogSegment() and then after // that during FSEditsLog.startLogSegment(). So the check is atLeast(1) Mockito.verify(mockRuntime, Mockito.atLeastOnce()).exit(Mockito.anyInt()); LOG.info("Got expected exception", ioe); } // Check that none of the edits dirs rolled, since the shared edits // dir didn't roll. Regression test for HDFS-2874. for (URI editsUri : cluster.getNameEditsDirs(0)) { if (editsUri.equals(sharedEditsUri)) { continue; } File editsDir = new File(editsUri.getPath()); File curDir = new File(editsDir, "current"); GenericTestUtils.assertGlobEquals(curDir, "edits_.*", NNStorage.getInProgressEditsFileName(1)); } } finally { if (sharedEditsDir != null) { // without this test cleanup will fail FileUtil.chmod(sharedEditsDir.getAbsolutePath(), "+w", true); } if (cluster != null) { cluster.shutdown(); } } }
From source file:test.eurocarbdb.tranche.UploadDownloadTestSuite.java
@Test public void testMultipleUpload() throws Exception { TrancheUtility tu = new TrancheUtility(); URL inputurl = Object.class.getResource("/test/BasicTestFile.test.xml"); File inputFile = new File(inputurl.getFile()); URI url = tu.uploadFile(inputFile); URI url2 = tu.uploadFile(inputFile); // We should have the same hash for uploading the same file twice. assert url.equals(url2); }
From source file:podd.util.iterator.CloseableOWLAxiomIterator.java
private void getNextMatch() { while (iterator.hasNext()) { final T axiom = iterator.next(); final URI currentURI = getPropertyURI(axiom); if ((null == property && null == object) || (null == property && getObject(axiom).equals(object)) || (null == object && currentURI.equals(property)) || (currentURI.equals(property) && getObject(axiom).equals(object))) { currentAxiom = axiom;/*ww w .j av a 2 s. c o m*/ return; } } currentAxiom = null; }
From source file:org.ambraproject.model.article.ArticleTypeTest.java
@Test public void testDefaultArticleType() { ArticleType dat = ArticleType.getDefaultArticleType(); assertNotNull(dat, "Default Article Type was Null"); String defaultHeading = "DefaultHeading"; URI defaultArticleTypeUri = URI.create("http://rdf.plos.org/RDF/articleType/Research%20Article"); assertTrue(defaultHeading.equals(dat.getHeading()), "Default ArticleType heading not as expected."); assertTrue(defaultArticleTypeUri.equals(dat.getUri()), "Default ArticleType URI not as expected."); }
From source file:org.mobicents.servlet.sip.restcomm.interpreter.tagstrategy.RcmlTagStrategy.java
protected URI resolveIfNotAbsolute(final URI base, final URI uri) { if (base.equals(uri)) { return uri; } else {/*from w w w . j a va2s . c o m*/ if (!uri.isAbsolute()) { return base.resolve(uri); } else { return uri; } } }
From source file:org.docear.plugin.core.listeners.WorkspaceChangeListener.java
private void setSystemNodes() { try {/*from ww w . j av a2s. com*/ File libPath = WorkspaceUtils.resolveURI(DocearController.getController().getLibraryPath()); URI _tempFile = Compat.fileToUrl(new File(libPath, "temp.mm")).toURI(); URI _trashFile = Compat.fileToUrl(new File(libPath, "trash.mm")).toURI(); AWorkspaceTreeNode parent = WorkspaceUtils .getNodeForPath(((WorkspaceRoot) WorkspaceUtils.getModel().getRoot()).getName() + "/Library"); for (AWorkspaceTreeNode node : Collections.list(parent.children())) { if (node.getType().equals(LinkTypeIncomingCreator.LINK_TYPE_INCOMING) || node.getType() .equals(LinkTypeLiteratureAnnotationsCreator.LINK_TYPE_LITERATUREANNOTATIONS) || node.getType().equals(LinkTypeMyPublicationsCreator.LINK_TYPE_MYPUBLICATIONS)) { node.setSystem(true); } if (node.getType().equals(ALinkNode.LINK_TYPE_FILE)) { URI linkPath = WorkspaceUtils.absoluteURI(((ALinkNode) node).getLinkPath()); if (linkPath.equals(_trashFile) || linkPath.equals(_tempFile)) { node.setSystem(true); } } } } catch (MalformedURLException e) { LogUtils.warn(e); } catch (URISyntaxException e) { LogUtils.warn(e); } }
From source file:lh.api.showcase.server.lh.api.referencedata.ReferenceDataRequestFactoryImplTest.java
@Test public void shouldConstructCountriesRequestUri() { ReferenceDataRequestFactoryImpl reqFact = new ReferenceDataRequestFactoryImpl(); try {/* ww w . j a v a2 s. com*/ URI constructedUri = reqFact.getRequestUri((NameValuePair) new BasicNameValuePair("countries", "DK"), null, Arrays.asList((NameValuePair) new BasicNameValuePair("lang", "EN"))); URI referenceUri = new URI("https://api.lufthansa.com/v1/references/countries/DK?lang=EN"); logger.log(Level.INFO, "constructed: " + constructedUri.toString()); logger.log(Level.INFO, "reference: " + referenceUri.toString()); assertTrue(referenceUri.equals(constructedUri)); } catch (URISyntaxException e) { assertTrue(false); } }
From source file:savant.diff.DiffDataSource.java
/** * Search through our existing tracks to find the ones which match our input URIs. * Because we can't rely on Savant loading the tracks in any known order, we may have * to call this method repeatedly before the inputs get hooked up. *///from w ww . j a v a 2 s . c om private boolean inputsAttached() { if (inputA != null && inputB != null) { return true; } try { String uriString = uri.getRawSchemeSpecificPart().substring(3); // Trim off the initial "diff://(" uriString = uriString.substring(0, uriString.length() - 1); // Trim off the final ")" int delimiterPos = uriString.indexOf(';'); if (delimiterPos > 0) { URI uriA = new URI(uriString.substring(0, delimiterPos)); URI uriB = new URI(uriString.substring(delimiterPos + 1)); TrackAdapter[] availableTracks = TrackUtils.getTracks(DataFormat.CONTINUOUS); for (TrackAdapter t : availableTracks) { URI u = t.getDataSource().getURI(); if (u.equals(uriA)) { inputA = t.getDataSource(); } else if (u.equals(uriB)) { inputB = t.getDataSource(); } } } } catch (URISyntaxException x) { LOG.error(String.format("Unable to parse %s as a valid URI.", x)); } return inputA != null && inputB != null; }