Example usage for org.springframework.boot SpringApplication SpringApplication

List of usage examples for org.springframework.boot SpringApplication SpringApplication

Introduction

In this page you can find the example usage for org.springframework.boot SpringApplication SpringApplication.

Prototype

@SuppressWarnings({ "unchecked", "rawtypes" })
public SpringApplication(ResourceLoader resourceLoader, Class<?>... primarySources) 

Source Link

Document

Create a new SpringApplication instance.

Usage

From source file:cf.spring.servicebroker.CatalogTest.java

@Test
public void serviceBrokerWithNoPlansInCatalog() throws Exception {
    final SpringApplication application = new SpringApplication(EmptyServiceBrokerCatalog.class,
            EmptyPlanServiceBrokerConfiguration.class);
    try (ConfigurableApplicationContext context = application.run();
            CloseableHttpClient client = buildAuthenticatingClient()) {
        JsonNode catalog = loadCatalog(client);
        assertNotNull(catalog);//from w  ww .j  a  v a2  s .  c om
        assertTrue(catalog.has("services"));
        final JsonNode services = catalog.get("services");
        assertTrue(services.isArray());
        assertEquals(services.size(), 1);

        final JsonNode serviceBroker = services.get(0);

        // Required "id" field
        assertTrue(serviceBroker.has("id"));
        assertEquals(serviceBroker.get("id").asText(), BROKER_ID);

        // Required "name" field
        assertTrue(serviceBroker.has("name"));
        assertEquals(serviceBroker.get("name").asText(), BROKER_NAME);

        // Required "description" field
        assertTrue(serviceBroker.has("description"));
        assertEquals(serviceBroker.get("description").asText(), BROKER_DESCRIPTION);

        // Required "bindable" field
        assertTrue(serviceBroker.has("bindable"));
        assertFalse(serviceBroker.get("bindable").asBoolean());

        // Required "plans" array field
        assertTrue(serviceBroker.has("plans"));
        final JsonNode plans = serviceBroker.get("plans");
        assertTrue(plans.isArray());
        assertEquals(plans.size(), 0);
    }
}

From source file:cf.spring.servicebroker.CatalogTest.java

@Test
public void serviceBrokerWithPlansInCatalog() throws Exception {
    final SpringApplication application = new SpringApplication(EmptyServiceBrokerCatalog.class,
            ServiceBrokerSinglePlanConfiguration.class);
    try (ConfigurableApplicationContext context = application.run();
            CloseableHttpClient client = buildAuthenticatingClient()) {
        JsonNode catalog = loadCatalog(client);
        assertNotNull(catalog);/*from   w  w w  . ja  va2  s .  c  o m*/
        assertTrue(catalog.has("services"));
        final JsonNode services = catalog.get("services");
        assertTrue(services.isArray());
        assertEquals(services.size(), 1);

        final JsonNode serviceBroker = services.get(0);

        assertTrue(serviceBroker.has("plans"));
        final JsonNode plans = serviceBroker.get("plans");
        assertTrue(plans.isArray());
        assertEquals(plans.size(), 1);

        final JsonNode plan = plans.get(0);
        assertTrue(plan.has("id"));
        assertEquals(plan.get("id").asText(), PLAN_ID);
        assertTrue(plan.has("name"));
        assertEquals(plan.get("name").asText(), PLAN_NAME);
        assertTrue(plan.has("description"));
        assertEquals(plan.get("description").asText(), PLAN_DESCRIPTION);
        assertTrue(plan.has("free"));
        assertTrue(plan.get("free").asBoolean());
    }
}