Here are the examples of the java api class java.net.URI taken from open source projects.
1. ClientDataSource#main()
Project: openejb
File: ClientDataSource.java
File: ClientDataSource.java
public static void main(String[] args) throws URISyntaxException { URI uri1; uri1 = new URI("datasource", null, "/path", null, null); uri1 = new URI("datasource", null, "/path", null, null); System.out.println("uri = " + uri1); uri1 = new URI("datasource", "host", "/path", null, null); System.out.println("uri = " + uri1); uri1 = new URI("datasource", "host", "/path", "query", "fragment"); System.out.println("uri = " + uri1); uri1 = new URI("jdbc:derby://localhost:8080/databaseName"); print(uri1); print(new URI(uri1.getSchemeSpecificPart())); }
2. SubFlowSystemTest#testCompileAndRunSubFlowBasic()
Project: cloud-slang
File: SubFlowSystemTest.java
File: SubFlowSystemTest.java
@Test public void testCompileAndRunSubFlowBasic() throws Exception { URI resource = getClass().getResource("/yaml/sub-flow/parent_flow.sl").toURI(); URI subFlow = getClass().getResource("/yaml/sub-flow/child_flow.sl").toURI(); URI operation1 = getClass().getResource("/yaml/test_op.sl").toURI(); URI operation2 = getClass().getResource("/yaml/check_weather.sl").toURI(); URI operation3 = getClass().getResource("/yaml/get_time_zone.sl").toURI(); URI operation4 = getClass().getResource("/yaml/check_number.sl").toURI(); Set<SlangSource> path = Sets.newHashSet(SlangSource.fromFile(subFlow), SlangSource.fromFile(operation1), SlangSource.fromFile(operation2), SlangSource.fromFile(operation3), SlangSource.fromFile(operation4)); CompilationArtifact compilationArtifact = slang.compile(SlangSource.fromFile(resource), path); Assert.assertEquals("the system properties size is not as expected", 2, compilationArtifact.getSystemProperties().size()); Set<SystemProperty> systemProperties = new HashSet<>(); systemProperties.add(new SystemProperty("user.sys", "props.port", "22")); systemProperties.add(new SystemProperty("user.sys", "props.alla", "balla")); Map<String, Value> userInputs = new HashMap<>(); userInputs.put("input1", ValueFactory.create("value1")); ScoreEvent event = trigger(compilationArtifact, userInputs, systemProperties); Assert.assertEquals(ScoreLangConstants.EVENT_EXECUTION_FINISHED, event.getEventType()); }
3. CompilerErrorsTest#testValidationMatchingNavigation()
Project: cloud-slang
File: CompilerErrorsTest.java
File: CompilerErrorsTest.java
@Test public void testValidationMatchingNavigation() throws Exception { URI resource = getClass().getResource("/corrupted/matching-navigation/parent_flow.sl").toURI(); URI subFlow = getClass().getResource("/corrupted/matching-navigation/child_flow.sl").toURI(); URI operation1 = getClass().getResource("/corrupted/matching-navigation/test_op.sl").toURI(); URI operation2 = getClass().getResource("/corrupted/matching-navigation/check_weather.sl").toURI(); URI operation3 = getClass().getResource("/corrupted/matching-navigation/get_time_zone.sl").toURI(); URI operation4 = getClass().getResource("/corrupted/matching-navigation/check_number.sl").toURI(); Set<SlangSource> dependencies = new HashSet<>(); dependencies.add(SlangSource.fromFile(subFlow)); dependencies.add(SlangSource.fromFile(operation1)); dependencies.add(SlangSource.fromFile(operation2)); dependencies.add(SlangSource.fromFile(operation3)); dependencies.add(SlangSource.fromFile(operation4)); exception.expect(IllegalArgumentException.class); exception.expectMessage("Cannot compile flow: 'child_flow' since for step: 'step01', the result 'NEGATIVE' " + "of its dependency: 'user.ops.get_time_zone' has no matching navigation"); compiler.compile(SlangSource.fromFile(resource), dependencies); }
4. URIUtilsTest#testResolve()
Project: RSSOwl
File: URIUtilsTest.java
File: URIUtilsTest.java
/** * @throws Exception */ @Test public void testResolve() throws Exception { URI baseWithTrailingSlash = new URI("http://www.rssowl.org/"); URI baseWithoutTrailingSlash = new URI("http://www.rssowl.org"); URI base2WithTrailingSlash = new URI("http://www.rssowl.org/other/"); URI base2WithoutTrailingSlash = new URI("http://www.rssowl.org/other"); URI relativeWithLeadingSlash = new URI("/path/download.mp3"); URI relativeWithoutLeadingSlash = new URI("path/download.mp3"); assertEquals("http://www.rssowl.org/path/download.mp3", URIUtils.resolve(baseWithTrailingSlash, relativeWithLeadingSlash).toString()); assertEquals("http://www.rssowl.org/path/download.mp3", URIUtils.resolve(baseWithTrailingSlash, relativeWithoutLeadingSlash).toString()); assertEquals("http://www.rssowl.org/path/download.mp3", URIUtils.resolve(baseWithoutTrailingSlash, relativeWithLeadingSlash).toString()); assertEquals("http://www.rssowl.org/path/download.mp3", URIUtils.resolve(baseWithoutTrailingSlash, relativeWithoutLeadingSlash).toString()); assertEquals("http://www.rssowl.org/path/download.mp3", URIUtils.resolve(base2WithTrailingSlash, relativeWithLeadingSlash).toString()); assertEquals("http://www.rssowl.org/other/path/download.mp3", URIUtils.resolve(base2WithTrailingSlash, relativeWithoutLeadingSlash).toString()); assertEquals("http://www.rssowl.org/path/download.mp3", URIUtils.resolve(base2WithoutTrailingSlash, relativeWithLeadingSlash).toString()); assertEquals("http://www.rssowl.org/other/path/download.mp3", URIUtils.resolve(base2WithoutTrailingSlash, relativeWithoutLeadingSlash).toString()); }
5. UrlHelperTest#testCollectionInDomainUrl()
Project: vso-intellij
File: UrlHelperTest.java
File: UrlHelperTest.java
@Test public void testCollectionInDomainUrl() { //vsts account final URI accountUri = URI.create("https://myaccount.visualstudio.com"); //collection not in domain final URI defaultCollectionUri = UrlHelper.getCollectionURI(accountUri, "DefaultCollection"); assertEquals(URI.create("https://myaccount.visualstudio.com/DefaultCollection"), defaultCollectionUri); //collection in domain final URI inDomainCollectionUri = UrlHelper.getCollectionURI(accountUri, "myaccount"); assertEquals(accountUri, inDomainCollectionUri); //onprem server final URI serverUri = URI.create("http://myserver:8080/tfs"); final URI collectionUri1 = UrlHelper.getCollectionURI(serverUri, "FabrikamCollection"); assertEquals(URI.create("http://myserver:8080/tfs/FabrikamCollection"), collectionUri1); final URI collectionUri2 = UrlHelper.getCollectionURI(serverUri, "myserver"); assertEquals(URI.create("http://myserver:8080/tfs/myserver"), collectionUri2); }
6. FactorImports#outputFileFor()
Project: xmlbeans
File: FactorImports.java
File: FactorImports.java
private static File outputFileFor(File file, File baseDir, File outdir) { URI base = baseDir.getAbsoluteFile().toURI(); URI abs = file.getAbsoluteFile().toURI(); URI rel = base.relativize(abs); if (rel.isAbsolute()) { System.out.println("Cannot relativize " + file); return null; } URI outbase = outdir.toURI(); URI out = CodeGenUtil.resolve(outbase, rel); return new File(out); }
7. XmlParser#getCumulativeXmlBase()
Project: gdata-java-client
File: XmlParser.java
File: XmlParser.java
/** * Computes a cumulative value of {@code xml:base} based on a prior value * and a new value. If the new value is an absolute URI, it is returned * unchanged. If the new value is a relative URI, it is combined with the * prior value. * * @param curBase * Current value of {@code xml:base} or {@code null}. * * @param newBase * New value of {@code xml:base}. * * @return Combined value of {@code xml:base}, which is guaranteed to be * an absolute URI. * * @throws URISyntaxException * Invalid value of {@code xml:base} (doesn't parse as a valid * relative/absolute URI depending on {@code xml:base} context). */ static String getCumulativeXmlBase(String curBase, String newBase) throws URISyntaxException { URI newBaseUri = new URI(newBase); if (curBase == null || curBase.equals("")) { // We require an absolute URI. if (!newBaseUri.isAbsolute()) { throw new URISyntaxException(newBase, "No xml:base established--need an absolute URI."); } return newBase; } URI curBaseUri = new URI(curBase); URI resultUri = curBaseUri.resolve(newBaseUri); assert resultUri.isAbsolute(); return resultUri.toString(); }
8. XmlParser#getCumulativeXmlBase()
Project: gdata-java-client
File: XmlParser.java
File: XmlParser.java
/** * Computes a cumulative value of {@code xml:base} based on a prior value * and a new value. If the new value is an absolute URI, it is returned * unchanged. If the new value is a relative URI, it is combined with the * prior value. * * @param curBase * Current value of {@code xml:base} or {@code null}. * * @param newBase * New value of {@code xml:base}. * * @return Combined value of {@code xml:base}, which is guaranteed to be * an absolute URI. * * @throws URISyntaxException * Invalid value of {@code xml:base} (doesn't parse as a valid * relative/absolute URI depending on {@code xml:base} context). */ static String getCumulativeXmlBase(String curBase, String newBase) throws URISyntaxException { URI newBaseUri = new URI(newBase); if (curBase == null || curBase.equals("")) { // We require an absolute URI. if (!newBaseUri.isAbsolute()) { throw new URISyntaxException(newBase, "No xml:base established--need an absolute URI."); } return newBase; } URI curBaseUri = new URI(curBase); URI resultUri = curBaseUri.resolve(newBaseUri); assert resultUri.isAbsolute(); return resultUri.toString(); }
9. FactorImports#relativeURIFor()
Project: xmlbeans
File: FactorImports.java
File: FactorImports.java
private static String relativeURIFor(File source, File target) { URI base = source.getAbsoluteFile().toURI(); URI abs = target.getAbsoluteFile().toURI(); // find common substring... URI commonBase = commonAncestor(base, abs); if (commonBase == null) return abs.toString(); URI baserel = commonBase.relativize(base); URI targetrel = commonBase.relativize(abs); if (baserel.isAbsolute() || targetrel.isAbsolute()) return abs.toString(); String prefix = ""; String sourceRel = baserel.toString(); for (int i = 0; i < sourceRel.length(); ) { i = sourceRel.indexOf('/', i); if (i < 0) break; prefix += "../"; i += 1; } return prefix + targetrel.toString(); }
10. URISupportTest#testCompositeCreateURIWithQuery()
Project: qpid-jms
File: URISupportTest.java
File: URISupportTest.java
@Test public void testCompositeCreateURIWithQuery() throws Exception { String queryString = "query=value"; URI originalURI = new URI("outerscheme:(innerscheme:innerssp)"); URI querylessURI = originalURI; assertEquals(querylessURI, PropertyUtil.eraseQuery(originalURI)); assertEquals(querylessURI, PropertyUtil.replaceQuery(originalURI, "")); assertEquals(new URI(querylessURI + "?" + queryString), PropertyUtil.replaceQuery(originalURI, queryString)); originalURI = new URI("outerscheme:(innerscheme:innerssp)?outerquery=0"); assertEquals(querylessURI, PropertyUtil.eraseQuery(originalURI)); assertEquals(querylessURI, PropertyUtil.replaceQuery(originalURI, "")); assertEquals(new URI(querylessURI + "?" + queryString), PropertyUtil.replaceQuery(originalURI, queryString)); originalURI = new URI("outerscheme:(innerscheme:innerssp?innerquery=0)"); querylessURI = originalURI; assertEquals(querylessURI, PropertyUtil.eraseQuery(originalURI)); assertEquals(querylessURI, PropertyUtil.replaceQuery(originalURI, "")); assertEquals(new URI(querylessURI + "?" + queryString), PropertyUtil.replaceQuery(originalURI, queryString)); originalURI = new URI("outerscheme:(innerscheme:innerssp?innerquery=0)?outerquery=0"); assertEquals(querylessURI, PropertyUtil.eraseQuery(originalURI)); assertEquals(querylessURI, PropertyUtil.replaceQuery(originalURI, "")); assertEquals(new URI(querylessURI + "?" + queryString), PropertyUtil.replaceQuery(originalURI, queryString)); }
11. FilesDatasetSourceTest#setUp()
Project: mr4c
File: FilesDatasetSourceTest.java
File: FilesDatasetSourceTest.java
@Before public void setUp() throws Exception { m_configNoSelfURI = new URI("input/data/dataset/test1/source.json"); m_configSelfURI = new URI("input/data/dataset/test1/source_self.json"); m_inputDir = new URI("input/data/dataset/test1/input_data"); m_inputSelfDir = new URI("input/data/dataset/test1/input_data_self"); m_outputDir = new URI("output/data/dataset/test1"); m_inputFileSrc = FileSources.getFileSource(m_inputDir); m_inputSelfFileSrc = FileSources.getFileSource(m_inputSelfDir); m_outputFileSrc = FileSources.getFileSource(m_outputDir); m_configNoSelf = FilesDatasetSourceConfig.load(new ConfigDescriptor(m_configNoSelfURI)); m_configSelf = FilesDatasetSourceConfig.load(new ConfigDescriptor(m_configSelfURI)); m_inputSrc = new FilesDatasetSource(m_configNoSelf, m_inputFileSrc); m_outputSrc = new FilesDatasetSource(m_configNoSelf, m_outputFileSrc); }
12. TestAvatarStorageSetup#testSameSharedEditsLocation()
Project: hadoop-20
File: TestAvatarStorageSetup.java
File: TestAvatarStorageSetup.java
@Test public void testSameSharedEditsLocation() throws Exception { Configuration conf = new Configuration(); URI img0 = new URI("qjm://localhost:1234;localhost:1235;localhost:1236/test-id/zero/"); URI img1 = new URI("qjm://localhost:1234;localhost:1235;localhost:1236/test-id/one/"); URI edit0 = new URI("qjm://localhost:1234;localhost:1235;localhost:1236/test-id/"); URI edit1 = new URI("qjm://localhost:1234;localhost:1235;localhost:1236/test-id/"); conf.set("dfs.name.dir.shared0", img0.toString()); conf.set("dfs.name.dir.shared1", img1.toString()); conf.set("dfs.name.edits.dir.shared0", edit0.toString()); conf.set("dfs.name.edits.dir.shared1", edit1.toString()); // local locations for image and edits Collection<URI> namedirs = NNStorageConfiguration.getNamespaceDirs(conf, null); Collection<URI> editsdir = NNStorageConfiguration.getNamespaceEditsDirs(conf, null); try { AvatarStorageSetup.validate(conf, namedirs, editsdir, img0, img1, edit0, edit1); fail("fail of same shared eduts location"); } catch (IOException ex) { assertTrue(ex.getMessage().contains("same edits location")); } }
13. TestAvatarStorageSetup#testSameSharedImageLocation()
Project: hadoop-20
File: TestAvatarStorageSetup.java
File: TestAvatarStorageSetup.java
@Test public void testSameSharedImageLocation() throws Exception { Configuration conf = new Configuration(); URI img0 = new URI("qjm://localhost:1234;localhost:1235;localhost:1236/test-id/"); URI img1 = new URI("qjm://localhost:1234;localhost:1235;localhost:1236/test-id/"); URI edit0 = new URI("qjm://localhost:1234;localhost:1235;localhost:1236/test-id/zero/"); URI edit1 = new URI("qjm://localhost:1234;localhost:1235;localhost:1236/test-id/one/"); conf.set("dfs.name.dir.shared0", img0.toString()); conf.set("dfs.name.dir.shared1", img1.toString()); conf.set("dfs.name.edits.dir.shared0", edit0.toString()); conf.set("dfs.name.edits.dir.shared1", edit1.toString()); // local locations for image and edits Collection<URI> namedirs = NNStorageConfiguration.getNamespaceDirs(conf, null); Collection<URI> editsdir = NNStorageConfiguration.getNamespaceEditsDirs(conf, null); try { AvatarStorageSetup.validate(conf, namedirs, editsdir, img0, img1, edit0, edit1); fail("fail of same shared image location"); } catch (IOException ex) { assertTrue(ex.getMessage().contains("same image location")); } }
14. TestHttpUtils#testResolveUri()
Project: oodt
File: TestHttpUtils.java
File: TestHttpUtils.java
public void testResolveUri() throws URISyntaxException { URI baseUri = new URI("http://localhost/base/directory/"); // Test absolute resolve. URI resolvedAbsoluteUri = HttpUtils.resolveUri(baseUri, "/path/to/file"); assertEquals("http://localhost/path/to/file", resolvedAbsoluteUri.toString()); // Test relative resolve. URI resolvedRelativeUri = HttpUtils.resolveUri(baseUri, "path/to/file"); assertEquals("http://localhost/base/directory/path/to/file", resolvedRelativeUri.toString()); // Test relative with base not ending in / baseUri = new URI("http://localhost/base/directory"); assertEquals("http://localhost/base/directory/path/to/file", resolvedRelativeUri.toString()); }
15. ApplicationConfigurationTest#testURLFormats()
Project: juddi
File: ApplicationConfigurationTest.java
File: ApplicationConfigurationTest.java
@Test public void testURLFormats() throws MalformedURLException, URISyntaxException { URI file = new URI("file:/tmp/"); String path = file.getSchemeSpecificPart(); Assert.assertEquals("/tmp/", path); URI fileInJar = new URI("jar:file:/tmp/my.jar!/"); String path1 = fileInJar.getSchemeSpecificPart(); Assert.assertEquals("file:/tmp/my.jar!/", path1); URI fileInZip = new URI("zip:D:/bea/tmp/_WL_user/JuddiEAR/nk4cwv/war/WEB-INF/lib/juddi-core-3.0.1.jar!"); String path2 = fileInZip.getSchemeSpecificPart(); Assert.assertEquals("D:/bea/tmp/_WL_user/JuddiEAR/nk4cwv/war/WEB-INF/lib/juddi-core-3.0.1.jar!", path2); URI fileInVfszip = new URI("vfsfile:/tmp/SOA%20Platform/jbossesb-registry.sar/juddi_custom_install_data/root_Publisher.xml"); String path3 = fileInVfszip.getSchemeSpecificPart(); Assert.assertEquals("/tmp/SOA Platform/jbossesb-registry.sar/juddi_custom_install_data/root_Publisher.xml", path3); }
16. CxfCacheUriInfoIssueTest#checkContextForDifferentHostNamesRequests()
Project: olingo-odata2
File: CxfCacheUriInfoIssueTest.java
File: CxfCacheUriInfoIssueTest.java
@Test public void checkContextForDifferentHostNamesRequests() throws ClientProtocolException, IOException, ODataException, URISyntaxException { URI uri1 = URI.create(getEndpoint().toString() + "$metadata"); HttpGet get1 = new HttpGet(uri1); HttpResponse response1 = getHttpClient().execute(get1); assertNotNull(response1); URI serviceRoot1 = getService().getProcessor().getContext().getPathInfo().getServiceRoot(); assertEquals(uri1.getHost(), serviceRoot1.getHost()); get1.reset(); URI uri2 = new URI(uri1.getScheme(), uri1.getUserInfo(), "127.0.0.1", uri1.getPort(), uri1.getPath(), uri1.getQuery(), uri1.getFragment()); HttpGet get2 = new HttpGet(uri2); HttpResponse response2 = getHttpClient().execute(get2); assertNotNull(response2); URI serviceRoot2 = getService().getProcessor().getContext().getPathInfo().getServiceRoot(); assertEquals(uri2.getHost(), serviceRoot2.getHost()); }
17. StagedDatasetSourceTest#setUp()
Project: mr4c
File: StagedDatasetSourceTest.java
File: StagedDatasetSourceTest.java
@Before public void setUp() throws Exception { m_configURI = new URI("input/data/dataset/test1/source.json"); m_inputDir = new URI("input/data/dataset/test1/input_data"); m_actualDir = new URI("output/data/sources/staged/actual"); m_stageDir = new URI("output/data/sources/staged/stage"); m_inputFileSrc = FileSources.getFileSource(m_inputDir); m_actualFileSrc = FileSources.getFileSource(m_actualDir); m_stageFileSrc = FileSources.getFileSource(m_stageDir); m_config = FilesDatasetSourceConfig.load(new ConfigDescriptor(m_configURI)); m_inputSrc = new FilesDatasetSource(m_config, m_inputFileSrc); m_actualSrc = new FilesDatasetSource(m_config, m_actualFileSrc); m_stageSrc = new FilesDatasetSource(m_config, m_stageFileSrc); m_outputSrc = new StagedDatasetSource(m_actualSrc, m_stageSrc); m_actualFileSrc.ensureExists(); m_actualFileSrc.clear(); m_stageFileSrc.ensureExists(); m_stageFileSrc.clear(); }
18. XBayaConfiguration#loadConfiguration()
Project: airavata
File: XBayaConfiguration.java
File: XBayaConfiguration.java
private void loadConfiguration(URI uri) { LeadDeploymentConfig config = LeadDeploymentConfig.loadConfig(null, uri); URI gpel = config.getGpelUrl(); if (gpel != null) { this.gpelEngineURL = config.getGpelUrl(); } URI dsc = config.getDscUrl(); if (dsc != null) { this.dscURL = dsc; } URI broker = config.getBrokerUrl(); if (broker != null) { this.brokerURL = broker; } URI msgBox = config.getMsgBoxUrl(); if (msgBox != null) { this.messageBoxURL = msgBox; } }
19. NavigationTest#testOnFailureNavigationMoreSteps()
Project: cloud-slang
File: NavigationTest.java
File: NavigationTest.java
@Test public void testOnFailureNavigationMoreSteps() throws Exception { expectedEx.expect(RuntimeException.class); expectedEx.expectMessage("Below 'on_failure' property there should be only one step"); URI resource = getClass().getResource("/yaml/on_failure_more_steps.sl").toURI(); URI operationPython = getClass().getResource("/yaml/produce_default_navigation.sl").toURI(); URI operation2Python = getClass().getResource("/yaml/send_email_mock.sl").toURI(); URI operation3Python = getClass().getResource("/yaml/check_weather.sl").toURI(); Set<SlangSource> path = Sets.newHashSet(SlangSource.fromFile(operationPython), SlangSource.fromFile(operation2Python), SlangSource.fromFile(operation3Python)); slang.compile(SlangSource.fromFile(resource), path); }
20. NavigationTest#testDefaultOnFailureNavigation()
Project: cloud-slang
File: NavigationTest.java
File: NavigationTest.java
@Test public void testDefaultOnFailureNavigation() throws Exception { URI resource = getClass().getResource("/yaml/flow_default_navigation.yaml").toURI(); URI operationPython = getClass().getResource("/yaml/produce_default_navigation.sl").toURI(); URI operation2Python = getClass().getResource("/yaml/send_email_mock.sl").toURI(); URI operation3Python = getClass().getResource("/yaml/check_weather.sl").toURI(); Set<SlangSource> path = Sets.newHashSet(SlangSource.fromFile(operationPython), SlangSource.fromFile(operation2Python), SlangSource.fromFile(operation3Python)); CompilationArtifact compilationArtifact = slang.compile(SlangSource.fromFile(resource), path); Map<String, Value> userInputs = new HashMap<>(); userInputs.put("navigationType", ValueFactory.create("failure")); userInputs.put("emailHost", ValueFactory.create("emailHost")); userInputs.put("emailPort", ValueFactory.create("25")); userInputs.put("emailSender", ValueFactory.create("[email protected]")); userInputs.put("emailRecipient", ValueFactory.create("[email protected]")); Map<String, StepData> steps = triggerWithData(compilationArtifact, userInputs, new HashSet<SystemProperty>()).getSteps(); Assert.assertEquals("produce_default_navigation", steps.get(FIRST_STEP_PATH).getName()); Assert.assertEquals("send_error_mail", steps.get(SECOND_STEP_KEY).getName()); }
21. NavigationTest#testDefaultSuccessNavigation()
Project: cloud-slang
File: NavigationTest.java
File: NavigationTest.java
@Test public void testDefaultSuccessNavigation() throws Exception { URI resource = getClass().getResource("/yaml/flow_default_navigation.yaml").toURI(); URI operationPython = getClass().getResource("/yaml/produce_default_navigation.sl").toURI(); URI operation2Python = getClass().getResource("/yaml/send_email_mock.sl").toURI(); URI operation3Python = getClass().getResource("/yaml/check_weather.sl").toURI(); Set<SlangSource> path = Sets.newHashSet(SlangSource.fromFile(operationPython), SlangSource.fromFile(operation2Python), SlangSource.fromFile(operation3Python)); CompilationArtifact compilationArtifact = slang.compile(SlangSource.fromFile(resource), path); Map<String, Value> userInputs = new HashMap<>(); userInputs.put("navigationType", ValueFactory.create("success")); userInputs.put("emailHost", ValueFactory.create("emailHost")); userInputs.put("emailPort", ValueFactory.create("25")); userInputs.put("emailSender", ValueFactory.create("[email protected]")); userInputs.put("emailRecipient", ValueFactory.create("[email protected]")); Map<String, StepData> steps = triggerWithData(compilationArtifact, userInputs, new HashSet<SystemProperty>()).getSteps(); Assert.assertEquals("produce_default_navigation", steps.get(FIRST_STEP_PATH).getName()); Assert.assertEquals("check_weather", steps.get(SECOND_STEP_KEY).getName()); }
22. CompilerErrorsTest#testValidationOfFlowThatCallsCorruptedFlow()
Project: cloud-slang
File: CompilerErrorsTest.java
File: CompilerErrorsTest.java
@Test public void testValidationOfFlowThatCallsCorruptedFlow() throws Exception { URI flowUri = getClass().getResource("/corrupted/flow_that_calls_corrupted_flow.sl").toURI(); URI operation1Uri = getClass().getResource("/test_op.sl").toURI(); URI operation2Uri = getClass().getResource("/check_op.sl").toURI(); URI operation3Uri = getClass().getResource("/corrupted/flow_input_in_step_same_name_as_dependency_output.sl").toURI(); Set<SlangSource> dependencies = new HashSet<>(); dependencies.add(SlangSource.fromFile(operation1Uri)); dependencies.add(SlangSource.fromFile(operation2Uri)); dependencies.add(SlangSource.fromFile(operation3Uri)); exception.expect(IllegalArgumentException.class); exception.expectMessage("Cannot compile flow 'io.cloudslang.flow_input_in_step_same_name_as_dependency_output'. " + "Step 'explicit_alias' has input 'balla' with the same name as the one of the outputs of 'user.ops.test_op'."); compiler.compile(SlangSource.fromFile(flowUri), dependencies); }
23. CompilerErrorsTest#testFlowWhereMapCannotBeCreated()
Project: cloud-slang
File: CompilerErrorsTest.java
File: CompilerErrorsTest.java
@Test public void testFlowWhereMapCannotBeCreated() throws Exception { //covers "No single argument constructor found for interface java.util.Map" URI resource = getClass().getResource("/corrupted/flow_where_map_cannot_be_created.sl").toURI(); URI operations = getClass().getResource("/java_op.sl").toURI(); URI flows = getClass().getResource("/flow_with_data.yaml").toURI(); URI checkWeather = getClass().getResource("/check_Weather.sl").toURI(); Set<SlangSource> path = new HashSet<>(); path.add(SlangSource.fromFile(operations)); path.add(SlangSource.fromFile(flows)); path.add(SlangSource.fromFile(checkWeather)); exception.expect(RuntimeException.class); exception.expectMessage(ParserExceptionHandler.CANNOT_CREATE_PROPERTY_ERROR); exception.expectMessage(ParserExceptionHandler.KEY_VALUE_PAIR_MISSING_OR_INDENTATION_PROBLEM_MSG); compiler.compile(SlangSource.fromFile(resource), path); }
24. CompilerErrorsTest#testFlowWithWrongIndentation()
Project: cloud-slang
File: CompilerErrorsTest.java
File: CompilerErrorsTest.java
@Test public void testFlowWithWrongIndentation() throws Exception { //covers "Unable to find property 'X' on class: io.cloudslang.lang.compiler.parser.model.ParsedSlang" URI resource = getClass().getResource("/corrupted/flow_with_wrong_indentation.sl").toURI(); URI operations = getClass().getResource("/java_op.sl").toURI(); URI flows = getClass().getResource("/flow_with_data.yaml").toURI(); URI checkWeather = getClass().getResource("/check_Weather.sl").toURI(); Set<SlangSource> path = new HashSet<>(); path.add(SlangSource.fromFile(operations)); path.add(SlangSource.fromFile(flows)); path.add(SlangSource.fromFile(checkWeather)); exception.expect(RuntimeException.class); exception.expectMessage(ParserExceptionHandler.CANNOT_CREATE_PROPERTY_ERROR); exception.expectMessage("Unable to find property"); exception.expectMessage("is not supported by CloudSlang"); compiler.compile(SlangSource.fromFile(resource), path); }
25. CompilerErrorsTest#testFlowWithMissingSpaceBeforeFirstImport()
Project: cloud-slang
File: CompilerErrorsTest.java
File: CompilerErrorsTest.java
@Test public void testFlowWithMissingSpaceBeforeFirstImport() throws Exception { //covers "mapping values are not allowed here" error URI resource = getClass().getResource("/corrupted/flow_with_missing_space_before_first_import.sl").toURI(); URI operations = getClass().getResource("/java_op.sl").toURI(); URI checkWeather = getClass().getResource("/check_Weather.sl").toURI(); URI flows = getClass().getResource("/flow_with_data.yaml").toURI(); Set<SlangSource> path = new HashSet<>(); path.add(SlangSource.fromFile(operations)); path.add(SlangSource.fromFile(flows)); path.add(SlangSource.fromFile(checkWeather)); exception.expect(RuntimeException.class); exception.expectMessage(ParserExceptionHandler.MAPPING_VALUES_NOT_ALLOWED_HERE_ERROR); exception.expectMessage(ParserExceptionHandler.KEY_VALUE_PAIR_MISSING_OR_INDENTATION_PROBLEM_MSG); compiler.compile(SlangSource.fromFile(resource), path); }
26. CompileFlowWithMultipleStepsTest#testCompileFlowBasic()
Project: cloud-slang
File: CompileFlowWithMultipleStepsTest.java
File: CompileFlowWithMultipleStepsTest.java
@Test public void testCompileFlowBasic() throws Exception { URI flow = getClass().getResource("/flow_with_multiple_steps.yaml").toURI(); URI operation1 = getClass().getResource("/test_op.sl").toURI(); URI operation2 = getClass().getResource("/java_op.sl").toURI(); URI operation3 = getClass().getResource("/check_Weather.sl").toURI(); Set<SlangSource> path = new HashSet<>(); path.add(SlangSource.fromFile(operation1)); path.add(SlangSource.fromFile(operation2)); path.add(SlangSource.fromFile(operation3)); CompilationArtifact compilationArtifact = compiler.compile(SlangSource.fromFile(flow), path); ExecutionPlan executionPlan = compilationArtifact.getExecutionPlan(); Assert.assertNotNull("execution plan is null", executionPlan); Assert.assertEquals("there is a different number of steps than expected", 10, executionPlan.getSteps().size()); Assert.assertEquals("execution plan name is different than expected", "flow_with_multiple_steps", executionPlan.getName()); Assert.assertEquals("the dependencies size is not as expected", 3, compilationArtifact.getDependencies().size()); }
27. CompileDependenciesTest#filesThatAreNotImportedShouldNotBeCompiled()
Project: cloud-slang
File: CompileDependenciesTest.java
File: CompileDependenciesTest.java
@Test public void filesThatAreNotImportedShouldNotBeCompiled() throws Exception { URI flow = getClass().getResource("/basic_flow.yaml").toURI(); URI notImportedOperation = getClass().getResource("/flow_with_data.yaml").toURI(); URI importedOperation = getClass().getResource("/test_op.sl").toURI(); URI importedOperation2 = getClass().getResource("/check_Weather.sl").toURI(); Set<SlangSource> path = new HashSet<>(); path.add(SlangSource.fromFile(notImportedOperation)); path.add(SlangSource.fromFile(importedOperation)); path.add(SlangSource.fromFile(importedOperation2)); CompilationArtifact compilationArtifact = compiler.compile(SlangSource.fromFile(flow), path); Assert.assertThat(compilationArtifact.getDependencies(), Matchers.<String, ExecutionPlan>hasKey("user.ops.test_op")); Assert.assertThat(compilationArtifact.getDependencies(), not(Matchers.<String, ExecutionPlan>hasKey("slang.sample.flows.SimpleFlow"))); }
28. CompilerHelperTest#testCompileMixedSlangFiles()
Project: cloud-slang
File: CompilerHelperTest.java
File: CompilerHelperTest.java
@Test public void testCompileMixedSlangFiles() throws Exception { URI flowFilePath = getClass().getResource("/flow.sl").toURI(); URI folderPath = getClass().getResource("/mixed_sl_files/").toURI(); URI dependency1 = getClass().getResource("/mixed_sl_files/configuration/properties/executables/test_flow.sl").toURI(); URI dependency2 = getClass().getResource("/mixed_sl_files/configuration/properties/executables/test_op.sl").toURI(); compilerHelper.compile(flowFilePath.getPath(), Lists.newArrayList(folderPath.getPath())); Mockito.verify(slang).compile(SlangSource.fromFile(flowFilePath), Sets.newHashSet(SlangSource.fromFile(dependency1), SlangSource.fromFile(dependency2))); }
29. TestConfigClientUtils#testGetConfigKeyPath()
Project: gobblin
File: TestConfigClientUtils.java
File: TestConfigClientUtils.java
@Test public void testGetConfigKeyPath() throws URISyntaxException { String expected = "/datasets/a1/a2"; URI clientAbsURI = new URI("etl-hdfs://eat1-nertznn01.grid.linkedin.com:9000/user/mitu/HdfsBasedConfigTest/datasets/a1/a2"); ConfigKeyPath result = ConfigClientUtils.buildConfigKeyPath(clientAbsURI, mockConfigStore); Assert.assertEquals(result.toString(), expected); URI clientRelativeURI = new URI("etl-hdfs:///datasets/a1/a2"); result = ConfigClientUtils.buildConfigKeyPath(clientRelativeURI, mockConfigStore); Assert.assertEquals(result.toString(), expected); clientRelativeURI = new URI("etl-hdfs:/datasets/a1/a2"); result = ConfigClientUtils.buildConfigKeyPath(clientRelativeURI, mockConfigStore); Assert.assertEquals(result.toString(), expected); ConfigKeyPath configKey = SingleLinkedListConfigKeyPath.ROOT.createChild("data").createChild("databases").createChild("Identity"); // client app pass URI without authority URI adjusted = ConfigClientUtils.buildUriInClientFormat(configKey, mockConfigStore, false); Assert.assertTrue(adjusted.toString().equals("etl-hdfs:/data/databases/Identity")); // client app pass URI with authority adjusted = ConfigClientUtils.buildUriInClientFormat(configKey, mockConfigStore, true); Assert.assertTrue(adjusted.toString().equals("etl-hdfs://eat1-nertznn01.grid.linkedin.com:9000/user/mitu/HdfsBasedConfigTest/data/databases/Identity")); }
30. DefaultServiceInstanceConverter#convert()
Project: spring-boot-admin
File: DefaultServiceInstanceConverter.java
File: DefaultServiceInstanceConverter.java
@Override public Application convert(ServiceInstance instance) { Application.Builder builder = Application.create(instance.getServiceId()); URI healthUrl = getHealthUrl(instance); if (healthUrl != null) { builder.withHealthUrl(healthUrl.toString()); } URI managementUrl = getManagementUrl(instance); if (managementUrl != null) { builder.withManagementUrl(managementUrl.toString()); } URI serviceUrl = getServiceUrl(instance); if (serviceUrl != null) { builder.withServiceUrl(serviceUrl.toString()); } return builder.build(); }
31. UriBuilderTest#testRelativize()
Project: Resteasy
File: UriBuilderTest.java
File: UriBuilderTest.java
@Test public void testRelativize() throws Exception { URI from = URI.create("a/b/c"); URI to = URI.create("a/b/c/d/e"); URI relativized = ResteasyUriBuilder.relativize(from, to); Assert.assertEquals(relativized.toString(), "d/e"); from = URI.create("a/b/c"); to = URI.create("d/e"); relativized = ResteasyUriBuilder.relativize(from, to); Assert.assertEquals(relativized.toString(), "../../../d/e"); from = URI.create("a/b/c"); to = URI.create("a/b/c"); relativized = ResteasyUriBuilder.relativize(from, to); Assert.assertEquals(relativized.toString(), ""); from = URI.create("a"); to = URI.create("d/e"); relativized = ResteasyUriBuilder.relativize(from, to); Assert.assertEquals(relativized.toString(), "../d/e"); }
32. StoreResourceBean#head()
Project: Resteasy
File: StoreResourceBean.java
File: StoreResourceBean.java
public Response head(UriInfo uriInfo) { UriBuilder absolute = uriInfo.getBaseUriBuilder(); URI customerUrl = absolute.clone().path("customers").build(); URI orderUrl = absolute.clone().path("orders").build(); URI productUrl = absolute.clone().path("products").build(); javax.ws.rs.core.Link customers = javax.ws.rs.core.Link.fromUri(customerUrl).rel("customers").type("application/xml").build(); javax.ws.rs.core.Link orders = javax.ws.rs.core.Link.fromUri(orderUrl).rel("orders").type("application/xml").build(); javax.ws.rs.core.Link products = javax.ws.rs.core.Link.fromUri(productUrl).rel("products").type("application/xml").build(); Response.ResponseBuilder builder = Response.ok().links(customers, orders, products); return builder.build(); }
33. StoreResourceBean#head()
Project: Resteasy
File: StoreResourceBean.java
File: StoreResourceBean.java
public Response head(UriInfo uriInfo) { UriBuilder absolute = uriInfo.getBaseUriBuilder(); URI customerUrl = absolute.clone().path("customers").build(); URI orderUrl = absolute.clone().path("orders").build(); URI productUrl = absolute.clone().path("products").build(); Link customers = Link.fromUri(customerUrl).rel("customers").type("application/xml").build(); Link orders = Link.fromUri(orderUrl).rel("orders").type("application/xml").build(); Link products = Link.fromUri(productUrl).rel("products").type("application/xml").build(); Response.ResponseBuilder builder = Response.ok().links(customers, orders, products); return builder.build(); }
34. TransportBrokerTestSupport#createConnection()
Project: activemq-artemis
File: TransportBrokerTestSupport.java
File: TransportBrokerTestSupport.java
@Override protected StubConnection createConnection() throws Exception { URI bindURI = getBindURI(); // Note: on platforms like OS X we cannot bind to the actual hostname, so we // instead use the original host name (typically localhost) to bind to URI actualURI = this.broker.getConnectURI(); URI connectURI = new URI(actualURI.getScheme(), actualURI.getUserInfo(), bindURI.getHost(), actualURI.getPort(), actualURI.getPath(), bindURI.getQuery(), bindURI.getFragment()); Transport transport = TransportFactory.connect(connectURI); StubConnection connection = new StubConnection(transport); connections.add(connection); return connection; }
35. ActiveMQConnectionFactoryTest#assertCreateConnection()
Project: activemq-artemis
File: ActiveMQConnectionFactoryTest.java
File: ActiveMQConnectionFactoryTest.java
protected void assertCreateConnection(String uri) throws Exception { // Start up a broker with a tcp connector. broker = new BrokerService(); broker.setPersistent(false); broker.setUseJmx(false); TransportConnector connector = broker.addConnector(uri); broker.start(); URI temp = new URI(uri); // URI connectURI = connector.getServer().getConnectURI(); // TODO this sometimes fails when using the actual local host name URI currentURI = new URI(connector.getPublishableConnectString()); // sometimes the actual host name doesn't work in this test case // e.g. on OS X so lets use the original details but just use the actual // port URI connectURI = new URI(temp.getScheme(), temp.getUserInfo(), temp.getHost(), currentURI.getPort(), temp.getPath(), temp.getQuery(), temp.getFragment()); LOG.info("connection URI is: " + connectURI); // This should create the connection. ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(connectURI); connection = (ActiveMQConnection) cf.createConnection(); assertNotNull(connection); }
36. CompileBasicFlowTest#testValidFlowWithMissingDependencyRequiredInputInGrandchild()
Project: cloud-slang
File: CompileBasicFlowTest.java
File: CompileBasicFlowTest.java
@Test public void testValidFlowWithMissingDependencyRequiredInputInGrandchild() throws Exception { URI flowUri = getClass().getResource("/corrupted/flow_missing_dependency_required_input_in_grandchild.sl").toURI(); Executable flowModel = compiler.preCompile(SlangSource.fromFile(flowUri)); URI operation2Uri = getClass().getResource("/check_op.sl").toURI(); Executable operation2Model = compiler.preCompile(SlangSource.fromFile(operation2Uri)); URI subFlowUri = getClass().getResource("/flow_implicit_alias_for_current_namespace.sl").toURI(); Executable subFlowModel = compiler.preCompile(SlangSource.fromFile(subFlowUri)); Set<Executable> dependencies = new HashSet<>(); dependencies.add(subFlowModel); dependencies.add(operation2Model); List<RuntimeException> errors = compiler.validateSlangModelWithDirectDependencies(flowModel, dependencies); Assert.assertEquals(0, errors.size()); }
37. DefaultConfigurationResolverTest#testCacheManagerPropertiesOverridesSystemProperty()
Project: ehcache3
File: DefaultConfigurationResolverTest.java
File: DefaultConfigurationResolverTest.java
@Test public void testCacheManagerPropertiesOverridesSystemProperty() throws Exception { URI uri1 = makeURI(); URI uri2 = makeURI(); assertFalse(uri1.equals(uri2)); Properties props = new Properties(); props.put(DefaultConfigurationResolver.DEFAULT_CONFIG_PROPERTY_NAME, uri1); System.getProperties().put(DefaultConfigurationResolver.DEFAULT_CONFIG_PROPERTY_NAME, uri2); URI resolved = DefaultConfigurationResolver.resolveConfigURI(props); assertSame(uri1, resolved); }
38. SimpleFlowTest#testFlowGetValue()
Project: cloud-slang
File: SimpleFlowTest.java
File: SimpleFlowTest.java
@Test public void testFlowGetValue() throws Exception { URI resource = getClass().getResource("/yaml/check_get_value.sl").toURI(); URI operation1 = getClass().getResource("/yaml/get_value.sl").toURI(); URI operation2 = getClass().getResource("/yaml/check_equal_types.sl").toURI(); Set<SlangSource> path = Sets.newHashSet(SlangSource.fromFile(operation1), SlangSource.fromFile(operation2)); CompilationArtifact compilationArtifact = slang.compile(SlangSource.fromFile(resource), path); Map<String, Value> userInputs = new HashMap<>(); Map<String, StepData> stepsData = triggerWithData(compilationArtifact, userInputs, EMPTY_SET).getSteps(); List<String> actualSteps = getStepsOnly(stepsData); Assert.assertEquals(2, actualSteps.size()); StepData firstStep = stepsData.get(FIRST_STEP_PATH); StepData secondStep = stepsData.get(SECOND_STEP_KEY); Assert.assertEquals("get_value", firstStep.getName()); Assert.assertEquals("SUCCESS", firstStep.getResult()); Assert.assertEquals("test_equality", secondStep.getName()); Assert.assertEquals("SUCCESS", secondStep.getResult()); }
39. SimpleFlowTest#testFlowWithSameInputNameAsStep()
Project: cloud-slang
File: SimpleFlowTest.java
File: SimpleFlowTest.java
@Test public void testFlowWithSameInputNameAsStep() throws Exception { URI resource = getClass().getResource("/yaml/flow_with_same_input_name_as_step.sl").toURI(); URI operation1 = getClass().getResource("/yaml/string_equals.sl").toURI(); URI operation2 = getClass().getResource("/yaml/test_op.sl").toURI(); Set<SlangSource> path = Sets.newHashSet(SlangSource.fromFile(operation1), SlangSource.fromFile(operation2)); CompilationArtifact compilationArtifact = slang.compile(SlangSource.fromFile(resource), path); Map<String, Value> userInputs = new HashMap<>(); userInputs.put("first", ValueFactory.create("value")); userInputs.put("second_string", ValueFactory.create("value")); Map<String, StepData> stepsData = triggerWithData(compilationArtifact, userInputs, EMPTY_SET).getSteps(); List<String> actualSteps = getStepsOnly(stepsData); Assert.assertEquals(2, actualSteps.size()); StepData firstStep = stepsData.get(FIRST_STEP_PATH); StepData secondStep = stepsData.get(SECOND_STEP_KEY); Assert.assertEquals("CheckBinding", firstStep.getName()); Assert.assertEquals("StepOnSuccess", secondStep.getName()); }
40. SimpleFlowTest#testFlowWithGlobalSession()
Project: cloud-slang
File: SimpleFlowTest.java
File: SimpleFlowTest.java
@Test public void testFlowWithGlobalSession() throws Exception { URI resource = getClass().getResource("/yaml/flow_using_global_session.yaml").toURI(); URI operation1 = getClass().getResource("/yaml/set_global_session_object.sl").toURI(); URI operation2 = getClass().getResource("/yaml/get_global_session_object.sl").toURI(); Set<SlangSource> path = Sets.newHashSet(SlangSource.fromFile(operation1), SlangSource.fromFile(operation2)); CompilationArtifact compilationArtifact = slang.compile(SlangSource.fromFile(resource), path); Map<String, Value> userInputs = new HashMap<>(); userInputs.put("object_value", ValueFactory.create("SessionValue")); ScoreEvent event = trigger(compilationArtifact, userInputs, EMPTY_SET); Assert.assertEquals(ScoreLangConstants.EVENT_EXECUTION_FINISHED, event.getEventType()); }
41. SensitiveValueSyntaxInFlowTest#testValues()
Project: cloud-slang
File: SensitiveValueSyntaxInFlowTest.java
File: SensitiveValueSyntaxInFlowTest.java
@Test public void testValues() throws Exception { // compile URI resource = getClass().getResource("/yaml/sensitive/sensitive_values_flow.sl").toURI(); URI op1 = getClass().getResource("/yaml/noop.sl").toURI(); URI op2 = getClass().getResource("/yaml/print.sl").toURI(); Set<SlangSource> path = Sets.newHashSet(SlangSource.fromFile(op1), SlangSource.fromFile(op2)); CompilationArtifact compilationArtifact = slang.compile(SlangSource.fromFile(resource), path); // trigger Map<String, StepData> steps = prepareAndRun(compilationArtifact); // verify StepData flowData = steps.get(EXEC_START_PATH); StepData stepData = steps.get(FIRST_STEP_PATH); verifyInOutParams(flowData.getInputs()); verifyInOutParams(flowData.getOutputs()); verifyInOutParams(stepData.getInputs()); verifyInOutParams(stepData.getOutputs()); verifySuccessResult(flowData); }
42. SensitiveValuesInPythonExpressionsFlowTest#testValues()
Project: cloud-slang
File: SensitiveValuesInPythonExpressionsFlowTest.java
File: SensitiveValuesInPythonExpressionsFlowTest.java
@Test public void testValues() throws Exception { // compile URI resource = getClass().getResource("/yaml/sensitive/sensitive_values_in_python_expressions_flow.sl").toURI(); URI op1 = getClass().getResource("/yaml/noop.sl").toURI(); URI op2 = getClass().getResource("/yaml/print.sl").toURI(); Set<SlangSource> path = Sets.newHashSet(SlangSource.fromFile(op1), SlangSource.fromFile(op2)); CompilationArtifact compilationArtifact = slang.compile(SlangSource.fromFile(resource), path); // trigger Map<String, StepData> steps = prepareAndRun(compilationArtifact); // verify StepData flowData = steps.get(EXEC_START_PATH); StepData stepData = steps.get(FIRST_STEP_PATH); verifyInOutParams(flowData.getInputs()); verifyInOutParams(flowData.getOutputs()); verifyInOutParams(stepData.getInputs()); verifyInOutParams(stepData.getOutputs()); verifySuccessResult(flowData); }
43. ParallelLoopFlowsTest#testFlowWithParallelLoopPublishNavigate()
Project: cloud-slang
File: ParallelLoopFlowsTest.java
File: ParallelLoopFlowsTest.java
@Test public void testFlowWithParallelLoopPublishNavigate() throws Exception { URI resource = getClass().getResource("/yaml/loops/parallel_loop/parallel_loop_publish_navigate.sl").toURI(); URI operation1 = getClass().getResource("/yaml/loops/parallel_loop/print_branch.sl").toURI(); URI operation2 = getClass().getResource("/yaml/loops/parallel_loop/print_list.sl").toURI(); Set<SlangSource> path = Sets.newHashSet(SlangSource.fromFile(operation1), SlangSource.fromFile(operation2)); RuntimeInformation runtimeInformation = triggerWithData(SlangSource.fromFile(resource), path, getSystemProperties()); List<StepData> branchesData = extractParallelLoopData(runtimeInformation); Assert.assertEquals("incorrect number of branches", 3, branchesData.size()); List<String> expectedNameOutputs = verifyBranchPublishValues(branchesData); verifyPublishValues(runtimeInformation, expectedNameOutputs); verifyNavigation(runtimeInformation); }
44. ParallelLoopFlowsTest#testFlowWithParallelLoopNavigate()
Project: cloud-slang
File: ParallelLoopFlowsTest.java
File: ParallelLoopFlowsTest.java
@Test public void testFlowWithParallelLoopNavigate() throws Exception { URI resource = getClass().getResource("/yaml/loops/parallel_loop/parallel_loop_navigate.sl").toURI(); URI operation1 = getClass().getResource("/yaml/loops/parallel_loop/print_branch.sl").toURI(); URI operation2 = getClass().getResource("/yaml/loops/parallel_loop/print_list.sl").toURI(); Set<SlangSource> path = Sets.newHashSet(SlangSource.fromFile(operation1), SlangSource.fromFile(operation2)); RuntimeInformation runtimeInformation = triggerWithData(SlangSource.fromFile(resource), path); List<StepData> branchesData = extractParallelLoopData(runtimeInformation); Assert.assertEquals("incorrect number of branches", 3, branchesData.size()); verifyNavigation(runtimeInformation); }
45. LoopFlowsTest#testFlowWithMapLoopsWithBreak()
Project: cloud-slang
File: LoopFlowsTest.java
File: LoopFlowsTest.java
@Test public void testFlowWithMapLoopsWithBreak() throws Exception { URI resource = getClass().getResource("/yaml/loops/loop_with_break_with_map.sl").toURI(); URI operation1 = getClass().getResource("/yaml/loops/operation_that_goes_to_custom_when_value_is_2.sl").toURI(); URI operation2 = getClass().getResource("/yaml/loops/print.sl").toURI(); Set<SlangSource> path = Sets.newHashSet(SlangSource.fromFile(operation1), SlangSource.fromFile(operation2)); CompilationArtifact compilationArtifact = slang.compile(SlangSource.fromFile(resource), path); Map<String, Value> userInputs = new HashMap<>(); Map<String, StepData> stepsData = triggerWithData(compilationArtifact, userInputs, EMPTY_SET).getSteps(); List<String> actualSteps = getStepsOnly(stepsData); Assert.assertEquals(2, actualSteps.size()); StepData secondStep = stepsData.get(SECOND_STEP_KEY); Assert.assertEquals("print_other_values", secondStep.getName()); }
46. LoopFlowsTest#testFlowWithLoopsWithBreak()
Project: cloud-slang
File: LoopFlowsTest.java
File: LoopFlowsTest.java
@Test public void testFlowWithLoopsWithBreak() throws Exception { URI resource = getClass().getResource("/yaml/loops/loop_with_break.sl").toURI(); URI operation1 = getClass().getResource("/yaml/loops/operation_that_goes_to_custom_when_value_is_2.sl").toURI(); URI operation2 = getClass().getResource("/yaml/loops/print.sl").toURI(); Set<SlangSource> path = Sets.newHashSet(SlangSource.fromFile(operation1), SlangSource.fromFile(operation2)); CompilationArtifact compilationArtifact = slang.compile(SlangSource.fromFile(resource), path); Map<String, Value> userInputs = new HashMap<>(); Map<String, StepData> stepsData = triggerWithData(compilationArtifact, userInputs, EMPTY_SET).getSteps(); List<String> actualSteps = getStepsOnly(stepsData); Assert.assertEquals(3, actualSteps.size()); StepData thirdStep = stepsData.get(THIRD_STEP_KEY); Assert.assertEquals("print_other_values", thirdStep.getName()); }
47. FlowWithJavaVersioningTest#testFlowWithGlobalSession()
Project: cloud-slang
File: FlowWithJavaVersioningTest.java
File: FlowWithJavaVersioningTest.java
@Test public void testFlowWithGlobalSession() throws Exception { Assume.assumeTrue(shouldRunMaven); URI resource = getClass().getResource("/yaml/versioning/testglobals/flow_using_global_session_dependencies.sl").toURI(); URI operation1 = getClass().getResource("/yaml/versioning/testglobals/set_global_session_object_dependencies.sl").toURI(); URI operation2 = getClass().getResource("/yaml/versioning/testglobals/get_global_session_object_dependencies.sl").toURI(); Set<SlangSource> path = Sets.newHashSet(SlangSource.fromFile(operation1), SlangSource.fromFile(operation2)); CompilationArtifact compilationArtifact = slang.compile(SlangSource.fromFile(resource), path); Map<String, Value> userInputs = new HashMap<>(); userInputs.put("object_value", ValueFactory.create("SessionValue")); ScoreEvent event = trigger(compilationArtifact, userInputs, Collections.<SystemProperty>emptySet()); Assert.assertEquals(ScoreLangConstants.EVENT_EXECUTION_FINISHED, event.getEventType()); LanguageEventData data = (LanguageEventData) event.getData(); Serializable result_object_value = data.getOutputs().get("result_object_value"); assertEquals("SessionValue", result_object_value); }
48. ValueSyntaxInFlowTest#testValues()
Project: cloud-slang
File: ValueSyntaxInFlowTest.java
File: ValueSyntaxInFlowTest.java
@Test public void testValues() throws Exception { // compile URI resource = getClass().getResource("/yaml/formats/values_flow.sl").toURI(); URI operation1 = getClass().getResource("/yaml/formats/values_op.sl").toURI(); URI operation2 = getClass().getResource("/yaml/noop.sl").toURI(); SlangSource dep1 = SlangSource.fromFile(operation1); SlangSource dep2 = SlangSource.fromFile(operation2); Set<SlangSource> path = Sets.newHashSet(dep1, dep2); CompilationArtifact compilationArtifact = slang.compile(SlangSource.fromFile(resource), path); // trigger Map<String, StepData> steps = prepareAndRun(compilationArtifact); // verify StepData flowData = steps.get(EXEC_START_PATH); StepData stepData = steps.get(FIRST_STEP_PATH); verifyExecutableInputs(flowData); verifyExecutableOutputs(flowData); verifyStepInputs(stepData); verifyStepPublishValues(stepData); verifySuccessResult(flowData); }
49. NavigationTest#testNavigationOnFailureContainsStepWithCustomResult()
Project: cloud-slang
File: NavigationTest.java
File: NavigationTest.java
@Test public void testNavigationOnFailureContainsStepWithCustomResult() throws Exception { URI resource = getClass().getResource("/yaml/on_failure_contains_step_with_custom_result.sl").toURI(); URI flow1 = getClass().getResource("/yaml/flow_with_custom_result.sl").toURI(); URI operation1 = getClass().getResource("/yaml/test_op.sl").toURI(); Set<SlangSource> path = Sets.newHashSet(SlangSource.fromFile(flow1), SlangSource.fromFile(operation1)); CompilationArtifact compilationArtifact = slang.compile(SlangSource.fromFile(resource), path); Map<String, Value> userInputs = new HashMap<>(); userInputs.put("alla", ValueFactory.create("alla message 1")); Map<String, StepData> steps = triggerWithData(compilationArtifact, userInputs, new HashSet<SystemProperty>()).getSteps(); Assert.assertEquals("on_failure_contains_step_with_custom_result", steps.get(EXEC_START_PATH).getName()); Assert.assertEquals(ScoreLangConstants.FAILURE_RESULT, steps.get(EXEC_START_PATH).getResult()); Assert.assertEquals("print_message1", steps.get(FIRST_STEP_PATH).getName()); Assert.assertEquals(ScoreLangConstants.SUCCESS_RESULT, steps.get(FIRST_STEP_PATH).getResult()); Assert.assertEquals("print_on_failure_1", steps.get(SECOND_STEP_KEY).getName()); Assert.assertEquals(ScoreLangConstants.FAILURE_RESULT, steps.get(SECOND_STEP_KEY).getResult()); Assert.assertEquals("print_message1_flow_with_custom_result", steps.get("0.1.0").getName()); Assert.assertEquals("CUSTOM_SUCCESS", steps.get("0.1.0").getResult()); }
50. CompilerErrorsTest#testValidationOfFlowInputInStepWithSameNameAsDependencyOutput()
Project: cloud-slang
File: CompilerErrorsTest.java
File: CompilerErrorsTest.java
@Test public void testValidationOfFlowInputInStepWithSameNameAsDependencyOutput() throws Exception { URI flowUri = getClass().getResource("/corrupted/flow_input_in_step_same_name_as_dependency_output.sl").toURI(); Executable flowModel = compiler.preCompile(SlangSource.fromFile(flowUri)); URI operation1Uri = getClass().getResource("/test_op.sl").toURI(); Executable operation1Model = compiler.preCompile(SlangSource.fromFile(operation1Uri)); URI operation2Uri = getClass().getResource("/check_op.sl").toURI(); Executable operation2Model = compiler.preCompile(SlangSource.fromFile(operation2Uri)); Set<Executable> dependencies = new HashSet<>(); dependencies.add(operation1Model); dependencies.add(operation2Model); exception.expect(IllegalArgumentException.class); exception.expectMessage("Cannot compile flow 'io.cloudslang.flow_input_in_step_same_name_as_dependency_output'. " + "Step 'explicit_alias' has input 'balla' with the same name as the one of the outputs of 'user.ops.test_op'."); List<RuntimeException> errors = compiler.validateSlangModelWithDirectDependencies(flowModel, dependencies); Assert.assertEquals(1, errors.size()); throw errors.get(0); }
51. CompilerErrorsTest#testValidationOfFlowWithMissingDependencyRequiredInputInStep()
Project: cloud-slang
File: CompilerErrorsTest.java
File: CompilerErrorsTest.java
@Test public void testValidationOfFlowWithMissingDependencyRequiredInputInStep() throws Exception { URI flowUri = getClass().getResource("/corrupted/flow_missing_dependency_required_input_in_step.sl").toURI(); Executable flowModel = compiler.preCompile(SlangSource.fromFile(flowUri)); URI operation1Uri = getClass().getResource("/test_op.sl").toURI(); Executable operation1Model = compiler.preCompile(SlangSource.fromFile(operation1Uri)); URI operation2Uri = getClass().getResource("/check_op.sl").toURI(); Executable operation2Model = compiler.preCompile(SlangSource.fromFile(operation2Uri)); Set<Executable> dependencies = new HashSet<>(); dependencies.add(operation1Model); dependencies.add(operation2Model); exception.expect(IllegalArgumentException.class); exception.expectMessage("Cannot compile flow 'io.cloudslang.flow_missing_dependency_required_input_in_step'. " + "Step 'explicit_alias' does not declare all the mandatory inputs of its reference. " + "The following inputs of 'user.ops.test_op' are not private, required and with no default value: alla."); List<RuntimeException> errors = compiler.validateSlangModelWithDirectDependencies(flowModel, dependencies); Assert.assertEquals(1, errors.size()); throw errors.get(0); }
52. CompilerErrorsTest#testFlowWithCorruptedKeyInImports()
Project: cloud-slang
File: CompilerErrorsTest.java
File: CompilerErrorsTest.java
@Test public void testFlowWithCorruptedKeyInImports() throws Exception { //covers problem parsing YAML source "while scanning a simple key" URI resource = getClass().getResource("/corrupted/flow_with_corrupted_key_in_imports.sl").toURI(); URI operations = getClass().getResource("/java_op.sl").toURI(); URI flows = getClass().getResource("/flow_with_data.yaml").toURI(); Set<SlangSource> path = new HashSet<>(); path.add(SlangSource.fromFile(operations)); path.add(SlangSource.fromFile(flows)); exception.expect(RuntimeException.class); exception.expectMessage(ParserExceptionHandler.SCANNING_A_SIMPLE_KEY_ERROR); exception.expectMessage(ParserExceptionHandler.KEY_VALUE_PAIR_MISSING_OR_INDENTATION_PROBLEM_MSG); compiler.compile(SlangSource.fromFile(resource), path); }
53. CompilerErrorsTest#testSystemPropertiesAsDep()
Project: cloud-slang
File: CompilerErrorsTest.java
File: CompilerErrorsTest.java
@Test public void testSystemPropertiesAsDep() throws Exception { URI flow = getClass().getResource("/basic_flow.yaml").toURI(); URI operation = getClass().getResource("/test_op.sl").toURI(); URI systemProperties = getClass().getResource("/corrupted/system_properties.yaml").toURI(); Set<SlangSource> path = new HashSet<>(); path.add(SlangSource.fromFile(operation)); path.add(SlangSource.fromFile(systemProperties)); exception.expect(RuntimeException.class); exception.expectMessage("There was a problem parsing the YAML source: system_properties.\n" + "Cannot create property=user.sys.props.host for JavaBean=io.cloudslang.lang.compiler.parser.model.ParsedSlang"); compiler.compile(SlangSource.fromFile(flow), path); }
54. CompileParallelLoopFlowTest#testAggregateKeyThrowsException()
Project: cloud-slang
File: CompileParallelLoopFlowTest.java
File: CompileParallelLoopFlowTest.java
@Test public void testAggregateKeyThrowsException() throws Exception { URI flow = getClass().getResource("/corrupted/loops/parallel_loop/parallel_loop_aggregate_key.sl").toURI(); URI operation1 = getClass().getResource("/loops/parallel_loop/print_branch.sl").toURI(); URI operation2 = getClass().getResource("/loops/parallel_loop/print_list.sl").toURI(); Set<SlangSource> path = new HashSet<>(); path.add(SlangSource.fromFile(operation1)); path.add(SlangSource.fromFile(operation2)); expectedException.expect(RuntimeException.class); expectedException.expectMessage("Artifact {print_values} has unrecognized tag {aggregate}. " + "Please take a look at the supported features per versions link"); compiler.compile(SlangSource.fromFile(flow), path); }
55. CompileParallelLoopFlowTest#testPublishOnBranchThrowsException()
Project: cloud-slang
File: CompileParallelLoopFlowTest.java
File: CompileParallelLoopFlowTest.java
@Test public void testPublishOnBranchThrowsException() throws Exception { URI flow = getClass().getResource("/corrupted/loops/parallel_loop/parallel_loop_publish_on_branch.sl").toURI(); URI operation1 = getClass().getResource("/loops/parallel_loop/print_branch.sl").toURI(); URI operation2 = getClass().getResource("/loops/parallel_loop/print_list.sl").toURI(); Set<SlangSource> path = new HashSet<>(); path.add(SlangSource.fromFile(operation1)); path.add(SlangSource.fromFile(operation2)); expectedException.expect(RuntimeException.class); expectedException.expectMessage("Artifact {print_values} has unrecognized tag {publish} under 'parallel_loop'. " + "Please take a look at the supported features per versions link"); compiler.compile(SlangSource.fromFile(flow), path); }
56. CompileDependenciesTest#circularDependencies()
Project: cloud-slang
File: CompileDependenciesTest.java
File: CompileDependenciesTest.java
@Test public void circularDependencies() throws Exception { URI flow = getClass().getResource("/circular-dependencies/circular_parent_flow.yaml").toURI(); URI child_flow = getClass().getResource("/circular-dependencies/circular_child_flow.yaml").toURI(); URI operation = getClass().getResource("/test_op.sl").toURI(); Set<SlangSource> path = new HashSet<>(); path.add(SlangSource.fromFile(child_flow)); path.add(SlangSource.fromFile(operation)); CompilationArtifact compilationArtifact = compiler.compile(SlangSource.fromFile(flow), path); ExecutionPlan executionPlan = compilationArtifact.getExecutionPlan(); Assert.assertNotNull(executionPlan); Assert.assertEquals(3, compilationArtifact.getDependencies().size()); }
57. CompileDependenciesTest#bothFileAreDependentOnTheSameFile()
Project: cloud-slang
File: CompileDependenciesTest.java
File: CompileDependenciesTest.java
@Test public void bothFileAreDependentOnTheSameFile() throws Exception { URI flow = getClass().getResource("/circular-dependencies/parent_flow.yaml").toURI(); URI child_flow = getClass().getResource("/circular-dependencies/child_flow.yaml").toURI(); URI operation = getClass().getResource("/test_op.sl").toURI(); Set<SlangSource> path = new HashSet<>(); path.add(SlangSource.fromFile(child_flow)); path.add(SlangSource.fromFile(operation)); CompilationArtifact compilationArtifact = compiler.compile(SlangSource.fromFile(flow), path); ExecutionPlan executionPlan = compilationArtifact.getExecutionPlan(); Assert.assertNotNull(executionPlan); Assert.assertEquals("different number of dependencies than expected", 2, compilationArtifact.getDependencies().size()); }
58. CompileDependenciesTest#subFlowRefId()
Project: cloud-slang
File: CompileDependenciesTest.java
File: CompileDependenciesTest.java
@Test public void subFlowRefId() throws Exception { URI flow = getClass().getResource("/circular-dependencies/parent_flow.yaml").toURI(); URI child_flow = getClass().getResource("/circular-dependencies/child_flow.yaml").toURI(); URI operation = getClass().getResource("/test_op.sl").toURI(); Set<SlangSource> path = new HashSet<>(); path.add(SlangSource.fromFile(child_flow)); path.add(SlangSource.fromFile(operation)); CompilationArtifact compilationArtifact = compiler.compile(SlangSource.fromFile(flow), path); ExecutionPlan executionPlan = compilationArtifact.getExecutionPlan(); Assert.assertNotNull(executionPlan); Assert.assertEquals("different number of dependencies than expected", 2, compilationArtifact.getDependencies().size()); ExecutionStep secondStepStartExecutionStep = executionPlan.getStep(4L); String refId = (String) secondStepStartExecutionStep.getActionData().get(ScoreLangConstants.REF_ID); Assert.assertEquals("refId is not as expected", "user.flows.circular.child_flow", refId); }
59. FileSet#isIncluded()
Project: bnd
File: FileSet.java
File: FileSet.java
public boolean isIncluded(File file) { URI target = file.toURI(); URI source = base.toURI(); URI relative = source.relativize(target); if (relative.equals(target) || relative.equals(source)) return false; String[] segments = relative.getPath().split("/"); if (dfa.isIncluded(segments, 0)) return true; return false; }
60. HadoopDataSourceUtil#contains()
Project: asakusafw
File: HadoopDataSourceUtil.java
File: HadoopDataSourceUtil.java
/** * Returns whether the parent path contains the child path, or not. * If the parent and child is same, this returns {@code false}. * @param parent the parent path * @param child the child path * @return {@code true} if parent path strictly contains the child, otherwise {@code false} * @throws IllegalArgumentException if some parameters were {@code null} */ public static boolean contains(Path parent, Path child) { if (parent == null) { //$NON-NLS-1$ throw new IllegalArgumentException("parent must not be null"); } if (child == null) { //$NON-NLS-1$ throw new IllegalArgumentException("child must not be null"); } if (parent.depth() >= child.depth()) { return false; } URI parentUri = parent.toUri(); URI childUri = child.toUri(); URI relative = parentUri.relativize(childUri); if (relative.equals(childUri) == false) { return true; } return false; }
61. TestRegisterParser#testRegisterArtifact()
Project: pig
File: TestRegisterParser.java
File: TestRegisterParser.java
// Test to check if all dependencies are successfully added to the classpath @Test public void testRegisterArtifact() throws URISyntaxException, IOException, ParserException { URI[] list = new URI[5]; list[0] = new URI(TEST_JAR_DIR + "testjar-1.jar"); list[1] = new URI(TEST_JAR_DIR + "testjar-2.jar"); list[2] = new URI(TEST_JAR_DIR + "testjar-3.jar"); list[3] = new URI(TEST_JAR_DIR + "testjar-4.jar"); list[4] = new URI(TEST_JAR_DIR + "testjar-5.jar"); // Make sure that the jars are not in the classpath for (URI dependency : list) { Assert.assertFalse(pigServer.getPigContext().hasJar(dependency.toString())); } RegisterResolver registerResolver = Mockito.spy(new RegisterResolver(pigServer)); Mockito.doReturn(list).when(registerResolver).resolve(new URI("ivy://testQuery")); registerResolver.parseRegister("ivy://testQuery", null, null); for (URI dependency : list) { Assert.assertTrue(pigServer.getPigContext().hasJar(dependency.toString())); } }
62. MultiReleaseJarTest#initialize()
Project: openjdk
File: MultiReleaseJarTest.java
File: MultiReleaseJarTest.java
@BeforeClass public void initialize() throws Exception { CreateMultiReleaseTestJars creator = new CreateMultiReleaseTestJars(); creator.compileEntries(); creator.buildUnversionedJar(); creator.buildMultiReleaseJar(); creator.buildShortMultiReleaseJar(); String ssp = Paths.get(userdir, "unversioned.jar").toUri().toString(); uvuri = new URI("jar", ssp, null); ssp = Paths.get(userdir, "multi-release.jar").toUri().toString(); mruri = new URI("jar", ssp, null); ssp = Paths.get(userdir, "short-multi-release.jar").toUri().toString(); smruri = new URI("jar", ssp, null); entryName = className.replace('.', '/') + ".class"; }
63. WindowsPathTypeTest#testWindows_toUri_normal()
Project: jimfs
File: WindowsPathTypeTest.java
File: WindowsPathTypeTest.java
@Test public void testWindows_toUri_normal() { URI fileUri = PathType.windows().toUri(fileSystemUri, "C:\\", ImmutableList.of("foo", "bar"), false); assertThat(fileUri.toString()).isEqualTo("jimfs://foo/C:/foo/bar"); assertThat(fileUri.getPath()).isEqualTo("/C:/foo/bar"); URI directoryUri = PathType.windows().toUri(fileSystemUri, "C:\\", ImmutableList.of("foo", "bar"), true); assertThat(directoryUri.toString()).isEqualTo("jimfs://foo/C:/foo/bar/"); assertThat(directoryUri.getPath()).isEqualTo("/C:/foo/bar/"); URI rootUri = PathType.windows().toUri(fileSystemUri, "C:\\", ImmutableList.<String>of(), true); assertThat(rootUri.toString()).isEqualTo("jimfs://foo/C:/"); assertThat(rootUri.getPath()).isEqualTo("/C:/"); }
64. UnixPathTypeTest#testUnix_toUri()
Project: jimfs
File: UnixPathTypeTest.java
File: UnixPathTypeTest.java
@Test public void testUnix_toUri() { URI fileUri = PathType.unix().toUri(fileSystemUri, "/", ImmutableList.of("foo", "bar"), false); assertThat(fileUri.toString()).isEqualTo("jimfs://foo/foo/bar"); assertThat(fileUri.getPath()).isEqualTo("/foo/bar"); URI directoryUri = PathType.unix().toUri(fileSystemUri, "/", ImmutableList.of("foo", "bar"), true); assertThat(directoryUri.toString()).isEqualTo("jimfs://foo/foo/bar/"); assertThat(directoryUri.getPath()).isEqualTo("/foo/bar/"); URI rootUri = PathType.unix().toUri(fileSystemUri, "/", ImmutableList.<String>of(), true); assertThat(rootUri.toString()).isEqualTo("jimfs://foo/"); assertThat(rootUri.getPath()).isEqualTo("/"); }
65. PathTypeTest#testToUri()
Project: jimfs
File: PathTypeTest.java
File: PathTypeTest.java
@Test public void testToUri() { URI fileUri = type.toUri(fileSystemUri, "$", ImmutableList.of("foo", "bar"), false); assertThat(fileUri.toString()).isEqualTo("jimfs://foo/$/foo/bar"); assertThat(fileUri.getPath()).isEqualTo("/$/foo/bar"); URI directoryUri = type.toUri(fileSystemUri, "$", ImmutableList.of("foo", "bar"), true); assertThat(directoryUri.toString()).isEqualTo("jimfs://foo/$/foo/bar/"); assertThat(directoryUri.getPath()).isEqualTo("/$/foo/bar/"); URI rootUri = type.toUri(fileSystemUri, "$", ImmutableList.<String>of(), true); assertThat(rootUri.toString()).isEqualTo("jimfs://foo/$/"); assertThat(rootUri.getPath()).isEqualTo("/$/"); }
66. WebURL#resolve()
Project: manifoldcf
File: WebURL.java
File: WebURL.java
public WebURL resolve(String raw) throws URISyntaxException { URI rawURL = new URI(raw); if (rawURL.isAbsolute()) return new WebURL(rawURL); URI fixedURL = theURL; if (theURL.getPath() == null || theURL.getPath().length() == 0) fixedURL = new URI(theURL.getScheme(), null, theURL.getHost(), theURL.getPort(), "/", null, null); if (raw.startsWith("?")) return new WebURL(fixedURL.getScheme(), fixedURL.getHost(), fixedURL.getPort(), fixedURL.getPath(), rawURL.getRawQuery()); return new WebURL(fixedURL.resolve(rawURL)); }
67. WebURL#resolve()
Project: manifoldcf
File: WebURL.java
File: WebURL.java
public WebURL resolve(String raw) throws URISyntaxException { URI rawURL = new URI(raw); if (rawURL.isAbsolute()) return new WebURL(rawURL); URI fixedURL = theURL; if (theURL.getPath() == null || theURL.getPath().length() == 0) fixedURL = new URI(theURL.getScheme(), null, theURL.getHost(), theURL.getPort(), "/", null, null); if (raw.startsWith("?")) return new WebURL(fixedURL.getScheme(), fixedURL.getHost(), fixedURL.getPort(), fixedURL.getPath(), rawURL.getRawQuery()); return new WebURL(fixedURL.resolve(rawURL)); }
68. Delombok#createFileWriter()
Project: lombok
File: Delombok.java
File: Delombok.java
private Writer createFileWriter(File outBase, File inBase, URI file) throws IOException { URI base = inBase.toURI(); URI relative = base.relativize(base.resolve(file)); File outFile; if (relative.isAbsolute()) { outFile = new File(outBase, new File(relative).getName()); } else { outFile = new File(outBase, relative.getPath()); } outFile.getParentFile().mkdirs(); FileOutputStream out = new FileOutputStream(outFile); return createUnicodeEscapeWriter(out); }
69. TestDefaultNameNodePort#testGetAddressFromConf()
Project: hadoop-20
File: TestDefaultNameNodePort.java
File: TestDefaultNameNodePort.java
@Test public void testGetAddressFromConf() throws Exception { Configuration conf = new Configuration(); FileSystem.setDefaultUri(conf, "hdfs://foo/"); URI uri = new URI(null, NameNode.getDefaultAddress(conf), null, null, null); assertEquals(-1, uri.getPort()); FileSystem.setDefaultUri(conf, "hdfs://foo:555"); uri = new URI(null, NameNode.getDefaultAddress(conf), null, null, null); assertEquals(555, uri.getPort()); FileSystem.setDefaultUri(conf, "foo"); uri = new URI(null, NameNode.getDefaultAddress(conf), null, null, null); assertEquals(-1, uri.getPort()); }
70. DiscoveryTransportNoBrokerTest#testSetDiscoveredStaticBrokerProperties()
Project: activemq-artemis
File: DiscoveryTransportNoBrokerTest.java
File: DiscoveryTransportNoBrokerTest.java
public void testSetDiscoveredStaticBrokerProperties() throws Exception { final String extraParameterName = "connectionTimeout"; final String extraParameterValue = "3000"; final URI uri = new URI("discovery:(static:tcp://localhost:61616)?initialReconnectDelay=100&" + DiscoveryListener.DISCOVERED_OPTION_PREFIX + extraParameterName + "=" + extraParameterValue); CompositeData compositeData = URISupport.parseComposite(uri); StubCompositeTransport compositeTransport = new StubCompositeTransport(); DiscoveryTransport discoveryTransport = DiscoveryTransportFactory.createTransport(compositeTransport, compositeData, compositeData.getParameters()); discoveryTransport.start(); assertEquals("expected added URI after discovery event", 1, compositeTransport.getTransportURIs().length); URI discoveredServiceURI = compositeTransport.getTransportURIs()[0]; Map<String, String> parameters = URISupport.parseParameters(discoveredServiceURI); assertTrue("unable to add parameter to discovered service", parameters.containsKey(extraParameterName)); assertEquals("incorrect value for parameter added to discovered service", parameters.get(extraParameterName), extraParameterValue); }
71. DiscoveryTransportNoBrokerTest#testSetDiscoveredBrokerProperties()
Project: activemq-artemis
File: DiscoveryTransportNoBrokerTest.java
File: DiscoveryTransportNoBrokerTest.java
public void testSetDiscoveredBrokerProperties() throws Exception { final String extraParameterName = "connectionTimeout"; final String extraParameterValue = "3000"; final URI uri = new URI("discovery:(multicast://default)?initialReconnectDelay=100&" + DiscoveryListener.DISCOVERED_OPTION_PREFIX + extraParameterName + "=" + extraParameterValue); CompositeData compositeData = URISupport.parseComposite(uri); StubCompositeTransport compositeTransport = new StubCompositeTransport(); DiscoveryTransport discoveryTransport = DiscoveryTransportFactory.createTransport(compositeTransport, compositeData, compositeData.getParameters()); discoveryTransport.onServiceAdd(new DiscoveryEvent("tcp://localhost:61616")); assertEquals("expected added URI after discovery event", compositeTransport.getTransportURIs().length, 1); URI discoveredServiceURI = compositeTransport.getTransportURIs()[0]; Map<String, String> parameters = URISupport.parseParameters(discoveredServiceURI); assertTrue("unable to add parameter to discovered service", parameters.containsKey(extraParameterName)); assertEquals("incorrect value for parameter added to discovered service", parameters.get(extraParameterName), extraParameterValue); }
72. CompressionOverNetworkTest#doSetUp()
Project: activemq-artemis
File: CompressionOverNetworkTest.java
File: CompressionOverNetworkTest.java
protected void doSetUp(boolean deleteAllMessages) throws Exception { localBroker = createLocalBroker(); localBroker.setDeleteAllMessagesOnStartup(deleteAllMessages); localBroker.start(); localBroker.waitUntilStarted(); remoteBroker = createRemoteBroker(); remoteBroker.setDeleteAllMessagesOnStartup(deleteAllMessages); remoteBroker.start(); remoteBroker.waitUntilStarted(); URI localURI = localBroker.getVmConnectorURI(); ActiveMQConnectionFactory fac = new ActiveMQConnectionFactory(localURI); fac.setAlwaysSyncSend(true); fac.setDispatchAsync(false); localConnection = fac.createConnection(); localConnection.setClientID("clientId"); localConnection.start(); URI remoteURI = remoteBroker.getVmConnectorURI(); fac = new ActiveMQConnectionFactory(remoteURI); remoteConnection = fac.createConnection(); remoteConnection.setClientID("clientId"); remoteConnection.start(); included = new ActiveMQTopic("include.test.bar"); localSession = localConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); remoteSession = remoteConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); }
73. FOMElement#getResolvedBaseUri()
Project: abdera
File: FOMElement.java
File: FOMElement.java
public URI getResolvedBaseUri() throws URISyntaxException { URI baseUri = null; URI uri = _getUriValue(getAttributeValue(BASE)); if (parent instanceof Element) baseUri = ((Element) parent).getResolvedBaseUri(); else if (parent instanceof Document) baseUri = ((Document) parent).getBaseUri(); if (uri != null && baseUri != null) { if (baseUri != null) { uri = baseUri.resolve(uri); } else { return getBaseUri(); } } else if (uri == null) { uri = baseUri; } return uri; }
74. SelendroidNativeDriver#get()
Project: selendroid
File: SelendroidNativeDriver.java
File: SelendroidNativeDriver.java
public void get(String url) { URI dest; try { dest = new URI(url); } catch (URISyntaxException exception) { throw new IllegalArgumentException(exception); } if (!"and-activity".equals(dest.getScheme())) { throw new SelendroidException("Unrecognized scheme in URI: " + dest.toString()); } else if (dest.getPath() != null && !dest.getPath().equals("")) { throw new SelendroidException("Unrecognized path in URI: " + dest.toString()); } URI currentUri = getCurrentURI(); if (currentUri != null && dest.getAuthority().endsWith(currentUri.getAuthority())) { // ignore request, activity is already open return; } serverInstrumentation.startActivity(dest.getAuthority()); DefaultSelendroidDriver.sleepQuietly(500); }
75. DBManagerTest#testNewsSetLink()
Project: RSSOwl
File: DBManagerTest.java
File: DBManagerTest.java
/** * Tests INews#setLink. * * @throws Exception */ @Test public void testNewsSetLink() throws Exception { IFeed feed = DynamicDAO.save(createFeed()); INews news = fTypesFactory.createNews(null, feed, new Date()); URI uri = createURI("http://uri.com"); news.setLink(uri); assertEquals(uri, news.getLink()); news.setLink(null); assertNull(news.getLink()); news.setLink(uri); assertEquals(uri, news.getLink()); URI anotherUri = createURI("http://anotheruri.com"); news.setLink(anotherUri); assertEquals(anotherUri, news.getLink()); }
76. ApplicationLayerTest#testLoadFeed()
Project: RSSOwl
File: ApplicationLayerTest.java
File: ApplicationLayerTest.java
/** * Tests {@link IFeedDAO#load(URI)}. * * @throws Exception */ @Test public void testLoadFeed() throws Exception { URI feed1Url = new URI("http://www.feed1.com"); IFeed feed1 = new Feed(feed1Url); feed1 = DynamicDAO.save(feed1); URI feed2Url = new URI("http://www.feed2.com"); IFeed feed2 = new Feed(feed2Url); feed2 = DynamicDAO.save(feed2); assertEquals(feed1, Owl.getPersistenceService().getDAOService().getFeedDAO().load(feed1Url)); assertEquals(feed2, Owl.getPersistenceService().getDAOService().getFeedDAO().load(feed2Url)); }
77. ApplicationLayerTest#testLoadFeedReference()
Project: RSSOwl
File: ApplicationLayerTest.java
File: ApplicationLayerTest.java
/** * Tests {@link IFeedDAO#loadReference(URI)}. * * @throws Exception */ @Test public void testLoadFeedReference() throws Exception { URI feed1Url = new URI("http://www.feed1.com"); IFeed feed1 = new Feed(feed1Url); feed1 = DynamicDAO.save(feed1); URI feed2Url = new URI("http://www.feed2.com"); IFeed feed2 = new Feed(feed2Url); feed2 = DynamicDAO.save(feed2); assertEquals(true, Owl.getPersistenceService().getDAOService().getFeedDAO().exists(feed1Url)); assertEquals(true, Owl.getPersistenceService().getDAOService().getFeedDAO().exists(feed2Url)); }
78. NFHttpClient#determineTarget()
Project: ribbon
File: NFHttpClient.java
File: NFHttpClient.java
// copied from httpclient source code private static HttpHost determineTarget(HttpUriRequest request) throws ClientProtocolException { // A null target may be acceptable if there is a default target. // Otherwise, the null target is detected in the director. HttpHost target = null; URI requestURI = request.getURI(); if (requestURI.isAbsolute()) { target = URIUtils.extractHost(requestURI); if (target == null) { throw new ClientProtocolException("URI does not specify a valid host name: " + requestURI); } } return target; }
79. UriBuilderTest#testUriReplace3()
Project: Resteasy
File: UriBuilderTest.java
File: UriBuilderTest.java
@Test public void testUriReplace3() throws Exception { String orig = "news:comp.lang.java"; String expected = "http://comp.lang.java"; URI replacement = new URI("http", "//comp.lang.java", null); UriBuilder uriBuilder = UriBuilder.fromUri(new URI(orig)); URI uri = uriBuilder.uri(replacement.toASCIIString()).build(); System.out.println(uri.toString()); System.out.println(expected); Assert.assertEquals(uri.toString(), expected); }
80. UriBuilderTest#testUriReplace2()
Project: Resteasy
File: UriBuilderTest.java
File: UriBuilderTest.java
@Test public void testUriReplace2() throws Exception { String orig = "tel:+1-816-555-1212"; String expected = "tel:+1-816-555-1212"; URI replacement = new URI("tel", "+1-816-555-1212", null); UriBuilder uriBuilder = UriBuilder.fromUri(new URI(orig)); URI uri = uriBuilder.uri(replacement.toASCIIString()).build(); System.out.println(uri.toString()); System.out.println(expected); Assert.assertEquals(uri.toString(), expected); }
81. UriBuilderTest#testUriReplace()
Project: Resteasy
File: UriBuilderTest.java
File: UriBuilderTest.java
@Test public void testUriReplace() throws Exception { String orig = "foo://example.com:8042/over/there?name=ferret#nose"; String expected = "http://example.com:8042/over/there?name=ferret#nose"; URI replacement = new URI("http", "//example.com:8042/over/there?name=ferret", null); URI uri = UriBuilder.fromUri(new URI(orig)).uri(replacement.toASCIIString()).build(); System.out.println(uri.toString()); System.out.println(expected); Assert.assertEquals(uri.toString(), expected); }
82. URIResultInfoRetriever#retrieveSupplementalInfo()
Project: zxingfragmentlib
File: URIResultInfoRetriever.java
File: URIResultInfoRetriever.java
@Override void retrieveSupplementalInfo() throws IOException { URI oldURI; try { oldURI = new URI(result.getURI()); } catch (URISyntaxException ignored) { return; } URI newURI = HttpHelper.unredirect(oldURI); int count = 0; while (count++ < MAX_REDIRECTS && !oldURI.equals(newURI)) { append(result.getDisplayResult(), null, new String[] { redirectString + " : " + newURI }, newURI.toString()); oldURI = newURI; newURI = HttpHelper.unredirect(newURI); } }
83. URIResultInfoRetriever#retrieveSupplementalInfo()
Project: zxing
File: URIResultInfoRetriever.java
File: URIResultInfoRetriever.java
@Override void retrieveSupplementalInfo() throws IOException { URI oldURI; try { oldURI = new URI(result.getURI()); } catch (URISyntaxException ignored) { return; } URI newURI = HttpHelper.unredirect(oldURI); int count = 0; while (count++ < MAX_REDIRECTS && !oldURI.equals(newURI)) { append(result.getDisplayResult(), null, new String[] { redirectString + " : " + newURI }, newURI.toString()); oldURI = newURI; newURI = HttpHelper.unredirect(newURI); } }
84. TempResourceURIGeneratorTestCase#testGenerate()
Project: xml-graphics-commons
File: TempResourceURIGeneratorTestCase.java
File: TempResourceURIGeneratorTestCase.java
@Test public void testGenerate() { URI first = sut.generate(); URI second = sut.generate(); Pattern regex = Pattern.compile("tmp:///test.*"); assertTrue(regex.matcher(first.toASCIIString()).matches()); assertTrue(regex.matcher(second.toASCIIString()).matches()); assertNotSame(first, second); // Test that they are unique over a large number of calls to generate() Set<URI> uniqueSet = new HashSet<URI>(); int numberOfTests = 1000; for (int i = 0; i < numberOfTests; i++) { uniqueSet.add(sut.generate()); } assertEquals(numberOfTests, uniqueSet.size()); }
85. URIResultInfoRetriever#retrieveSupplementalInfo()
Project: weex
File: URIResultInfoRetriever.java
File: URIResultInfoRetriever.java
@Override void retrieveSupplementalInfo() throws IOException { URI oldURI; try { oldURI = new URI(result.getURI()); } catch (URISyntaxException ignored) { return; } URI newURI = HttpHelper.unredirect(oldURI); int count = 0; while (count++ < MAX_REDIRECTS && !oldURI.equals(newURI)) { append(result.getDisplayResult(), null, new String[] { redirectString + " : " + newURI }, newURI.toString()); oldURI = newURI; newURI = HttpHelper.unredirect(newURI); } }
86. AzureAuthorityTest#createAuthorizationEndpointUri_extraState()
Project: vsts-authentication-library-for-java
File: AzureAuthorityTest.java
File: AzureAuthorityTest.java
@Test public void createAuthorizationEndpointUri_extraState() throws Exception { final URI redirectUri = URI.create("https://example.com"); final String state = "519a4fa6-c18f-4230-8290-6c57407656c9"; final URI actual = AzureAuthority.createAuthorizationEndpointUri("https://login.microsoftonline.com/common", "a8860e8f-ca7d-4efe-b80d-4affab13d4ba", "f7e11bcd-b50b-4869-ad88-8bdd6cbc8473", redirectUri, UserIdentifier.ANY_USER, state, PromptBehavior.ALWAYS, "state=bliss"); Assert.assertEquals("https://login.microsoftonline.com/common/oauth2/authorize?resource=a8860e8f-ca7d-4efe-b80d-4affab13d4ba&client_id=f7e11bcd-b50b-4869-ad88-8bdd6cbc8473&response_type=code&redirect_uri=https%3A%2F%2Fexample.com&state=519a4fa6-c18f-4230-8290-6c57407656c9&prompt=login&state=bliss", actual.toString()); }
87. AzureAuthorityTest#createAuthorizationEndpointUri_typical()
Project: vsts-authentication-library-for-java
File: AzureAuthorityTest.java
File: AzureAuthorityTest.java
@Test public void createAuthorizationEndpointUri_typical() throws Exception { final URI redirectUri = URI.create("https://example.com"); final String state = "519a4fa6-c18f-4230-8290-6c57407656c9"; final URI actual = AzureAuthority.createAuthorizationEndpointUri("https://login.microsoftonline.com/common", "a8860e8f-ca7d-4efe-b80d-4affab13d4ba", "f7e11bcd-b50b-4869-ad88-8bdd6cbc8473", redirectUri, UserIdentifier.ANY_USER, state, PromptBehavior.ALWAYS, null); Assert.assertEquals("https://login.microsoftonline.com/common/oauth2/authorize?resource=a8860e8f-ca7d-4efe-b80d-4affab13d4ba&client_id=f7e11bcd-b50b-4869-ad88-8bdd6cbc8473&response_type=code&redirect_uri=https%3A%2F%2Fexample.com&state=519a4fa6-c18f-4230-8290-6c57407656c9&prompt=login", actual.toString()); }
88. AzureAuthorityTest#createAuthorizationEndpointUri_minimal()
Project: vsts-authentication-library-for-java
File: AzureAuthorityTest.java
File: AzureAuthorityTest.java
@Test public void createAuthorizationEndpointUri_minimal() throws Exception { final URI redirectUri = URI.create("https://example.com"); final URI actual = AzureAuthority.createAuthorizationEndpointUri("https://login.microsoftonline.com/common", "a8860e8f-ca7d-4efe-b80d-4affab13d4ba", "f7e11bcd-b50b-4869-ad88-8bdd6cbc8473", redirectUri, UserIdentifier.ANY_USER, null, PromptBehavior.AUTO, null); Assert.assertEquals("https://login.microsoftonline.com/common/oauth2/authorize?resource=a8860e8f-ca7d-4efe-b80d-4affab13d4ba&client_id=f7e11bcd-b50b-4869-ad88-8bdd6cbc8473&response_type=code&redirect_uri=https%3A%2F%2Fexample.com", actual.toString()); }
89. AzureAuthority#acquireToken()
Project: vsts-authentication-library-for-java
File: AzureAuthority.java
File: AzureAuthority.java
public TokenPair acquireToken(final String clientId, final String resource, final URI redirectUri, final Action<DeviceFlowResponse> callback) throws AuthorizationException { Debug.Assert(!StringHelper.isNullOrWhiteSpace(clientId), "The clientId parameter is null or empty"); Debug.Assert(!StringHelper.isNullOrWhiteSpace(resource), "The resource parameter is null or empty"); Debug.Assert(redirectUri != null, "The redirectUri parameter is null"); Debug.Assert(callback != null, "The callback parameter is null"); logger.debug("AzureAuthority::acquireToken"); azureDeviceFlow.setResource(resource); azureDeviceFlow.setRedirectUri(redirectUri.toString()); final URI deviceEndpoint = URI.create(authorityHostUrl + "/oauth2/devicecode"); final DeviceFlowResponse response = azureDeviceFlow.requestAuthorization(deviceEndpoint, clientId, null); callback.call(response); final URI tokenEndpoint = createTokenEndpointUri(authorityHostUrl); final TokenPair tokens = azureDeviceFlow.requestToken(tokenEndpoint, clientId, response); logger.debug(" token acquisition succeeded."); return tokens; }
90. PropertyMapBuilderTest#currentOrActiveContext()
Project: vso-intellij
File: PropertyMapBuilderTest.java
File: PropertyMapBuilderTest.java
@Test public void currentOrActiveContext() { // Set the active context final URI uri = URI.create("http://server/path"); final URI uri2 = URI.create("http://server2/path"); final ServerContext context = new ServerContextBuilder().type(ServerContext.Type.TFS).uri(uri).build(); final ServerContext context2 = new ServerContextBuilder().type(ServerContext.Type.TFS).uri(uri2).build(); // set active context ServerContextManager.getInstance().add(context); // try to use active context final TfsTelemetryHelper.PropertyMapBuilder builder = new TfsTelemetryHelper.PropertyMapBuilder(); final Map<String, String> map = builder.currentOrActiveContext(null).build(); Assert.assertEquals("server", map.get("VSO.TeamFoundationServer.ServerId")); // try to use current context final TfsTelemetryHelper.PropertyMapBuilder builder2 = new TfsTelemetryHelper.PropertyMapBuilder(); final Map<String, String> map2 = builder2.currentOrActiveContext(context2).build(); Assert.assertEquals("server2", map2.get("VSO.TeamFoundationServer.ServerId")); }
91. LinkTool#toString()
Project: velocity-tools
File: LinkTool.java
File: LinkTool.java
/** * Returns the full URI reference that's been built with this tool, * including the query string and anchor, e.g. * <code>http://myserver.net/myapp/stuff/View.vm?id=42&type=blue#foo</code>. * Typically, it is not necessary to call this method explicitely. * Velocity will call the toString() method automatically to obtain * a representable version of an object. */ public String toString() { URI uri = createURI(); if (uri == null) { return null; } if (query != null) { return decodeQueryPercents(uri.toString()); } return uri.toString(); }
92. URIResultInfoRetriever#retrieveSupplementalInfo()
Project: VallasciApp-ionic
File: URIResultInfoRetriever.java
File: URIResultInfoRetriever.java
@Override void retrieveSupplementalInfo() throws IOException { URI oldURI; try { oldURI = new URI(result.getURI()); } catch (URISyntaxException e) { return; } URI newURI = HttpHelper.unredirect(oldURI); int count = 0; while (count++ < MAX_REDIRECTS && !oldURI.equals(newURI)) { append(result.getDisplayResult(), null, new String[] { redirectString + " : " + newURI }, newURI.toString()); oldURI = newURI; newURI = HttpHelper.unredirect(newURI); } }
93. MockHttpRequest#initWithUri()
Project: Resteasy
File: MockHttpRequest.java
File: MockHttpRequest.java
private static MockHttpRequest initWithUri(URI absoluteUri, URI baseUri) { if (baseUri == null) baseUri = EMPTY_URI; MockHttpRequest request = new MockHttpRequest(); request.httpHeaders = new ResteasyHttpHeaders(new CaseInsensitiveMap<String>()); //request.uri = new UriInfoImpl(absoluteUri, absoluteUri, absoluteUri.getPath(), absoluteUri.getQuery(), PathSegmentImpl.parseSegments(absoluteUri.getPath())); // remove query part URI absolutePath = UriBuilder.fromUri(absoluteUri).replaceQuery(null).build(); // path must be relative to the application's base uri URI relativeUri = baseUri.relativize(absoluteUri); relativeUri = UriBuilder.fromUri(relativeUri.getRawPath()).replaceQuery(absoluteUri.getRawQuery()).build(); request.uri = new ResteasyUriInfo(absoluteUri.toString(), absoluteUri.getRawQuery(), baseUri.getRawPath()); return request; }
94. StoreResource#head()
Project: Resteasy
File: StoreResource.java
File: StoreResource.java
@HEAD public Response head(@Context UriInfo uriInfo) { UriBuilder absolute = uriInfo.getBaseUriBuilder(); URI customerUrl = absolute.clone().path(CustomerResource.class).build(); URI orderUrl = absolute.clone().path(OrderResource.class).build(); Response.ResponseBuilder builder = Response.ok(); Link customers = Link.fromUri(customerUrl).rel("customers").type("application/xml").build(); Link orders = Link.fromUri(orderUrl).rel("orders").type("application/xml").build(); builder.links(customers, orders); return builder.build(); }
95. ClusterConnectionManager#upDownSlaves()
Project: redisson
File: ClusterConnectionManager.java
File: ClusterConnectionManager.java
private void upDownSlaves(final MasterSlaveEntry entry, final ClusterPartition currentPart, final ClusterPartition newPart) { Set<URI> aliveSlaves = new HashSet<URI>(currentPart.getFailedSlaveAddresses()); aliveSlaves.removeAll(newPart.getFailedSlaveAddresses()); for (URI uri : aliveSlaves) { currentPart.removeFailedSlaveAddress(uri); if (entry.slaveUp(uri.getHost(), uri.getPort(), FreezeReason.MANAGER)) { log.info("slave: {} has up for slot ranges: {}", uri, currentPart.getSlotRanges()); } } Set<URI> failedSlaves = new HashSet<URI>(newPart.getFailedSlaveAddresses()); failedSlaves.removeAll(currentPart.getFailedSlaveAddresses()); for (URI uri : failedSlaves) { currentPart.addFailedSlaveAddress(uri); if (entry.slaveDown(uri.getHost(), uri.getPort(), FreezeReason.MANAGER)) { log.warn("slave: {} has down for slot ranges: {}", uri, currentPart.getSlotRanges()); } } }
96. NettyHandlerContainer#messageReceived()
Project: recipes-rss
File: NettyHandlerContainer.java
File: NettyHandlerContainer.java
@Override public void messageReceived(ChannelHandlerContext context, MessageEvent e) throws Exception { HttpRequest request = (HttpRequest) e.getMessage(); String base = getBaseUri(request); URI baseUri = new URI(base); URI requestUri = new URI(base.substring(0, base.length() - 1) + request.getUri()); ContainerRequest cRequest = new ContainerRequest(application, request.getMethod().getName(), baseUri, requestUri, getHeaders(request), new ChannelBufferInputStream(request.getContent())); application.handleRequest(cRequest, new Writer(e.getChannel())); }
97. URIResultInfoRetriever#retrieveSupplementalInfo()
Project: reacteu-app
File: URIResultInfoRetriever.java
File: URIResultInfoRetriever.java
@Override void retrieveSupplementalInfo() throws IOException { URI oldURI; try { oldURI = new URI(result.getURI()); } catch (URISyntaxException e) { return; } URI newURI = HttpHelper.unredirect(oldURI); int count = 0; while (count++ < MAX_REDIRECTS && !oldURI.equals(newURI)) { append(result.getDisplayResult(), null, new String[] { redirectString + " : " + newURI }, newURI.toString()); oldURI = newURI; newURI = HttpHelper.unredirect(newURI); } }
98. FileWatcherDiscoveryAgent#updateURIs()
Project: qpid-jms
File: FileWatcherDiscoveryAgent.java
File: FileWatcherDiscoveryAgent.java
private void updateURIs(List<URI> updates) throws IOException { // Remove any previously discovered URIs that are no longer in the watched resource HashSet<URI> removedPeers = new HashSet<URI>(discovered); removedPeers.removeAll(updates); for (URI removed : removedPeers) { listener.onServiceRemove(removed); } // Only add the newly discovered remote peers HashSet<URI> addedPeers = new HashSet<URI>(updates); addedPeers.removeAll(discovered); for (URI addition : addedPeers) { listener.onServiceAdd(addition); } // Now just store the new set of URIs and advertise them. discovered.clear(); discovered.addAll(updates); }
99. URISupportTest#testParsingURIWithEmptyValuesInOptions()
Project: qpid-jms
File: URISupportTest.java
File: URISupportTest.java
@Test public void testParsingURIWithEmptyValuesInOptions() throws Exception { URI source = new URI("tcp://localhost:61626/foo/bar?cheese=&x="); Map<String, String> map = PropertyUtil.parseParameters(source); assertEquals("Size: " + map, 2, map.size()); assertMapKey(map, "cheese", ""); assertMapKey(map, "x", ""); URI result = URISupport.removeQuery(source); assertEquals("result", new URI("tcp://localhost:61626/foo/bar"), result); }
100. URISupportTest#testParsingURI()
Project: qpid-jms
File: URISupportTest.java
File: URISupportTest.java
@Test public void testParsingURI() throws Exception { URI source = new URI("tcp://localhost:61626/foo/bar?cheese=Edam&x=123"); Map<String, String> map = PropertyUtil.parseParameters(source); assertEquals("Size: " + map, 2, map.size()); assertMapKey(map, "cheese", "Edam"); assertMapKey(map, "x", "123"); URI result = URISupport.removeQuery(source); assertEquals("result", new URI("tcp://localhost:61626/foo/bar"), result); }