java.net.URI

Here are the examples of the java api class java.net.URI taken from open source projects.

1. CompilerErrorsTest#testValidationMatchingNavigation()

Project: cloud-slang
Source File: CompilerErrorsTest.java
View license
@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);
}

2. SubFlowSystemTest#testCompileAndRunSubFlowBasic()

Project: cloud-slang
Source File: SubFlowSystemTest.java
View license
@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. ClientDataSource#main()

Project: openejb
Source File: ClientDataSource.java
View license
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()));
}

4. URIUtilsTest#testResolve()

Project: RSSOwl
Source File: URIUtilsTest.java
View license
/**
   * @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
Source File: UrlHelperTest.java
View license
@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
Source File: FactorImports.java
View license
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
Source File: XmlParser.java
View license
/**
   * 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
Source File: XmlParser.java
View license
/**
   * 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. FilesDatasetSourceTest#setUp()

Project: mr4c
Source File: FilesDatasetSourceTest.java
View license
@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);
}

10. URISupportTest#testCompositeCreateURIWithQuery()

Project: qpid-jms
Source File: URISupportTest.java
View license
@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. FactorImports#relativeURIFor()

Project: xmlbeans
Source File: FactorImports.java
View license
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();
}

12. XBayaConfiguration#loadConfiguration()

Project: airavata
Source File: XBayaConfiguration.java
View license
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;
    }
}

13. CompilerHelperTest#testCompileMixedSlangFiles()

Project: cloud-slang
Source File: CompilerHelperTest.java
View license
@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)));
}

14. CompileDependenciesTest#filesThatAreNotImportedShouldNotBeCompiled()

View license
@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")));
}

15. CompileFlowWithMultipleStepsTest#testCompileFlowBasic()

View license
@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());
}

16. CompilerErrorsTest#testFlowWithMissingSpaceBeforeFirstImport()

Project: cloud-slang
Source File: CompilerErrorsTest.java
View license
@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);
}

17. CompilerErrorsTest#testFlowWithWrongIndentation()

Project: cloud-slang
Source File: CompilerErrorsTest.java
View license
@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);
}

18. CompilerErrorsTest#testFlowWhereMapCannotBeCreated()

Project: cloud-slang
Source File: CompilerErrorsTest.java
View license
@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);
}

19. CompilerErrorsTest#testValidationOfFlowThatCallsCorruptedFlow()

Project: cloud-slang
Source File: CompilerErrorsTest.java
View license
@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);
}

20. NavigationTest#testDefaultSuccessNavigation()

Project: cloud-slang
Source File: NavigationTest.java
View license
@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("user@host.com"));
    userInputs.put("emailRecipient", ValueFactory.create("user@host.com"));
    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());
}

21. NavigationTest#testDefaultOnFailureNavigation()

Project: cloud-slang
Source File: NavigationTest.java
View license
@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("user@host.com"));
    userInputs.put("emailRecipient", ValueFactory.create("user@host.com"));
    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());
}

22. NavigationTest#testOnFailureNavigationMoreSteps()

Project: cloud-slang
Source File: NavigationTest.java
View license
@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);
}

23. TestConfigClientUtils#testGetConfigKeyPath()

Project: gobblin
Source File: TestConfigClientUtils.java
View license
@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"));
}

24. TestAvatarStorageSetup#testSameSharedImageLocation()

View license
@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"));
    }
}

25. TestAvatarStorageSetup#testSameSharedEditsLocation()

View license
@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"));
    }
}

26. ApplicationConfigurationTest#testURLFormats()

View license
@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);
}

27. StagedDatasetSourceTest#setUp()

Project: mr4c
Source File: StagedDatasetSourceTest.java
View license
@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();
}

28. CxfCacheUriInfoIssueTest#checkContextForDifferentHostNamesRequests()

View license
@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());
}

29. TestHttpUtils#testResolveUri()

Project: oodt
Source File: TestHttpUtils.java
View license
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());
}

30. ActiveMQConnectionFactoryTest#assertCreateConnection()

View license
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);
}

31. TransportBrokerTestSupport#createConnection()

View license
@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;
}

32. HadoopDataSourceUtil#contains()

Project: asakusafw
Source File: HadoopDataSourceUtil.java
View license
/**
     * 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;
}

33. FileSet#isIncluded()

Project: bnd
Source File: FileSet.java
View license
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;
}

34. CompileBasicFlowTest#testValidFlowWithMissingDependencyRequiredInputInGrandchild()

View license
@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());
}

35. CompileDependenciesTest#subFlowRefId()

View license
@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);
}

36. CompileDependenciesTest#bothFileAreDependentOnTheSameFile()

View license
@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());
}

37. CompileDependenciesTest#circularDependencies()

View license
@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());
}

38. CompileParallelLoopFlowTest#testPublishOnBranchThrowsException()

View license
@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);
}

39. CompileParallelLoopFlowTest#testAggregateKeyThrowsException()

View license
@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);
}

40. CompilerErrorsTest#testSystemPropertiesAsDep()

Project: cloud-slang
Source File: CompilerErrorsTest.java
View license
@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);
}

41. CompilerErrorsTest#testFlowWithCorruptedKeyInImports()

Project: cloud-slang
Source File: CompilerErrorsTest.java
View license
@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);
}

42. CompilerErrorsTest#testValidationOfFlowWithMissingDependencyRequiredInputInStep()

Project: cloud-slang
Source File: CompilerErrorsTest.java
View license
@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);
}

43. CompilerErrorsTest#testValidationOfFlowInputInStepWithSameNameAsDependencyOutput()

Project: cloud-slang
Source File: CompilerErrorsTest.java
View license
@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);
}

44. NavigationTest#testNavigationOnFailureContainsStepWithCustomResult()

Project: cloud-slang
Source File: NavigationTest.java
View license
@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());
}

45. ValueSyntaxInFlowTest#testValues()

View license
@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);
}

46. FlowWithJavaVersioningTest#testFlowWithGlobalSession()

View license
@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);
}

47. LoopFlowsTest#testFlowWithLoopsWithBreak()

Project: cloud-slang
Source File: LoopFlowsTest.java
View license
@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());
}

48. LoopFlowsTest#testFlowWithMapLoopsWithBreak()

Project: cloud-slang
Source File: LoopFlowsTest.java
View license
@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());
}

49. ParallelLoopFlowsTest#testFlowWithParallelLoopNavigate()

View license
@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);
}

50. ParallelLoopFlowsTest#testFlowWithParallelLoopPublishNavigate()

View license
@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);
}

51. SensitiveValuesInPythonExpressionsFlowTest#testValues()

View license
@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);
}

52. SensitiveValueSyntaxInFlowTest#testValues()

View license
@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);
}

53. SimpleFlowTest#testFlowWithGlobalSession()

Project: cloud-slang
Source File: SimpleFlowTest.java
View license
@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());
}

54. SimpleFlowTest#testFlowWithSameInputNameAsStep()

Project: cloud-slang
Source File: SimpleFlowTest.java
View license
@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());
}

55. SimpleFlowTest#testFlowGetValue()

Project: cloud-slang
Source File: SimpleFlowTest.java
View license
@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());
}

56. DefaultConfigurationResolverTest#testCacheManagerPropertiesOverridesSystemProperty()

View license
@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);
}

57. TestDefaultNameNodePort#testGetAddressFromConf()

View license
@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());
}

58. PathTypeTest#testToUri()

Project: jimfs
Source File: PathTypeTest.java
View license
@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("/$/");
}

59. UnixPathTypeTest#testUnix_toUri()

Project: jimfs
Source File: UnixPathTypeTest.java
View license
@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("/");
}

60. WindowsPathTypeTest#testWindows_toUri_normal()

Project: jimfs
Source File: WindowsPathTypeTest.java
View license
@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:/");
}

61. Delombok#createFileWriter()

Project: lombok
Source File: Delombok.java
View license
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);
}

62. WebURL#resolve()

Project: manifoldcf
Source File: WebURL.java
View license
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));
}

63. WebURL#resolve()

Project: manifoldcf
Source File: WebURL.java
View license
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));
}

64. MultiReleaseJarTest#initialize()

Project: openjdk
Source File: MultiReleaseJarTest.java
View license
@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";
}

65. TestRegisterParser#testRegisterArtifact()

Project: pig
Source File: TestRegisterParser.java
View license
// 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()));
    }
}

66. StoreResourceBean#head()

Project: Resteasy
Source File: StoreResourceBean.java
View license
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();
}

67. StoreResourceBean#head()

Project: Resteasy
Source File: StoreResourceBean.java
View license
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();
}

68. UriBuilderTest#testRelativize()

Project: Resteasy
Source File: UriBuilderTest.java
View license
@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");
}

69. DefaultServiceInstanceConverter#convert()

View license
@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();
}

70. FOMElement#getResolvedBaseUri()

Project: abdera
Source File: FOMElement.java
View license
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;
}

71. CompressionOverNetworkTest#doSetUp()

View license
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);
}

72. DiscoveryTransportNoBrokerTest#testSetDiscoveredBrokerProperties()

View license
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);
}

73. DiscoveryTransportNoBrokerTest#testSetDiscoveredStaticBrokerProperties()

View license
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);
}

74. TestEventSubmissionFailedException#testPicksFirstCause()

View license
@Test
public void testPicksFirstCause() {
    URI uri1 = URI.create("/y");
    URI uri2 = URI.create("/x");
    RuntimeException cause1 = new RuntimeException("y");
    RuntimeException cause2 = new RuntimeException("x");
    Map<URI, RuntimeException> causes = ImmutableSortedMap.<URI, RuntimeException>orderedBy(Ordering.explicit(uri1, uri2)).put(uri1, cause1).put(uri2, cause2).build();
    EventSubmissionFailedException e = new EventSubmissionFailedException("service", "type", causes);
    assertSame(e.getCause(), cause1);
}

75. ExcelSheetRuleProviderTest#uri()

View license
private URI uri(String file, String fragment) throws Exception {
    URL url = getClass().getResource(file);
    assertThat(file, url, not(nullValue()));
    URI resource = url.toURI();
    URI uri = new URI(resource.getScheme(), resource.getUserInfo(), resource.getHost(), resource.getPort(), resource.getPath(), resource.getQuery(), fragment);
    return uri;
}

76. ExcelSheetSourceProviderTest#uri()

View license
private URI uri(String file, String fragment) throws Exception {
    URL url = getClass().getResource(file);
    assertThat(file, url, not(nullValue()));
    URI resource = url.toURI();
    URI uri = new URI(resource.getScheme(), resource.getUserInfo(), resource.getHost(), resource.getPort(), resource.getPath(), resource.getQuery(), fragment);
    return uri;
}

77. DriverElementBase#toUri()

Project: asakusafw
Source File: DriverElementBase.java
View license
/**
     * Returns URI for the existing resource.
     * @param path the path string of the target resource
     * @return the URI for the target resource
     * @throws URISyntaxException if the URI is not valid
     */
