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:reconf.server.domain.result.PropertyResult.java

public void addSelfUri(String baseUrl) {
    if (links == null) {
        links = new ArrayList<>();
    }//  w w  w  .jav  a  2 s .c  o m
    this.links.add(new Link(URI.create(baseUrl + getSelfUri()), "self"));
}

From source file:jfs.sync.util.WindowsProxySelector.java

@Override
public List<Proxy> select(URI uri) {
    List<Proxy> result = null;

    URI url = URI.create(uri.toString().replace("https://", "http://"));
    result = root.select(url);/*from   w w  w  .j  av  a2 s  . c  o  m*/
    if (LOG.isDebugEnabled()) {
        LOG.debug("select() uri " + uri);
        LOG.debug("select() url " + url);
        LOG.debug("select() proxies " + result);
    } // if
    return result;
}

From source file:nl.salp.warcraft4j.io.CachedHttpDataReader.java

/**
 * Read the data from a file (direct blocking http read).
 *
 * @param url The URL of the file to read.
 *
 * @return The file contents.//from w ww . j av a  2s . c o m
 *
 * @throws DataReadingException When reading the file failed.
 */
private static byte[] getData(String url) throws DataReadingException {
    try (CloseableHttpClient httpClient = HttpClients.createDefault();
            CloseableHttpResponse response = httpClient.execute(new HttpGet(URI.create(url)))) {
        StatusLine statusLine = response.getStatusLine();
        if (statusLine.getStatusCode() > 300) {
            throw new DataReadingException(String.format("Error opening HTTP data reader for %s: error %d: %s",
                    url, statusLine.getStatusCode(), statusLine.getReasonPhrase()));
        }
        HttpEntity entity = response.getEntity();
        if (entity == null) {
            throw new DataReadingException(format("HTTP data reader received no response from for %s", url));
        }
        byte[] data = EntityUtils.toByteArray(entity);
        EntityUtils.consume(entity);
        return data;
    } catch (IOException e) {
        throw new DataReadingException(e);
    }
}

From source file:org.jclouds.http.httpnio.pool.NioHttpCommandConnectionPoolTest.java

public void testConstructorGoodPort() throws Exception {
    NioHttpCommandConnectionPool pool = new NioHttpCommandConnectionPool(null, null, null, null,
            createNiceMock(AsyncNHttpClientHandler.class), null, createNiceMock(HttpParams.class),
            URI.create("http://localhost:80"));
    assertEquals(pool.getTarget(), new InetSocketAddress("localhost", 80));
}

From source file:com.nesscomputing.quartz.TestQuartzJobBuilder.java

@Before
public void setUp() throws Exception {
    config = Config.getConfig(URI.create("classpath:/test-config"), "builder");
    nessJobConfig = config.getConfiguration("ness.job");
    scheduler = createMock(Scheduler.class);

    EasyMock.expect(scheduler.scheduleJob(EasyMock.capture(jobDetailCapture), EasyMock.capture(triggerCapture)))
            .andReturn(null).anyTimes();
    scheduler.addJob(EasyMock.capture(jobAddCapture), EasyMock.anyBoolean());
    EasyMock.expectLastCall().anyTimes();

    replayAll();/*from  www . ja va2 s .  c  o m*/
}

From source file:se.vgregion.mobile.controllers.AdminGuiControllerTest.java

@Test
public void index() throws IOException {
    HttpServletRequest request = mock(HttpServletRequest.class);

    Printer p1 = new Printer("p1", "help", "info", new PrinterQueue("A4"));
    List<Printer> printers = Arrays.asList(p1);

    PrinterService printerService = mock(PrinterService.class);

    Mockito.when(printerService.findAllPrinters()).thenReturn(printers);
    controller.setPrinterService(printerService);

    URI applicationUrl = URI.create("http://example.com");
    controller.setApplicationUrl(applicationUrl);

    ModelAndView mav = controller.index(request);
    Assert.assertEquals(printers, mav.getModel().get("printers"));
    Assert.assertEquals(applicationUrl, mav.getModel().get("appurl"));
}

From source file:org.fcrepo.importexport.integration.ExporterIT.java

public ExporterIT() {
    super();
    url = URI.create(serverAddress + UUID.randomUUID());
}

From source file:se.vgregion.pubsub.push.impl.PushTest.java

@Test
@Transactional // TODO remove
public void test() throws InterruptedException {
    final URI testUri = URI.create("http://feeds.feedburner.com/protocol7/main");

    PubSubEngine pubSubEngine = applicationContext.getBean(PubSubEngine.class);

    final LinkedBlockingQueue<Feed> publishedFeeds = new LinkedBlockingQueue<Feed>();

    pubSubEngine.subscribe(new Subscriber() {

        @Override//w  ww  .  ja v  a2  s .  c om
        public void timedOut() {
        }

        @Override
        public void publish(Feed feed, PushJms pushJms) throws PublicationFailedException {
            publishedFeeds.add(feed);
        }

        @Override
        public URI getTopic() {
            return testUri;
        }

        @Override
        public DateTime getTimeout() {
            return null;
        }

        @Override
        public DateTime getLastUpdated() {
            return null;
        }
    });

    //        pubSubEngine.getOrCreateTopic(testUri).addSubscriber(new DefaultPushSubscriber(
    //                applicationContext.getBean(PushSubscriberRepository.class),
    //                testUri, URI.create("http://localhost:9000"), 100, "verify"));

    PushSubscriberManager pushSubscriberManager = applicationContext.getBean(PushSubscriberManager.class);
    pushSubscriberManager.retrive(testUri);

    Feed feed = publishedFeeds.poll(10000, TimeUnit.MILLISECONDS);

    //        Thread.sleep(200000);
}

From source file:io.pivotal.strepsirrhini.chaoslemur.infrastructure.StandardDirectorUtilsTest.java

@Test
public void getDeployments() {
    when(this.restTemplate.getForObject(URI.create("http://localhost/deployments"), List.class))
            .thenReturn(Arrays.asList(this.deployment));

    Set<String> expected = new HashSet<>();
    expected.add("test-deployment");

    assertEquals(expected, this.directorUtils.getDeployments());
}

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

@Test
public void should_use_default_values_if_config_empty() throws Exception {
    final FlockConfig result = make(Id.valueOf("test"), Payload.encodeUtf8("{}"));
    assertThat(result.getName(), equalTo(Id.valueOf("test")));
    assertThat(result.getTimeout(), equalTo(Timeout.from(23, TimeUnit.DAYS)));
    assertThat(result.getIdentifier(), equalTo(URI.create("asio:///flock/")));
}