List of usage examples for java.net URI create
public static URI create(String str)
From source file:se.vgregion.pubsub.websocket.JettyWebsocketServlet.java
@Override protected WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) { ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); PubSubEngine pubSubEngine = ctx.getBean(PubSubEngine.class); String topic = request.getParameter("topic"); if (topic != null) { return new WebsocketSubscriber(pubSubEngine, URI.create(topic)); } else {//w w w .java 2 s.c o m // invalid request return null; } }
From source file:net.javacrumbs.restfire.httpcomponents.HttpComponentsRequestBuilderTest.java
@Test public void testToOverride() throws URISyntaxException { requestBuilder.withUri("http://localhost:8080"); requestBuilder.to("https://www.google.com/test?q=1"); assertEquals(URI.create("https://www.google.com/test?q=1"), requestBuilder.getUriBuilder().build()); }
From source file:edu.cuhk.hccl.SequenceFileWriter.java
private static void createSeqFile(File[] files, String seqName) { Configuration conf = new Configuration(); LongWritable key = new LongWritable(); Text value = new Text(); SequenceFile.Writer writer = null; try {/* w ww .j av a 2 s .co m*/ FileSystem fs = FileSystem.get(URI.create(seqName), conf); writer = SequenceFile.createWriter(fs, conf, new Path(seqName), key.getClass(), value.getClass()); for (File file : files) { //System.out.printf("Processing file: %s \n", file.getPath()); key.set(Integer.parseInt(file.getName().split("_")[1])); value.set(FileUtils.readFileToString(file)); writer.append(key, value); } System.out.printf("[INFO] The sequence file %s has been created for %d files! \n", seqName, files.length); } catch (IOException e) { System.out.println(e.getMessage()); } finally { IOUtils.closeStream(writer); } }
From source file:com.vmware.photon.controller.model.adapters.vsphere.ovf.OvfParserTest.java
@Test public void test() throws IOException, SAXException { OvfParser parser = new OvfParser(); Document ovfDoc = parser.retrieveDescriptor(new File("src/test/resources/vcenter.ovf").toURI()); ComputeDescription template = new ComputeDescription(); template.instanceAdapterReference = URI.create("http://test"); List<ComputeDescription> results = parser.parse(ovfDoc, template); System.out.println(Utils.toJsonHtml(results)); // all hw configurations are converted assertEquals(9, results.size());//from w w w .j a v a 2 s . c o m // template properties are copied for (ComputeDescription description : results) { assertEquals(description.instanceAdapterReference, template.instanceAdapterReference); } // network, properties and hardware config translated for (ComputeDescription description : results) { assertTrue( description.customProperties.containsKey("ovf.prop:guestinfo.cis.appliance.net.addr.family")); assertTrue(description.customProperties.containsKey("ovf.prop:guestinfo.cis.appliance.root.passwd")); assertTrue(description.customProperties.containsKey("ovf.net:Network 1")); assertTrue(description.cpuCount > 0); assertTrue(description.totalMemoryBytes > 0); } }
From source file:com.msopentech.odatajclient.engine.client.http.HttpMerge.java
/** * Constructor.//from w w w. j a v a 2 s . co m * * @param uri request URI. * @throws IllegalArgumentException if the uri is invalid. */ public HttpMerge(final String uri) { super(); setURI(URI.create(uri)); }
From source file:org.springframework.cloud.netflix.ribbon.apache.RibbonApacheHttpResponseTests.java
@Test public void testNullEntity() throws Exception { StatusLine statusLine = mock(StatusLine.class); given(statusLine.getStatusCode()).willReturn(204); HttpResponse response = mock(HttpResponse.class); given(response.getStatusLine()).willReturn(statusLine); RibbonApacheHttpResponse httpResponse = new RibbonApacheHttpResponse(response, URI.create("http://example.com")); assertThat(httpResponse.isSuccess(), is(true)); assertThat(httpResponse.hasPayload(), is(false)); assertThat(httpResponse.getPayload(), is(nullValue())); assertThat(httpResponse.getInputStream(), is(nullValue())); }
From source file:com.tc.websocket.junit.tests.RhinoClientTest.java
@Before public void setUp() throws Exception { //set this value to your local system's path. System.setProperty("java.library.path", "C:/Domino"); IScriptRunner runner = new ScriptRunnerModule().provideScriptRunner(); URI uri = URI.create("ws://localhost:8889/websocket/rhinotest/rhinoclient"); client = new RhinoClient(uri); IUser user = new User(); user.setUserId("rhinoclient"); user.setSessionId("rhinoclient"); client.setUser(user);/*from ww w .j a v a 2s . c o m*/ // set the runner client.setScriptRunner(runner); //load the test script InputStream in = RhinoClientTest.class.getResourceAsStream("rhinotest.js"); String javascript = IOUtils.toString(in); CloseUtils.close(in); //build the script with appropriate target event. Script script = new Script(); script.setScript(javascript); script.setEvent(IScriptClient.ON_MESSAGE); //add the script client.addScript(script); // connect the client. client.connect(); }
From source file:com.almende.eve.test.agents.TestResultMonitorAgent.java
/** * Prepare./*from ww w .j a va2 s .c om*/ */ public void prepare() { String monitorID = getResultMonitorFactory().create("Poll", URI.create("local:bob"), "getData", JOM.createObjectNode(), null, new Poll(1000), new Cache()); if (monitorID != null) { getState().put("PollKey", monitorID); } final Cache testCache = new Cache(); monitorID = getResultMonitorFactory().create("Push", URI.create("local:bob"), "getData", JOM.createObjectNode(), null, new Push().onInterval(1000).onChange(), testCache); if (monitorID != null) { getState().put("PushKey", monitorID); } monitorID = new ResultMonitor("LazyPush", getId(), URI.create("local:bob"), "getData", JOM.createObjectNode()).add(new Push(-1, true)).add(testCache).store(); if (monitorID != null) { getState().put("LazyPushKey", monitorID); } monitorID = getResultMonitorFactory().create("LazyPoll", URI.create("local:bob"), "getData", JOM.createObjectNode(), "returnRes", new Poll(800), new Poll(1500)); if (monitorID != null) { getState().put("LazyPollKey", monitorID); } monitorID = getResultMonitorFactory().create("EventPush", URI.create("local:bob"), "getData", JOM.createObjectNode(), "returnResParm", new Push().onEvent("Go")); if (monitorID != null) { getState().put("EventPushKey", monitorID); } }
From source file:com.almende.pi5.common.agents.LoggerAgent.java
@Override public void onReady() { final ObjectNode config = getConfig(); this.graphs = config.hasNonNull("clientUrl") ? URI.create(config.get("clientUrl").asText()) : null; }
From source file:kontrol.HttpUtil.java
public static InputStream getUrlAsStream(URL url, int timeout) throws IOException { return getUrlAsStream(URI.create(url.toString()), timeout, Locale.US); }