public URI toUri(String path) throws URISyntaxException {
    if (path == null) {
        //$NON-NLS-1$
        throw new IllegalArgumentException("path must not be null");
    }
    // FIXME for invalid characters
    URI uri = URI.create(path.replace('\\', '/'));
    if (uri.getScheme() != null) {
        return uri;
    }
    URL url = getCallerClass().getResource(uri.getPath());
    if (url == null) {
        throw new IllegalArgumentException(MessageFormat.format(Messages.getString("DriverElementBase.errorMissingResource"), path, getCallerClass().getName()));
    }
    URI resourceUri = url.toURI();
    if (uri.getFragment() == null) {
        return resourceUri;
    } else {
        URI resolvedUri = URI.create(resourceUri.toString() + '#' + uri.getFragment());
        return resolvedUri;
    }
}

78. AWSGitPushCommand#getRemoteUrl()

View license
private String getRemoteUrl() throws Exception {
    AWSElasticBeanstalkGitPushRequest request = new AWSElasticBeanstalkGitPushRequest();
    request.setHost(getGitPushHost());
    Region region = RegionUtils.getRegionByEndpoint(environment.getRegionEndpoint());
    request.setRegion(region.getId());
    request.setApplication(environment.getApplicationName());
    if (!skipEnvironmentDeployment) {
        request.setEnvironment(environment.getEnvironmentName());
    }
    AWSGitPushAuth auth = new AWSGitPushAuth(request);
    URI uri = auth.deriveRemote(accessKey, secretKey);
    return uri.toString();
}

