Example usage for org.springframework.ide.eclipse.boot.dash.cloudfoundry.client.v2 CFPushArguments setRoutes

List of usage examples for org.springframework.ide.eclipse.boot.dash.cloudfoundry.client.v2 CFPushArguments setRoutes

Introduction

In this page you can find the example usage for org.springframework.ide.eclipse.boot.dash.cloudfoundry.client.v2 CFPushArguments setRoutes.

Prototype

public void setRoutes(String... routes) 

Source Link

Usage

From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryClientTest.java

@Test
public void testPushAndBindHostAndDomain() throws Exception {
    String appName = appHarness.randomAppName();

    for (int i = 0; i < 2; i++) {
        //Why this loop? Because there was bug which CF V2 that made second push fail to bind to
        // map a host that was previously mapped.
        if (i > 0) {
            System.out.println("Delete app");
            client.deleteApplication(appName);
        }/*from   w ww.  j a  v a  2  s  . com*/

        System.out.println("Pushing " + (i + 1));
        CFPushArguments params = new CFPushArguments();
        params.setAppName(appName);
        params.setApplicationData(getTestZip("testapp"));
        params.setBuildpack("staticfile_buildpack");
        params.setRoutes(ImmutableList.of(appName + "." + CFAPPS_IO()));

        push(params);
    }

    System.out.println("Pushing SUCCESS");

    CFApplicationDetail app = client.getApplication(appName);
    assertNotNull("Expected application to exist after push: " + appName, app);

    assertEquals(ImmutableSet.of(appName + "." + CFAPPS_IO()), ImmutableSet.copyOf(app.getUris()));
}

From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryClientTest.java

@Test
public void testPushAndBindMultipleHosts() throws Exception {
    String[] hostNames = { appHarness.randomAppName(), appHarness.randomAppName() };
    String appName = hostNames[0];

    CFPushArguments params = new CFPushArguments();
    params.setAppName(hostNames[0]);// w  ww .j ava  2s .c  o  m
    params.setApplicationData(getTestZip("testapp"));
    params.setBuildpack("staticfile_buildpack");

    Set<String> routes = ImmutableSet
            .copyOf(Stream.of(hostNames).map((host) -> host + "." + CFAPPS_IO()).collect(Collectors.toList()));
    params.setRoutes(routes);

    push(params);

    System.out.println("Pushing SUCCESS");

    CFApplicationDetail app = client.getApplication(appName);
    assertNotNull("Expected application to exist after push: " + appName, app);

    assertEquals(routes, ImmutableSet.copyOf(app.getUris()));
}

From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryClientTest.java

@Test
public void testPushAndSetRoutes() throws Exception {
    String[] hostNames = { appHarness.randomAppName(), appHarness.randomAppName() };
    String appName = hostNames[0];

    CFPushArguments params = new CFPushArguments();
    params.setAppName(hostNames[0]);/*w  w w .  j a v  a  2 s  . c  o  m*/
    params.setApplicationData(getTestZip("testapp"));
    params.setBuildpack("staticfile_buildpack");

    Set<String> routes = ImmutableSet
            .copyOf(Stream.of(hostNames).map((host) -> host + "." + CFAPPS_IO()).collect(Collectors.toList()));
    params.setRoutes(routes);

    push(params);

    System.out.println("Pushing SUCCESS");

    {
        CFApplicationDetail app = client.getApplication(appName);
        assertNotNull("Expected application to exist after push: " + appName, app);
        assertEquals(routes, ImmutableSet.copyOf(app.getUris()));
    }

    doSetRoutesTest(appName, ImmutableSet.of());

    for (String route : routes) {
        doSetRoutesTest(appName, ImmutableSet.of(route));
    }

}

From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryClientTest.java

@Test
public void testPushAndSetEnv() throws Exception {
    String appName = appHarness.randomAppName();

    CFPushArguments params = new CFPushArguments();
    params.setAppName(appName);/*from  w ww .  j a v  a 2 s.  c  o m*/
    params.setRoutes(appName + "." + CFAPPS_IO());
    params.setApplicationData(getTestZip("testapp"));
    params.setBuildpack("staticfile_buildpack");
    params.setEnv(ImmutableMap.of("foo", "foo_value", "bar", "bar_value"));
    push(params);

    CFApplicationDetail app = client.getApplication(appName);
    assertNotNull("Expected application to exist after push: " + appName, app);
    ACondition.waitFor("app content to be availabe", 10_000, () -> {
        String content = IOUtils.toString(new URI("http://" + appName + '.' + CFAPPS_IO() + "/test.txt"));
        assertTrue(content.length() > 0);
        assertTrue(content.contains("content"));
    });

    {
        Map<String, String> env = client.getEnv(appName).block();
        assertEquals("foo_value", env.get("foo"));
        assertEquals("bar_value", env.get("bar"));
        assertEquals(2, env.size());
    }

    client.setEnvVars(appName, ImmutableMap.of("other", "value")).block();
    {
        Map<String, String> env = client.getEnv(appName).block();
        assertEquals("value", env.get("other"));
        assertEquals(1, env.size());
    }

    //This last piece is commented because it fails.
    //See: https://www.pivotaltracker.com/story/show/116804259

    // The last var doesn't get removed. Not sure how to fix it.
    // But eventually we won't even be using 'setEnvVars' it will be part of the push.
    // and its not going to be our problem to fix that.
    //      client.updateApplicationEnvironment(appName, ImmutableMap.of()).get();
    //      {
    //         Map<String, Object> env = client.getEnv(appName).get();
    //         assertEquals(0, env.size());
    //      }
}