- [ ] dependency convergence with Maven Enforcer plugin
-- [ ] add all *Wiring+++ upstream, and make the project disappear (incl GuiceRule2 etc.)
+- [ ] add all *Wiring+++ upstream, and make the project disappear
- [ ] headless distribution without shell
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.infrautils.inject;
-
-/**
- * Callback invoked when system injection is fully complete.
- *
- * @author Michael Vorburger.ch
- */
-public interface PostFullSystemInjectionListener {
-
- void onFullSystemInjected();
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.infrautils.inject.guice.testutils;
-
-import com.google.inject.ConfigurationException;
-import com.google.inject.Module;
-import org.opendaylight.infrautils.inject.PostFullSystemInjectionListener;
-
-public class GuiceRule2 extends GuiceRule {
-
- @SafeVarargs
- public GuiceRule2(Class<? extends Module>... moduleClasses) {
- super(moduleClasses);
- }
-
- public GuiceRule2(Module... modules) {
- super(modules);
- }
-
- @Override
- protected void setUpGuice(Object target) {
- super.setUpGuice(target);
- try {
- injector.getInstance(PostFullSystemInjectionListener.class).onFullSystemInjected();
- } catch (ConfigurationException e) {
- // It's OK if we didn't bind a PostFullSystemInjectionListener.
- }
- }
-}
package org.opendaylight.infrautils.simple;
import com.google.inject.AbstractModule;
+import org.opendaylight.infrautils.ready.guice.ReadyModule;
import org.opendaylight.infrautils.web.WebModule;
public class InfraUtilsModule extends AbstractModule {
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.infrautils.simple;
-
-import com.google.inject.AbstractModule;
-import org.opendaylight.infrautils.inject.PostFullSystemInjectionListener;
-import org.opendaylight.infrautils.ready.SystemReadyMonitor;
-import org.opendaylight.infrautils.ready.spi.SimpleSystemReadyMonitor;
-
-public class ReadyModule extends AbstractModule implements PostFullSystemInjectionListener {
-
- private final SimpleSystemReadyMonitor systemReadyMonitor = new SimpleSystemReadyMonitor();
-
- @Override
- protected void configure() {
- bind(SystemReadyMonitor.class).toInstance(systemReadyMonitor);
- bind(PostFullSystemInjectionListener.class).toInstance(this);
- }
-
- @Override
- public void onFullSystemInjected() {
- systemReadyMonitor.ready();
- }
-}
import org.opendaylight.aaa.simple.AAAModule;
import org.opendaylight.controller.simple.InMemoryControllerModule;
import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
-import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule2;
+import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
import org.opendaylight.infrautils.simple.testutils.AbstractSimpleDistributionTest;
@Ignore // TODO fix NullPointerException at org.opendaylight.aaa.cert.impl.DefaultMdsalSslData.createKeyStores :155
public class AAAModuleTest extends AbstractSimpleDistributionTest {
- public @Rule GuiceRule2 guice = new GuiceRule2(new AAAModule(), new InMemoryControllerModule(),
+ public @Rule GuiceRule guice = new GuiceRule(new AAAModule(), new InMemoryControllerModule(),
// TODO new WebWiring(true), new ReferencesWiring(),
new AnnotationsModule());
import org.opendaylight.aaa.simple.CertModule;
import org.opendaylight.controller.simple.InMemoryControllerModule;
import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
-import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule2;
+import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
import org.opendaylight.infrautils.simple.testutils.AbstractSimpleDistributionTest;
public class CertModuleTest extends AbstractSimpleDistributionTest {
- public @Rule GuiceRule2 guice = new GuiceRule2(
+ public @Rule GuiceRule guice = new GuiceRule(
new CertModule(), new InMemoryControllerModule(), new AnnotationsModule());
@Inject ICertificateManager certificateManager;
import org.opendaylight.aaa.simple.EncryptModule;
import org.opendaylight.controller.simple.InMemoryControllerModule;
import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
-import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule2;
+import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
import org.opendaylight.infrautils.simple.testutils.AbstractSimpleDistributionTest;
public class EncryptModuleTest extends AbstractSimpleDistributionTest {
- public @Rule GuiceRule2 guice = new GuiceRule2(
+ public @Rule GuiceRule guice = new GuiceRule(
new EncryptModule(), new InMemoryControllerModule(), new AnnotationsModule());
@Inject AAAEncryptionService encryptionService;
import org.opendaylight.controller.md.sal.binding.api.NotificationService;
import org.opendaylight.controller.simple.InMemoryControllerModule;
import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
-import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule2;
+import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
import org.opendaylight.infrautils.simple.testutils.AbstractSimpleDistributionTest;
import org.opendaylight.mdsal.simple.PingPong;
public class InMemoryControllerModuleTest extends AbstractSimpleDistributionTest {
- public @Rule GuiceRule2 guice = new GuiceRule2(InMemoryControllerModule.class, AnnotationsModule.class);
+ public @Rule GuiceRule guice = new GuiceRule(InMemoryControllerModule.class, AnnotationsModule.class);
@Inject DataBroker dataBroker;
@Inject @PingPong DataBroker pingPongDataBroker;
import org.opendaylight.genius.itm.api.IITMProvider;
import org.opendaylight.genius.simple.GeniusModule;
import org.opendaylight.infrautils.inject.guice.GuiceClassPathBinder;
-import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule2;
+import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
import org.opendaylight.infrautils.simple.ShellTestModule;
import org.opendaylight.infrautils.simple.testutils.AbstractSimpleDistributionTest;
private static final GuiceClassPathBinder CLASS_PATH_BINDER = new GuiceClassPathBinder("org.opendaylight");
- public @Rule GuiceRule2 guice = new GuiceRule2(new GeniusModule(CLASS_PATH_BINDER), new ShellTestModule());
+ public @Rule GuiceRule guice = new GuiceRule(new GeniusModule(CLASS_PATH_BINDER), new ShellTestModule());
@Inject InterfaceManagerService interfaceManagerService;
import org.junit.runners.model.Statement;
import org.opendaylight.infrautils.inject.guice.AbstractCloseableModule;
import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
-import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule2;
+import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
/**
* Test PreDestroy in Module.
@Test public void testModuleWithPreDestroy() throws Throwable {
@SuppressWarnings("resource")
TestModule testModule = new TestModule();
- new GuiceRule2(testModule, new AnnotationsModule()).apply(EMPTY_STATEMENT, null, new Object()).evaluate();
+ new GuiceRule(testModule, new AnnotationsModule()).apply(EMPTY_STATEMENT, null, new Object()).evaluate();
assertThat(testModule.isClosed).isTrue();
}
import org.junit.Rule;
import org.junit.Test;
import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
-import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule2;
+import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
/**
* Test illustrating how to use the GuiceRule with an inline lamda binding.
public class GuiceRuleLambdaTest {
@SuppressWarnings("BindingToUnqualifiedCommonType")
- public @Rule GuiceRule2 guice = new GuiceRule2(
+ public @Rule GuiceRule guice = new GuiceRule(
binder -> binder.bind(String.class).toInstance("hello, world"),
new AnnotationsModule());
import org.junit.Test;
import org.opendaylight.infrautils.diagstatus.DiagStatusService;
import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
-import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule2;
+import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
+import org.opendaylight.infrautils.ready.guice.ReadyModule;
import org.opendaylight.infrautils.simple.DiagStatusModule;
-import org.opendaylight.infrautils.simple.ReadyModule;
import org.opendaylight.infrautils.web.WebModule;
/**
*/
public class DiagStatusModuleTest {
- public @Rule GuiceRule2 guice = new GuiceRule2(WebModule.class, DiagStatusModule.class, ReadyModule.class,
+ public @Rule GuiceRule guice = new GuiceRule(WebModule.class, DiagStatusModule.class, ReadyModule.class,
AnnotationsModule.class);
@Inject DiagStatusService diagStatusService;
import org.junit.Test;
import org.opendaylight.infrautils.inject.guice.testutils.AbstractGuiceJsr250Module;
+import org.opendaylight.infrautils.ready.guice.ReadyModule;
import org.opendaylight.infrautils.simple.Main;
-import org.opendaylight.infrautils.simple.ReadyModule;
/**
* Unit test for Main.
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.infrautils.simple.test;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
-import org.junit.Rule;
-import org.junit.Test;
-import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
-import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule2;
-import org.opendaylight.infrautils.ready.SystemReadyMonitor;
-import org.opendaylight.infrautils.simple.ReadyModule;
-
-/**
- * Unit test for {@link ReadyModule}.
- *
- * @author Michael Vorburger.ch
- */
-public class ReadyModuleTest {
-
- public static class TestBean {
- private final SystemReadyMonitor systemReadyMonitor;
- boolean invokedReadyCallbackRegisteredInConstructor = false;
- boolean invokedReadyCallbackRegisteredInPostConstruct = false;
-
- @Inject public TestBean(SystemReadyMonitor systemReadyMonitor) {
- this.systemReadyMonitor = systemReadyMonitor;
- systemReadyMonitor.registerListener(() -> {
- invokedReadyCallbackRegisteredInConstructor = true;
- });
- }
-
- @PostConstruct public void init() {
- systemReadyMonitor.registerListener(() -> {
- invokedReadyCallbackRegisteredInPostConstruct = true;
- });
- }
- }
-
- public @Rule GuiceRule2 guice = new GuiceRule2(ReadyModule.class, AnnotationsModule.class);
-
- @Inject TestBean testBean;
-
- @Test public void testReadyListener() {
- assertThat(testBean.invokedReadyCallbackRegisteredInConstructor).isTrue();
- assertThat(testBean.invokedReadyCallbackRegisteredInPostConstruct).isTrue();
- }
-
-}
import org.junit.Test;
import org.opendaylight.controller.simple.InMemoryControllerModule;
import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
-import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule2;
+import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
import org.opendaylight.infrautils.simple.testutils.AbstractSimpleDistributionTest;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
public class InMemoryMdsalModuleTest extends AbstractSimpleDistributionTest {
- public @Rule GuiceRule2 guice = new GuiceRule2(InMemoryControllerModule.class, AnnotationsModule.class);
+ public @Rule GuiceRule guice = new GuiceRule(InMemoryControllerModule.class, AnnotationsModule.class);
@Inject @PingPong DataBroker pingPongDataBroker;
@Inject DataBroker dataBroker;
import org.junit.Ignore;
import org.junit.Rule;
import org.opendaylight.infrautils.inject.guice.GuiceClassPathBinder;
-import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule2;
+import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
import org.opendaylight.infrautils.simple.ShellTestModule;
import org.opendaylight.infrautils.simple.testutils.AbstractSimpleDistributionTest;
import org.opendaylight.netvirt.simple.NetvirtModule;
private static final GuiceClassPathBinder CLASS_PATH_BINDER = new GuiceClassPathBinder("org.opendaylight");
- public @Rule GuiceRule2 guice = new GuiceRule2(new NetvirtModule(CLASS_PATH_BINDER), new ShellTestModule());
+ public @Rule GuiceRule guice = new GuiceRule(new NetvirtModule(CLASS_PATH_BINDER), new ShellTestModule());
}
import org.opendaylight.aaa.web.WebServer;
import org.opendaylight.controller.simple.InMemoryControllerModule;
import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
-import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule2;
+import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
import org.opendaylight.infrautils.simple.testutils.AbstractSimpleDistributionTest;
import org.opendaylight.infrautils.testutils.TestHttpClient;
import org.opendaylight.infrautils.web.WebModule;
*/
public class NeutronModuleTest extends AbstractSimpleDistributionTest {
- public @Rule GuiceRule2 guice = new GuiceRule2(
+ public @Rule GuiceRule guice = new GuiceRule(
NeutronModule.class, InMemoryControllerModule.class, WebModule.class, AnnotationsModule.class);
@Inject WebServer webServer;
import org.opendaylight.controller.simple.InMemoryControllerModule;
import org.opendaylight.infrautils.inject.guice.GuiceClassPathBinder;
import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
-import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule2;
+import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
+import org.opendaylight.infrautils.ready.guice.ReadyModule;
import org.opendaylight.infrautils.simple.DiagStatusModule;
-import org.opendaylight.infrautils.simple.ReadyModule;
import org.opendaylight.infrautils.simple.testutils.AbstractSimpleDistributionTest;
import org.opendaylight.infrautils.web.WebModule;
import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider;
private static final GuiceClassPathBinder CLASS_PATH_BINDER = new GuiceClassPathBinder("org.opendaylight");
- public @Rule GuiceRule2 guice = new GuiceRule2(new OpenFlowPluginModule(CLASS_PATH_BINDER),
+ public @Rule GuiceRule guice = new GuiceRule(new OpenFlowPluginModule(CLASS_PATH_BINDER),
new ServiceUtilsModule(), new InMemoryControllerModule(), new DiagStatusModule(), new WebModule(),
new ReadyModule(), new AnnotationsModule());
import org.opendaylight.aaa.web.WebServer;
import org.opendaylight.controller.simple.InMemoryControllerModule;
import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
-import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule2;
+import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
import org.opendaylight.infrautils.simple.testutils.AbstractSimpleDistributionTest;
import org.opendaylight.infrautils.testutils.TestHttpClient;
import org.opendaylight.infrautils.web.WebModule;
*/
public class RestConfModuleTest extends AbstractSimpleDistributionTest {
- public @Rule GuiceRule2 guice = new GuiceRule2(
+ public @Rule GuiceRule guice = new GuiceRule(
RestConfModule.class, InMemoryControllerModule.class, WebModule.class, AnnotationsModule.class);
@Inject WebServer webServer;
import org.junit.Rule;
import org.opendaylight.controller.simple.InMemoryControllerModule;
import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
-import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule2;
+import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
import org.opendaylight.infrautils.simple.testutils.AbstractSimpleDistributionTest;
import org.opendaylight.serviceutils.simple.ServiceUtilsModule;
import org.opendaylight.serviceutils.upgrade.UpgradeState;
*/
public class ServiceUtilsModuleTest extends AbstractSimpleDistributionTest {
- public @Rule GuiceRule2 guice = new GuiceRule2(ServiceUtilsModule.class, InMemoryControllerModule.class,
+ public @Rule GuiceRule guice = new GuiceRule(ServiceUtilsModule.class, InMemoryControllerModule.class,
AnnotationsModule.class);
@Inject UpgradeState upgradeState;