79. Processor#_uri()

Project: bnd
Source File: Processor.java
View license
public String _uri(String args[]) throws Exception {
    Macro.verifyCommand(args, _uri, null, 2, 3);
    URI uri = new URI(args[1]);
    if (!uri.isAbsolute() || uri.getScheme().equals("file")) {
        URI base;
        if (args.length > 2) {
            base = new URI(args[2]);
        } else {
            base = getBaseURI();
            if (base == null) {
                throw new IllegalArgumentException("No base dir set");
            }
        }
        uri = base.resolve(uri.getSchemeSpecificPart());
    }
    return uri.toString();
}

80. CachingUriResourceHandlerTest#testFailedLoadFromRemote()

View license
public static void testFailedLoadFromRemote() throws Exception {
    String testDirName = "testdata/httpcache/2";
    File cacheDir = new File(testDirName);
    URI baseUri = new URI("http://localhost:18083/bundles");
    URI uri = new URI(baseUri + "/dummybundle.jar");
    CachingUriResourceHandle handle = new CachingUriResourceHandle(uri, cacheDir, new DefaultURLConnector(), (String) null);
    try {
        handle.request();
        fail("Should throw IOException");
    } catch (IOException e) {
        List<String> cacheFiles = Arrays.asList(cacheDir.list());
        String uriCacheDir = URLEncoder.encode(baseUri.toURL().toExternalForm(), "UTF-8");
        assert (cacheFiles.size() == 1 || cacheFiles.size() == 2);
        assert (cacheFiles.contains(uriCacheDir));
        if (cacheFiles.size() == 2) {
            assert (cacheFiles.contains(".gitignore"));
        }
        IO.getFile(testDirName + "/" + uriCacheDir).delete();
    }
}

