List of usage examples for java.net URI create
public static URI create(String str)
From source file:com.collaborne.jsonschema.generator.pojo.PojoGeneratorTest.java
@Test public void generateInternalPrimitiveTypeReturnsPrimitiveTypeWithoutGeneration() throws CodeGenerationException, IOException { JsonNode schemaNode = jsonNodeReader.fromReader(new StringReader("{\"type\": \"string\"}")); SchemaTree schema = schemaLoader.load(schemaNode); Mapping mapping = new Mapping(URI.create("http://example.com/type.json#"), ClassName.create(Integer.TYPE)); final AtomicBoolean writeSourceCalled = new AtomicBoolean(); PojoGenerator generator = new PojoGenerator(null, null, null) { @Override//from w w w. j a v a2 s . c om protected void writeSource(URI type, ClassName className, Buffer buffer) throws IOException { writeSourceCalled.set(true); } }; ClassName className = generator.generateInternal(mapping.getTarget(), schema, mapping); assertEquals(mapping.getClassName(), className); assertFalse(writeSourceCalled.get()); }
From source file:me.lazerka.gae.jersey.oauth2.facebook.TokenVerifierFacebookCodeTest.java
@BeforeMethod public void setUp() throws URISyntaxException, IOException { MockitoAnnotations.initMocks(this); unit = new TokenVerifierFacebookCode(mock(URLFetchService.class), jackson, "138483919580948", "secret", "http://local.host/test"); when(request.getRequestUri()).thenReturn(URI.create("https://example.com")); }
From source file:net.sf.taverna.t2.activities.rshell.RshellActivityFactoryTest.java
/** * Test method for {@link net.sf.taverna.t2.activities.rshell.RshellActivityFactory#getActivityType()}. *///w w w . j a v a 2s . c o m @Test public void testGetActivityURI() { assertEquals(URI.create(RshellActivity.URI), factory.getActivityType()); }
From source file:com.optimizely.ab.config.HttpProjectConfigManager.java
private HttpProjectConfigManager(long period, TimeUnit timeUnit, OptimizelyHttpClient httpClient, String url, long blockingTimeoutPeriod, TimeUnit blockingTimeoutUnit) { super(period, timeUnit, blockingTimeoutPeriod, blockingTimeoutUnit); this.httpClient = httpClient; this.uri = URI.create(url); }
From source file:se.vgregion.urlservice.services.SambaFacilitiesServiceTest.java
@Before public void before() throws IOException { MockitoAnnotations.initMocks(this); facilityService.setSambaBaseUrl(URI.create("http://example.com/")); when(httpClientFactory.getClient()).thenReturn(httpClient); when(httpClient.execute(Mockito.any(HttpUriRequest.class))).thenReturn(httpResponse); when(httpResponse.getEntity()).thenReturn(httpEntity); when(httpResponse.getStatusLine())//w ww .ja v a 2s .com .thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 0), 200, "OK")); facilityService.setHttpClientFactory(httpClientFactory); }
From source file:com.proofpoint.event.collector.combiner.S3CombineObjectMetadataStore.java
@Inject public S3CombineObjectMetadataStore(ServerConfig config, AmazonS3 s3Service) { this(URI.create(checkNotNull(config, "config is null").getS3MetadataLocation()), s3Service); }
From source file:ddf.registry.server.rest.internal.RestRegistryServerTest.java
/** * Tests that the server returns correct values back in JSON format. *//*from w ww . j av a 2 s . c o m*/ @Test public void testGetServices() { ServiceRegistry serviceRegistry = createRegistry(); RestRegistryServer registryServer = new RestRegistryServer(serviceRegistry); UriInfo uriInfo = mock(UriInfo.class); URI baseUri = URI.create(LOCAL_URL); when(uriInfo.getBaseUri()).thenReturn(baseUri); Response response = registryServer.getServices(uriInfo); Object entity = response.getEntity(); assertNotNull(entity); JSONArray serviceArray = new JSONArray(entity.toString()); assertEquals(2, serviceArray.length()); JSONObject service1 = serviceArray.getJSONObject(0); assertEquals(TYPE_1, service1.get("type")); assertEquals(DESCRIPTION_1, service1.get("description")); assertEquals(LOCAL_URL + URL_1, service1.get("url")); }
From source file:org.commonjava.maven.atlas.graph.jackson.ProjectRelationshipSerializerModuleTest.java
@Test public void roundTrip_ParentRelationship() throws Exception { ParentRelationship rel = new SimpleParentRelationship(URI.create("some:test:location"), new SimpleProjectVersionRef("org.foo", "bar", "1"), new SimpleProjectVersionRef("org.foo", "parent", "1001")); String json = mapper.writeValueAsString(rel); System.out.println(json);// w w w . j ava 2 s .c o m ProjectRelationship<?, ?> result = mapper.readValue(json, ProjectRelationship.class); assertThat((ParentRelationship) result, equalTo(rel)); }
From source file:org.fcrepo.importexport.integration.BagItIT.java
@Test public void testExportBag() throws Exception { final String exampleID = UUID.randomUUID().toString(); final URI uri = URI.create(serverAddress + exampleID); final FcrepoResponse response = create(uri); assertEquals(SC_CREATED, response.getStatusCode()); assertEquals(uri, response.getLocation()); final Config config = new Config(); config.setMode("export"); config.setBaseDirectory(TARGET_DIR + File.separator + exampleID); config.setIncludeBinaries(true);//w w w . ja v a 2 s . co m config.setResource(uri); config.setPredicates(new String[] { CONTAINS.toString() }); config.setRdfExtension(DEFAULT_RDF_EXT); config.setRdfLanguage(DEFAULT_RDF_LANG); config.setUsername(USERNAME); config.setPassword(PASSWORD); config.setBagProfile(DEFAULT_BAG_PROFILE); config.setBagConfigPath("src/test/resources/configs/bagit-config.yml"); new Exporter(config, clientBuilder).run(); final Path target = Paths.get(TARGET_DIR, exampleID); assertTrue(target.resolve("bagit.txt").toFile().exists()); assertTrue(target.resolve("manifest-sha1.txt").toFile().exists()); final Path dataDir = target.resolve("data"); assertTrue(dataDir.toFile().exists()); assertTrue(dataDir.toFile().isDirectory()); final Path resourceFile = Paths.get(dataDir.toString(), uri.getPath() + DEFAULT_RDF_EXT); assertTrue(resourceFile.toFile().exists()); final FcrepoResponse response1 = clientBuilder.build().get(uri).perform(); final MessageDigest sha1 = MessageDigest.getInstance("SHA-1"); final byte[] buf = new byte[8192]; int read = 0; while ((read = response1.getBody().read(buf)) != -1) { sha1.update(buf, 0, read); } final String checksum = new String(encodeHex(sha1.digest())); final BufferedReader reader = new BufferedReader( new FileReader(target.resolve("manifest-sha1.txt").toFile())); final String checksumLine = reader.readLine(); reader.close(); assertEquals(checksum, checksumLine.split(" ")[0]); }
From source file:com.collective.celos.ci.config.deploy.CelosCiTargetParser.java
public CelosCiTarget parse(URI targetFileUri) throws Exception { FileObject file = worker.getFileObjectByUri(targetFileUri); InputStream is = file.getContent().getInputStream(); HashMap<String, String> result = Util.JSON_READER.withType(HashMap.class).readValue(is); URI hdfsSiteXml = URI.create(getNotNull(result, HADOOP_HDFS_SITE_XML)); URI hdfsCoreXml = URI.create(getNotNull(result, HADOOP_CORE_SITE_XML)); URI workflowDir = URI.create(getNotNull(result, WORKFLOWS_DIR_URI)); URI defaultsFile = URI.create(getNotNull(result, DEFAULTS_DIR_URI)); URI hiveJdbc = result.get(HIVE_JDBC_URL) != null ? URI.create(result.get(HIVE_JDBC_URL)) : null; return new CelosCiTarget(hdfsSiteXml, hdfsCoreXml, workflowDir, defaultsFile, hiveJdbc); }