2 * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.odlguice.inject.guice.testutils.tests;
10 import static org.junit.Assert.assertTrue;
12 import com.google.inject.AbstractModule;
13 import com.google.inject.Guice;
14 import com.google.inject.Injector;
15 import org.junit.Test;
16 import org.opendaylight.odlguice.inject.guice.extensions.closeable.CloseableModule;
17 import org.opendaylight.odlguice.inject.guice.extensions.jsr250.Jsr250Module;
20 * Example Guice Test without using Rule, just for illustration.
22 * @see ExampleGuiceRuleTest
24 * @author Michael Vorburger
26 public class ExamplePureGuiceTest {
29 public void testPostConstruct() {
30 Injector injector = Guice.createInjector(new TestModule());
31 SomeClassWithPostConstruct someClass = injector.getInstance(SomeClassWithPostConstruct.class);
32 assertTrue(someClass.isInit);
35 static class TestModule extends AbstractModule {
37 protected void configure() {
38 install(new CloseableModule());
39 install(new Jsr250Module());
40 bind(SomeClassWithPostConstruct.class).asEagerSingleton();