81. JPMTest#testAddMirrorURL()

Project: bnd
Source File: JPMTest.java
View license
public void testAddMirrorURL() throws Exception {
    // Drop two URIs for an identical resource
    URI uri1 = IO.getFile("testdata/ws/cnf/jar/biz.aQute.bnd.annotation-2.3.0.jar").toURI();
    repo.dropTarget(uri1);
    URI uri2 = IO.getFile("testdata/ws/cnf/jar/biz.aQute.bnd.annotation-2.3.0-duplicate.jar").toURI();
    repo.dropTarget(uri2);
    // Read the index, there should be one resource but two mirror URLs
    List<RevisionRef> refs = new Index(IO.getFile(tmp, "index")).getRevisionRefs();
    assertEquals(1, refs.size());
    assertEquals(2, refs.get(0).urls.size());
    assertTrue(refs.get(0).urls.contains(uri1));
    assertTrue(refs.get(0).urls.contains(uri2));
}

82. MavenUrlDecoderTest#shouldAddSlashesToMavenRepoUriIfOneIsMissing()

Project: buck
Source File: MavenUrlDecoderTest.java
View license
@Test
public void shouldAddSlashesToMavenRepoUriIfOneIsMissing() throws URISyntaxException {
    String validUri = "mvn:junit:junit:jar:4.12";
    URI slashless = MavenUrlDecoder.toHttpUrl(Optional.of("http://www.example.com"), new URI(validUri));
    URI withslash = MavenUrlDecoder.toHttpUrl(Optional.of("http://www.example.com/"), new URI(validUri));
    assertEquals(withslash, slashless);
}

