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 javax.inject.Inject;
13 import org.junit.Rule;
14 import org.junit.Test;
15 import org.opendaylight.odlguice.inject.guice.testutils.AbstractGuiceJsr250Module;
16 import org.opendaylight.odlguice.inject.guice.testutils.GuiceRule;
19 * Example Guice Test using the {@link GuiceRule} & {@link AbstractGuiceJsr250Module}.
21 * @author Michael Vorburger
23 public class ExampleGuiceRuleTest {
24 @Rule public GuiceRule guice = new GuiceRule(TestModule.class);
26 @Inject SomeInterfaceWithPostConstruct someService;
29 public void testGuiceWithRule() {
30 assertTrue(someService.isInit());
33 public static class TestModule extends AbstractGuiceJsr250Module {
35 protected void configureBindings() {
36 bind(SomeInterfaceWithPostConstruct.class).to(SomeClassWithPostConstruct.class);