You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2017/10/16 23:03:18 UTC
[2/7] incubator-tamaya-extensions git commit: TAMAYA-300 Added tests
to improver coverage.
TAMAYA-300 Added tests to improver coverage.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/a91e434e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/a91e434e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/a91e434e
Branch: refs/heads/master
Commit: a91e434ecac4cb96aba287d260741271d0e3c005
Parents: 1e8ac05
Author: Anatole Tresch <an...@apache.org>
Authored: Mon Oct 16 17:17:51 2017 +0200
Committer: Anatole Tresch <an...@apache.org>
Committed: Mon Oct 16 17:17:51 2017 +0200
----------------------------------------------------------------------
modules/osgi/gogo-shell/bnd.bnd | 34 +++++++
modules/osgi/gogo-shell/pom.xml | 71 +++++++++++++
.../org/apache/tamaya/gogo/shell/Activator.java | 92 +++++++++++++++++
.../tamaya/gogo/shell/BackupCommands.java | 78 ++++++++++++++
.../tamaya/gogo/shell/ConfigCommands.java | 89 ++++++++++++++++
.../tamaya/gogo/shell/HistoryCommands.java | 89 ++++++++++++++++
.../tamaya/gogo/shell/SettingsCommands.java | 83 +++++++++++++++
.../tamaya/gogo/shell/AbstractOSGITest.java | 101 +++++++++++++++++++
.../apache/tamaya/gogo/shell/ActivatorTest.java | 46 +++++++++
.../tamaya/gogo/shell/BackupCommandsTest.java | 71 +++++++++++++
.../tamaya/gogo/shell/ConfigCommandsTest.java | 90 +++++++++++++++++
.../tamaya/gogo/shell/HistoryCommandsTest.java | 73 ++++++++++++++
.../tamaya/gogo/shell/SettingsCommandsTest.java | 78 ++++++++++++++
13 files changed, 995 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a91e434e/modules/osgi/gogo-shell/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/osgi/gogo-shell/bnd.bnd b/modules/osgi/gogo-shell/bnd.bnd
new file mode 100644
index 0000000..67e951a
--- /dev/null
+++ b/modules/osgi/gogo-shell/bnd.bnd
@@ -0,0 +1,34 @@
+-buildpath: \
+ osgi.annotation; version=6.0.0,\
+ osgi.core; version=6.0,\
+ osgi.cmpn; version=6.0
+
+-testpath: \
+ ${junit}
+
+javac.source: 1.8
+javac.target: 1.8
+
+Bundle-Activator: org.apache.tamaya.gogo.shell.Activator
+Bundle-Version: ${version}.${tstamp}
+Bundle-Name: Apache Tamaya - Felix Shell Commands
+Bundle-SymbolicName: org.apache.tamaya.osgi.gogo.shell
+Bundle-Description: Apacha Tamaya Configuration - Gogo Shell Extensions
+Bundle-Category: Implementation
+Bundle-Copyright: (C) Apache Foundation
+Bundle-License: Apache Licence version 2
+Bundle-Vendor: Apache Software Foundation
+Bundle-ContactAddress: dev-tamaya@incubator.apache.org
+Bundle-DocURL: http://tamaya.apache.org
+Export-Package: \
+ org.apache.tamaya.gogo.shell
+Import-Package: \
+ org.osgi.service.cm,\
+ org.osgi.framework,\
+ org.apache.tamaya,\
+ org.apache.tamaya.spi,\
+ org.apache.tamaya.functions,\
+ org.apache.tamaya.spisupport,\
+ org.apache.tamaya.osgi,\
+ org.apache.tamaya.osgi.commands,\
+ org.apache.felix.service.command
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a91e434e/modules/osgi/gogo-shell/pom.xml
----------------------------------------------------------------------
diff --git a/modules/osgi/gogo-shell/pom.xml b/modules/osgi/gogo-shell/pom.xml
new file mode 100644
index 0000000..ba9fa64
--- /dev/null
+++ b/modules/osgi/gogo-shell/pom.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-osgi-all</artifactId>
+ <version>0.4-incubating-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>tamaya-osgi-gogo-shell</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Tamaya :: OSGI :: Gogo :: Shell</name>
+ <description>Tamaya Gogo Shell Commands</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-osgi</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.gogo.runtime</artifactId>
+ <version>1.0.8</version>
+ </dependency>
+
+ <!-- Testing -->
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>java-hamcrest</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a91e434e/modules/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/Activator.java
----------------------------------------------------------------------
diff --git a/modules/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/Activator.java b/modules/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/Activator.java
new file mode 100644
index 0000000..f7a2aa9
--- /dev/null
+++ b/modules/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/Activator.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.gogo.shell;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.logging.Logger;
+
+/**
+ * Activator that registers the Tamaya commands for the Felix Gogo console used
+ * in Apache Felix and Equinox.
+ */
+public class Activator implements BundleActivator {
+
+ private static final Logger LOG = Logger.getLogger(Activator.class.getName());
+
+ private ServiceRegistration<HistoryCommands> histReg;
+ private ServiceRegistration<ConfigCommands> configReg;
+ private ServiceRegistration<BackupCommands> backupReg;
+ private ServiceRegistration<SettingsCommands> settingsReg;
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ LOG.finest("Registering Tamaya commands...");
+ Dictionary<String, Object> props = new Hashtable<>();
+ props.put("osgi.command.scope", "tamaya");
+ props.put("osgi.command.function",
+ new String[] {"tm_config", "tm_property",
+ "tm_propertysource","tm_propertysources"});
+ configReg = context.registerService(
+ ConfigCommands.class,
+ new ConfigCommands(context), props);
+ props.put("osgi.command.function",
+ new String[] {"tm_history","tm_history_delete","tm_history_delete_all",
+ "tm_history_maxsize", "tm_history_maxsize_set"});
+ histReg = context.registerService(
+ HistoryCommands.class,
+ new HistoryCommands(context), props);
+ props.put("osgi.command.function",
+ new String[] {"tm_backup_create","tm_backup_delete",
+ "tm_backup","tm_backup_restore"});
+ backupReg = context.registerService(
+ BackupCommands.class,
+ new BackupCommands(context), props);
+ props.put("osgi.command.function",
+ new String[] {"tm_enable","tm_enabled", "tm_policy",
+ "tm_policy_set","tm_info", "tm_propagate_updates",
+ "tm_propagate_updates_set"});
+ settingsReg = context.registerService(
+ SettingsCommands.class,
+ new SettingsCommands(context), props);
+ LOG.info("Registered Tamaya commands.");
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ LOG.info("Unregistering Tamaya commands.");
+ if (histReg != null) {
+ histReg.unregister();
+ }
+ if (configReg != null) {
+ configReg.unregister();
+ }
+ if (backupReg != null) {
+ backupReg.unregister();
+ }
+ if (settingsReg != null) {
+ settingsReg.unregister();
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a91e434e/modules/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/BackupCommands.java
----------------------------------------------------------------------
diff --git a/modules/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/BackupCommands.java b/modules/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/BackupCommands.java
new file mode 100644
index 0000000..67c7b66
--- /dev/null
+++ b/modules/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/BackupCommands.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.gogo.shell;
+
+import org.apache.felix.service.command.Descriptor;
+import org.apache.felix.service.command.Parameter;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+import java.io.IOException;
+import java.util.Objects;
+
+public class BackupCommands {
+
+ private BundleContext context;
+
+ public BackupCommands(BundleContext context){
+ this.context = Objects.requireNonNull(context);
+ }
+
+ private <T> T getService(Class<T> type){
+ ServiceReference<T> cmRef = context.getServiceReference(type);
+ return context.getService(cmRef);
+ }
+
+
+ @Descriptor("Creates an OSGI ConfigAdmin configuration backup for a PID.")
+ public void tm_backup_create(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-p", "--pid"})
+ @Descriptor("The PID (requred)") String pid,
+ @Parameter(absentValue = Parameter.UNSPECIFIED, names={"-f", "--force"})
+ @Descriptor("If set any existing backup will be overriden, default is false.") Boolean force) throws IOException {
+ System.out.println(org.apache.tamaya.osgi.commands.BackupCommands.createBackup(
+ getService(TamayaConfigService.class),
+ getService(ConfigurationAdmin.class), pid, force));
+ }
+
+ @Descriptor("Deletes an OSGI ConfigAdmin configuration backup for a PID.")
+ public void tm_backup_delete(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-p", "--pid"})
+ @Descriptor("The target PID") String pid) throws IOException {
+ System.out.println(org.apache.tamaya.osgi.commands.BackupCommands.deleteBackup(
+ getService(TamayaConfigService.class),
+ pid));
+ }
+
+ @Descriptor("Restores an OSGI ConfigAdmin configuration backup for a PID and disabled Tamaya for the given PID.")
+ public void tm_backup_restore(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-p", "--pid"})
+ @Descriptor("The target PID") String pid) throws IOException {
+ System.out.println(org.apache.tamaya.osgi.commands.BackupCommands.restoreBackup(
+ getService(TamayaConfigService.class), pid));
+ }
+
+ @Descriptor("Shows the contents of the OSGI ConfigAdmin configuration backup for a PID.")
+ public void tm_backup_get(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-p", "--pid"})
+ @Descriptor("The PID (requred)") String pid) throws IOException {
+ System.out.println(org.apache.tamaya.osgi.commands.BackupCommands.listBackup(
+ getService(TamayaConfigService.class),
+ Objects.requireNonNull(pid)));
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a91e434e/modules/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/ConfigCommands.java
----------------------------------------------------------------------
diff --git a/modules/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/ConfigCommands.java b/modules/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/ConfigCommands.java
new file mode 100644
index 0000000..8926ede
--- /dev/null
+++ b/modules/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/ConfigCommands.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.gogo.shell;
+
+import org.apache.felix.service.command.Descriptor;
+import org.apache.felix.service.command.Parameter;
+import org.apache.tamaya.osgi.Policy;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+import java.io.IOException;
+import java.util.Objects;
+
+public class ConfigCommands {
+
+ private BundleContext context;
+
+ private <T> T getService(Class<T> type){
+ ServiceReference<T> cmRef = context.getServiceReference(type);
+ return context.getService(cmRef);
+ }
+
+ public ConfigCommands(BundleContext context){
+ this.context = Objects.requireNonNull(context);
+ }
+
+ @Descriptor("Shows the current Tamaya configuration.")
+ public void tm_config(@Parameter(absentValue = "", names={"-s", "--section"})
+ @Descriptor("The section start expression to filter.") String section,
+ @Parameter(absentValue = "", names={"-p", "--pid"})
+ @Descriptor("The pid to filter (required).") String pid) throws IOException {
+ if(pid.isEmpty()){
+ System.out.println(org.apache.tamaya.osgi.commands.ConfigCommands.readTamayaConfig(section, null));
+ }else {
+ System.out.println(org.apache.tamaya.osgi.commands.ConfigCommands.readTamayaConfig4PID(pid, section));
+ }
+ }
+
+ public void tm_apply_config(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-p", "--pid"})
+ @Descriptor("The target OSGI component PID.")
+ String pid,
+ @Parameter(absentValue = "OVERRIDE", names={"-m", "--opmode"})
+ @Descriptor("Explicitly set (override) the operation mode to use, one of: EXTEND, OVERRIDE, UPDATE_ONLY")
+ Policy policy,
+ @Parameter(absentValue = "false", names={"-d", "--dryrun"})
+ @Descriptor("If set to true no OSGI configuration gets changed.")
+ boolean dryRun){
+ System.out.println(org.apache.tamaya.osgi.commands.ConfigCommands.applyTamayaConfiguration(
+ getService(TamayaConfigService.class), pid, policy.toString(), dryRun));
+ }
+
+ @Descriptor("Gets the detailed property values.")
+ public void tm_property(@Parameter(absentValue = "", names={"-ps", "--propertysource"})
+ @Descriptor("The property source name")String propertysource,
+ @Parameter(absentValue = Parameter.UNSPECIFIED, names={"-k", "--key"})
+ @Descriptor("The property key")String key,
+ @Parameter(absentValue = "false", names={"-e", "--extended"})
+ @Descriptor("Show extended info, default=false")Boolean extended) throws IOException {
+ System.out.println(org.apache.tamaya.osgi.commands.ConfigCommands.getProperty(propertysource, key, extended.booleanValue()));
+ }
+
+ @Descriptor("Get details of a property source.")
+ public void tm_propertysource(@Parameter(absentValue = "", names={"-ps", "--propertysource"})
+ @Descriptor("The property source name, empty returns a list of possible values")String propertysource) throws IOException {
+ System.out.println(org.apache.tamaya.osgi.commands.ConfigCommands.getPropertySource(propertysource));
+ }
+
+ @Descriptor("Show details of all registered property sources.")
+ public void tm_propertysources() throws IOException {
+ System.out.println(org.apache.tamaya.osgi.commands.ConfigCommands.getPropertySourceOverview());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a91e434e/modules/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/HistoryCommands.java
----------------------------------------------------------------------
diff --git a/modules/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/HistoryCommands.java b/modules/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/HistoryCommands.java
new file mode 100644
index 0000000..906f471
--- /dev/null
+++ b/modules/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/HistoryCommands.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.gogo.shell;
+
+import org.apache.felix.service.command.Descriptor;
+import org.apache.felix.service.command.Parameter;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+import java.io.IOException;
+import java.util.Objects;
+
+public class HistoryCommands {
+
+ private BundleContext context;
+
+ private <T> T getService(Class<T> type){
+ ServiceReference<T> cmRef = context.getServiceReference(type);
+ return context.getService(cmRef);
+ }
+
+ public HistoryCommands(BundleContext context){
+ this.context = Objects.requireNonNull(context);
+ }
+
+ @Descriptor("Deletes the getHistory of configuration changes.")
+ public void tm_history_delete(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-p", "--pid"})
+ @Descriptor("The PID.") String pid) throws IOException {
+ System.out.println(org.apache.tamaya.osgi.commands.HistoryCommands.clearHistory(
+ getService(TamayaConfigService.class),
+ pid));
+ }
+
+ @Descriptor("Deletes the full getHistory of configuration changes.")
+ public void tm_history_delete_all() throws IOException {
+ System.out.println(org.apache.tamaya.osgi.commands.HistoryCommands.clearHistory(
+ getService(TamayaConfigService.class),
+ null));
+ }
+
+ @Descriptor("Read the getHistory of configuration changes.")
+ public void tm_history_get(@Parameter(absentValue = "", names={"-p", "--pid"})
+ @Descriptor("The PID.")String pid,
+ @Parameter(absentValue = "", names={"-t", "--eventtypes"})
+ @Descriptor("The comma separated Event types to filter, valid types are " +
+ "PROPERTY,BEGIN,END")String eventTypes) throws IOException {
+ if(eventTypes.isEmpty()){
+ System.out.println(org.apache.tamaya.osgi.commands.HistoryCommands.getHistory(
+ getService(TamayaConfigService.class),
+ pid, null));
+ }else {
+ System.out.println(org.apache.tamaya.osgi.commands.HistoryCommands.getHistory(
+ getService(TamayaConfigService.class),
+ pid, eventTypes.split(",")));
+ }
+ }
+
+ @Descriptor("Get the maximum configuration change getHistory size.")
+ public void tm_history_maxsize() throws IOException {
+ System.out.println(String.valueOf(org.apache.tamaya.osgi.commands.HistoryCommands.getMaxHistorySize(
+ getService(TamayaConfigService.class))));
+ }
+
+ @Descriptor("Sets the maximum configuration change getHistory size.")
+ public void tm_history_maxsize_set(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-s", "--size"})
+ @Descriptor("The maximum size of getHistory entries stored.")int maxSize) throws IOException {
+ System.out.println(org.apache.tamaya.osgi.commands.HistoryCommands.setMaxHistorySize(
+ getService(TamayaConfigService.class),
+ maxSize));
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a91e434e/modules/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/SettingsCommands.java
----------------------------------------------------------------------
diff --git a/modules/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/SettingsCommands.java b/modules/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/SettingsCommands.java
new file mode 100644
index 0000000..cf79f0a
--- /dev/null
+++ b/modules/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/SettingsCommands.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.gogo.shell;
+
+import org.apache.felix.service.command.Descriptor;
+import org.apache.felix.service.command.Parameter;
+import org.apache.tamaya.osgi.Policy;
+import org.apache.tamaya.osgi.commands.ConfigCommands;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+import java.io.IOException;
+import java.util.Objects;
+
+public class SettingsCommands {
+
+ private BundleContext context;
+
+ public SettingsCommands(BundleContext context){
+ this.context = Objects.requireNonNull(context);
+ }
+
+ private <T> T getService(Class<T> type){
+ ServiceReference<T> cmRef = context.getServiceReference(type);
+ return context.getService(cmRef);
+ }
+
+ @Descriptor("Allows to disable/enable Tamaya configuration by default.")
+ public void tm_enable(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-e", "--enable"})
+ @Descriptor("if true Tamaya is enabled by default (default=false)") boolean enabled) throws IOException {
+ System.out.println(ConfigCommands.setDefaultEnabled(getService(TamayaConfigService.class), enabled));
+ }
+
+ @Descriptor("Access if Tamaya is currently enabled by default to change OSGI configuration.")
+ public void tm_enabled(){
+ System.out.println(ConfigCommands.getDefaultEnabled(getService(TamayaConfigService.class)));
+ }
+
+ @Descriptor("Get the default Tamaya configuration policy.")
+ public void tm_policy() throws IOException {
+ System.out.println(ConfigCommands.getDefaultOpPolicy(getService(TamayaConfigService.class)));
+ }
+
+ @Descriptor("Set the default Tamaya configuration policy.")
+ public void tm_policy_set(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-p", "--policy"})
+ @Descriptor("The policy to apply (required), one of: EXTEND, OVERRIDE, UPDATE_ONLY") Policy policy) throws IOException {
+ System.out.println(ConfigCommands.setDefaultOpPolicy(getService(TamayaConfigService.class), policy.toString()));
+ }
+
+ @Descriptor("Get info about the current Tamaya configuration settings.")
+ public void tm_info() throws IOException {
+ System.out.println(ConfigCommands.getInfo(getService(TamayaConfigService.class)));
+ }
+
+ @Descriptor("Flag if Tamaya is automatically triggering OSGI config updates, when according " +
+ "Tamaya configuration changes.")
+ public void tm_propagate_updates() throws IOException {
+ System.out.println(getService(TamayaConfigService.class).isAutoUpdateEnabled());
+ }
+
+ @Descriptor("Configure if Tamaya is automatically triggering OSGI config updates, when according " +
+ "Tamaya configuration changes.")
+ public void tm_propagate_updates_set(boolean enabled) throws IOException {
+ System.out.println(ConfigCommands.setAutoUpdateEnabled(getService(TamayaConfigService.class), enabled));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a91e434e/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/AbstractOSGITest.java
----------------------------------------------------------------------
diff --git a/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/AbstractOSGITest.java b/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/AbstractOSGITest.java
new file mode 100644
index 0000000..d33e7e0
--- /dev/null
+++ b/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/AbstractOSGITest.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.gogo.shell;
+
+import org.apache.tamaya.osgi.TamayaConfigPlugin;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
+import org.junit.Before;
+import org.mockito.Mock;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.*;
+
+/**
+ * Created by atsticks on 27.09.17.
+ */
+public abstract class AbstractOSGITest {
+
+ private Map<String,Hashtable<String, Object>> properties = new ConcurrentHashMap<>();
+
+ @Mock
+ protected BundleContext bundleContext;
+
+ @Mock
+ protected ConfigurationAdmin cm;
+
+ @Mock
+ private ServiceReference<ConfigurationAdmin> cmRef;
+ @Mock
+ private ServiceReference<TamayaConfigService> tamayaRef;
+
+ @Mock
+ protected TamayaConfigService tamayaConfigPlugin;
+
+ protected Dictionary<String,Object> getProperties(String pid){
+ return this.properties.get(pid);
+ }
+
+ @Before
+ public void setup()throws Exception{
+ doAnswer(invocation -> {
+ return initConfigurationMock((String)invocation.getArguments()[0]);
+ }).when(cm).getConfiguration(any());
+ doAnswer(invocation -> {
+ return initConfigurationMock((String)invocation.getArguments()[0]);
+ }).when(cm).getConfiguration(any(), any());
+ doReturn(new Bundle[0]).when(bundleContext).getBundles();
+ doReturn(cmRef).when(bundleContext).getServiceReference(ConfigurationAdmin.class);
+ doReturn(cm).when(bundleContext).getService(cmRef);
+ doReturn(tamayaRef).when(bundleContext).getServiceReference(TamayaConfigService.class);
+// tamayaConfigPlugin = new TamayaConfigPlugin(bundleContext);
+ doReturn(tamayaConfigPlugin).when(bundleContext).getService(tamayaRef);
+ }
+
+ protected Configuration initConfigurationMock(final String pid)throws Exception{
+ Configuration config = mock(Configuration.class);
+ doAnswer(invocation -> {
+ Hashtable<String,Object> props = properties.get(pid);
+ props.clear();
+ props.putAll((Map<? extends String, ?>) invocation.getArguments()[0]);
+ return null;
+ }).when(config).update(any(Dictionary.class));
+ doAnswer(invocation -> {
+ Hashtable<String,Object> props = properties.get(pid);
+ if(props==null){
+ props = new Hashtable<>();
+ properties.put(pid, props);
+ for(Map.Entry en:System.getProperties().entrySet()){
+ props.put(en.getKey().toString(), en.getValue());
+ }
+ }
+ return new Hashtable<>(props);
+ }).when(config).getProperties();
+ return config;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a91e434e/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/ActivatorTest.java
----------------------------------------------------------------------
diff --git a/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/ActivatorTest.java b/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/ActivatorTest.java
new file mode 100644
index 0000000..03608c3
--- /dev/null
+++ b/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/ActivatorTest.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.gogo.shell;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.verify;
+
+/**
+ * Created by atsti on 30.09.2017.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class ActivatorTest extends AbstractOSGITest{
+
+ @Test
+ public void startStop() throws Exception {
+ Activator activator = new Activator();
+ activator.start(super.bundleContext);
+ verify(bundleContext).registerService(eq(BackupCommands.class), anyObject(), anyObject());
+ verify(bundleContext).registerService(eq(ConfigCommands.class), anyObject(), anyObject());
+ verify(bundleContext).registerService(eq(HistoryCommands.class), anyObject(), anyObject());
+ verify(bundleContext).registerService(eq(SettingsCommands.class), anyObject(), anyObject());
+ activator.stop(super.bundleContext);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a91e434e/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/BackupCommandsTest.java
----------------------------------------------------------------------
diff --git a/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/BackupCommandsTest.java b/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/BackupCommandsTest.java
new file mode 100644
index 0000000..8478cb1
--- /dev/null
+++ b/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/BackupCommandsTest.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.gogo.shell;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.verify;
+
+/**
+ * Created by atsti on 30.09.2017.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class BackupCommandsTest extends AbstractOSGITest{
+
+ private BackupCommands commands;
+
+ @Before
+ public void setupCommands(){
+ commands = new BackupCommands(bundleContext);
+ }
+
+
+ @Test
+ public void testBackup_Create() throws Exception {
+ commands.tm_backup_create("testBackup_Create1",false);
+ verify(tamayaConfigPlugin).createBackup("testBackup_Create1");
+ commands.tm_backup_create("testBackup_Create2",true);
+ verify(tamayaConfigPlugin).createBackup("testBackup_Create2");
+ }
+
+ @Test
+ public void testBackup_Delete() throws Exception {
+ commands.tm_backup_delete("testBackup_Delete");
+ verify(tamayaConfigPlugin).deleteBackup("testBackup_Delete");
+ }
+
+ @Test
+ public void testBackup_Get() throws Exception {
+ commands.tm_backup_get("testBackup_Get");
+ verify(tamayaConfigPlugin).getBackup("testBackup_Get");
+ }
+
+ @Test
+ public void testBackup_Restore() throws Exception {
+ commands.tm_backup_restore("testBackup_Restore");
+ verify(tamayaConfigPlugin).restoreBackup("testBackup_Restore");
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a91e434e/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/ConfigCommandsTest.java
----------------------------------------------------------------------
diff --git a/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/ConfigCommandsTest.java b/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/ConfigCommandsTest.java
new file mode 100644
index 0000000..5926029
--- /dev/null
+++ b/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/ConfigCommandsTest.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.gogo.shell;
+
+import org.apache.tamaya.osgi.Policy;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+
+/**
+ * Created by atsti on 30.09.2017.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class ConfigCommandsTest extends AbstractOSGITest{
+
+ private ConfigCommands commands;
+
+ @Before
+ public void setupCommands(){
+ commands = new ConfigCommands(bundleContext);
+ }
+
+
+ @Test
+ public void testPropertySources() throws Exception {
+ commands.tm_propertysources();
+ }
+
+ @Test
+ public void testProperty_Default() throws Exception {
+ commands.tm_property("system-properties", "java.version", false);
+ }
+
+ @Test
+ public void testProperty_Extended() throws Exception {
+ commands.tm_property("system-properties", "java.version", true);
+ }
+
+ @Test
+ public void testPropertsource() throws Exception {
+ commands.tm_propertysource("system-properties");
+ }
+
+ @Test
+ public void testConfig() throws Exception {
+ Dictionary<String,Object> testConfig = new Hashtable<>();
+ testConfig.put("test","testVal");
+ doReturn(testConfig).when(tamayaConfigPlugin).getOSGIConfiguration(any(),any());
+ commands.tm_config(null,"testConfig");
+ commands.tm_config("java","testConfig");
+ }
+
+ @Test
+ public void testApplyConfig() throws Exception {
+ Dictionary<String,Object> testConfig = new Hashtable<>();
+ testConfig.put("test","testVal");
+ doReturn(testConfig).when(tamayaConfigPlugin).updateConfig(any(),any(), anyBoolean(), anyBoolean());
+ commands.tm_apply_config("testApplyConfig", Policy.EXTEND, true);
+ verify(tamayaConfigPlugin).updateConfig("testApplyConfig", Policy.EXTEND, true, true);
+ commands.tm_apply_config("testApplyConfig", Policy.OVERRIDE, false);
+ verify(tamayaConfigPlugin).updateConfig("testApplyConfig", Policy.OVERRIDE, true, false);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a91e434e/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/HistoryCommandsTest.java
----------------------------------------------------------------------
diff --git a/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/HistoryCommandsTest.java b/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/HistoryCommandsTest.java
new file mode 100644
index 0000000..1d129a0
--- /dev/null
+++ b/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/HistoryCommandsTest.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.gogo.shell;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import static org.mockito.Mockito.verify;
+
+/**
+ * Created by atsti on 30.09.2017.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class HistoryCommandsTest extends AbstractOSGITest{
+
+ private HistoryCommands commands;
+
+ @Before
+ public void setupCommands(){
+ commands = new HistoryCommands(bundleContext);
+ }
+
+
+ @Test
+ public void testDeleteHistory() throws Exception {
+ commands.tm_history_delete("testDeleteHistory");
+ verify(tamayaConfigPlugin).clearHistory("testDeleteHistory");
+ }
+
+ @Test
+ public void testDeleteHistory_All() throws Exception {
+ commands.tm_history_delete_all();
+ verify(tamayaConfigPlugin).clearHistory();
+ }
+
+ @Test
+ public void testHisatory_Get() throws Exception {
+ commands.tm_history_get("testHisatory_Get", "");
+ verify(tamayaConfigPlugin).getHistory("testHisatory_Get");
+ }
+
+ @Test
+ public void testHistoryMaxSize() throws Exception {
+ commands.tm_history_maxsize();
+ verify(tamayaConfigPlugin).getMaxHistorySize();
+ }
+
+ @Test
+ public void testHistoryMaxSizeSet() throws Exception {
+ commands.tm_history_maxsize_set(30);
+ verify(tamayaConfigPlugin).setMaxHistorySize(30);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a91e434e/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/SettingsCommandsTest.java
----------------------------------------------------------------------
diff --git a/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/SettingsCommandsTest.java b/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/SettingsCommandsTest.java
new file mode 100644
index 0000000..fa4e3aa
--- /dev/null
+++ b/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/SettingsCommandsTest.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.gogo.shell;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import static org.mockito.Mockito.verify;
+
+/**
+ * Created by atsti on 30.09.2017.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class SettingsCommandsTest extends AbstractOSGITest{
+
+ private SettingsCommands commands;
+
+ @Before
+ public void setupCommands(){
+ commands = new SettingsCommands(bundleContext);
+ }
+
+
+ @Test
+ public void testEnable() throws Exception {
+ commands.tm_enable(true);
+ verify(tamayaConfigPlugin).setTamayaEnabledByDefault(true);
+ commands.tm_enable(false);
+ verify(tamayaConfigPlugin).setTamayaEnabledByDefault(false);
+ }
+
+ @Test
+ public void testEnabled() throws Exception {
+ commands.tm_enabled();
+ verify(tamayaConfigPlugin).isTamayaEnabledByDefault();
+ }
+
+ @Test
+ public void testInfo() throws Exception {
+ commands.tm_info();
+ verify(tamayaConfigPlugin).isTamayaEnabledByDefault();
+ verify(tamayaConfigPlugin).getDefaultPolicy();
+ }
+
+ @Test
+ public void testPropagateUpdates() throws Exception {
+ commands.tm_propagate_updates();
+ verify(tamayaConfigPlugin).isAutoUpdateEnabled();
+ }
+
+ @Test
+ public void testPropagateUpdatesSet() throws Exception {
+ commands.tm_propagate_updates_set(true);
+ verify(tamayaConfigPlugin).setAutoUpdateEnabled(true);
+ commands.tm_propagate_updates_set(false);
+ verify(tamayaConfigPlugin).setAutoUpdateEnabled(false);
+ }
+
+}
\ No newline at end of file