List of usage examples for java.net URI create
public static URI create(String str)
From source file:org.codehaus.httpcache4j.resolver.HTTPClientResponseResolverTest.java
@Test public void testSimpleGET() throws IOException { HTTPClientResponseResolver resolver = new TestableResolver(); HttpResponse mockedResponse = mock(HttpResponse.class); when(mockedResponse.getAllHeaders()).thenReturn(new org.apache.http.Header[0]); when(mockedResponse.getStatusLine()).thenReturn(new BasicStatusLine(new HttpVersion(1, 1), 200, "OK")); when(client.execute(Mockito.<HttpUriRequest>anyObject())).thenReturn(mockedResponse); HTTPResponse response = resolver.resolve(new HTTPRequest(URI.create("http://www.vg.no"))); assertNotNull("Response was null", response); assertEquals("Wrong header size", 0, response.getHeaders().size()); assertFalse("Response did have payload", response.hasPayload()); }
From source file:net.tirasa.olingooauth2.AzureADOAuth2HttpClientFactory.java
public AzureADOAuth2HttpClientFactory(final String authority, final String clientId, final String redirectURI, final String resourceURI, final UsernamePasswordCredentials creds) { super(URI.create(authority + "/oauth2/authorize"), URI.create(authority + "/oauth2/token")); this.clientId = clientId; this.redirectURI = redirectURI; this.resourceURI = resourceURI; this.creds = creds; }
From source file:com.datatorrent.stram.StringCodecs.java
public static void loadDefaultConverters() { LOG.debug("Loading default converters for BeanUtils"); ConvertUtils.register(new Converter() { @Override// w w w . j av a 2s. c o m @SuppressWarnings("unchecked") public Object convert(Class type, Object value) { if (value == null) { return null; } for (Class<?> clazz = value.getClass(); clazz != null; clazz = clazz.getSuperclass()) { Class<? extends StringCodec> codec = codecs.get(clazz); if (codec == null) { continue; } StringCodec instance; try { instance = codec.newInstance(); } catch (IllegalAccessException ex) { throw new RuntimeException( "Internal Error - it's impossible for this exception to be thrown!", ex); } catch (InstantiationException ex) { throw new RuntimeException( "Internal Error - it's impossible for this exception to be thrown!", ex); } return instance.toString(value); } return value.toString(); } }, String.class); ConvertUtils.register(new Converter() { @Override public Object convert(Class type, Object value) { return value == null ? null : URI.create(value.toString()); } }, URI.class); }
From source file:org.gbif.registry.metasync.protocols.biocase.BiocaseMetadataSynchroniserTest.java
@Before public void setup() { synchroniser = new BiocaseMetadataSynchroniser(client); installation = new Installation(); installation.setType(InstallationType.BIOCASE_INSTALLATION); Endpoint endpoint = new Endpoint(); endpoint.setUrl(URI.create("http://localhost")); installation.addEndpoint(endpoint);/*w w w. jav a 2 s .c om*/ }
From source file:cz.cvut.portal.kos.utils.UriBuilder.java
public URI build() { URI path = builder.buildAndExpand(variables).toUri(); return path.isAbsolute() ? path : URI.create(base + path); }
From source file:com.lithium.flow.filer.lucene.RecordDoc.java
@Nonnull public static RecordDoc create(@Nonnull Document doc) throws IOException { checkNotNull(doc);/*from w w w .j a va2 s. com*/ URI uri = URI.create(doc.get(RECORD_URI)); String parent = doc.get(RECORD_PARENT); String name = doc.get(RECORD_NAME); long time = Long.parseLong(doc.get(RECORD_TIME)); long size = Long.parseLong(doc.get(RECORD_SIZE)); boolean dir = Boolean.valueOf(doc.get(RECORD_DIR)); long indexTime = Long.parseLong(doc.get(INDEX_TIME)); Record record = new Record(uri, parent, name, time, size, dir); return new RecordDoc(record, doc, indexTime); }
From source file:se.vgregion.urlservice.repository.jpa.JpaBookmarkRepositoryTest.java
@Before @Transactional//from www .jav a 2 s. c o m public void setup() { owner = new Owner("roblu"); longUrl = new LongUrl(URI.create("http://example.com"), GLOBAL_HASH); Keyword kw1 = new Keyword("kw1"); List<Keyword> keywords = Arrays.asList(kw1); // the keyword, owner and LongUrl must be persisted first UserRepository userRepository = applicationContext.getBean(UserRepository.class); userRepository.persist(owner); userRepository.flush(); longUrlRepository = applicationContext.getBean(LongUrlRepository.class); longUrlRepository.persist(longUrl); longUrlRepository.flush(); KeywordRepository keywordRepository = applicationContext.getBean(KeywordRepository.class); keywordRepository.persist(kw1); keywordRepository.flush(); Bookmark shortLink = new Bookmark(HASH, longUrl, keywords, owner); dao = applicationContext.getBean(BookmarkRepository.class); bookmark1 = dao.persist(shortLink); //dao.flush(); }
From source file:com.curiousby.baoyou.cn.hadoop.HDFSUtils.java
public void init() { try {/*w ww .j ava 2 s .com*/ System.setProperty("hadoop.home.dir", "I:\\software\\hadoop-2.6.0"); configuration = new JobConf(HDFSUtils.class); configuration.setBoolean("dfs.support.append", true); configuration.set("dfs.client.block.write.replace-datanode-on-failure.policy", "NEVER"); configuration.set("dfs.client.block.write.replace-datanode-on-failure.enable", "true"); fileSystem = FileSystem.get(URI.create(HDFS_URL), configuration); } catch (IOException e) { System.out.println("??"); e.printStackTrace(); } }
From source file:com.msopentech.odatajclient.engine.data.json.JSONPropertyDeserializer.java
@Override protected JSONProperty doDeserializeV3(final JsonParser parser, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final ObjectNode tree = (ObjectNode) parser.getCodec().readTree(parser); final JSONProperty property = new JSONProperty(); if (tree.hasNonNull(ODataConstants.JSON_METADATA)) { property.setMetadata(URI.create(tree.get(ODataConstants.JSON_METADATA).textValue())); tree.remove(ODataConstants.JSON_METADATA); }/*from w w w . j a v a 2s. c om*/ try { final DocumentBuilder builder = ODataConstants.DOC_BUILDER_FACTORY.newDocumentBuilder(); final Document document = builder.newDocument(); Element content = document.createElement(ODataConstants.ELEM_PROPERTY); if (property.getMetadata() != null) { final String metadataURI = property.getMetadata().toASCIIString(); final int dashIdx = metadataURI.lastIndexOf('#'); if (dashIdx != -1) { content.setAttribute(ODataConstants.ATTR_M_TYPE, metadataURI.substring(dashIdx + 1)); } } JsonNode subtree = null; if (tree.has(ODataConstants.JSON_VALUE)) { if (tree.has(ODataConstants.JSON_TYPE) && StringUtils.isBlank(content.getAttribute(ODataConstants.ATTR_M_TYPE))) { content.setAttribute(ODataConstants.ATTR_M_TYPE, tree.get(ODataConstants.JSON_TYPE).asText()); } final JsonNode value = tree.get(ODataConstants.JSON_VALUE); if (value.isValueNode()) { content.appendChild(document.createTextNode(value.asText())); } else if (EdmSimpleType.isGeospatial(content.getAttribute(ODataConstants.ATTR_M_TYPE))) { subtree = tree.objectNode(); ((ObjectNode) subtree).put(ODataConstants.JSON_VALUE, tree.get(ODataConstants.JSON_VALUE)); if (StringUtils.isNotBlank(content.getAttribute(ODataConstants.ATTR_M_TYPE))) { ((ObjectNode) subtree).put(ODataConstants.JSON_VALUE + "@" + ODataConstants.JSON_TYPE, content.getAttribute(ODataConstants.ATTR_M_TYPE)); } } else { subtree = tree.get(ODataConstants.JSON_VALUE); } } else { subtree = tree; } if (subtree != null) { DOMTreeUtilsV3.buildSubtree(content, subtree); } final List<Node> children = XMLUtils.getChildNodes(content, Node.ELEMENT_NODE); if (children.size() == 1) { final Element value = (Element) children.iterator().next(); if (ODataConstants.JSON_VALUE.equals(XMLUtils.getSimpleName(value))) { if (StringUtils.isNotBlank(content.getAttribute(ODataConstants.ATTR_M_TYPE))) { value.setAttribute(ODataConstants.ATTR_M_TYPE, content.getAttribute(ODataConstants.ATTR_M_TYPE)); } content = value; } } property.setContent(content); } catch (ParserConfigurationException e) { throw new JsonParseException("Cannot build property", parser.getCurrentLocation(), e); } return property; }
From source file:com.gopivotal.cloudfoundry.test.support.TestConfiguration.java
@Bean(initMethod = "login", destroyMethod = "logout") CloudFoundryOperations cloudFoundryOperations() throws MalformedURLException { CloudCredentials credentials = new CloudCredentials(this.username, this.password); return new CloudFoundryClient(credentials, URI.create(this.target).toURL(), this.organization, this.space); }