Java Code Examples for io.micronaut.context.ApplicationContext#run()

The following examples show how to use io.micronaut.context.ApplicationContext#run() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalFunctionInvokeJavaSpec.java    From micronaut-aws with Apache License 2.0 5 votes vote down vote up
@Test
public void testInvokingALocalFunction() {
    Sum sum = new Sum();
    sum.setA(5);
    sum.setB(10);

    EmbeddedServer server = ApplicationContext.run(EmbeddedServer.class);
    MathClient mathClient = server.getApplicationContext().getBean(MathClient.class);

    assertEquals(Long.valueOf(Integer.MAX_VALUE), mathClient.max());
    assertEquals(2, mathClient.rnd(1.6f));
    assertEquals(15, mathClient.sum(sum));

}
 
Example 2
Source File: LocalFunctionInvokeJavaSpec.java    From micronaut-aws with Apache License 2.0 5 votes vote down vote up
@Test
public void testInvokingALocalFunctionRX() {
    Sum sum = new Sum();
    sum.setA(5);
    sum.setB(10);

    EmbeddedServer server = ApplicationContext.run(EmbeddedServer.class);
    RxMathClient mathClient = server.getApplicationContext().getBean(RxMathClient.class);

    assertEquals(Long.valueOf(Integer.MAX_VALUE), mathClient.max().blockingGet());
    assertEquals(2, mathClient.rnd(1.6f).blockingGet().longValue());
    assertEquals(15, mathClient.sum(sum).blockingGet().longValue());

}
 
Example 3
Source File: BookSenderTest.java    From micronaut-kafka with Apache License 2.0 5 votes vote down vote up
@Test
public void testBookSender() throws IOException {
    Map<String, Object> config = Collections.singletonMap( // <1>
            AbstractKafkaConfiguration.EMBEDDED, true
    );

    try (ApplicationContext ctx = ApplicationContext.run(config)) {
        BookSender bookSender = ctx.getBean(BookSender.class); // <2>
        Book book = new Book();
        book.setTitle("The Stand");
        bookSender.send("Stephen King", book);
    }
}
 
Example 4
Source File: DocTests.java    From micronaut-kafka with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setup() {
    kafkaContainer.start();
    applicationContext = ApplicationContext.run(
            CollectionUtils.mapOf(
                    "kafka.bootstrap.servers", kafkaContainer.getBootstrapServers()
        )
    );
}
 
Example 5
Source File: EmbeddedMain.java    From micronaut-kafka with Apache License 2.0 5 votes vote down vote up
public static void main(String...args) {
    ApplicationContext applicationContext = ApplicationContext.run(
            Collections.singletonMap(
                    AbstractKafkaConfiguration.EMBEDDED, true
            )
    , Environment.TEST);
    KafkaEmbedded embedded = applicationContext.getBean(KafkaEmbedded.class);
}
 
Example 6
Source File: BookRepositoryTest.java    From micronaut-data with Apache License 2.0 5 votes vote down vote up
@BeforeAll
void setup() {
    this.context = ApplicationContext.run();
    this.bookRepository = context.getBean(BookRepository.class);
    this.bookRepository.saveAll(Arrays.asList(
            new Book("The Stand", 1000),
            new Book("The Shining", 600),
            new Book("The Power of the Dog", 500),
            new Book("The Border", 700),
            new Book("Along Came a Spider", 300),
            new Book("Pet Cemetery", 400),
            new Book("A Game of Thrones", 900),
            new Book("A Clash of Kings", 1100)
    ));
}
 
Example 7
Source File: BookRepositoryTest.java    From micronaut-data with Apache License 2.0 5 votes vote down vote up
@BeforeAll
void setup() {
    this.context = ApplicationContext.run();
    this.bookRepository = context.getBean(BookRepository.class);
    this.bookRepository.saveAll(Arrays.asList(
            new Book("The Stand", 1000),
            new Book("The Shining", 600),
            new Book("The Power of the Dog", 500),
            new Book("The Border", 700),
            new Book("Along Came a Spider", 300),
            new Book("Pet Cemetery", 400),
            new Book("A Game of Thrones", 900),
            new Book("A Clash of Kings", 1100)
    ));
}
 
Example 8
Source File: PlainTest.java    From micronaut-test with Apache License 2.0 4 votes vote down vote up
@Test
void testRunApplicationContext() {
    try (ApplicationContext context = ApplicationContext.run()) {
        Assert.assertTrue(true);
    }
}
 
Example 9
Source File: PricingControllerTest.java    From micronaut-microservices-poc with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setup() {
    server = ApplicationContext.run(EmbeddedServer.class);
    client = server.getApplicationContext().createBean(PricingTestClient.class, server.getURL());
}
 
Example 10
Source File: PolicySearchControllerTest.java    From micronaut-microservices-poc with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setup() {
    server = ApplicationContext.run(EmbeddedServer.class);
    client = server.getApplicationContext().createBean(PolicySearchTestClient.class, server.getURL());
}
 
Example 11
Source File: HelloControllerTest.java    From micronaut-microservices-poc with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setup() {
    server = ApplicationContext.run(EmbeddedServer.class);
    client = server.getApplicationContext().createBean(HelloTestClient.class, server.getURL());
}
 
Example 12
Source File: PolicyControllerTest.java    From micronaut-microservices-poc with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setup() {
    server = ApplicationContext.run(EmbeddedServer.class);
    client = server.getApplicationContext().createBean(PolicyTestClient.class, server.getURL());
}
 
Example 13
Source File: ConcreteGreetingClientUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
@Before
public void setup()
{
   server = ApplicationContext.run(EmbeddedServer.class);
   client = server.getApplicationContext().getBean(ConcreteGreetingClient.class);
}
 
Example 14
Source File: GreetingClientUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
@Before
public void setup()
{
    server = ApplicationContext.run(EmbeddedServer.class);
    client = server.getApplicationContext().getBean(GreetingClient.class);
}
 
Example 15
Source File: HelloControllerTest.java    From java-docs-samples with Apache License 2.0 3 votes vote down vote up
@BeforeClass
public static void setupServer() {

  server = ApplicationContext.run(EmbeddedServer.class);

  client = server.getApplicationContext().createBean(HttpClient.class, server.getURL());
}