Example usage for java.net URI create

List of usage examples for java.net URI create

Introduction

In this page you can find the example usage for java.net URI create.

Prototype

public static URI create(String str) 

Source Link

Document

Creates a URI by parsing the given string.

Usage

From source file:com.couchbase.spring.TestApplicationConfig.java

@Bean
@Override//  www  .ja v a  2 s.c  o  m
public CouchbaseClient couchbaseClient() throws IOException {
    String defaultHost = "http://127.0.0.1:8091/pools";
    String host = env.getProperty("couchbase.host", defaultHost);

    String bucket = env.getProperty("couchbase.bucket", "default");
    String pass = env.getProperty("couchbase.password", "");
    return new CouchbaseClient(Arrays.asList(URI.create(host)), bucket, pass);
}

From source file:com.googlecode.jsonschema2pojo.SchemaStore.java

private URI removeFragment(URI id) {
    return URI.create(substringBefore(id.toString(), "#"));
}

From source file:top.zhacker.ms.reactor.spring.function.Client.java

public void createPerson() {
    URI uri = URI.create(String.format("http://%s:%d/person", Server.HOST, Server.PORT));
    Person jack = new Person("Jack Doe", 16);

    ClientRequest request = ClientRequest.method(HttpMethod.POST, uri).body(BodyInserters.fromObject(jack))
            .build();// w  w w  .j a v  a2 s  . c om

    Mono<ClientResponse> response = exchange.exchange(request);

    System.out.println(response.block().statusCode());
}

From source file:com.bbva.kltt.apirest.core.web.Utilities.java

/**
 * Read the file content//from  ww  w .ja  va  2 s  . c o m
 * @param filePath with the file path
 * @return the file content as byte array
 * @throws APIRestGeneratorException with an occurred exception
 */
public static byte[] readFileContent(final String filePath) throws APIRestGeneratorException {
    Path path = null;

    if (filePath.toLowerCase().startsWith(ConstantsInput.SO_PATH_STRING_PREFIX)) {
        path = Paths.get(URI.create(filePath));
    } else {
        path = Paths.get(filePath, new String[0]);
    }

    byte[] fileContent = null;

    if (Files.exists(path, new LinkOption[0])) {
        try {
            fileContent = FileUtils.readFileToByteArray(path.toFile());
        } catch (IOException ioException) {
            final String errorString = "IOException when reading the file '" + filePath + "': " + ioException;

            Utilities.LOGGER.error(errorString, ioException);
            throw new APIRestGeneratorException(errorString, ioException);
        }
    }

    return fileContent;
}

From source file:com.github.fge.jsonschema.core.load.URIManagerTest.java

@Test
public void unhandledSchemeShouldBeReportedAsSuch() {
    final URI uri = URI.create("bar://baz");
    final URIManager manager = new URIManager();

    try {/* w  w  w  .ja  va 2s  .  c o m*/
        manager.getContent(uri);
    } catch (ProcessingException e) {
        assertMessage(e.getProcessingMessage())
                .hasMessage(BUNDLE.printf("refProcessing.unhandledScheme", "bar", uri))
                .hasField("scheme", "bar").hasField("uri", uri).hasLevel(LogLevel.FATAL);
    }
}

From source file:org.jsonschema2pojo.SchemaStore.java

protected URI removeFragment(URI id) {
    return URI.create(substringBefore(id.toString(), "#"));
}

From source file:at.ac.univie.isc.asio.flock.FlockAssemblerTest.java

@Test
public void should_use_provided_configuration_properties() throws Exception {
    final FlockConfig input = new FlockConfig().setName(Id.valueOf("test"))
            .setIdentifier(URI.create("asio:///test/")).setTimeout(Timeout.from(21, TimeUnit.HOURS));
    final FlockConfig result = make(Id.valueOf("test"), JACKSON.writeValueAsBytes(input));
    assertThat(result.getIdentifier(), equalTo(URI.create("asio:///test/")));
    assertThat(result.getTimeout(), equalTo(Timeout.from(21, TimeUnit.HOURS)));
}

From source file:com.collective.celos.ci.mode.test.TestRunTest.java

@Test
public void testCelosCiDeployContextEmbedded() throws Exception {

    URI hadoopCoreUrl = Thread.currentThread().getContextClassLoader()
            .getResource("com/collective/celos/ci/testing/config/core-site.xml").toURI();
    URI hadoopHdfsUrl = Thread.currentThread().getContextClassLoader()
            .getResource("com/collective/celos/ci/testing/config/hdfs-site.xml").toURI();

    CiCommandLine commandLine = new CiCommandLine("", "TEST", tmpDirFile.getAbsolutePath(), "workflow",
            tmpDirFile.getAbsolutePath(), "uname", false, null, "/hdfsRoot");
    CelosCiTarget target = new CelosCiTarget(hadoopHdfsUrl, hadoopCoreUrl, URI.create("celoswfdir"),
            URI.create("defdir"), URI.create(""));
    TestCase testCase = new TestCase("tc1", "2013-12-20T16:00Z", "2013-12-20T16:00Z");
    TestRun testRunContext = new TestRun(target, commandLine, testCase, tempDir.newFolder());

    CelosCiContext context = testRunContext.getCiContext();

    String tmpDir = new File(System.getProperty("java.io.tmpdir"), "celos").getAbsolutePath();

    Assert.assertEquals(context.getDeployDir(), commandLine.getDeployDir());
    Assert.assertTrue(StringUtils.isNotEmpty(context.getHdfsPrefix()));
    Assert.assertEquals(context.getMode(), commandLine.getMode());
    Assert.assertEquals(context.getTarget().getWorkflowsDirUri(),
            new File(testRunContext.getTestCaseTempDir(), "workflows").toURI());
    Assert.assertFalse(context.getTarget().getDefaultsDirUri().toString().startsWith(tmpDir));
    Assert.assertEquals(context.getTarget().getPathToCoreSite(), hadoopCoreUrl);
    Assert.assertEquals(context.getTarget().getPathToHdfsSite(), hadoopHdfsUrl);
    Assert.assertEquals(context.getUserName(), commandLine.getUserName());
    Assert.assertEquals(context.getWorkflowName(), commandLine.getWorkflowName());

    Assert.assertTrue(/*  w w w . ja v  a 2s  .com*/
            testRunContext.getTestCaseTempDir().toString().startsWith(System.getProperty("java.io.tmpdir")));
    Assert.assertTrue(testRunContext.getTestCaseTempDir().toString().length() > tmpDir.length());
    Assert.assertEquals(testRunContext.getOriginalTarget().getWorkflowsDirUri(), URI.create("celoswfdir"));
}

From source file:CompileString.java

JavaSourceFromString(String name, String code) {
    super(URI.create("string:///" + name.replace('.', '/') + Kind.SOURCE.extension), Kind.SOURCE);
    this.code = code;
}

From source file:com.twosigma.beaker.core.rest.LoginRest.java

@POST
@Path("login")
@Produces(MediaType.TEXT_HTML)/*  www .j a  v  a 2s. c om*/
public Response login(@FormParam("password") String password, @FormParam("origin") String origin)
        throws UnknownHostException {
    String cookie = config.getAuthCookie();
    if (password != null && origin != null && hash(password).equals(config.getPasswordHash())) {
        return Response.seeOther(URI.create(origin + "/beaker/"))
                .cookie(new NewCookie("BeakerAuth", cookie, "/", null, null, NewCookie.DEFAULT_MAX_AGE, true))
                .build();
    }
    // bad password, try again
    return Response.seeOther(URI.create(origin + "/login/login.html")).build();
}