83. URISupportTest#testParseParameters()

Project: camel
Source File: URISupportTest.java
View license
public void testParseParameters() throws Exception {
    URI u = new URI("quartz:myGroup/myTimerName?cron=0+0+*+*+*+?");
    Map<String, Object> params = URISupport.parseParameters(u);
    assertEquals(1, params.size());
    assertEquals("0 0 * * * ?", params.get("cron"));
    u = new URI("quartz:myGroup/myTimerName?cron=0+0+*+*+*+?&bar=123");
    params = URISupport.parseParameters(u);
    assertEquals(2, params.size());
    assertEquals("0 0 * * * ?", params.get("cron"));
    assertEquals("123", params.get("bar"));
}

84. AuthorizationRestServiceImpl#availableOperations()

View license
public ResourceOptionsDto availableOperations(UriInfo context) {
    UriBuilder baseUriBuilder = context.getBaseUriBuilder().path(relativeRootResourcePath).path(AuthorizationRestService.PATH);
    ResourceOptionsDto resourceOptionsDto = new ResourceOptionsDto();
    // GET /
    URI baseUri = baseUriBuilder.build();
    resourceOptionsDto.addReflexiveLink(baseUri, HttpMethod.GET, "list");
    // GET /count
    URI countUri = baseUriBuilder.clone().path("/count").build();
    resourceOptionsDto.addReflexiveLink(countUri, HttpMethod.GET, "count");
    // POST /create
    if (isAuthorized(CREATE)) {
        URI createUri = baseUriBuilder.clone().path("/create").build();
        resourceOptionsDto.addReflexiveLink(createUri, HttpMethod.POST, "create");
    }
    return resourceOptionsDto;
}

85. FilterRestServiceImpl#availableOperations()

View license
public ResourceOptionsDto availableOperations(UriInfo context) {
    UriBuilder baseUriBuilder = context.getBaseUriBuilder().path(relativeRootResourcePath).path(FilterRestService.PATH);
    ResourceOptionsDto resourceOptionsDto = new ResourceOptionsDto();
    // GET /
    URI baseUri = baseUriBuilder.build();
    resourceOptionsDto.addReflexiveLink(baseUri, HttpMethod.GET, "list");
    // GET /count
    URI countUri = baseUriBuilder.clone().path("/count").build();
    resourceOptionsDto.addReflexiveLink(countUri, HttpMethod.GET, "count");
    // POST /create
    if (isAuthorized(CREATE)) {
        URI createUri = baseUriBuilder.clone().path("/create").build();
        resourceOptionsDto.addReflexiveLink(createUri, HttpMethod.POST, "create");
    }
    return resourceOptionsDto;
}

86. TenantRestServiceImpl#availableOperations()

View license
public ResourceOptionsDto availableOperations(UriInfo context) {
    UriBuilder baseUriBuilder = context.getBaseUriBuilder().path(relativeRootResourcePath).path(TenantRestService.PATH);
    ResourceOptionsDto resourceOptionsDto = new ResourceOptionsDto();
    // GET /
    URI baseUri = baseUriBuilder.build();
    resourceOptionsDto.addReflexiveLink(baseUri, HttpMethod.GET, "list");
    // GET /count
    URI countUri = baseUriBuilder.clone().path("/count").build();
    resourceOptionsDto.addReflexiveLink(countUri, HttpMethod.GET, "count");
    // POST /create
    if (!getIdentityService().isReadOnly() && isAuthorized(CREATE)) {
        URI createUri = baseUriBuilder.clone().path("/create").build();
        resourceOptionsDto.addReflexiveLink(createUri, HttpMethod.POST, "create");
    }
    return resourceOptionsDto;
}

87. UserResourceImpl#availableOperations()

