add UpgradeWiring & ServiceUtilsModuleTest
authorMichael Vorburger <mike@vorburger.ch>
Wed, 31 Oct 2018 19:54:57 +0000 (20:54 +0100)
committerMichael Vorburger <mike@vorburger.ch>
Wed, 1 Jul 2020 23:37:37 +0000 (01:37 +0200)
openflowplugin actually uses the UpgradeState service

Signed-off-by: Michael Vorburger <mike@vorburger.ch>
src/main/java/org/opendaylight/serviceutils/simple/ServiceUtilsWiring.java
src/main/java/org/opendaylight/serviceutils/simple/UpgradeWiring.java [new file with mode: 0644]
src/test/java/org/opendaylight/serviceutils/simple/test/ServiceUtilsModuleTest.java [new file with mode: 0644]

index 955eba0985af1388977eb178c2c4573d48a5c269..fc2f1bdd3fd685701adf93e1632edc81d1de320d 100644 (file)
@@ -13,5 +13,6 @@ public class ServiceUtilsWiring extends AbstractModule {
     @Override
     protected void configure() {
         install(new ServiceRecoveryWiring());
+        install(new UpgradeWiring());
     }
 }
diff --git a/src/main/java/org/opendaylight/serviceutils/simple/UpgradeWiring.java b/src/main/java/org/opendaylight/serviceutils/simple/UpgradeWiring.java
new file mode 100644 (file)
index 0000000..44229b4
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2018 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.serviceutils.simple;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import javax.inject.Singleton;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.simple.ConfigReader;
+import org.opendaylight.serviceutils.upgrade.UpgradeState;
+import org.opendaylight.serviceutils.upgrade.impl.UpgradeStateListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.upgrade.rev180702.UpgradeConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.upgrade.rev180702.UpgradeConfigBuilder;
+
+/**
+ * Guice Module for the Upgrades API.
+ *
+ * @author Michael Vorburger.ch
+ */
+public class UpgradeWiring extends AbstractModule {
+
+    @Override
+    protected void configure() {
+    }
+
+    @Provides
+    @Singleton UpgradeConfig getUpgradeConfig(ConfigReader configReader) {
+        return new UpgradeConfigBuilder().setUpgradeInProgress(false).build();
+    }
+
+    @Provides
+    @Singleton UpgradeState getUpgradeStateService(DataBroker dataBroker, UpgradeConfig upgradeConfig) {
+        return new UpgradeStateListener(dataBroker, upgradeConfig);
+    }
+}
diff --git a/src/test/java/org/opendaylight/serviceutils/simple/test/ServiceUtilsModuleTest.java b/src/test/java/org/opendaylight/serviceutils/simple/test/ServiceUtilsModuleTest.java
new file mode 100644 (file)
index 0000000..cb35828
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2018 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.serviceutils.simple.test;
+
+import javax.inject.Inject;
+import org.junit.Rule;
+import org.opendaylight.controller.simple.ControllerWiring;
+import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
+import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
+import org.opendaylight.infrautils.simple.testutils.AbstractSimpleDistributionTest;
+import org.opendaylight.serviceutils.simple.ServiceUtilsWiring;
+import org.opendaylight.serviceutils.upgrade.UpgradeState;
+
+/**
+ * Test the serviceutils wiring.
+ *
+ * @author Michael Vorburger.ch
+ */
+public class ServiceUtilsModuleTest extends AbstractSimpleDistributionTest {
+
+    public @Rule GuiceRule guice = new GuiceRule(ServiceUtilsWiring.class, ControllerWiring.class, AnnotationsModule.class);
+
+    @Inject UpgradeState upgradeState;
+
+}