Change all the package names from infrautils to odlguice
[odlguice.git] / inject / inject-guice-testutils / src / test / java / org / opendaylight / odlguice / inject / guice / testutils / tests / ExamplePureGuiceTest.java
1 /*
2  * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.odlguice.inject.guice.testutils.tests;
9
10 import static org.junit.Assert.assertTrue;
11
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;
18
19 /**
20  * Example Guice Test without using Rule, just for illustration.
21  *
22  * @see ExampleGuiceRuleTest
23  *
24  * @author Michael Vorburger
25  */
26 public class ExamplePureGuiceTest {
27
28     @Test
29     public void testPostConstruct() {
30         Injector injector = Guice.createInjector(new TestModule());
31         SomeClassWithPostConstruct someClass = injector.getInstance(SomeClassWithPostConstruct.class);
32         assertTrue(someClass.isInit);
33     }
34
35     static class TestModule extends AbstractModule {
36         @Override
37         protected void configure() {
38             install(new CloseableModule());
39             install(new Jsr250Module());
40             bind(SomeClassWithPostConstruct.class).asEagerSingleton();
41         }
42     }
43 }