From 72231250ed81e10d66bfe70701e64fa5fe50f712 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Wed, 15 Jun 2016 23:09:44 +0200 Subject: Publish --- .../application/ApplicationNotReadyTestCase.java | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 jdisc_core/src/test/java/com/yahoo/jdisc/application/ApplicationNotReadyTestCase.java (limited to 'jdisc_core/src/test/java/com/yahoo/jdisc/application/ApplicationNotReadyTestCase.java') diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/application/ApplicationNotReadyTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/application/ApplicationNotReadyTestCase.java new file mode 100644 index 00000000000..1351e717015 --- /dev/null +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/application/ApplicationNotReadyTestCase.java @@ -0,0 +1,53 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.jdisc.application; + +import com.google.inject.Inject; +import com.google.inject.ProvisionException; +import com.yahoo.jdisc.test.TestDriver; +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + + +/** + * @author Simon Thoresen + */ +public class ApplicationNotReadyTestCase { + + @Test + public void requireThatExceptionIsThrown() { + try { + TestDriver.newInjectedApplicationInstanceWithoutOsgi(MyApplication.class); + fail(); + } catch (ProvisionException e) { + Throwable t = e.getCause(); + assertNotNull(t); + assertTrue(t instanceof ApplicationNotReadyException); + } + } + + private static class MyApplication implements Application { + + @Inject + MyApplication(ContainerActivator activator) { + activator.activateContainer(activator.newContainerBuilder()); + } + + @Override + public void start() { + + } + + @Override + public void stop() { + + } + + @Override + public void destroy() { + + } + } +} -- cgit v1.2.3