View license
public ResourceOptionsDto availableOperations(UriInfo context) {
    ResourceOptionsDto dto = new ResourceOptionsDto();
    // add links if operations are authorized
    UriBuilder baseUriBuilder = context.getBaseUriBuilder().path(rootResourcePath).path(UserRestService.PATH).path(resourceId);
    URI baseUri = baseUriBuilder.build();
    URI profileUri = baseUriBuilder.path("/profile").build();
    dto.addReflexiveLink(profileUri, HttpMethod.GET, "self");
    if (!identityService.isReadOnly() && isAuthorized(DELETE)) {
        dto.addReflexiveLink(baseUri, HttpMethod.DELETE, "delete");
    }
    if (!identityService.isReadOnly() && isAuthorized(UPDATE)) {
        dto.addReflexiveLink(profileUri, HttpMethod.PUT, "update");
    }
    return dto;
}

88. Locations#getParent()

Project: cdap
Source File: Locations.java
View license
/**
   * Creates a {@link Location} instance which represents the parent of the given location.
   *
   * @param location location to extra parent from.
   * @return an instance representing the parent location or {@code null} if there is no parent.
   */
@Nullable
public static Location getParent(Location location) {
    URI source = location.toURI();
    // If it is root, return null
    if ("/".equals(source.getPath())) {
        return null;
    }
    URI resolvedParent = URI.create(source.toString() + "/..").normalize();
    // does not work in MapR. so we remove the trailing slash (if any) at the end.
    if (resolvedParent.toString().endsWith("/")) {
        String parent = resolvedParent.toString();
        resolvedParent = URI.create(parent.substring(0, parent.length() - 1));
    }
    return location.getLocationFactory().create(resolvedParent);
}

89. LogCleanup#deleteEmptyDirsInNamespace()

Project: cdap
Source File: LogCleanup.java
View license
/**
   * Given a namespaced log dir - e.g. /{root}/ns1/logs, deletes dir if it is empty, and recursively deletes parent dirs
   * if they are empty too. The recursion stops at non-empty parent or the specified namespaced log base directory.
   * If dir is not child of base directory then the recursion stops at root.
   * @param dirToDelete dir to be deleted.
   */
private void deleteEmptyDirsInNamespace(Location namespacedLogBaseDir, Location dirToDelete) {
    // Don't delete a dir if it is equal to or a parent of logBaseDir
    URI namespacedLogBaseURI = namespacedLogBaseDir.toURI();
    URI dirToDeleteURI = dirToDelete.toURI();
    if (namespacedLogBaseURI.equals(dirToDeleteURI) || !dirToDeleteURI.getRawPath().startsWith(namespacedLogBaseURI.getRawPath())) {
        LOG.debug("{} not deletion candidate.", dirToDelete);
        return;
    }
    try {
        if (dirToDelete.list().isEmpty() && dirToDelete.delete()) {
            LOG.info("Deleted empty dir {}", dirToDelete);
            // See if parent dir is empty, and needs deleting
            Location parent = getParent(dirToDelete);
            LOG.debug("Deleting parent dir {}", parent);
            deleteEmptyDirsInNamespace(namespacedLogBaseDir, parent);
        } else {
            LOG.debug("Not deleting non-dir or non-empty dir {}", dirToDelete);
        }
    } catch (IOException e) {
        LOG.error("Got exception while deleting dir {}", dirToDelete, e);
    }
}

90. SBOLCircuitWriter#setCircuitComponentDefinition()

Project: cello
Source File: SBOLCircuitWriter.java
View license
/**
     * The circuit plasmid is the highest level in structural layer.
     * Will include vector backbone if one was specified in the UCF genetic_locations collection.
     * Currently, I am not creating an SBOL document for each output plasmid, if the output module is on
     * a separate plasmid from the circuit module.
     * @param plasmid
     */
public void setCircuitComponentDefinition(ArrayList<Part> plasmid) {
    URI circuitTypeURI = URI.create("http://www.biopax.org/release/biopax-level3.owl#DnaRegion");
    HashSet<URI> circuitTypeURIs = new HashSet<URI>();
    circuitTypeURIs.add(circuitTypeURI);
    _circuit_component_definition = _document.createComponentDefinition(_circuit_name + "_circuit", circuitTypeURIs);
    String concatenated_plasmid_sequence = "";
    for (Part p : plasmid) {
        //what if revcomp?
        concatenated_plasmid_sequence += p.get_seq();
    }
    String sequenceDisplayID = _circuit_name + "_circuit" + "_sequence";
    URI encodingURI = URI.create("http://www.chem.qmul.ac.uk/iubmb/misc/naseq.html");
    Sequence s = _document.createSequence(sequenceDisplayID, concatenated_plasmid_sequence, encodingURI);
}

91. CeylonDocTool#getObjectUrl()

Project: ceylon
Source File: CeylonDocTool.java
View license
protected String getObjectUrl(Object from, Object to, boolean withFragment) throws IOException {
    Module module = getModule(from);
    URI fromUrl = getAbsoluteObjectUrl(from);
    URI toUrl = getAbsoluteObjectUrl(to);
    String result = relativize(module, fromUrl, toUrl).toString();
    if (withFragment && to instanceof Package && isRootPackage(module, (Package) to)) {
        result += "#section-package";
    }
    return result;
}

92. CeylonDocTool#getObjectUrl()

Project: ceylon-compiler
Source File: CeylonDocTool.java
View license
protected String getObjectUrl(Object from, Object to, boolean withFragment) throws IOException {
    Module module = getModule(from);
    URI fromUrl = getAbsoluteObjectUrl(from);
    URI toUrl = getAbsoluteObjectUrl(to);
    String result = relativize(module, fromUrl, toUrl).toString();
    if (withFragment && to instanceof Package && isRootPackage(module, (Package) to)) {
        result += "#section-package";
    }
    return result;
}

93. CompilerHelperTest#testDependenciesFileParentFolder()

Project: cloud-slang
Source File: CompilerHelperTest.java
View license
@Test
public void testDependenciesFileParentFolder() throws Exception {
    URI flowPath = getClass().getResource("/executables/dir3/flow.sl").toURI();
    URI opPath = getClass().getResource("/executables/dir3/dir3_1/test_op.sl").toURI();
    compilerHelper.compile(flowPath.getPath(), null);
    Mockito.verify(slang).compile(SlangSource.fromFile(flowPath), Sets.newHashSet(SlangSource.fromFile(opPath), SlangSource.fromFile(flowPath)));
}

94. CompileBasicFlowTest#testCompileFlowBasic()

View license
@Test
public void testCompileFlowBasic() throws Exception {
    URI flow = getClass().getResource("/basic_flow.yaml").toURI();
    URI operation = getClass().getResource("/test_op.sl").toURI();
    Set<SlangSource> path = new HashSet<>();
    path.add(SlangSource.fromFile(operation));
    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", 4, executionPlan.getSteps().size());
    Assert.assertEquals("execution plan name is different than expected", "basic_flow", executionPlan.getName());
    Assert.assertEquals("the dependencies size is not as expected", 1, compilationArtifact.getDependencies().size());
    Assert.assertEquals("the inputs size is not as expected", 3, compilationArtifact.getInputs().size());
}

95. CompileBasicFlowTest#testValidateSlangModelWithDependenciesBasic()

View license
@Test
public void testValidateSlangModelWithDependenciesBasic() throws Exception {
    URI flowUri = getClass().getResource("/basic_flow.yaml").toURI();
    Executable flow = compiler.preCompile(SlangSource.fromFile(flowUri));
    URI operationUri = getClass().getResource("/test_op.sl").toURI();
    Executable op = compiler.preCompile(SlangSource.fromFile(operationUri));
    Set<Executable> dependencies = new HashSet();
    dependencies.add(op);
    List<RuntimeException> errors = compiler.validateSlangModelWithDirectDependencies(flow, dependencies);
    Assert.assertEquals("", 0, errors.size());
}

96. CompileBasicFlowTest#testCompileFlowNavigateDuplicateKeysFirstIsTaken()

View license
@Test
public void testCompileFlowNavigateDuplicateKeysFirstIsTaken() throws Exception {
    URI flow = getClass().getResource("/flow_navigate_duplicate_keys.sl").toURI();
    URI operation = getClass().getResource("/check_Weather.sl").toURI();
    Set<SlangSource> path = new HashSet<>();
    path.add(SlangSource.fromFile(operation));
    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", 4, executionPlan.getSteps().size());
    ExecutionStep endStepExecutionStep = executionPlan.getStep(3L);
    @SuppressWarnings("unchecked") Map<String, ResultNavigation> actualNavigationValues = (Map<String, ResultNavigation>) endStepExecutionStep.getActionData().get(ScoreLangConstants.STEP_NAVIGATION_KEY);
    Map<String, ResultNavigation> expectedNavigationValues = new HashMap<>();
    // first in list is taken
    expectedNavigationValues.put("SUCCESS", new ResultNavigation(0, "RESULT1"));
    expectedNavigationValues.put("FAILURE", new ResultNavigation(0, "RESULT2"));
    Assert.assertEquals("navigation values not as expected", expectedNavigationValues, actualNavigationValues);
}

97. CompileDependenciesTest#referenceDoesNoExistInPath()

View license
@Test
public void referenceDoesNoExistInPath() throws Exception {
    URI flow = getClass().getResource("/basic_flow.yaml").toURI();
    URI operation = getClass().getResource("/operation_with_data.sl").toURI();
    Set<SlangSource> path = new HashSet<>();
    path.add(SlangSource.fromFile(operation));
    exception.expect(RuntimeException.class);
    exception.expectMessage(containsString("ops.test_op"));
    compiler.compile(SlangSource.fromFile(flow), path);
}

98. CompileDependenciesTest#importHasAKeyThatDoesNotExistInPath()

View license
@Test
public void importHasAKeyThatDoesNotExistInPath() throws Exception {
    URI flow = getClass().getResource("/basic_flow.yaml").toURI();
    URI operation = getClass().getResource("/flow_with_data.yaml").toURI();
    Set<SlangSource> path = new HashSet<>();
    path.add(SlangSource.fromFile(operation));
    exception.expect(RuntimeException.class);
    exception.expectMessage(containsString("ops"));
    compiler.compile(SlangSource.fromFile(flow), path);
}

99. CompileFlowReferenceIDTest#testBasicAlias()

View license
@Test
public void testBasicAlias() throws Exception {
    URI flow = getClass().getResource("/alias/basic_alias.yaml").toURI();
    URI operation = getClass().getResource("/alias/simple_op.sl").toURI();
    Set<SlangSource> path = new HashSet<>();
    path.add(SlangSource.fromFile(operation));
    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", 4, executionPlan.getSteps().size());
    ExecutionStep beginStepExecutionStep = executionPlan.getStep(2L);
    @SuppressWarnings("unchecked") String referenceID = (String) beginStepExecutionStep.getActionData().get(ScoreLangConstants.REF_ID);
    Assert.assertEquals("Wrong reference ID for step", "cloudslang.sample.simple_op", referenceID);
}

100. CompileFlowReferenceIDTest#testDefaultNamespace()

View license
@Test
public void testDefaultNamespace() throws Exception {
    URI flow = getClass().getResource("/alias/default_namespace.yaml").toURI();
    URI operation = getClass().getResource("/alias/simple_op.sl").toURI();
    Set<SlangSource> path = new HashSet<>();
    path.add(SlangSource.fromFile(operation));
    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", 4, executionPlan.getSteps().size());
    ExecutionStep beginStepExecutionStep = executionPlan.getStep(2L);
    @SuppressWarnings("unchecked") String referenceID = (String) beginStepExecutionStep.getActionData().get(ScoreLangConstants.REF_ID);
    Assert.assertEquals("Wrong reference ID for step", "cloudslang.sample.simple_op", referenceID);
}