# HG changeset patch # User Severin Gehwolf # Date 1358359139 -3600 # Node ID 186115da601f88f72392cd24df2e97ffeb6b3398 # Parent 4290490a2e056f1d807bb6add86e96a3e3e19f92 Make common-core not depend on storage-core. Reviewed-by: vanaltj, omajid, ebaron Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2013-January/005042.html diff -r 4290490a2e05 -r 186115da601f agent/cli/pom.xml --- a/agent/cli/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/agent/cli/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -90,6 +90,17 @@ org.osgi org.osgi.core + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + + + com.redhat.thermostat + thermostat-storage-core + ${project.version} + diff -r 4290490a2e05 -r 186115da601f agent/cli/src/main/java/com/redhat/thermostat/agent/cli/impl/AgentApplication.java --- a/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/impl/AgentApplication.java Fri Jan 25 16:33:19 2013 -0500 +++ b/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/impl/AgentApplication.java Wed Jan 16 18:58:59 2013 +0100 @@ -53,21 +53,21 @@ import com.redhat.thermostat.agent.config.AgentStartupConfiguration; import com.redhat.thermostat.backend.BackendRegistry; import com.redhat.thermostat.backend.BackendService; +import com.redhat.thermostat.common.cli.BasicCommand; import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.LaunchException; import com.redhat.thermostat.common.cli.Arguments; import com.redhat.thermostat.common.cli.CommandContext; import com.redhat.thermostat.common.cli.CommandException; import com.redhat.thermostat.common.config.InvalidConfigurationException; -import com.redhat.thermostat.common.dao.DAOFactory; -import com.redhat.thermostat.common.dao.DAOFactoryImpl; -import com.redhat.thermostat.common.tools.BasicCommand; import com.redhat.thermostat.common.utils.LoggingUtils; import com.redhat.thermostat.storage.core.Connection; import com.redhat.thermostat.storage.core.StorageProvider; import com.redhat.thermostat.storage.core.StorageProviderUtil; import com.redhat.thermostat.storage.core.Connection.ConnectionListener; import com.redhat.thermostat.storage.core.Connection.ConnectionStatus; +import com.redhat.thermostat.storage.dao.DAOFactory; +import com.redhat.thermostat.storage.dao.DAOFactoryImpl; @SuppressWarnings("restriction") public final class AgentApplication extends BasicCommand { @@ -95,11 +95,6 @@ parser = new AgentOptionParser(configuration, args); parser.parse(); } - - @Override - public AgentStartupConfiguration getConfiguration() { - return configuration; - } private void runAgent(CommandContext ctx) { long startTime = System.currentTimeMillis(); diff -r 4290490a2e05 -r 186115da601f agent/cli/src/main/java/com/redhat/thermostat/agent/cli/impl/ServiceCommand.java --- a/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/impl/ServiceCommand.java Fri Jan 25 16:33:19 2013 -0500 +++ b/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/impl/ServiceCommand.java Wed Jan 16 18:58:59 2013 +0100 @@ -45,13 +45,13 @@ import com.redhat.thermostat.agent.cli.impl.locale.LocaleResources; import com.redhat.thermostat.common.ActionEvent; import com.redhat.thermostat.common.ActionListener; +import com.redhat.thermostat.common.Launcher; import com.redhat.thermostat.common.cli.CommandContext; import com.redhat.thermostat.common.cli.CommandException; import com.redhat.thermostat.common.cli.SimpleCommand; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.common.tools.ApplicationState; import com.redhat.thermostat.common.utils.OSGIUtils; -import com.redhat.thermostat.launcher.Launcher; /** * Simple service that allows starting Agent and DB Backend diff -r 4290490a2e05 -r 186115da601f agent/cli/src/main/java/com/redhat/thermostat/agent/cli/impl/db/StorageCommand.java --- a/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/impl/db/StorageCommand.java Fri Jan 25 16:33:19 2013 -0500 +++ b/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/impl/db/StorageCommand.java Wed Jan 16 18:58:59 2013 +0100 @@ -39,6 +39,7 @@ import java.io.File; import java.io.IOException; +import com.redhat.thermostat.common.cli.BasicCommand; import com.redhat.thermostat.common.cli.Arguments; import com.redhat.thermostat.common.cli.CommandContext; import com.redhat.thermostat.common.cli.CommandException; @@ -46,7 +47,6 @@ import com.redhat.thermostat.common.config.InvalidConfigurationException; import com.redhat.thermostat.common.tools.ApplicationException; import com.redhat.thermostat.common.tools.ApplicationState; -import com.redhat.thermostat.common.tools.BasicCommand; public class StorageCommand extends BasicCommand { @@ -137,7 +137,6 @@ } } - @Override public DBStartupConfiguration getConfiguration() { return configuration; } diff -r 4290490a2e05 -r 186115da601f agent/cli/src/test/java/com/redhat/thermostat/agent/cli/impl/ActivatorTest.java --- a/agent/cli/src/test/java/com/redhat/thermostat/agent/cli/impl/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/agent/cli/src/test/java/com/redhat/thermostat/agent/cli/impl/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -43,7 +43,7 @@ import com.redhat.thermostat.agent.cli.impl.db.StorageCommand; import com.redhat.thermostat.common.cli.Command; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f agent/cli/src/test/java/com/redhat/thermostat/agent/cli/impl/AgentApplicationTest.java --- a/agent/cli/src/test/java/com/redhat/thermostat/agent/cli/impl/AgentApplicationTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/agent/cli/src/test/java/com/redhat/thermostat/agent/cli/impl/AgentApplicationTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -58,11 +58,11 @@ import com.redhat.thermostat.common.cli.CommandContext; import com.redhat.thermostat.common.cli.CommandException; import com.redhat.thermostat.common.config.InvalidConfigurationException; -import com.redhat.thermostat.common.dao.DAOFactory; import com.redhat.thermostat.storage.core.Connection; import com.redhat.thermostat.storage.core.Connection.ConnectionListener; import com.redhat.thermostat.storage.core.Connection.ConnectionStatus; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.storage.dao.DAOFactory; +import com.redhat.thermostat.testutils.StubBundleContext; public class AgentApplicationTest { diff -r 4290490a2e05 -r 186115da601f agent/command/pom.xml --- a/agent/command/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/agent/command/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -92,6 +92,12 @@ ${project.version} + + com.redhat.thermostat + thermostat-storage-core + ${project.version} + + diff -r 4290490a2e05 -r 186115da601f agent/core/pom.xml --- a/agent/core/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/agent/core/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -72,6 +72,17 @@ ${project.version} + com.redhat.thermostat + thermostat-storage-core + ${project.version} + + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + + org.osgi org.osgi.core diff -r 4290490a2e05 -r 186115da601f agent/core/src/main/java/com/redhat/thermostat/agent/Agent.java --- a/agent/core/src/main/java/com/redhat/thermostat/agent/Agent.java Fri Jan 25 16:33:19 2013 -0500 +++ b/agent/core/src/main/java/com/redhat/thermostat/agent/Agent.java Wed Jan 16 18:58:59 2013 +0100 @@ -49,11 +49,11 @@ import com.redhat.thermostat.common.ActionListener; import com.redhat.thermostat.common.LaunchException; import com.redhat.thermostat.common.ThermostatExtensionRegistry; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.BackendInfoDAO; -import com.redhat.thermostat.common.dao.DAOFactory; import com.redhat.thermostat.common.utils.LoggingUtils; import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; +import com.redhat.thermostat.storage.dao.BackendInfoDAO; +import com.redhat.thermostat.storage.dao.DAOFactory; import com.redhat.thermostat.storage.model.AgentInformation; import com.redhat.thermostat.storage.model.BackendInformation; diff -r 4290490a2e05 -r 186115da601f agent/core/src/main/java/com/redhat/thermostat/backend/Backend.java --- a/agent/core/src/main/java/com/redhat/thermostat/backend/Backend.java Fri Jan 25 16:33:19 2013 -0500 +++ b/agent/core/src/main/java/com/redhat/thermostat/backend/Backend.java Wed Jan 16 18:58:59 2013 +0100 @@ -43,8 +43,8 @@ import com.redhat.thermostat.annotations.ExtensionPoint; import com.redhat.thermostat.common.LaunchException; import com.redhat.thermostat.common.Ordered; -import com.redhat.thermostat.common.dao.DAOFactory; import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.dao.DAOFactory; /** * Represents a plugin that runs on the agent and performs monitoring of host diff -r 4290490a2e05 -r 186115da601f agent/core/src/main/java/com/redhat/thermostat/utils/management/MXBeanConnector.java --- a/agent/core/src/main/java/com/redhat/thermostat/utils/management/MXBeanConnector.java Fri Jan 25 16:33:19 2013 -0500 +++ b/agent/core/src/main/java/com/redhat/thermostat/utils/management/MXBeanConnector.java Wed Jan 16 18:58:59 2013 +0100 @@ -46,7 +46,7 @@ import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; import com.sun.tools.attach.VirtualMachine; public class MXBeanConnector implements Closeable { diff -r 4290490a2e05 -r 186115da601f agent/core/src/test/java/com/redhat/thermostat/agent/AgentTest.java --- a/agent/core/src/test/java/com/redhat/thermostat/agent/AgentTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/agent/core/src/test/java/com/redhat/thermostat/agent/AgentTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -63,10 +63,10 @@ import com.redhat.thermostat.common.ActionEvent; import com.redhat.thermostat.common.ActionListener; import com.redhat.thermostat.common.ThermostatExtensionRegistry; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.BackendInfoDAO; -import com.redhat.thermostat.common.dao.DAOFactory; import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; +import com.redhat.thermostat.storage.dao.BackendInfoDAO; +import com.redhat.thermostat.storage.dao.DAOFactory; import com.redhat.thermostat.storage.model.AgentInformation; import com.redhat.thermostat.storage.model.BackendInformation; diff -r 4290490a2e05 -r 186115da601f agent/core/src/test/java/com/redhat/thermostat/agent/VmStatusListenerRegistrarTest.java --- a/agent/core/src/test/java/com/redhat/thermostat/agent/VmStatusListenerRegistrarTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/agent/core/src/test/java/com/redhat/thermostat/agent/VmStatusListenerRegistrarTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -45,7 +45,7 @@ import com.redhat.thermostat.agent.VmStatusListener; import com.redhat.thermostat.agent.VmStatusListenerRegistrar; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; public class VmStatusListenerRegistrarTest { diff -r 4290490a2e05 -r 186115da601f client/cli/pom.xml --- a/client/cli/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/client/cli/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -82,7 +82,7 @@ com.redhat.thermostat - thermostat-launcher + thermostat-storage-core ${project.version} @@ -91,12 +91,6 @@ ${project.version} - com.redhat.thermostat - thermostat-common-test - ${project.version} - test - - org.osgi org.osgi.core provided @@ -106,6 +100,12 @@ org.osgi.compendium provided + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f client/cli/src/main/java/com/redhat/thermostat/client/cli/HostVMArguments.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/cli/src/main/java/com/redhat/thermostat/client/cli/HostVMArguments.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,93 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.client.cli; + +import com.redhat.thermostat.common.cli.Arguments; +import com.redhat.thermostat.common.cli.CommandException; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; + +public class HostVMArguments { + + static final String HOST_ID_ARGUMENT = "hostId"; + static final String VM_ID_ARGUMENT = "vmId"; + + private HostRef host; + private VmRef vm; + + public HostVMArguments(Arguments args) throws CommandException { + this(args, true, true); + } + + public HostVMArguments(Arguments args, boolean hostRequired, boolean vmRequired) throws CommandException { + String hostId = args.getArgument(HOST_ID_ARGUMENT); + String vmId = args.getArgument(VM_ID_ARGUMENT); + if (hostRequired && hostId == null) { + throw new CommandException("a " + HOST_ID_ARGUMENT + " is required"); + } else if (hostId == null) { + host = null; + } else { + host = new HostRef(hostId, "dummy"); + } + try { + int parsedVmId = parseVmId(vmId); + vm = new VmRef(host, parsedVmId, "dummy"); + } catch (CommandException ce) { + if (vmRequired) { + throw ce; + } + vm = null; + } + } + + private int parseVmId(String vmId) throws CommandException { + try { + return Integer.parseInt(vmId); + } catch (NumberFormatException ex) { + throw new CommandException("Invalid VM ID: " + vmId, ex); + } + } + + public HostRef getHost() { + return host; + } + + public VmRef getVM() { + return vm; + } +} + diff -r 4290490a2e05 -r 186115da601f client/cli/src/main/java/com/redhat/thermostat/client/cli/VMStatPrintDelegate.java --- a/client/cli/src/main/java/com/redhat/thermostat/client/cli/VMStatPrintDelegate.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/cli/src/main/java/com/redhat/thermostat/client/cli/VMStatPrintDelegate.java Wed Jan 16 18:58:59 2013 +0100 @@ -39,7 +39,7 @@ import java.util.List; import com.redhat.thermostat.common.Ordered; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.model.TimeStampedPojo; /** diff -r 4290490a2e05 -r 186115da601f client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/ConnectCommand.java --- a/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/ConnectCommand.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/ConnectCommand.java Wed Jan 16 18:58:59 2013 +0100 @@ -36,8 +36,6 @@ package com.redhat.thermostat.client.cli.internal; -import com.redhat.thermostat.common.DbService; -import com.redhat.thermostat.common.DbServiceFactory; import com.redhat.thermostat.common.cli.CommandContext; import com.redhat.thermostat.common.cli.CommandException; import com.redhat.thermostat.common.cli.SimpleCommand; @@ -45,6 +43,8 @@ import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.storage.core.ConnectionException; +import com.redhat.thermostat.storage.core.DbService; +import com.redhat.thermostat.storage.core.DbServiceFactory; import com.redhat.thermostat.storage.core.StorageException; import com.redhat.thermostat.utils.keyring.Keyring; diff -r 4290490a2e05 -r 186115da601f client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/DisconnectCommand.java --- a/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/DisconnectCommand.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/DisconnectCommand.java Wed Jan 16 18:58:59 2013 +0100 @@ -38,13 +38,13 @@ import org.apache.commons.cli.Options; -import com.redhat.thermostat.common.DbService; import com.redhat.thermostat.common.cli.CommandContext; import com.redhat.thermostat.common.cli.CommandException; import com.redhat.thermostat.common.cli.SimpleCommand; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.storage.core.ConnectionException; +import com.redhat.thermostat.storage.core.DbService; public class DisconnectCommand extends SimpleCommand { diff -r 4290490a2e05 -r 186115da601f client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/ListVMsCommand.java --- a/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/ListVMsCommand.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/ListVMsCommand.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,12 +41,12 @@ import com.redhat.thermostat.common.cli.CommandContext; import com.redhat.thermostat.common.cli.CommandException; import com.redhat.thermostat.common.cli.SimpleCommand; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.storage.model.VmInfo; public class ListVMsCommand extends SimpleCommand { diff -r 4290490a2e05 -r 186115da601f client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/ShellCommand.java --- a/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/ShellCommand.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/ShellCommand.java Wed Jan 16 18:58:59 2013 +0100 @@ -52,6 +52,7 @@ import org.osgi.framework.FrameworkUtil; import org.osgi.framework.ServiceReference; +import com.redhat.thermostat.common.Launcher; import com.redhat.thermostat.common.cli.CommandContext; import com.redhat.thermostat.common.cli.CommandException; import com.redhat.thermostat.common.cli.Console; @@ -59,7 +60,6 @@ import com.redhat.thermostat.common.config.Configuration; import com.redhat.thermostat.common.config.InvalidConfigurationException; import com.redhat.thermostat.common.utils.LoggingUtils; -import com.redhat.thermostat.launcher.Launcher; public class ShellCommand extends SimpleCommand { diff -r 4290490a2e05 -r 186115da601f client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/VMInfoCommand.java --- a/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/VMInfoCommand.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/VMInfoCommand.java Wed Jan 16 18:58:59 2013 +0100 @@ -40,17 +40,17 @@ import java.util.Collection; import java.util.Date; +import com.redhat.thermostat.client.cli.HostVMArguments; import com.redhat.thermostat.common.cli.CommandContext; import com.redhat.thermostat.common.cli.CommandException; -import com.redhat.thermostat.common.cli.HostVMArguments; import com.redhat.thermostat.common.cli.SimpleCommand; import com.redhat.thermostat.common.cli.TableRenderer; -import com.redhat.thermostat.common.dao.DAOException; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.DAOException; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.storage.model.VmInfo; public class VMInfoCommand extends SimpleCommand { diff -r 4290490a2e05 -r 186115da601f client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/VMListFormatter.java --- a/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/VMListFormatter.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/VMListFormatter.java Wed Jan 16 18:58:59 2013 +0100 @@ -39,8 +39,8 @@ import java.io.PrintStream; import com.redhat.thermostat.common.cli.TableRenderer; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.locale.Translate; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.model.VmInfo; class VMListFormatter { diff -r 4290490a2e05 -r 186115da601f client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/VMStatCommand.java --- a/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/VMStatCommand.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/VMStatCommand.java Wed Jan 16 18:58:59 2013 +0100 @@ -38,7 +38,6 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; @@ -51,16 +50,15 @@ import org.osgi.framework.ServiceReference; import org.osgi.util.tracker.ServiceTracker; +import com.redhat.thermostat.client.cli.HostVMArguments; import com.redhat.thermostat.client.cli.VMStatPrintDelegate; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.OrderedComparator; import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.cli.CommandContext; import com.redhat.thermostat.common.cli.CommandException; -import com.redhat.thermostat.common.cli.HostVMArguments; import com.redhat.thermostat.common.cli.SimpleCommand; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.LoggingUtils; +import com.redhat.thermostat.storage.core.VmRef; public class VMStatCommand extends SimpleCommand { diff -r 4290490a2e05 -r 186115da601f client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/VMStatPrinter.java --- a/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/VMStatPrinter.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/VMStatPrinter.java Wed Jan 16 18:58:59 2013 +0100 @@ -51,8 +51,8 @@ import com.redhat.thermostat.client.cli.VMStatPrintDelegate; import com.redhat.thermostat.common.OrderedComparator; import com.redhat.thermostat.common.cli.TableRenderer; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.locale.Translate; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.model.TimeStampedPojo; import com.redhat.thermostat.storage.model.TimeStampedPojoComparator; import com.redhat.thermostat.storage.model.TimeStampedPojoCorrelator; diff -r 4290490a2e05 -r 186115da601f client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/ActivatorTest.java --- a/client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -51,7 +51,7 @@ import org.powermock.modules.junit4.PowerMockRunner; import com.redhat.thermostat.common.cli.Command; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; @RunWith(PowerMockRunner.class) @PrepareForTest(FrameworkUtil.class) diff -r 4290490a2e05 -r 186115da601f client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/ConnectCommandTest.java --- a/client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/ConnectCommandTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/ConnectCommandTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -55,13 +55,13 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import com.redhat.thermostat.common.DbService; -import com.redhat.thermostat.common.DbServiceFactory; import com.redhat.thermostat.common.cli.CommandContext; import com.redhat.thermostat.common.cli.CommandException; import com.redhat.thermostat.common.cli.SimpleArguments; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.DbService; +import com.redhat.thermostat.storage.core.DbServiceFactory; import com.redhat.thermostat.test.TestCommandContextFactory; @RunWith(PowerMockRunner.class) diff -r 4290490a2e05 -r 186115da601f client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/DisconnectCommandTest.java --- a/client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/DisconnectCommandTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/DisconnectCommandTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -57,12 +57,12 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import com.redhat.thermostat.common.DbService; import com.redhat.thermostat.common.cli.CommandContext; import com.redhat.thermostat.common.cli.CommandException; import com.redhat.thermostat.common.cli.SimpleArguments; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.DbService; import com.redhat.thermostat.test.TestCommandContextFactory; @RunWith(PowerMockRunner.class) diff -r 4290490a2e05 -r 186115da601f client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/ListVMsCommandTest.java --- a/client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/ListVMsCommandTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/ListVMsCommandTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -53,11 +53,11 @@ import com.redhat.thermostat.common.cli.CommandContext; import com.redhat.thermostat.common.cli.CommandException; import com.redhat.thermostat.common.cli.SimpleArguments; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.storage.model.VmInfo; import com.redhat.thermostat.test.TestCommandContextFactory; diff -r 4290490a2e05 -r 186115da601f client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/LocaleResourcesTest.java --- a/client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/LocaleResourcesTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/LocaleResourcesTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -36,7 +36,7 @@ package com.redhat.thermostat.client.cli.internal; -import com.redhat.thermostat.test.locale.AbstractLocaleResourcesTest; +import com.redhat.thermostat.testutils.AbstractLocaleResourcesTest; public class LocaleResourcesTest extends AbstractLocaleResourcesTest { diff -r 4290490a2e05 -r 186115da601f client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/ShellCommandTest.java --- a/client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/ShellCommandTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/ShellCommandTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -59,11 +59,11 @@ import org.osgi.framework.ServiceReference; import com.redhat.thermostat.client.cli.internal.ShellCommand.HistoryProvider; +import com.redhat.thermostat.common.Launcher; import com.redhat.thermostat.common.cli.Arguments; import com.redhat.thermostat.common.cli.CommandContext; import com.redhat.thermostat.common.cli.CommandException; import com.redhat.thermostat.common.cli.SimpleArguments; -import com.redhat.thermostat.launcher.Launcher; import com.redhat.thermostat.test.TestCommandContextFactory; public class ShellCommandTest { diff -r 4290490a2e05 -r 186115da601f client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/VMInfoCommandTest.java --- a/client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/VMInfoCommandTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/VMInfoCommandTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -58,11 +58,11 @@ import com.redhat.thermostat.common.cli.CommandException; import com.redhat.thermostat.common.cli.SimpleArguments; -import com.redhat.thermostat.common.dao.DAOException; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.DAOException; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.storage.model.VmInfo; import com.redhat.thermostat.test.Bug; import com.redhat.thermostat.test.TestCommandContextFactory; diff -r 4290490a2e05 -r 186115da601f client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/VmStatCommandTest.java --- a/client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/VmStatCommandTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/VmStatCommandTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -68,9 +68,15 @@ import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.cli.CommandException; import com.redhat.thermostat.common.cli.SimpleArguments; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.storage.model.TimeStampedPojo; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; +import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.model.VmCpuStat; +import com.redhat.thermostat.storage.model.VmMemoryStat; +import com.redhat.thermostat.storage.model.VmMemoryStat.Generation; +import com.redhat.thermostat.storage.model.VmMemoryStat.Space; import com.redhat.thermostat.test.TestCommandContextFactory; import com.redhat.thermostat.test.TestTimerFactory; diff -r 4290490a2e05 -r 186115da601f client/command/pom.xml --- a/client/command/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/client/command/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -93,6 +93,11 @@ com.redhat.thermostat + thermostat-storage-core + ${project.version} + + + com.redhat.thermostat thermostat-common-command ${project.version} diff -r 4290490a2e05 -r 186115da601f client/command/src/main/java/com/redhat/thermostat/client/command/cli/PingCommand.java --- a/client/command/src/main/java/com/redhat/thermostat/client/command/cli/PingCommand.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/command/src/main/java/com/redhat/thermostat/client/command/cli/PingCommand.java Wed Jan 16 18:58:59 2013 +0100 @@ -51,11 +51,11 @@ import com.redhat.thermostat.common.command.Request.RequestType; import com.redhat.thermostat.common.command.RequestResponseListener; import com.redhat.thermostat.common.command.Response; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; +import com.redhat.thermostat.storage.dao.HostInfoDAO; public class PingCommand extends SimpleCommand { diff -r 4290490a2e05 -r 186115da601f client/command/src/test/java/com/redhat/thermostat/client/command/cli/PingCommandTest.java --- a/client/command/src/test/java/com/redhat/thermostat/client/command/cli/PingCommandTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/command/src/test/java/com/redhat/thermostat/client/command/cli/PingCommandTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -47,9 +47,9 @@ import com.redhat.thermostat.common.cli.CommandException; import com.redhat.thermostat.common.cli.SimpleArguments; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.dao.HostInfoDAO; import com.redhat.thermostat.test.TestCommandContextFactory; public class PingCommandTest { diff -r 4290490a2e05 -r 186115da601f client/core/pom.xml --- a/client/core/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/client/core/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -85,6 +85,12 @@ + com.redhat.thermostat + thermostat-storage-core + ${project.version} + + + org.jfree jfreechart diff -r 4290490a2e05 -r 186115da601f client/core/src/main/java/com/redhat/thermostat/client/core/InformationService.java --- a/client/core/src/main/java/com/redhat/thermostat/client/core/InformationService.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/core/InformationService.java Wed Jan 16 18:58:59 2013 +0100 @@ -39,7 +39,7 @@ import com.redhat.thermostat.annotations.ExtensionPoint; import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.Ordered; -import com.redhat.thermostat.common.dao.Ref; +import com.redhat.thermostat.storage.core.Ref; /** diff -r 4290490a2e05 -r 186115da601f client/core/src/main/java/com/redhat/thermostat/client/core/NameMatchingRefFilter.java --- a/client/core/src/main/java/com/redhat/thermostat/client/core/NameMatchingRefFilter.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/core/NameMatchingRefFilter.java Wed Jan 16 18:58:59 2013 +0100 @@ -38,7 +38,7 @@ import java.util.Objects; -import com.redhat.thermostat.common.dao.Ref; +import com.redhat.thermostat.storage.core.Ref; /** * A {@link Filter} that checks if the name of a {@link Ref} contains diff -r 4290490a2e05 -r 186115da601f client/core/src/main/java/com/redhat/thermostat/client/core/controllers/InformationServiceController.java --- a/client/core/src/main/java/com/redhat/thermostat/client/core/controllers/InformationServiceController.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/core/controllers/InformationServiceController.java Wed Jan 16 18:58:59 2013 +0100 @@ -37,7 +37,7 @@ package com.redhat.thermostat.client.core.controllers; import com.redhat.thermostat.client.core.views.UIComponent; -import com.redhat.thermostat.common.dao.Ref; +import com.redhat.thermostat.storage.core.Ref; /** * The UI controller for a view that provides some information about a Host or a VM. diff -r 4290490a2e05 -r 186115da601f client/core/src/main/java/com/redhat/thermostat/client/osgi/service/DecoratorProvider.java --- a/client/core/src/main/java/com/redhat/thermostat/client/osgi/service/DecoratorProvider.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/osgi/service/DecoratorProvider.java Wed Jan 16 18:58:59 2013 +0100 @@ -38,7 +38,7 @@ import com.redhat.thermostat.client.core.Filter; import com.redhat.thermostat.client.ui.Decorator; -import com.redhat.thermostat.common.dao.Ref; +import com.redhat.thermostat.storage.core.Ref; /** * This interface allows plugins to install a custom {@link Decorator} into diff -r 4290490a2e05 -r 186115da601f client/core/src/main/java/com/redhat/thermostat/client/osgi/service/HostContextAction.java --- a/client/core/src/main/java/com/redhat/thermostat/client/osgi/service/HostContextAction.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/osgi/service/HostContextAction.java Wed Jan 16 18:58:59 2013 +0100 @@ -38,7 +38,7 @@ import com.redhat.thermostat.annotations.ExtensionPoint; import com.redhat.thermostat.client.core.Filter; -import com.redhat.thermostat.common.dao.HostRef; +import com.redhat.thermostat.storage.core.HostRef; /** * {@code HostContextAction}s provide actions that are associated with hosts and diff -r 4290490a2e05 -r 186115da601f client/core/src/main/java/com/redhat/thermostat/client/osgi/service/VMContextAction.java --- a/client/core/src/main/java/com/redhat/thermostat/client/osgi/service/VMContextAction.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/osgi/service/VMContextAction.java Wed Jan 16 18:58:59 2013 +0100 @@ -38,7 +38,7 @@ import com.redhat.thermostat.annotations.ExtensionPoint; import com.redhat.thermostat.client.core.Filter; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; /** * {@code VMContextAction}s provide actions that are associated with Java diff -r 4290490a2e05 -r 186115da601f client/core/src/main/java/com/redhat/thermostat/client/ui/AgentInformationDisplayModel.java --- a/client/core/src/main/java/com/redhat/thermostat/client/ui/AgentInformationDisplayModel.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/ui/AgentInformationDisplayModel.java Wed Jan 16 18:58:59 2013 +0100 @@ -42,10 +42,10 @@ import java.util.List; import java.util.Map; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.BackendInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; +import com.redhat.thermostat.storage.dao.BackendInfoDAO; import com.redhat.thermostat.storage.model.AgentInformation; import com.redhat.thermostat.storage.model.BackendInformation; diff -r 4290490a2e05 -r 186115da601f client/core/src/main/java/com/redhat/thermostat/client/ui/HostInformationController.java --- a/client/core/src/main/java/com/redhat/thermostat/client/ui/HostInformationController.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/ui/HostInformationController.java Wed Jan 16 18:58:59 2013 +0100 @@ -45,7 +45,7 @@ import com.redhat.thermostat.client.core.views.HostInformationView; import com.redhat.thermostat.client.core.views.HostInformationViewProvider; import com.redhat.thermostat.common.OrderedComparator; -import com.redhat.thermostat.common.dao.HostRef; +import com.redhat.thermostat.storage.core.HostRef; public class HostInformationController { diff -r 4290490a2e05 -r 186115da601f client/core/src/main/java/com/redhat/thermostat/client/ui/SummaryController.java --- a/client/core/src/main/java/com/redhat/thermostat/client/ui/SummaryController.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/ui/SummaryController.java Wed Jan 16 18:58:59 2013 +0100 @@ -47,8 +47,8 @@ import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.Timer.SchedulingType; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.VmInfoDAO; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.dao.VmInfoDAO; public class SummaryController { diff -r 4290490a2e05 -r 186115da601f client/core/src/main/java/com/redhat/thermostat/client/ui/UiFacadeFactory.java --- a/client/core/src/main/java/com/redhat/thermostat/client/ui/UiFacadeFactory.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/ui/UiFacadeFactory.java Wed Jan 16 18:58:59 2013 +0100 @@ -42,10 +42,10 @@ import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.client.osgi.service.HostContextAction; import com.redhat.thermostat.client.osgi.service.VMContextAction; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.dao.VmInfoDAO; public interface UiFacadeFactory { diff -r 4290490a2e05 -r 186115da601f client/core/src/main/java/com/redhat/thermostat/client/ui/VmInformationController.java --- a/client/core/src/main/java/com/redhat/thermostat/client/ui/VmInformationController.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/ui/VmInformationController.java Wed Jan 16 18:58:59 2013 +0100 @@ -45,8 +45,8 @@ import com.redhat.thermostat.client.core.views.VmInformationView; import com.redhat.thermostat.client.core.views.VmInformationViewProvider; import com.redhat.thermostat.common.OrderedComparator; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.VmRef; public class VmInformationController { diff -r 4290490a2e05 -r 186115da601f client/core/src/test/java/com/redhat/thermostat/client/locale/LocaleResourcesTest.java --- a/client/core/src/test/java/com/redhat/thermostat/client/locale/LocaleResourcesTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/core/src/test/java/com/redhat/thermostat/client/locale/LocaleResourcesTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -36,7 +36,7 @@ package com.redhat.thermostat.client.locale; -import com.redhat.thermostat.test.locale.AbstractLocaleResourcesTest; +import com.redhat.thermostat.testutils.AbstractLocaleResourcesTest; public class LocaleResourcesTest extends AbstractLocaleResourcesTest { diff -r 4290490a2e05 -r 186115da601f client/core/src/test/java/com/redhat/thermostat/client/ui/AgentInformationDisplayModelTest.java --- a/client/core/src/test/java/com/redhat/thermostat/client/ui/AgentInformationDisplayModelTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/core/src/test/java/com/redhat/thermostat/client/ui/AgentInformationDisplayModelTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -45,8 +45,8 @@ import org.junit.Before; import org.junit.Test; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.BackendInfoDAO; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; +import com.redhat.thermostat.storage.dao.BackendInfoDAO; import com.redhat.thermostat.storage.model.AgentInformation; public class AgentInformationDisplayModelTest { diff -r 4290490a2e05 -r 186115da601f client/core/src/test/java/com/redhat/thermostat/client/ui/HostInformationControllerTest.java --- a/client/core/src/test/java/com/redhat/thermostat/client/ui/HostInformationControllerTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/core/src/test/java/com/redhat/thermostat/client/ui/HostInformationControllerTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -53,7 +53,7 @@ import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.views.HostInformationView; import com.redhat.thermostat.client.core.views.HostInformationViewProvider; -import com.redhat.thermostat.common.dao.HostRef; +import com.redhat.thermostat.storage.core.HostRef; public class HostInformationControllerTest { diff -r 4290490a2e05 -r 186115da601f client/core/src/test/java/com/redhat/thermostat/client/ui/SummaryControllerTest.java --- a/client/core/src/test/java/com/redhat/thermostat/client/ui/SummaryControllerTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/core/src/test/java/com/redhat/thermostat/client/ui/SummaryControllerTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -58,8 +58,8 @@ import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.Timer.SchedulingType; import com.redhat.thermostat.common.TimerFactory; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.VmInfoDAO; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.dao.VmInfoDAO; public class SummaryControllerTest { diff -r 4290490a2e05 -r 186115da601f client/core/src/test/java/com/redhat/thermostat/client/ui/VmInformationControllerTest.java --- a/client/core/src/test/java/com/redhat/thermostat/client/ui/VmInformationControllerTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/core/src/test/java/com/redhat/thermostat/client/ui/VmInformationControllerTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -53,7 +53,7 @@ import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.views.VmInformationView; import com.redhat.thermostat.client.core.views.VmInformationViewProvider; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; public class VmInformationControllerTest { diff -r 4290490a2e05 -r 186115da601f client/living-vm-filter/core/pom.xml --- a/client/living-vm-filter/core/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/client/living-vm-filter/core/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -72,6 +72,13 @@ thermostat-client-core ${project.version} + + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f client/living-vm-filter/core/src/main/java/com/redhat/thermostat/client/filter/vm/core/LivingVMFilter.java --- a/client/living-vm-filter/core/src/main/java/com/redhat/thermostat/client/filter/vm/core/LivingVMFilter.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/living-vm-filter/core/src/main/java/com/redhat/thermostat/client/filter/vm/core/LivingVMFilter.java Wed Jan 16 18:58:59 2013 +0100 @@ -37,8 +37,8 @@ package com.redhat.thermostat.client.filter.vm.core; import com.redhat.thermostat.client.core.Filter; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.storage.model.VmInfo; public class LivingVMFilter implements Filter { diff -r 4290490a2e05 -r 186115da601f client/living-vm-filter/core/src/main/java/com/redhat/thermostat/client/filter/vm/core/VMFilterActivator.java --- a/client/living-vm-filter/core/src/main/java/com/redhat/thermostat/client/filter/vm/core/VMFilterActivator.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/living-vm-filter/core/src/main/java/com/redhat/thermostat/client/filter/vm/core/VMFilterActivator.java Wed Jan 16 18:58:59 2013 +0100 @@ -52,8 +52,8 @@ import com.redhat.thermostat.client.core.Filter; import com.redhat.thermostat.client.osgi.service.MenuAction; import com.redhat.thermostat.common.Constants; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.VmInfoDAO; public class VMFilterActivator implements BundleActivator { diff -r 4290490a2e05 -r 186115da601f client/living-vm-filter/core/src/test/java/com/redhat/thermostat/client/filter/vm/core/LivingVMFilterTest.java --- a/client/living-vm-filter/core/src/test/java/com/redhat/thermostat/client/filter/vm/core/LivingVMFilterTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/living-vm-filter/core/src/test/java/com/redhat/thermostat/client/filter/vm/core/LivingVMFilterTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -46,8 +46,8 @@ import com.redhat.thermostat.client.filter.vm.core.LivingVMFilter; import com.redhat.thermostat.client.filter.vm.core.LivingVMFilterMenuAction; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.storage.model.VmInfo; public class LivingVMFilterTest { diff -r 4290490a2e05 -r 186115da601f client/living-vm-filter/core/src/test/java/com/redhat/thermostat/client/filter/vm/core/VMFilterActivatorTest.java --- a/client/living-vm-filter/core/src/test/java/com/redhat/thermostat/client/filter/vm/core/VMFilterActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/living-vm-filter/core/src/test/java/com/redhat/thermostat/client/filter/vm/core/VMFilterActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -45,8 +45,10 @@ import com.redhat.thermostat.client.core.Filter; import com.redhat.thermostat.client.osgi.service.MenuAction; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.storage.dao.VmInfoDAO; +import com.redhat.thermostat.testutils.StubBundleContext; +import com.redhat.thermostat.testutils.StubServiceReference; +import com.redhat.thermostat.testutils.StubServiceRegistration; public class VMFilterActivatorTest { diff -r 4290490a2e05 -r 186115da601f client/living-vm-filter/swing/pom.xml --- a/client/living-vm-filter/swing/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/client/living-vm-filter/swing/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -80,6 +80,13 @@ thermostat-client-swing ${project.version} + + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/vm/swing/DeadVMDecoratorProvider.java --- a/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/vm/swing/DeadVMDecoratorProvider.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/vm/swing/DeadVMDecoratorProvider.java Wed Jan 16 18:58:59 2013 +0100 @@ -42,8 +42,8 @@ import com.redhat.thermostat.client.osgi.service.DecoratorProvider; import com.redhat.thermostat.client.ui.Decorator; import com.redhat.thermostat.client.ui.IconDescriptor; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.storage.model.VmInfo; public class DeadVMDecoratorProvider implements DecoratorProvider { diff -r 4290490a2e05 -r 186115da601f client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/vm/swing/LivingVMDecoratorProvider.java --- a/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/vm/swing/LivingVMDecoratorProvider.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/vm/swing/LivingVMDecoratorProvider.java Wed Jan 16 18:58:59 2013 +0100 @@ -44,8 +44,8 @@ import com.redhat.thermostat.client.swing.IconResource; import com.redhat.thermostat.client.ui.Decorator; import com.redhat.thermostat.client.ui.IconDescriptor; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.VmInfoDAO; public class LivingVMDecoratorProvider implements DecoratorProvider { diff -r 4290490a2e05 -r 186115da601f client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/vm/swing/VMFilterActivator.java --- a/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/vm/swing/VMFilterActivator.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/vm/swing/VMFilterActivator.java Wed Jan 16 18:58:59 2013 +0100 @@ -51,8 +51,8 @@ import com.redhat.thermostat.client.osgi.service.DecoratorProvider; import com.redhat.thermostat.common.Constants; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.VmInfoDAO; public class VMFilterActivator implements BundleActivator { diff -r 4290490a2e05 -r 186115da601f client/living-vm-filter/swing/src/test/java/com/redhat/thermostat/client/filter/vm/swing/VMFilterActivatorTest.java --- a/client/living-vm-filter/swing/src/test/java/com/redhat/thermostat/client/filter/vm/swing/VMFilterActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/living-vm-filter/swing/src/test/java/com/redhat/thermostat/client/filter/vm/swing/VMFilterActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -44,8 +44,10 @@ import org.osgi.framework.ServiceRegistration; import com.redhat.thermostat.client.osgi.service.DecoratorProvider; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.storage.dao.VmInfoDAO; +import com.redhat.thermostat.testutils.StubBundleContext; +import com.redhat.thermostat.testutils.StubServiceReference; +import com.redhat.thermostat.testutils.StubServiceRegistration; public class VMFilterActivatorTest { diff -r 4290490a2e05 -r 186115da601f client/swing/pom.xml --- a/client/swing/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/client/swing/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -99,6 +99,12 @@ + com.redhat.thermostat + thermostat-storage-core + ${project.version} + + + org.jfree jfreechart @@ -113,6 +119,12 @@ org.osgi.compendium provided + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/HostFilterRegistry.java --- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/HostFilterRegistry.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/HostFilterRegistry.java Wed Jan 16 18:58:59 2013 +0100 @@ -42,7 +42,7 @@ import com.redhat.thermostat.client.core.Filter; import com.redhat.thermostat.common.ThermostatExtensionRegistry; -import com.redhat.thermostat.common.dao.HostRef; +import com.redhat.thermostat.storage.core.HostRef; class HostFilterRegistry extends ThermostatExtensionRegistry { diff -r 4290490a2e05 -r 186115da601f client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/HostIconDecoratorProvider.java --- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/HostIconDecoratorProvider.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/HostIconDecoratorProvider.java Wed Jan 16 18:58:59 2013 +0100 @@ -47,8 +47,8 @@ import com.redhat.thermostat.client.swing.IconResource; import com.redhat.thermostat.client.ui.Decorator; import com.redhat.thermostat.client.ui.IconDescriptor; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.utils.StreamUtils; +import com.redhat.thermostat.storage.core.HostRef; public class HostIconDecoratorProvider implements DecoratorProvider { diff -r 4290490a2e05 -r 186115da601f client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/HostTreeDecoratorRegistry.java --- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/HostTreeDecoratorRegistry.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/HostTreeDecoratorRegistry.java Wed Jan 16 18:58:59 2013 +0100 @@ -42,7 +42,7 @@ import com.redhat.thermostat.client.osgi.service.DecoratorProvider; import com.redhat.thermostat.common.ThermostatExtensionRegistry; -import com.redhat.thermostat.common.dao.HostRef; +import com.redhat.thermostat.storage.core.HostRef; @SuppressWarnings("rawtypes") class HostTreeDecoratorRegistry extends ThermostatExtensionRegistry { diff -r 4290490a2e05 -r 186115da601f client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/Main.java --- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/Main.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/Main.java Wed Jan 16 18:58:59 2013 +0100 @@ -60,8 +60,6 @@ import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.config.ClientPreferences; -import com.redhat.thermostat.common.dao.DAOFactory; -import com.redhat.thermostat.common.dao.DAOFactoryImpl; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.common.utils.LoggingUtils; import com.redhat.thermostat.common.utils.OSGIUtils; @@ -72,6 +70,8 @@ import com.redhat.thermostat.storage.core.Connection.ConnectionType; import com.redhat.thermostat.storage.core.StorageProvider; import com.redhat.thermostat.storage.core.StorageProviderUtil; +import com.redhat.thermostat.storage.dao.DAOFactory; +import com.redhat.thermostat.storage.dao.DAOFactoryImpl; import com.redhat.thermostat.utils.keyring.Keyring; public class Main { diff -r 4290490a2e05 -r 186115da601f client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainView.java --- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainView.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainView.java Wed Jan 16 18:58:59 2013 +0100 @@ -48,10 +48,10 @@ import com.redhat.thermostat.client.osgi.service.MenuAction; import com.redhat.thermostat.common.ActionEvent; import com.redhat.thermostat.common.ActionListener; -import com.redhat.thermostat.common.HostsVMsLoader; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.Ref; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.HostsVMsLoader; +import com.redhat.thermostat.storage.core.Ref; +import com.redhat.thermostat.storage.core.VmRef; public interface MainView { diff -r 4290490a2e05 -r 186115da601f client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainWindow.java --- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainWindow.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainWindow.java Wed Jan 16 18:58:59 2013 +0100 @@ -112,12 +112,12 @@ import com.redhat.thermostat.common.ActionEvent; import com.redhat.thermostat.common.ActionListener; import com.redhat.thermostat.common.ActionNotifier; -import com.redhat.thermostat.common.HostsVMsLoader; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.Ref; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.common.utils.StringUtils; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.HostsVMsLoader; +import com.redhat.thermostat.storage.core.Ref; +import com.redhat.thermostat.storage.core.VmRef; public class MainWindow extends JFrame implements MainView { diff -r 4290490a2e05 -r 186115da601f client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImpl.java --- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImpl.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImpl.java Wed Jan 16 18:58:59 2013 +0100 @@ -72,19 +72,19 @@ import com.redhat.thermostat.common.ActionListener; import com.redhat.thermostat.common.ApplicationInfo; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.DefaultHostsVMsLoader; -import com.redhat.thermostat.common.HostsVMsLoader; import com.redhat.thermostat.common.ThermostatExtensionRegistry; import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.Timer.SchedulingType; import com.redhat.thermostat.common.config.ClientPreferences; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.Ref; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.LoggingUtils; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.DefaultHostsVMsLoader; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.HostsVMsLoader; +import com.redhat.thermostat.storage.core.Ref; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.utils.keyring.Keyring; public class MainWindowControllerImpl implements MainWindowController { diff -r 4290490a2e05 -r 186115da601f client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/UiFacadeFactoryImpl.java --- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/UiFacadeFactoryImpl.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/UiFacadeFactoryImpl.java Wed Jan 16 18:58:59 2013 +0100 @@ -55,11 +55,11 @@ import com.redhat.thermostat.client.ui.UiFacadeFactory; import com.redhat.thermostat.client.ui.VmInformationController; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.dao.VmInfoDAO; public class UiFacadeFactoryImpl implements UiFacadeFactory { diff -r 4290490a2e05 -r 186115da601f client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/VMInformationRegistry.java --- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/VMInformationRegistry.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/VMInformationRegistry.java Wed Jan 16 18:58:59 2013 +0100 @@ -42,7 +42,7 @@ import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ThermostatExtensionRegistry; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; @SuppressWarnings("rawtypes") class VMInformationRegistry extends ThermostatExtensionRegistry { diff -r 4290490a2e05 -r 186115da601f client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/VMTreeDecoratorRegistry.java --- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/VMTreeDecoratorRegistry.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/VMTreeDecoratorRegistry.java Wed Jan 16 18:58:59 2013 +0100 @@ -42,7 +42,7 @@ import com.redhat.thermostat.client.osgi.service.DecoratorProvider; import com.redhat.thermostat.common.ThermostatExtensionRegistry; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; @SuppressWarnings("rawtypes") class VMTreeDecoratorRegistry extends ThermostatExtensionRegistry { diff -r 4290490a2e05 -r 186115da601f client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/VmFilterRegistry.java --- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/VmFilterRegistry.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/VmFilterRegistry.java Wed Jan 16 18:58:59 2013 +0100 @@ -42,7 +42,7 @@ import com.redhat.thermostat.client.core.Filter; import com.redhat.thermostat.common.ThermostatExtensionRegistry; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; class VmFilterRegistry extends ThermostatExtensionRegistry { diff -r 4290490a2e05 -r 186115da601f client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/components/DecoratedDefaultMutableTreeNode.java --- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/components/DecoratedDefaultMutableTreeNode.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/components/DecoratedDefaultMutableTreeNode.java Wed Jan 16 18:58:59 2013 +0100 @@ -42,7 +42,7 @@ import javax.swing.tree.DefaultMutableTreeNode; import com.redhat.thermostat.client.ui.Decorator; -import com.redhat.thermostat.common.dao.Ref; +import com.redhat.thermostat.storage.core.Ref; public class DecoratedDefaultMutableTreeNode extends DefaultMutableTreeNode { diff -r 4290490a2e05 -r 186115da601f client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/osgi/InformationServiceTracker.java --- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/osgi/InformationServiceTracker.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/osgi/InformationServiceTracker.java Wed Jan 16 18:58:59 2013 +0100 @@ -45,9 +45,9 @@ import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.client.ui.UiFacadeFactory; import com.redhat.thermostat.common.Constants; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.LoggingUtils; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; @SuppressWarnings("rawtypes") public class InformationServiceTracker extends ServiceTracker { diff -r 4290490a2e05 -r 186115da601f client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/osgi/ThermostatActivator.java --- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/osgi/ThermostatActivator.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/osgi/ThermostatActivator.java Wed Jan 16 18:58:59 2013 +0100 @@ -64,7 +64,7 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.cli.CommandRegistry; import com.redhat.thermostat.common.cli.CommandRegistryImpl; -import com.redhat.thermostat.common.dao.HostRef; +import com.redhat.thermostat.storage.core.HostRef; import com.redhat.thermostat.utils.keyring.Keyring; public class ThermostatActivator implements BundleActivator { diff -r 4290490a2e05 -r 186115da601f client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/HostIconDecoratorProviderTest.java --- a/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/HostIconDecoratorProviderTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/HostIconDecoratorProviderTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -51,7 +51,7 @@ import com.redhat.thermostat.client.core.Filter; import com.redhat.thermostat.client.ui.Decorator; -import com.redhat.thermostat.common.dao.HostRef; +import com.redhat.thermostat.storage.core.HostRef; public class HostIconDecoratorProviderTest { diff -r 4290490a2e05 -r 186115da601f client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainTest.java --- a/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -58,11 +58,11 @@ import com.redhat.thermostat.client.ui.UiFacadeFactory; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.TimerFactory; -import com.redhat.thermostat.common.dao.DAOFactory; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.storage.core.Connection; import com.redhat.thermostat.storage.core.Connection.ConnectionListener; import com.redhat.thermostat.storage.core.Connection.ConnectionStatus; +import com.redhat.thermostat.storage.dao.DAOFactory; public class MainTest { diff -r 4290490a2e05 -r 186115da601f client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImplTest.java --- a/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImplTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImplTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -77,16 +77,16 @@ import com.redhat.thermostat.common.ActionEvent; import com.redhat.thermostat.common.ActionListener; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.HostsVMsLoader; import com.redhat.thermostat.common.ThermostatExtensionRegistry; import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.ThermostatExtensionRegistry.Action; import com.redhat.thermostat.common.Timer.SchedulingType; import com.redhat.thermostat.common.TimerFactory; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.HostsVMsLoader; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.storage.model.VmInfo; import com.redhat.thermostat.test.Bug; diff -r 4290490a2e05 -r 186115da601f client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainWindowTest.java --- a/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainWindowTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainWindowTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -84,8 +84,8 @@ import com.redhat.thermostat.client.ui.Decorator; import com.redhat.thermostat.common.ActionEvent; import com.redhat.thermostat.common.ActionListener; -import com.redhat.thermostat.common.HostsVMsLoader; -import com.redhat.thermostat.common.dao.HostRef; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.HostsVMsLoader; @RunWith(CacioFESTRunner.class) public class MainWindowTest { diff -r 4290490a2e05 -r 186115da601f client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/osgi/HostContextActionServiceTrackerTest.java --- a/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/osgi/HostContextActionServiceTrackerTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/osgi/HostContextActionServiceTrackerTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -44,7 +44,7 @@ import com.redhat.thermostat.client.osgi.service.HostContextAction; import com.redhat.thermostat.client.ui.UiFacadeFactory; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; public class HostContextActionServiceTrackerTest { diff -r 4290490a2e05 -r 186115da601f client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/osgi/ThermostatActivatorTest.java --- a/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/osgi/ThermostatActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/osgi/ThermostatActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -53,7 +53,7 @@ import com.redhat.thermostat.client.swing.internal.views.SwingHostInformationViewProvider; import com.redhat.thermostat.client.swing.internal.views.SwingSummaryViewProvider; import com.redhat.thermostat.client.swing.internal.views.SwingVmInformationViewProvider; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; public class ThermostatActivatorTest { diff -r 4290490a2e05 -r 186115da601f common/core/pom.xml --- a/common/core/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/common/core/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -84,7 +84,6 @@ com.redhat.thermostat.common, com.redhat.thermostat.common.appctx, com.redhat.thermostat.common.config, - com.redhat.thermostat.common.dao, com.redhat.thermostat.common.utils, com.redhat.thermostat.common.heap, com.redhat.thermostat.common.locale, @@ -170,12 +169,6 @@ thermostat-keyring ${project.version} - - com.redhat.thermostat - thermostat-storage-core - ${project.version} - - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/DbService.java --- a/common/core/src/main/java/com/redhat/thermostat/common/DbService.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common; - -import com.redhat.thermostat.annotations.Service; -import com.redhat.thermostat.storage.core.ConnectionException; - -@Service -public interface DbService { - - /** - * Connects to the given database. - * - * @throws ConnectionException - * If DB connection cannot be established. - */ - void connect() throws ConnectionException; - - /** - * Disconnects from the database. - * - * @throws ConnectionException - */ - void disconnect() throws ConnectionException; - - /** - * @returns the storage URL which was used for connection. - * - * @throws IllegalStateException - * if not connected to storage. - */ - String getConnectionUrl(); -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/DbServiceFactory.java --- a/common/core/src/main/java/com/redhat/thermostat/common/DbServiceFactory.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common; - -import org.osgi.framework.BundleContext; - -import com.redhat.thermostat.common.internal.DbServiceImpl; - -/* - * Factory in order to be able to hide the DbService implementation. Note that - * this package will be part of Export-Package whereas the package where *Impl - * classes are won't be. - * - */ -public class DbServiceFactory { - - public DbService createDbService(String username, String password, String dbUrl) { - return DbServiceImpl.create(username, password, dbUrl); - } -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/DefaultHostsVMsLoader.java --- a/common/core/src/main/java/com/redhat/thermostat/common/DefaultHostsVMsLoader.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common; - -import java.util.Collection; - -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; - -public class DefaultHostsVMsLoader implements HostsVMsLoader { - - private HostInfoDAO hostsDAO; - private VmInfoDAO vmsDAO; - private boolean liveHosts; - - /** - * - * @param hostDAO - * @param vmsDAO - * @param liveHosts {@code true} if only alive agent documents should get retrieved. - */ - public DefaultHostsVMsLoader(HostInfoDAO hostDAO, VmInfoDAO vmsDAO, boolean liveHosts) { - this.hostsDAO = hostDAO; - this.vmsDAO = vmsDAO; - this.liveHosts = liveHosts; - } - - @Override - public Collection getHosts() { - if (liveHosts) { - return hostsDAO.getAliveHosts(); - } else { - return hostsDAO.getHosts(); - } - } - - @Override - public Collection getVMs(HostRef host) { - return vmsDAO.getVMs(host); - } - -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/HostsVMsLoader.java --- a/common/core/src/main/java/com/redhat/thermostat/common/HostsVMsLoader.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common; - -import java.util.Collection; - -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; - -/** - * Provides a way to load the current hosts and VMs. - */ -public interface HostsVMsLoader { - - Collection getHosts(); - Collection getVMs(HostRef host); -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/Launcher.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/core/src/main/java/com/redhat/thermostat/common/Launcher.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,72 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.common; + +import java.util.Collection; + +import com.redhat.thermostat.annotations.Service; +import com.redhat.thermostat.common.ActionListener; +import com.redhat.thermostat.common.tools.ApplicationState; + +/** + * Launcher is the main entry point for all Thermostat commands. + */ +@Service +public interface Launcher { + + /** + * Invoked in order to start a command, either when Thermostat starts, or within + * the thermostat shell. Equivalent to calling run(null). + */ + void run(); + + /** + * Invoked in order to start a command, either when Thermostat starts, or within + * the thermostat shell. If the command being run happens to be a BasicCommand, + * and the argument is non-null, the listeners will be added to the command for + * life cycle notifications. Otherwise, the argument is ignored. + */ + void run(Collection> listeners); + + /** + * Should be set before calling run() + * @param command line arguments to the program + */ + void setArgs(String[] args); + +} + diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/cli/BasicCommand.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/core/src/main/java/com/redhat/thermostat/common/cli/BasicCommand.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,77 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.common.cli; + +import com.redhat.thermostat.common.ActionNotifier; +import com.redhat.thermostat.common.tools.ApplicationState; + +/** + * Common base class for all daemon and application + */ +public abstract class BasicCommand extends CommandWithInfo { + + private ActionNotifier notifier; + private boolean storageRequired; + + public BasicCommand() { + this.notifier = new ActionNotifier<>(this); + } + + public ActionNotifier getNotifier() { + return notifier; + } + + @Override + public boolean isStorageRequired() { + return storageRequired; + } + + protected void setStorageRequired(boolean storageRequired) { + this.storageRequired = storageRequired; + } + + @Override + public boolean isAvailableInShell() { + return true; + } + + @Override + public boolean isAvailableOutsideShell() { + return true; + } +} + diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/cli/HostVMArguments.java --- a/common/core/src/main/java/com/redhat/thermostat/common/cli/HostVMArguments.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,91 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.cli; - -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; - -public class HostVMArguments { - - static final String HOST_ID_ARGUMENT = "hostId"; - static final String VM_ID_ARGUMENT = "vmId"; - - private HostRef host; - private VmRef vm; - - public HostVMArguments(Arguments args) throws CommandException { - this(args, true, true); - } - - public HostVMArguments(Arguments args, boolean hostRequired, boolean vmRequired) throws CommandException { - String hostId = args.getArgument(HOST_ID_ARGUMENT); - String vmId = args.getArgument(VM_ID_ARGUMENT); - if (hostRequired && hostId == null) { - throw new CommandException("a " + HOST_ID_ARGUMENT + " is required"); - } else if (hostId == null) { - host = null; - } else { - host = new HostRef(hostId, "dummy"); - } - try { - int parsedVmId = parseVmId(vmId); - vm = new VmRef(host, parsedVmId, "dummy"); - } catch (CommandException ce) { - if (vmRequired) { - throw ce; - } - vm = null; - } - } - - private int parseVmId(String vmId) throws CommandException { - try { - return Integer.parseInt(vmId); - } catch (NumberFormatException ex) { - throw new CommandException("Invalid VM ID: " + vmId, ex); - } - } - - public HostRef getHost() { - return host; - } - - public VmRef getVM() { - return vm; - } -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/dao/AgentInfoDAO.java --- a/common/core/src/main/java/com/redhat/thermostat/common/dao/AgentInfoDAO.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -import java.util.List; - -import com.redhat.thermostat.annotations.Service; -import com.redhat.thermostat.storage.core.Category; -import com.redhat.thermostat.storage.core.Key; -import com.redhat.thermostat.storage.model.AgentInformation; - -@Service -public interface AgentInfoDAO extends Countable { - - static final Key START_TIME_KEY = new Key<>("startTime", false); - static final Key STOP_TIME_KEY = new Key<>("stopTime", false); - static final Key ALIVE_KEY = new Key<>("alive", false); - static final Key CONFIG_LISTEN_ADDRESS = new Key<>("configListenAddress", false); - - static final Category CATEGORY = new Category<>("agent-config", AgentInformation.class, - Key.AGENT_ID, - START_TIME_KEY, - STOP_TIME_KEY, - ALIVE_KEY, - CONFIG_LISTEN_ADDRESS); - - List getAllAgentInformation(); - - List getAliveAgents(); - - AgentInformation getAgentInformation(HostRef agentRef); - - void addAgentInformation(AgentInformation agentInfo); - - void updateAgentInformation(AgentInformation agentInfo); - - void removeAgentInformation(AgentInformation agentInfo); - -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/dao/AgentInfoDAOImpl.java --- a/common/core/src/main/java/com/redhat/thermostat/common/dao/AgentInfoDAOImpl.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -import java.util.ArrayList; -import java.util.List; - -import com.redhat.thermostat.storage.core.Cursor; -import com.redhat.thermostat.storage.core.Key; -import com.redhat.thermostat.storage.core.Put; -import com.redhat.thermostat.storage.core.Query; -import com.redhat.thermostat.storage.core.Remove; -import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.storage.core.Update; -import com.redhat.thermostat.storage.core.Query.Criteria; -import com.redhat.thermostat.storage.model.AgentInformation; - -public class AgentInfoDAOImpl implements AgentInfoDAO { - - private final Storage storage; - - public AgentInfoDAOImpl(Storage storage) { - this.storage = storage; - storage.registerCategory(CATEGORY); - } - - @Override - public long getCount() { - return storage.getCount(CATEGORY); - } - - @Override - public List getAllAgentInformation() { - Query query = storage.createQuery(CATEGORY); - Cursor agentCursor = query.execute(); - - List results = new ArrayList<>(); - - while (agentCursor.hasNext()) { - AgentInformation agentInfo = agentCursor.next(); - results.add(agentInfo); - } - return results; - } - - @Override - public List getAliveAgents() { - Query query = storage.createQuery(CATEGORY); - query.where(AgentInfoDAO.ALIVE_KEY, Criteria.EQUALS, true); - - Cursor agentCursor = query.execute(); - - List results = new ArrayList<>(); - - while (agentCursor.hasNext()) { - AgentInformation agentInfo = agentCursor.next(); - results.add(agentInfo); - } - return results; - } - - @Override - public AgentInformation getAgentInformation(HostRef agentRef) { - Query query = storage.createQuery(CATEGORY); - query.where(Key.AGENT_ID, Criteria.EQUALS, agentRef.getAgentId()); - query.limit(1); - return query.execute().next(); - } - - @Override - public void addAgentInformation(AgentInformation agentInfo) { - Put replace = storage.createReplace(CATEGORY); - replace.setPojo(agentInfo); - replace.apply(); - } - - @Override - public void removeAgentInformation(AgentInformation agentInfo) { - Remove remove = storage.createRemove().from(CATEGORY).where(Key.AGENT_ID, agentInfo.getAgentId()); - storage.removePojo(remove); - } - - @Override - public void updateAgentInformation(AgentInformation agentInfo) { - Update update = storage.createUpdate(CATEGORY); - update.where(Key.AGENT_ID, agentInfo.getAgentId()); - update.set(START_TIME_KEY, agentInfo.getStartTime()); - update.set(STOP_TIME_KEY, agentInfo.getStopTime()); - update.set(ALIVE_KEY, agentInfo.isAlive()); - update.set(CONFIG_LISTEN_ADDRESS, agentInfo.getConfigListenAddress()); - update.apply(); - } - -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/dao/BackendInfoDAO.java --- a/common/core/src/main/java/com/redhat/thermostat/common/dao/BackendInfoDAO.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -import java.util.List; - -import com.redhat.thermostat.annotations.Service; -import com.redhat.thermostat.storage.core.Category; -import com.redhat.thermostat.storage.core.Key; -import com.redhat.thermostat.storage.model.BackendInformation; - -@Service -public interface BackendInfoDAO { - - static final Key BACKEND_NAME = new Key<>("name", true); - static final Key BACKEND_DESCRIPTION = new Key<>("description", false); - static final Key IS_ACTIVE = new Key<>("active", false); - static final Key SHOULD_MONITOR_NEW_PROCESSES = new Key<>("observeNewJvm", false); - static final Key> PIDS_TO_MONITOR = new Key<>("pids", false); - static final Key ORDER_VALUE = new Key<>("orderValue", false); - - static final Category CATEGORY = new Category<>("backend-info", BackendInformation.class, - Key.AGENT_ID, - BACKEND_NAME, - BACKEND_DESCRIPTION, - IS_ACTIVE, - SHOULD_MONITOR_NEW_PROCESSES, - PIDS_TO_MONITOR, - ORDER_VALUE); - - List getBackendInformation(HostRef host); - - void addBackendInformation(BackendInformation info); - - void removeBackendInformation(BackendInformation info); - -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/dao/BackendInfoDAOImpl.java --- a/common/core/src/main/java/com/redhat/thermostat/common/dao/BackendInfoDAOImpl.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import com.redhat.thermostat.storage.core.Cursor; -import com.redhat.thermostat.storage.core.Key; -import com.redhat.thermostat.storage.core.Put; -import com.redhat.thermostat.storage.core.Query; -import com.redhat.thermostat.storage.core.Query.Criteria; -import com.redhat.thermostat.storage.core.Remove; -import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.storage.model.BackendInformation; - -public class BackendInfoDAOImpl implements BackendInfoDAO { - - private final Storage storage; - - public BackendInfoDAOImpl(Storage storage) { - this.storage = storage; - storage.registerCategory(CATEGORY); - } - - @Override - public List getBackendInformation(HostRef host) { - // Sort by order value - Query query = storage.createQuery(CATEGORY); - query.where(Key.AGENT_ID, Criteria.EQUALS, host.getAgentId()); - - List results = new ArrayList<>(); - Cursor cursor = query.execute(); - while (cursor.hasNext()) { - BackendInformation backendInfo = cursor.next(); - results.add(backendInfo); - } - - // Sort before returning - Collections.sort(results, new Comparator() { - - // TODO Use OrderedComparator when common-core - // doesn't depend on storage-core - @Override - public int compare(BackendInformation o1, BackendInformation o2) { - int result = o1.getOrderValue() - o2.getOrderValue(); - // Break ties using class name - if (result == 0) { - result = o1.getClass().getName().compareTo(o2.getClass().getName()); - } - return result; - } - }); - - return results; - } - - @Override - public void addBackendInformation(BackendInformation info) { - Put add = storage.createAdd(BackendInfoDAO.CATEGORY); - add.setPojo(info); - add.apply(); - } - - @Override - public void removeBackendInformation(BackendInformation info) { - Remove remove = storage.createRemove().from(CATEGORY).where(BACKEND_NAME, info.getName()); - storage.removePojo(remove); - } - -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/dao/Countable.java --- a/common/core/src/main/java/com/redhat/thermostat/common/dao/Countable.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -public interface Countable { - - public long getCount(); - -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/dao/DAOException.java --- a/common/core/src/main/java/com/redhat/thermostat/common/dao/DAOException.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -public class DAOException extends RuntimeException { - - public DAOException() { - super(); - } - - public DAOException(String message) { - super(message); - } - - public DAOException(Throwable cause) { - super(cause); - } - - public DAOException(String message, Throwable cause) { - super(message, cause); - } - -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/dao/DAOFactory.java --- a/common/core/src/main/java/com/redhat/thermostat/common/dao/DAOFactory.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -import com.redhat.thermostat.storage.core.Connection; -import com.redhat.thermostat.storage.core.Storage; - -public interface DAOFactory { - - // TODO this is temporary until DAO is made for those that are still using Storage directly. - public Storage getStorage(); - - public Connection getConnection(); - - public AgentInfoDAO getAgentInfoDAO(); - - public BackendInfoDAO getBackendInfoDAO(); - - public HostInfoDAO getHostInfoDAO(); - - public NetworkInterfaceInfoDAO getNetworkInterfaceInfoDAO(); - - public VmInfoDAO getVmInfoDAO(); - - public void registerDAOsAndStorageAsOSGiServices(); - public void unregisterDAOsAndStorageAsOSGiServices(); - -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/dao/DAOFactoryImpl.java --- a/common/core/src/main/java/com/redhat/thermostat/common/dao/DAOFactoryImpl.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,158 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceRegistration; - -import com.redhat.thermostat.storage.core.Connection; -import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.storage.core.StorageProvider; - -public class DAOFactoryImpl implements DAOFactory { - - private final Storage storage; - private final BundleContext bundleContext; - @SuppressWarnings("rawtypes") - private final List registeredServices = new ArrayList<>(); - private AgentInfoDAO agentDAO; - private BackendInfoDAO backendInfoDAO; - private HostInfoDAO hostInfoDAO; - private NetworkInterfaceInfoDAO networkInfoDAO; - private VmInfoDAO vmInfoDAO; - - public DAOFactoryImpl(StorageProvider prov) { - this(FrameworkUtil.getBundle(DAOFactoryImpl.class).getBundleContext(), prov); - } - - public DAOFactoryImpl(BundleContext bundleContext, StorageProvider prov) { - this.bundleContext = bundleContext; - storage = prov.createStorage(); - } - - @Override - public Connection getConnection() { - return storage.getConnection(); - } - - @Override - public AgentInfoDAO getAgentInfoDAO() { - ensureStorageConnected(); - return agentDAO; - } - - @Override - public BackendInfoDAO getBackendInfoDAO() { - ensureStorageConnected(); - return backendInfoDAO; - } - - @Override - public HostInfoDAO getHostInfoDAO() { - ensureStorageConnected(); - return hostInfoDAO; - } - - @Override - public NetworkInterfaceInfoDAO getNetworkInterfaceInfoDAO() { - ensureStorageConnected(); - return networkInfoDAO; - } - - @Override - public VmInfoDAO getVmInfoDAO() { - ensureStorageConnected(); - return vmInfoDAO; - } - - @Override - public Storage getStorage() { - return storage; - } - - private void ensureStorageConnected() { - if (!storage.getConnection().isConnected()) { - throw new IllegalStateException("Set up connection before accessing DAO"); - } - } - - @Override - public void registerDAOsAndStorageAsOSGiServices() { - ensureStorageConnected(); - createDAOs(); - registerAndRecordService(Storage.class, getStorage()); - - registerAndRecordService(AgentInfoDAO.class, getAgentInfoDAO()); - registerAndRecordService(BackendInfoDAO.class, getBackendInfoDAO()); - - registerAndRecordService(HostInfoDAO.class, getHostInfoDAO()); - registerAndRecordService(NetworkInterfaceInfoDAO.class, getNetworkInterfaceInfoDAO()); - - registerAndRecordService(VmInfoDAO.class, getVmInfoDAO()); - } - - /* - * Pre: Db connected - */ - void createDAOs() { - agentDAO = new AgentInfoDAOImpl(storage); - backendInfoDAO = new BackendInfoDAOImpl(storage); - hostInfoDAO = new HostInfoDAOImpl(storage, agentDAO); - networkInfoDAO = new NetworkInterfaceInfoDAOImpl(storage); - vmInfoDAO = new VmInfoDAOImpl(storage); - } - - private void registerAndRecordService(Class serviceType, K serviceImplementation) { - registeredServices.add(bundleContext.registerService(serviceType, serviceImplementation, null)); - } - - public void unregisterDAOsAndStorageAsOSGiServices() { - Iterator iter = registeredServices.iterator(); - while (iter.hasNext()) { - ServiceRegistration registration = iter.next(); - registration.unregister(); - iter.remove(); - } - } - -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/dao/HostInfoDAO.java --- a/common/core/src/main/java/com/redhat/thermostat/common/dao/HostInfoDAO.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -import java.util.Collection; - -import com.redhat.thermostat.annotations.Service; -import com.redhat.thermostat.storage.core.Category; -import com.redhat.thermostat.storage.core.Key; -import com.redhat.thermostat.storage.model.HostInfo; - -@Service -public interface HostInfoDAO extends Countable { - - static Key hostNameKey = new Key<>("hostname", true); - static Key osNameKey = new Key<>("osName", false); - static Key osKernelKey = new Key<>("osKernel", false); - static Key cpuCountKey = new Key<>("cpuCount", false); - static Key cpuModelKey = new Key<>("cpuModel", false); - static Key hostMemoryTotalKey = new Key<>("totalMemory", false); - - static final Category hostInfoCategory = new Category<>("host-info", HostInfo.class, - Key.AGENT_ID, hostNameKey, osNameKey, osKernelKey, - cpuCountKey, cpuModelKey, hostMemoryTotalKey); - - HostInfo getHostInfo(HostRef ref); - - void putHostInfo(HostInfo info); - - Collection getHosts(); - Collection getAliveHosts(); -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/dao/HostInfoDAOImpl.java --- a/common/core/src/main/java/com/redhat/thermostat/common/dao/HostInfoDAOImpl.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,118 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import com.redhat.thermostat.storage.core.Cursor; -import com.redhat.thermostat.storage.core.Key; -import com.redhat.thermostat.storage.core.Put; -import com.redhat.thermostat.storage.core.Query; -import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.storage.core.Query.Criteria; -import com.redhat.thermostat.storage.model.AgentInformation; -import com.redhat.thermostat.storage.model.HostInfo; - -class HostInfoDAOImpl implements HostInfoDAO { - - private final Storage storage; - private final AgentInfoDAO agentInfoDao; - - - public HostInfoDAOImpl(Storage storage, AgentInfoDAO agentInfo) { - this.storage = storage; - this.agentInfoDao = agentInfo; - storage.registerCategory(hostInfoCategory); - } - - @Override - public HostInfo getHostInfo(HostRef ref) { - Query query = storage.createQuery(hostInfoCategory); - query.where(Key.AGENT_ID, Criteria.EQUALS, ref.getAgentId()); - query.limit(1); - HostInfo result = query.execute().next(); - return result; - } - - @Override - public void putHostInfo(HostInfo info) { - Put add = storage.createAdd(hostInfoCategory); - add.setPojo(info); - add.apply(); - } - - @Override - public Collection getHosts() { - Query allHosts = storage.createQuery(hostInfoCategory); - return getHosts(allHosts); - } - - @Override - public Collection getAliveHosts() { - List hosts = new ArrayList<>(); - List agentInfos = agentInfoDao.getAliveAgents(); - for (AgentInformation agentInfo : agentInfos) { - Query filter = storage.createQuery(hostInfoCategory); - filter.where(Key.AGENT_ID, Criteria.EQUALS, agentInfo.getAgentId()); - hosts.addAll(getHosts(filter)); - } - - return hosts; - } - - - private Collection getHosts(Query filter) { - Collection hosts = new ArrayList(); - - Cursor hostsCursor = filter.execute(); - while(hostsCursor.hasNext()) { - HostInfo host = hostsCursor.next(); - String agentId = host.getAgentId(); - String hostName = host.getHostname(); - hosts.add(new HostRef(agentId, hostName)); - } - return hosts; - } - - @Override - public long getCount() { - return storage.getCount(hostInfoCategory); - } -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/dao/HostLatestPojoListGetter.java --- a/common/core/src/main/java/com/redhat/thermostat/common/dao/HostLatestPojoListGetter.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -import java.util.ArrayList; -import java.util.List; - -import com.redhat.thermostat.storage.core.Category; -import com.redhat.thermostat.storage.core.Cursor; -import com.redhat.thermostat.storage.core.Key; -import com.redhat.thermostat.storage.core.Query; -import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.storage.core.Query.Criteria; -import com.redhat.thermostat.storage.model.TimeStampedPojo; - -public class HostLatestPojoListGetter { - - private final Storage storage; - private final Category cat; - - public HostLatestPojoListGetter(Storage storage, Category cat) { - this.storage = storage; - this.cat = cat; - } - - public List getLatest(HostRef hostRef, long since) { - Query query = buildQuery(hostRef, since); - return getLatest(query); - } - - private List getLatest(Query query) { - Cursor cursor = query.execute(); - List result = new ArrayList<>(); - while (cursor.hasNext()) { - T pojo = cursor.next(); - result.add(pojo); - } - return result; - } - - protected Query buildQuery(HostRef hostRef, long since) { - Query query = storage.createQuery(cat); - query.where(Key.AGENT_ID, Criteria.EQUALS, hostRef.getAgentId()); - query.where(Key.TIMESTAMP, Criteria.GREATER_THAN, since); - query.sort(Key.TIMESTAMP, Query.SortDirection.DESCENDING); - return query; - } -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/dao/HostRef.java --- a/common/core/src/main/java/com/redhat/thermostat/common/dao/HostRef.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,99 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -public class HostRef implements Ref { - - private final String uid; - private final String name; - - public HostRef(String id, String name) { - this.uid = id; - this.name = name; - } - - @Override - public String toString() { - return name; - } - - public String getAgentId() { - return uid; - } - - public String getHostName() { - return name; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (obj == this) { - return true; - } - if (obj.getClass() != this.getClass()) { - return false; - } - HostRef other = (HostRef) obj; - if (equals(this.uid, other.uid) && equals(this.name, other.name)) { - return true; - } - return false; - } - - private static boolean equals(Object obj1, Object obj2) { - return (obj1 == null && obj2 == null) || (obj1 != null && obj1.equals(obj2)); - } - - @Override - public int hashCode() { - return uid.hashCode(); - } - - @Override - public String getStringID() { - return getAgentId(); - } - - @Override - public String getName() { - return getHostName(); - } -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/dao/NetworkInterfaceInfoDAO.java --- a/common/core/src/main/java/com/redhat/thermostat/common/dao/NetworkInterfaceInfoDAO.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -import java.util.List; - -import com.redhat.thermostat.annotations.Service; -import com.redhat.thermostat.storage.core.Category; -import com.redhat.thermostat.storage.core.Key; -import com.redhat.thermostat.storage.model.NetworkInterfaceInfo; - -@Service -public interface NetworkInterfaceInfoDAO { - - static Key ifaceKey = new Key<>("interfaceName", true); - static Key ip4AddrKey = new Key<>("ip4Addr", false); - static Key ip6AddrKey = new Key<>("ip6Addr", false); - - static final Category networkInfoCategory = new Category<>("network-info", NetworkInterfaceInfo.class, - Key.AGENT_ID, ifaceKey, ip4AddrKey, ip6AddrKey); - - public List getNetworkInterfaces(HostRef ref); - - public void putNetworkInterfaceInfo(NetworkInterfaceInfo info); -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/dao/NetworkInterfaceInfoDAOImpl.java --- a/common/core/src/main/java/com/redhat/thermostat/common/dao/NetworkInterfaceInfoDAOImpl.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -import java.util.ArrayList; -import java.util.List; - -import com.redhat.thermostat.storage.core.Cursor; -import com.redhat.thermostat.storage.core.Key; -import com.redhat.thermostat.storage.core.Put; -import com.redhat.thermostat.storage.core.Query; -import com.redhat.thermostat.storage.core.Query.Criteria; -import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.storage.model.NetworkInterfaceInfo; - -class NetworkInterfaceInfoDAOImpl implements NetworkInterfaceInfoDAO { - - private Storage storage; - - NetworkInterfaceInfoDAOImpl(Storage storage) { - this.storage = storage; - storage.registerCategory(networkInfoCategory); - } - - @Override - public List getNetworkInterfaces(HostRef ref) { - Query allHostNetworkInterfaces = storage.createQuery(networkInfoCategory); - allHostNetworkInterfaces.where(Key.AGENT_ID, Criteria.EQUALS, ref.getAgentId()); - - Cursor cursor = allHostNetworkInterfaces.execute(); - List result = new ArrayList<>(); - while (cursor.hasNext()) { - NetworkInterfaceInfo stat = cursor.next(); - result.add(stat); - } - return result; - } - - @Override - public void putNetworkInterfaceInfo(NetworkInterfaceInfo info) { - Put replace = storage.createReplace(networkInfoCategory); - replace.setPojo(info); - replace.apply(); - } - -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/dao/Ref.java --- a/common/core/src/main/java/com/redhat/thermostat/common/dao/Ref.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -public interface Ref { - - String getStringID(); - String getName(); -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/dao/VmInfoDAO.java --- a/common/core/src/main/java/com/redhat/thermostat/common/dao/VmInfoDAO.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import com.redhat.thermostat.annotations.Service; -import com.redhat.thermostat.storage.core.Category; -import com.redhat.thermostat.storage.core.Key; -import com.redhat.thermostat.storage.model.VmInfo; - -@Service -public interface VmInfoDAO extends Countable { - - static final Key vmPidKey = new Key<>("vmPid", false); - static final Key runtimeVersionKey = new Key<>("javaVersion", false); - static final Key javaHomeKey = new Key<>("javaHome", false); - static final Key mainClassKey = new Key<>("mainClass", false); - static final Key commandLineKey = new Key<>("javaCommandLine", false); - static final Key vmArgumentsKey = new Key<>("vmArguments", false); - static final Key vmNameKey = new Key<>("vmName", false); - static final Key vmInfoKey = new Key<>("vmInfo", false); - static final Key vmVersionKey = new Key<>("vmVersion", false); - static final Key> propertiesKey = new Key<>("properties", false); - static final Key> environmentKey = new Key<>("environment", false); - static final Key> librariesKey = new Key<>("loadedNativeLibraries", false); - static final Key startTimeKey = new Key<>("startTimeStamp", false); - static final Key stopTimeKey = new Key<>("stopTimeStamp", false); - - static final Category vmInfoCategory = new Category<>("vm-info", VmInfo.class, - Key.AGENT_ID, Key.VM_ID, vmPidKey, runtimeVersionKey, javaHomeKey, - mainClassKey, commandLineKey, - vmArgumentsKey, vmNameKey, vmInfoKey, vmVersionKey, - propertiesKey, environmentKey, librariesKey, - startTimeKey, stopTimeKey); - - public VmInfo getVmInfo(VmRef ref); - - Collection getVMs(HostRef host); - - public void putVmInfo(VmInfo info); - - public void putVmStoppedTime(int vmId, long since); -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/dao/VmInfoDAOImpl.java --- a/common/core/src/main/java/com/redhat/thermostat/common/dao/VmInfoDAOImpl.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,128 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import com.redhat.thermostat.storage.core.Cursor; -import com.redhat.thermostat.storage.core.Key; -import com.redhat.thermostat.storage.core.Put; -import com.redhat.thermostat.storage.core.Query; -import com.redhat.thermostat.storage.core.Query.Criteria; -import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.storage.core.Update; -import com.redhat.thermostat.storage.model.VmInfo; - -class VmInfoDAOImpl implements VmInfoDAO { - - private final Storage storage; - - VmInfoDAOImpl(Storage storage) { - this.storage = storage; - storage.registerCategory(vmInfoCategory); - } - - @Override - public VmInfo getVmInfo(VmRef ref) { - Query findMatchingVm = storage.createQuery(vmInfoCategory); - findMatchingVm.where(Key.AGENT_ID, Criteria.EQUALS, ref.getAgent().getAgentId()); - findMatchingVm.where(Key.VM_ID, Criteria.EQUALS, ref.getId()); - findMatchingVm.limit(1); - VmInfo result = findMatchingVm.execute().next(); - if (result == null) { - throw new DAOException("Unknown VM: host:" + ref.getAgent().getAgentId() + ";vm:" + ref.getId()); - } - return result; - } - - @Override - public Collection getVMs(HostRef host) { - - Query query = buildQuery(host); - Cursor cursor = query.execute(); - return buildVMsFromQuery(cursor, host); - } - - private Query buildQuery(HostRef host) { - Query query = storage.createQuery(vmInfoCategory); - query.where(Key.AGENT_ID, Criteria.EQUALS, host.getAgentId()); - return query; - } - - private Collection buildVMsFromQuery(Cursor cursor, HostRef host) { - List vmRefs = new ArrayList(); - while (cursor.hasNext()) { - VmInfo vmInfo = cursor.next(); - VmRef vm = buildVmRefFromChunk(vmInfo, host); - vmRefs.add(vm); - } - - return vmRefs; - } - - private VmRef buildVmRefFromChunk(VmInfo vmInfo, HostRef host) { - Integer id = vmInfo.getVmId(); - // TODO can we do better than the main class? - String mainClass = vmInfo.getMainClass(); - VmRef ref = new VmRef(host, id, mainClass); - return ref; - } - - @Override - public long getCount() { - return storage.getCount(vmInfoCategory); - } - - @Override - public void putVmInfo(VmInfo info) { - Put replace = storage.createReplace(vmInfoCategory); - replace.setPojo(info); - replace.apply(); - } - - @Override - public void putVmStoppedTime(int vmId, long timestamp) { - Update update = storage.createUpdate(vmInfoCategory); - update.where(Key.VM_ID, vmId); - update.set(VmInfoDAO.stopTimeKey, timestamp); - update.apply(); - } - -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/dao/VmLatestPojoListGetter.java --- a/common/core/src/main/java/com/redhat/thermostat/common/dao/VmLatestPojoListGetter.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -import java.util.ArrayList; -import java.util.List; - -import com.redhat.thermostat.storage.core.Category; -import com.redhat.thermostat.storage.core.Cursor; -import com.redhat.thermostat.storage.core.Key; -import com.redhat.thermostat.storage.core.Query; -import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.storage.core.Query.Criteria; -import com.redhat.thermostat.storage.model.TimeStampedPojo; - -public class VmLatestPojoListGetter { - - private final Storage storage; - private final Category cat; - - public VmLatestPojoListGetter(Storage storage, Category cat) { - this.storage = storage; - this.cat = cat; - } - - public List getLatest(VmRef vmRef, long since) { - Query query = buildQuery(vmRef, since); - return getLatest(query); - } - - private List getLatest(Query query) { - Cursor cursor = query.execute(); - List result = new ArrayList<>(); - while (cursor.hasNext()) { - T pojo = cursor.next(); - result.add(pojo); - } - return result; - } - - protected Query buildQuery(VmRef vmRef, long since) { - Query query = storage.createQuery(cat); - query.where(Key.AGENT_ID, Criteria.EQUALS, vmRef.getAgent().getAgentId()); - query.where(Key.VM_ID, Criteria.EQUALS, vmRef.getId()); - query.where(Key.TIMESTAMP, Criteria.GREATER_THAN, since); - query.sort(Key.TIMESTAMP, Query.SortDirection.DESCENDING); - return query; - } - -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/dao/VmRef.java --- a/common/core/src/main/java/com/redhat/thermostat/common/dao/VmRef.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,109 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -public class VmRef implements Ref { - - private final HostRef hostRef; - private final Integer uid; - private final String uidString; - private final String name; - - public VmRef(HostRef hostRef, Integer id, String name) { - this.hostRef = hostRef; - this.uid = id; - this.uidString = id.toString(); - this.name = name; - } - - @Override - public String toString() { - return name; - } - - public HostRef getAgent() { - return hostRef; - } - - public Integer getId() { - return uid; - } - - /** - * Equivalent to {@link #getStringID()}. - */ - public String getIdString() { - return uidString; - } - - public String getName() { - return name; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (obj == this) { - return true; - } - if (obj.getClass() != this.getClass()) { - return false; - } - VmRef other = (VmRef) obj; - if (equals(this.hostRef, other.hostRef) && equals(this.uid, other.uid) && equals(this.name, other.name)) { - return true; - } - return false; - } - - private static boolean equals(Object obj1, Object obj2) { - return (obj1 == null && obj2 == null) || (obj1 != null && obj1.equals(obj2)); - } - - @Override - public int hashCode() { - return uid.hashCode(); - } - - @Override - public String getStringID() { - return getIdString(); - } -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/internal/DbServiceImpl.java --- a/common/core/src/main/java/com/redhat/thermostat/common/internal/DbServiceImpl.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,122 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.internal; - -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceRegistration; - -import com.redhat.thermostat.common.DbService; -import com.redhat.thermostat.common.dao.DAOFactory; -import com.redhat.thermostat.common.dao.DAOFactoryImpl; -import com.redhat.thermostat.storage.config.ConnectionConfiguration; -import com.redhat.thermostat.storage.config.StartupConfiguration; -import com.redhat.thermostat.storage.core.ConnectionException; -import com.redhat.thermostat.storage.core.StorageException; -import com.redhat.thermostat.storage.core.StorageProvider; -import com.redhat.thermostat.storage.core.StorageProviderUtil; - -public class DbServiceImpl implements DbService { - - @SuppressWarnings("rawtypes") - private ServiceRegistration registration; - - private DAOFactory daoFactory; - private BundleContext context; - private String dbUrl; - - DbServiceImpl(String username, String password, String dbUrl) throws StorageException { - this(FrameworkUtil.getBundle(DbService.class).getBundleContext(), getDAOFactory(username, password, dbUrl), dbUrl); - } - - // for testing - DbServiceImpl(BundleContext context, DAOFactory daoFactory, String dbUrl) { - this.daoFactory = daoFactory; - this.context = context; - this.dbUrl = dbUrl; - } - - public void connect() throws ConnectionException { - try { - daoFactory.getConnection().connect(); - registration = context.registerService(DbService.class, this, null); - daoFactory.registerDAOsAndStorageAsOSGiServices(); - } catch (Exception cause) { - throw new ConnectionException(cause); - } - } - - public void disconnect() throws ConnectionException { - try { - daoFactory.unregisterDAOsAndStorageAsOSGiServices(); - daoFactory.getConnection().disconnect(); - registration.unregister(); - } catch (Exception cause) { - throw new ConnectionException(cause); - } - } - - @Override - public String getConnectionUrl() { - return dbUrl; - } - - /** - * Factory method for creating a DbService instance. - * - * @param username - * @param password - * @param dbUrl - * @return a DbService instance - * @throws StorageException if no storage provider exists for the given {@code dbUrl}. - */ - public static DbService create(String username, String password, String dbUrl) throws StorageException { - return new DbServiceImpl(username, password, dbUrl); - } - - private static DAOFactory getDAOFactory(String username, String password, String dbUrl) throws StorageException { - StartupConfiguration config = new ConnectionConfiguration(dbUrl, username, password); - StorageProvider prov = StorageProviderUtil.getStorageProvider(config); - if (prov == null) { - // no suitable provider found - throw new StorageException("No storage found for URL " + dbUrl); - } - return new DAOFactoryImpl(prov); - } - -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/common/tools/BasicCommand.java --- a/common/core/src/main/java/com/redhat/thermostat/common/tools/BasicCommand.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.tools; - -import com.redhat.thermostat.common.ActionNotifier; -import com.redhat.thermostat.common.cli.CommandWithInfo; -import com.redhat.thermostat.storage.config.StartupConfiguration; - -/** - * Common base class for all daemon and application - */ -public abstract class BasicCommand extends CommandWithInfo { - - private ActionNotifier notifier; - private boolean storageRequired; - - public BasicCommand() { - this.notifier = new ActionNotifier<>(this); - } - - public ActionNotifier getNotifier() { - return notifier; - } - - public abstract StartupConfiguration getConfiguration(); - - @Override - public boolean isStorageRequired() { - return storageRequired; - } - - protected void setStorageRequired(boolean storageRequired) { - this.storageRequired = storageRequired; - } - - @Override - public boolean isAvailableInShell() { - return true; - } - - @Override - public boolean isAvailableOutsideShell() { - return true; - } -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/test/StubBundleContext.java --- a/common/core/src/main/java/com/redhat/thermostat/test/StubBundleContext.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,404 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.test; - -import java.io.File; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Dictionary; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.BundleException; -import org.osgi.framework.BundleListener; -import org.osgi.framework.Constants; -import org.osgi.framework.Filter; -import org.osgi.framework.FrameworkListener; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.InvalidSyntaxException; -import org.osgi.framework.ServiceEvent; -import org.osgi.framework.ServiceFactory; -import org.osgi.framework.ServiceListener; -import org.osgi.framework.ServiceReference; -import org.osgi.framework.ServiceRegistration; - -import com.redhat.thermostat.common.NotImplementedException; - -/** - * An implementation of BundleContext that's useful for writing unit tests. - *

- * WARNING: if you static mock {@link FrameworkUtil#createFilter(String)}, you - * are going to have a bad time. - */ -public class StubBundleContext implements BundleContext { - - static class ServiceInformation { - public Object implementation; - public Dictionary properties; - public int exportedReferences; - - public ServiceInformation(Object impl, Dictionary props) { - this.implementation = impl; - this.properties = props; - } - } - - private int nextServiceId = 0; - - private Map frameworkProperties = new HashMap<>(); - private List bundles = new ArrayList<>(); - private List registeredServices = new ArrayList<>(); - private Map registeredListeners = new HashMap<>(); - private Bundle contextBundle = null; - - /* - * Interface methods - */ - - @Override - public String getProperty(String key) { - String result = null; - result = frameworkProperties.get(key); - if (result == null) { - result = System.getProperty(key); - } - return result; - } - - @Override - public Bundle getBundle() { - return contextBundle; - } - - @Override - public Bundle installBundle(String location, InputStream input) throws BundleException { - throw new NotImplementedException(); - } - - @Override - public Bundle installBundle(String location) throws BundleException { - throw new NotImplementedException(); - } - - @Override - public Bundle getBundle(long id) { - if (id > Integer.MAX_VALUE) { - throw new NotImplementedException(); - } - if (id >= bundles.size()) { - return null; - } - - return bundles.get((int) id); - } - - @Override - public Bundle getBundle(String location) { - throw new NotImplementedException(); - } - - @Override - public Bundle[] getBundles() { - return bundles.toArray(new Bundle[bundles.size()]); - } - - @Override - public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException { - registeredListeners.put(listener, filter == null ? null : createFilter(filter)); - } - - @Override - public void addServiceListener(ServiceListener listener) { - try { - addServiceListener(listener, null); - } catch (InvalidSyntaxException e) { - throw new AssertionError("a null filter can not have invalid systax"); - } - } - - @Override - public void removeServiceListener(ServiceListener listener) { - registeredListeners.remove(listener); - } - - @Override - public void addBundleListener(BundleListener listener) { - throw new NotImplementedException(); - } - - @Override - public void removeBundleListener(BundleListener listener) { - throw new NotImplementedException(); - } - - @Override - public void addFrameworkListener(FrameworkListener listener) { - throw new NotImplementedException(); - } - - @Override - public void removeFrameworkListener(FrameworkListener listener) { - throw new NotImplementedException(); - } - - @Override - public ServiceRegistration registerService(Class clazz, Object service, Dictionary properties) { - return registerService(clazz.getName(), service, properties); - } - - @Override - public ServiceRegistration registerService(String className, Object service, Dictionary properties) { - return registerService(new String[] { className }, service, properties); - } - - @Override - public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties) { - if (service instanceof ServiceFactory) { - throw new NotImplementedException("support for service factories is not implemented"); - } - - for (String className : clazzes) { - try { - Class clazz = Class.forName(className); - if (!clazz.isAssignableFrom(service.getClass())) { - throw new IllegalArgumentException("service is not a subclass of " + className); - } - } catch (ClassNotFoundException classNotFound) { - throw new IllegalArgumentException("not a valid class: " + className); - } - } - - Object specifiedRanking = null; - Hashtable newProperties = new Hashtable<>(); - if (properties != null) { - Enumeration enumeration = properties.keys(); - while (enumeration.hasMoreElements()) { - Object key = enumeration.nextElement(); - newProperties.put((String)key, properties.get(key)); - } - specifiedRanking = properties.get(Constants.SERVICE_RANKING); - } - - newProperties.put(Constants.OBJECTCLASS, clazzes); - newProperties.put(Constants.SERVICE_ID, nextServiceId); - nextServiceId++; - if (specifiedRanking == null || !(specifiedRanking instanceof Integer)) { - specifiedRanking = 0; - } - newProperties.put(Constants.SERVICE_RANKING, (Integer) specifiedRanking); - - ServiceInformation info = new ServiceInformation(service, newProperties); - registeredServices.add(info); - - notifyServiceChange(new StubServiceReference(info, contextBundle), true); - - return new StubServiceRegistration(this, info); - } - - @Override - public ServiceReference getServiceReference(Class clazz) { - return getServiceReference(clazz.getName()); - } - - @Override - public ServiceReference getServiceReference(String clazz) { - try { - ServiceReference[] initial = getServiceReferences(clazz, null); - if (initial == null) { - return null; - } - - Arrays.sort(initial); - return initial[initial.length-1]; - } catch (InvalidSyntaxException invalidFilterSyntax) { - throw new AssertionError("a null filter can not have an invalid syntax"); - } - } - - @Override - public Collection getServiceReferences(Class clazz, String filter) throws InvalidSyntaxException { - return Arrays.asList(getServiceReferences(clazz.getName(), filter)); - } - - @Override - public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException { - ServiceReference[] allRefs = getAllServiceReferences(clazz, filter); - if (allRefs == null) { - return null; - } - - List result = new ArrayList<>(); - for (ServiceReference ref : allRefs) { - if (ref.isAssignableTo(contextBundle, clazz)) { - result.add(ref); - } - } - return result.toArray(new ServiceReference[0]); - } - - @Override - public ServiceReference[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException { - List toReturn = new ArrayList<>(); - - Filter toMatch = (filter == null) ? null : createFilter(filter); - - for (ServiceInformation info : registeredServices) { - for (String serviceInterface : (String[]) info.properties.get(Constants.OBJECTCLASS)) { - if (clazz == null || serviceInterface.equals(clazz)) { - if (toMatch == null || toMatch.match(info.properties)) { - toReturn.add(new StubServiceReference(info, contextBundle)); - } - } - } - } - - if (toReturn.size() == 0) { - return null; - } - return toReturn.toArray(new ServiceReference[0]); - } - - - @Override - public Filter createFilter(String filter) throws InvalidSyntaxException { - // FIXME this will break service trackers if FrameworkUtil is mocked. - // The following call will return null if FrameworkUtil is mocked. - // that's a problem because this is meant to be used (mostly) in test - // environments and that's where FrameworkUtil is likely to be mocked. - return FrameworkUtil.createFilter(filter); - } - - @Override - public Object getService(ServiceReference reference) { - StubServiceReference ref = (StubServiceReference) reference; - ServiceInformation info = ref.getInformation(); - info.exportedReferences++; - return info.implementation; - } - - @Override - public boolean ungetService(ServiceReference reference) { - StubServiceReference ref = (StubServiceReference) reference; - ServiceInformation info = ref.getInformation(); - if (info.exportedReferences == 0) { - return false; - } - if (!registeredServices.contains(info)) { - return false; - } - info.exportedReferences--; - return true; - } - - @Override - public File getDataFile(String filename) { - throw new NotImplementedException(); - } - - /* - * Our custom methods - */ - public void setProperty(String key, String value) { - frameworkProperties.put(key, value); - } - - /** Set the context bundle */ - public void setBundle(Bundle bundle) { - this.contextBundle = bundle; - } - - /** Set the bundle associated with an id */ - public void setBundle(int i, Bundle bundle) { - bundles.add(i, bundle); - } - - public boolean isServiceRegistered(String serviceName, Class implementationClass) { - for (ServiceInformation info : registeredServices) { - for (String serviceInterface : (String[]) info.properties.get(Constants.OBJECTCLASS)) { - if (serviceInterface.equals(serviceName) - && info.implementation.getClass().equals(implementationClass)) { - return true; - } - } - } - return false; - } - - public Collection getAllServices() { - return registeredServices; - } - - public Collection getServiceListeners() { - return registeredListeners.keySet(); - } - - public void removeService(ServiceInformation info) { - if (!registeredServices.contains(info)) { - throw new IllegalArgumentException("service not registered"); - } - registeredServices.remove(info); - notifyServiceChange(new StubServiceReference(info, contextBundle), false); - } - - private void notifyServiceChange(ServiceReference serviceReference, boolean registered) { - int eventType = registered ? ServiceEvent.REGISTERED : ServiceEvent.UNREGISTERING; - ServiceEvent event = new ServiceEvent(eventType, serviceReference); - for (Entry entry : registeredListeners.entrySet()) { - ServiceListener listener = entry.getKey(); - Filter filter = entry.getValue(); - if (filter == null || filter.match(serviceReference)) { - listener.serviceChanged(event); - } - } - } - - public int getExportedServiceCount(ServiceRegistration registration) { - StubServiceRegistration reg = (StubServiceRegistration) registration; - return reg.getInfo().exportedReferences; - } - - -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/test/StubServiceReference.java --- a/common/core/src/main/java/com/redhat/thermostat/test/StubServiceReference.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.test; - -import java.util.ArrayList; -import java.util.Dictionary; -import java.util.Enumeration; -import java.util.List; - -import org.osgi.framework.Bundle; -import org.osgi.framework.Constants; -import org.osgi.framework.ServiceReference; - -import com.redhat.thermostat.common.NotImplementedException; -import com.redhat.thermostat.test.StubBundleContext.ServiceInformation; - -public class StubServiceReference implements ServiceReference { - - private final Bundle sourceBundle; - private final ServiceInformation information; - - public StubServiceReference(ServiceInformation info, Bundle sourceBundle) { - this.information = info; - this.sourceBundle = sourceBundle; - } - - @Override - public Object getProperty(String key) { - return information.properties.get(key); - } - - @Override - public String[] getPropertyKeys() { - Dictionary props = information.properties; - List toReturn = new ArrayList<>(props.size()); - Enumeration keyEnumeration = props.keys(); - while (keyEnumeration.hasMoreElements()) { - toReturn.add((String) keyEnumeration.nextElement()); - } - return toReturn.toArray(new String[0]); - } - - @Override - public Bundle getBundle() { - return sourceBundle; - } - - @Override - public Bundle[] getUsingBundles() { - throw new NotImplementedException(); - } - - @Override - public boolean isAssignableTo(Bundle bundle, String className) { - if (sourceBundle == bundle) { - return true; - } - throw new NotImplementedException(); - } - - @Override - public int compareTo(Object reference) { - if (!(reference instanceof ServiceReference)) { - throw new NotImplementedException(); - } - - ServiceReference ref = (ServiceReference) reference; - - Integer myRanking = (Integer) getProperty(Constants.SERVICE_RANKING); - Integer otherRanking = (Integer) ref.getProperty(Constants.SERVICE_RANKING); - - if (myRanking > otherRanking) { - return 1; - } else if (myRanking < otherRanking) { - return -1; - } else { - Integer myServiceId = (Integer) getProperty(Constants.SERVICE_ID); - Integer otherServiceId = (Integer) ref.getProperty(Constants.SERVICE_ID); - - if (myServiceId < otherServiceId) { - return 1; - } else if (myServiceId > otherServiceId) { - return -1; - } else { - return 0; - } - } - } - - public ServiceInformation getInformation() { - return information; - } - -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/main/java/com/redhat/thermostat/test/StubServiceRegistration.java --- a/common/core/src/main/java/com/redhat/thermostat/test/StubServiceRegistration.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.test; - -import java.util.Dictionary; - -import org.osgi.framework.ServiceReference; -import org.osgi.framework.ServiceRegistration; - -import com.redhat.thermostat.common.NotImplementedException; -import com.redhat.thermostat.test.StubBundleContext.ServiceInformation; - -public class StubServiceRegistration implements ServiceRegistration { - - private StubBundleContext bundleContext; - private ServiceInformation info; - - public StubServiceRegistration(StubBundleContext ctx, ServiceInformation info) { - this.bundleContext = ctx; - this.info = info; - } - - @Override - public ServiceReference getReference() { - return new StubServiceReference(info, bundleContext.getBundle()); - } - - @Override - public void setProperties(Dictionary properties) { - throw new NotImplementedException(); - } - - @Override - public void unregister() { - bundleContext.removeService(info); - } - - public ServiceInformation getInfo() { - return info; - } - -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/test/java/com/redhat/thermostat/common/DefaultHostsVMsLoaderTest.java --- a/common/core/src/test/java/com/redhat/thermostat/common/DefaultHostsVMsLoaderTest.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,109 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.Collection; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.redhat.thermostat.common.DefaultHostsVMsLoader; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; - -public class DefaultHostsVMsLoaderTest { - - private HostInfoDAO mockHostsDAO; - private VmInfoDAO mockVmsDAO; - private DefaultHostsVMsLoader loader; - - @Before - public void setUp() throws Exception { - mockHostsDAO = mock(HostInfoDAO.class); - mockVmsDAO = mock(VmInfoDAO.class); - } - - @After - public void tearDown() throws Exception { - mockHostsDAO = null; - mockVmsDAO = null; - loader = null; - } - - @Test - public void canGetHosts() { - Collection expectedHosts = new ArrayList<>(); - expectedHosts.add(new HostRef("123", "fluffhost1")); - expectedHosts.add(new HostRef("456", "fluffhost2")); - expectedHosts.add(new HostRef("007", "deadHost")); - - loader = new DefaultHostsVMsLoader(mockHostsDAO, mockVmsDAO, false); - when(mockHostsDAO.getHosts()).thenReturn(expectedHosts); - assertEquals(loader.getHosts(), expectedHosts); - - loader = new DefaultHostsVMsLoader(mockHostsDAO, mockVmsDAO, true); - Collection aliveHosts = new ArrayList<>(); - expectedHosts.add(new HostRef("123", "fluffhost1")); - expectedHosts.add(new HostRef("456", "fluffhost2")); - when(mockHostsDAO.getAliveHosts()).thenReturn(aliveHosts); - assertEquals(loader.getHosts(), aliveHosts); - } - - @Test - public void canGetVms() { - HostRef hostR = mock(HostRef.class); - Collection expectedVms = new ArrayList<>(); - expectedVms.add(new VmRef(hostR, 1, "test1")); - expectedVms.add(new VmRef(hostR, 2, "test2")); - - loader = new DefaultHostsVMsLoader(mockHostsDAO, mockVmsDAO, false /* irrelevant */); - when(mockVmsDAO.getVMs(hostR)).thenReturn(expectedVms); - assertEquals(loader.getVMs(hostR), expectedVms); - - assertEquals(0, loader.getVMs(mock(HostRef.class)).size()); - } - -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/test/java/com/redhat/thermostat/common/cli/BasicCommandTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/core/src/test/java/com/redhat/thermostat/common/cli/BasicCommandTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,100 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.common.cli; + +import static org.junit.Assert.assertNotNull; + +import org.apache.commons.cli.Options; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.redhat.thermostat.common.cli.BasicCommand; +import com.redhat.thermostat.common.cli.CommandContext; +import com.redhat.thermostat.common.cli.CommandException; + +public class BasicCommandTest { + + private BasicCommand application; + + @Before + public void setUp() { + application = new BasicCommand() { + + @Override + public void run(CommandContext ctx) throws CommandException { + // Nothing to do here. + } + + @Override + public String getName() { + return null; + } + + @Override + public String getDescription() { + return null; + } + + @Override + public String getUsage() { + return null; + } + + @Override + public Options getOptions() { + return new Options(); + } + + @Override + public boolean isStorageRequired() { + return false; + } + }; + } + + @After + public void tearDown() { + application = null; + } + + @Test + public void testNotfier() { + assertNotNull(application.getNotifier()); + } +} + diff -r 4290490a2e05 -r 186115da601f common/core/src/test/java/com/redhat/thermostat/common/dao/AgentInfoDAOTest.java --- a/common/core/src/test/java/com/redhat/thermostat/common/dao/AgentInfoDAOTest.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,258 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -import java.util.Collection; -import java.util.List; - -import org.junit.Before; -import org.junit.Test; - -import com.redhat.thermostat.storage.core.Category; -import com.redhat.thermostat.storage.core.Cursor; -import com.redhat.thermostat.storage.core.Key; -import com.redhat.thermostat.storage.core.Query; -import com.redhat.thermostat.storage.core.Query.Criteria; -import com.redhat.thermostat.storage.core.Remove; -import com.redhat.thermostat.storage.core.Replace; -import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.storage.core.Update; -import com.redhat.thermostat.storage.model.AgentInformation; - -public class AgentInfoDAOTest { - - private AgentInformation agentInfo1; - private AgentInformation agent1; - - @Before - public void setUp() { - agentInfo1 = new AgentInformation(); - agentInfo1.setAgentId("1234"); - agentInfo1.setAlive(true); - agentInfo1.setConfigListenAddress("foobar:666"); - agentInfo1.setStartTime(100); - agentInfo1.setStopTime(10); - - agent1 = new AgentInformation(); - agent1.setAgentId("1234"); - agent1.setAlive(true); - agent1.setConfigListenAddress("foobar:666"); - agent1.setStartTime(100); - agent1.setStopTime(10); - } - - @Test - public void verifyCategoryName() { - Category category = AgentInfoDAO.CATEGORY; - assertEquals("agent-config", category.getName()); - } - - @Test - public void verifyKeyNames() { - assertEquals("agentId", Key.AGENT_ID.getName()); - assertEquals("alive", AgentInfoDAO.ALIVE_KEY.getName()); - assertEquals("startTime", AgentInfoDAO.START_TIME_KEY.getName()); - assertEquals("stopTime", AgentInfoDAO.STOP_TIME_KEY.getName()); - assertEquals("configListenAddress", AgentInfoDAO.CONFIG_LISTEN_ADDRESS.getName()); - } - - @Test - public void verifyCategoryHasAllKeys() { - Collection> keys = AgentInfoDAO.CATEGORY.getKeys(); - - assertTrue(keys.contains(Key.AGENT_ID)); - assertTrue(keys.contains(AgentInfoDAO.ALIVE_KEY)); - assertTrue(keys.contains(AgentInfoDAO.START_TIME_KEY)); - assertTrue(keys.contains(AgentInfoDAO.STOP_TIME_KEY)); - assertTrue(keys.contains(AgentInfoDAO.CONFIG_LISTEN_ADDRESS)); - } - - @Test - public void verifyGetAllAgentInformationWithOneAgentInStorage() { - @SuppressWarnings("unchecked") - Cursor agentCursor = mock(Cursor.class); - when(agentCursor.hasNext()).thenReturn(true).thenReturn(false); - when(agentCursor.next()).thenReturn(agent1).thenReturn(null); - - Storage storage = mock(Storage.class); - Query query = mock(Query.class); - when(query.execute()).thenReturn(agentCursor); - when(storage.createQuery(any(Category.class))).thenReturn(query); - AgentInfoDAOImpl dao = new AgentInfoDAOImpl(storage); - - List allAgentInfo = dao.getAllAgentInformation(); - - assertEquals(1, allAgentInfo.size()); - - AgentInformation result = allAgentInfo.get(0); - AgentInformation expected = agentInfo1; - assertEquals(expected, result); - } - - @Test - public void verifyGetAliveAgent() { - @SuppressWarnings("unchecked") - Cursor agentCursor = mock(Cursor.class); - when(agentCursor.hasNext()).thenReturn(true).thenReturn(false); - when(agentCursor.next()).thenReturn(agent1).thenReturn(null); - - Query query = mock(Query.class); - Storage storage = mock(Storage.class); - when(storage.createQuery(any(Category.class))).thenReturn(query); - when(query.execute()).thenReturn(agentCursor); - - AgentInfoDAO dao = new AgentInfoDAOImpl(storage); - List aliveAgents = dao.getAliveAgents(); - - verify(storage).createQuery(AgentInfoDAO.CATEGORY); - verify(query).where(AgentInfoDAO.ALIVE_KEY, Criteria.EQUALS, true); - verify(query).execute(); - verifyNoMoreInteractions(query); - - assertEquals(1, aliveAgents.size()); - - AgentInformation result = aliveAgents.get(0); - AgentInformation expected = agentInfo1; - assertEquals(expected, result); - } - - @Test - public void verifyGetAgentInformationWhenStorageCantFindIt() { - HostRef agentRef = mock(HostRef.class); - - Query query = mock(Query.class); - Cursor cursor = mock(Cursor.class); - when(cursor.hasNext()).thenReturn(false); - when(cursor.next()).thenReturn(null); - when(query.execute()).thenReturn(cursor); - - Storage storage = mock(Storage.class); - when(storage.createQuery(any(Category.class))).thenReturn(query); - - AgentInfoDAO dao = new AgentInfoDAOImpl(storage); - - AgentInformation computed = dao.getAgentInformation(agentRef); - - assertEquals(null, computed); - } - - @Test - public void verifyGetAgentInformation() { - HostRef agentRef = mock(HostRef.class); - when(agentRef.getAgentId()).thenReturn(agentInfo1.getAgentId()); - - Storage storage = mock(Storage.class); - Query query = mock(Query.class); - when(storage.createQuery(any(Category.class))).thenReturn(query); - Cursor cursor = mock(Cursor.class); - when(cursor.hasNext()).thenReturn(true).thenReturn(false); - when(cursor.next()).thenReturn(agentInfo1).thenReturn(null); - when(query.execute()).thenReturn(cursor); - AgentInfoDAO dao = new AgentInfoDAOImpl(storage); - - AgentInformation computed = dao.getAgentInformation(agentRef); - - verify(storage).createQuery(AgentInfoDAO.CATEGORY); - verify(query).where(Key.AGENT_ID, Criteria.EQUALS, agentInfo1.getAgentId()); - verify(query).limit(1); - verify(query).execute(); - verifyNoMoreInteractions(query); - AgentInformation expected = agentInfo1; - assertSame(expected, computed); - } - - @Test - public void verifyAddAgentInformation() { - Storage storage = mock(Storage.class); - Replace replace = mock(Replace.class); - when(storage.createReplace(any(Category.class))).thenReturn(replace); - - AgentInfoDAO dao = new AgentInfoDAOImpl(storage); - - dao.addAgentInformation(agentInfo1); - - verify(storage).createReplace(AgentInfoDAO.CATEGORY); - verify(replace).setPojo(agentInfo1); - verify(replace).apply(); - } - - @Test - public void verifyUpdateAgentInformation() { - - Update mockUpdate = mock(Update.class); - Storage storage = mock(Storage.class); - when(storage.createUpdate(any(Category.class))).thenReturn(mockUpdate); - AgentInfoDAO dao = new AgentInfoDAOImpl(storage); - - dao.updateAgentInformation(agentInfo1); - - verify(storage).createUpdate(AgentInfoDAO.CATEGORY); - verify(mockUpdate).where(Key.AGENT_ID, "1234"); - verify(mockUpdate).set(AgentInfoDAO.START_TIME_KEY, 100L); - verify(mockUpdate).set(AgentInfoDAO.STOP_TIME_KEY, 10L); - verify(mockUpdate).set(AgentInfoDAO.CONFIG_LISTEN_ADDRESS, "foobar:666"); - verify(mockUpdate).set(AgentInfoDAO.ALIVE_KEY, true); - verify(mockUpdate).apply(); - verifyNoMoreInteractions(mockUpdate); - - } - - @Test - public void verifyRemoveAgentInformation() { - Remove mockRemove = QueryTestHelper.createMockRemove(); - Storage storage = mock(Storage.class); - when(storage.createRemove()).thenReturn(mockRemove); - AgentInfoDAO dao = new AgentInfoDAOImpl(storage); - - dao.removeAgentInformation(agentInfo1); - - verify(storage).removePojo(mockRemove); - verify(mockRemove).from(AgentInfoDAO.CATEGORY); - verify(mockRemove).where(Key.AGENT_ID, "1234"); - } - -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/test/java/com/redhat/thermostat/common/dao/BackendInfoDAOTest.java --- a/common/core/src/test/java/com/redhat/thermostat/common/dao/BackendInfoDAOTest.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,171 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.InOrder; - -import com.redhat.thermostat.storage.core.Add; -import com.redhat.thermostat.storage.core.Category; -import com.redhat.thermostat.storage.core.Cursor; -import com.redhat.thermostat.storage.core.Key; -import com.redhat.thermostat.storage.core.Query; -import com.redhat.thermostat.storage.core.Query.Criteria; -import com.redhat.thermostat.storage.core.Remove; -import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.storage.model.BackendInformation; - -public class BackendInfoDAOTest { - - private BackendInformation backendInfo1; - private BackendInformation backend1; - - @Before - public void setUp() { - - backendInfo1 = new BackendInformation(); - - backendInfo1.setName("backend-name"); - backendInfo1.setDescription("description"); - backendInfo1.setActive(true); - backendInfo1.setObserveNewJvm(true); - backendInfo1.setPids(new int[] { -1, 0, 1}); - backendInfo1.setOrderValue(100); - - backend1 = new BackendInformation(); - backend1.setName("backend-name"); - backend1.setDescription("description"); - backend1.setActive(true); - backend1.setObserveNewJvm(true); - backend1.setPids(new int[] { -1, 0, 1}); - backend1.setOrderValue(100); - } - - @Test - public void verifyCategoryName() { - Category c = BackendInfoDAO.CATEGORY; - assertEquals("backend-info", c.getName()); - } - - @Test - public void verifyCategoryHasAllKeys() { - Category c = BackendInfoDAO.CATEGORY; - Collection> keys = c.getKeys(); - - assertTrue(keys.contains(Key.AGENT_ID)); - assertTrue(keys.contains(BackendInfoDAO.BACKEND_NAME)); - assertTrue(keys.contains(BackendInfoDAO.BACKEND_DESCRIPTION)); - assertTrue(keys.contains(BackendInfoDAO.IS_ACTIVE)); - assertTrue(keys.contains(BackendInfoDAO.PIDS_TO_MONITOR)); - assertTrue(keys.contains(BackendInfoDAO.SHOULD_MONITOR_NEW_PROCESSES)); - assertTrue(keys.contains(BackendInfoDAO.ORDER_VALUE)); - } - - @Test - public void verifyAddBackendInformation() { - Storage storage = mock(Storage.class); - Add add = mock(Add.class); - when(storage.createAdd(any(Category.class))).thenReturn(add); - - BackendInfoDAO dao = new BackendInfoDAOImpl(storage); - - dao.addBackendInformation(backendInfo1); - - verify(storage).createAdd(BackendInfoDAO.CATEGORY); - verify(add).setPojo(backendInfo1); - verify(add).apply(); - } - - @Test - public void verifyGetBackendInformation() { - final String AGENT_ID = "agent-id"; - HostRef agentref = mock(HostRef.class); - when(agentref.getAgentId()).thenReturn(AGENT_ID); - - @SuppressWarnings("unchecked") - Cursor backendCursor = mock(Cursor.class); - when(backendCursor.hasNext()).thenReturn(true).thenReturn(false); - when(backendCursor.next()).thenReturn(backend1).thenReturn(null); - - Query query = mock(Query.class); - Storage storage = mock(Storage.class); - when(storage.createQuery(any(Category.class))).thenReturn(query); - when(query.execute()).thenReturn(backendCursor); - - BackendInfoDAO dao = new BackendInfoDAOImpl(storage); - - List result = dao.getBackendInformation(agentref); - - verify(storage).createQuery(BackendInfoDAO.CATEGORY); - verify(query).where(Key.AGENT_ID, Criteria.EQUALS, AGENT_ID); - verify(query).execute(); - verifyNoMoreInteractions(query); - - assertEquals(Arrays.asList(backendInfo1), result); - } - - @Test - public void verifyRemoveBackendInformation() { - Remove remove = QueryTestHelper.createMockRemove(); - Storage storage = mock(Storage.class); - when(storage.createRemove()).thenReturn(remove); - BackendInfoDAO dao = new BackendInfoDAOImpl(storage); - - dao.removeBackendInformation(backendInfo1); - - verify(storage).removePojo(remove); - InOrder inOrder = inOrder(remove); - inOrder.verify(remove).from(BackendInfoDAO.CATEGORY); - inOrder.verify(remove).where(BackendInfoDAO.BACKEND_NAME, "backend-name"); - } - -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/test/java/com/redhat/thermostat/common/dao/HostInfoDAOTest.java --- a/common/core/src/test/java/com/redhat/thermostat/common/dao/HostInfoDAOTest.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,341 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.atLeast; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.Arrays; -import java.util.Collection; - -import org.junit.Test; - -import com.redhat.thermostat.storage.core.Add; -import com.redhat.thermostat.storage.core.Category; -import com.redhat.thermostat.storage.core.Cursor; -import com.redhat.thermostat.storage.core.Key; -import com.redhat.thermostat.storage.core.Query; -import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.storage.model.AgentInformation; -import com.redhat.thermostat.storage.model.HostInfo; - - -public class HostInfoDAOTest { - - static class Pair { - final T first; - final U second; - - public Pair(T first, U second) { - this.first = first; - this.second = second; - } - } - - private static final String HOST_NAME = "a host name"; - private static final String OS_NAME = "some os"; - private static final String OS_KERNEL = "some kernel"; - private static final String CPU_MODEL = "some cpu that runs fast"; - private static final int CPU_NUM = -1; - private static final long MEMORY_TOTAL = 0xCAFEBABEl; - - @Test - public void testCategory() { - assertEquals("host-info", HostInfoDAO.hostInfoCategory.getName()); - Collection> keys = HostInfoDAO.hostInfoCategory.getKeys(); - assertTrue(keys.contains(new Key<>("agentId", true))); - assertTrue(keys.contains(new Key("hostname", true))); - assertTrue(keys.contains(new Key("osName", false))); - assertTrue(keys.contains(new Key("osKernel", false))); - assertTrue(keys.contains(new Key("cpuModel", false))); - assertTrue(keys.contains(new Key("cpuCount", false))); - assertTrue(keys.contains(new Key("totalMemory", false))); - assertEquals(7, keys.size()); - } - - @Test - public void testGetHostInfo() { - - Storage storage = mock(Storage.class); - Query query = mock(Query.class); - when(storage.createQuery(any(Category.class))).thenReturn(query); - HostInfo info = new HostInfo(HOST_NAME, OS_NAME, OS_KERNEL, CPU_MODEL, CPU_NUM, MEMORY_TOTAL); - Cursor cursor = mock(Cursor.class); - when(cursor.hasNext()).thenReturn(true).thenReturn(false); - when(cursor.next()).thenReturn(info).thenReturn(null); - when(query.execute()).thenReturn(cursor); - AgentInfoDAO agentInfoDao = mock(AgentInfoDAO.class); - - HostInfo result = new HostInfoDAOImpl(storage, agentInfoDao).getHostInfo(new HostRef("some uid", HOST_NAME)); - assertSame(result, info); - } - - @Test - public void testGetHostsSingleHost() { - - Storage storage = setupStorageForSingleHost(); - AgentInfoDAO agentInfo = mock(AgentInfoDAO.class); - - HostInfoDAO hostsDAO = new HostInfoDAOImpl(storage, agentInfo); - Collection hosts = hostsDAO.getHosts(); - - assertEquals(1, hosts.size()); - assertTrue(hosts.contains(new HostRef("123", "fluffhost1"))); - } - - private Storage setupStorageForSingleHost() { - - HostInfo hostConfig = new HostInfo("fluffhost1", OS_NAME, OS_KERNEL, CPU_MODEL, CPU_NUM, MEMORY_TOTAL); - hostConfig.setAgentId("123"); - - @SuppressWarnings("unchecked") - Cursor cursor = mock(Cursor.class); - when(cursor.hasNext()).thenReturn(true).thenReturn(false); - when(cursor.next()).thenReturn(hostConfig); - - Storage storage = mock(Storage.class); - Query query = mock(Query.class); - when(storage.createQuery(any(Category.class))).thenReturn(query); - when(query.execute()).thenReturn(cursor); - - return storage; - } - - @Test - public void testGetHosts3Hosts() { - - Storage storage = setupStorageFor3Hosts(); - AgentInfoDAO agentInfo = mock(AgentInfoDAO.class); - - HostInfoDAO hostsDAO = new HostInfoDAOImpl(storage, agentInfo); - Collection hosts = hostsDAO.getHosts(); - - assertEquals(3, hosts.size()); - assertTrue(hosts.contains(new HostRef("123", "fluffhost1"))); - assertTrue(hosts.contains(new HostRef("456", "fluffhost2"))); - assertTrue(hosts.contains(new HostRef("789", "fluffhost3"))); - } - - private Storage setupStorageFor3Hosts() { - - HostInfo hostConfig1 = new HostInfo("fluffhost1", OS_NAME, OS_KERNEL, CPU_MODEL, CPU_NUM, MEMORY_TOTAL); - hostConfig1.setAgentId("123"); - HostInfo hostConfig2 = new HostInfo("fluffhost2", OS_NAME, OS_KERNEL, CPU_MODEL, CPU_NUM, MEMORY_TOTAL); - hostConfig2.setAgentId("456"); - HostInfo hostConfig3 = new HostInfo("fluffhost3", OS_NAME, OS_KERNEL, CPU_MODEL, CPU_NUM, MEMORY_TOTAL); - hostConfig3.setAgentId("789"); - - - @SuppressWarnings("unchecked") - Cursor cursor = mock(Cursor.class); - when(cursor.hasNext()).thenReturn(true).thenReturn(true).thenReturn(true).thenReturn(false); - when(cursor.next()).thenReturn(hostConfig1).thenReturn(hostConfig2).thenReturn(hostConfig3); - - Storage storage = mock(Storage.class); - Query query = mock(Query.class); - when(storage.createQuery(any(Category.class))).thenReturn(query); - when(query.execute()).thenReturn(cursor); - - return storage; - } - - @Test - public void testPutHostInfo() { - Storage storage = mock(Storage.class); - Add add = mock(Add.class); - when(storage.createAdd(any(Category.class))).thenReturn(add); - - AgentInfoDAO agentInfo = mock(AgentInfoDAO.class); - - HostInfo info = new HostInfo(HOST_NAME, OS_NAME, OS_KERNEL, CPU_MODEL, CPU_NUM, MEMORY_TOTAL); - HostInfoDAO dao = new HostInfoDAOImpl(storage, agentInfo); - dao.putHostInfo(info); - - verify(storage).createAdd(HostInfoDAO.hostInfoCategory); - verify(add).setPojo(info); - verify(add).apply(); - } - - @Test - public void testGetCount() { - Storage storage = mock(Storage.class); - when(storage.getCount(any(Category.class))).thenReturn(5L); - AgentInfoDAO agentInfoDao = mock(AgentInfoDAO.class); - - HostInfoDAO dao = new HostInfoDAOImpl(storage, agentInfoDao); - Long count = dao.getCount(); - assertEquals((Long) 5L, count); - } - - @Test - public void getAliveHostSingle() { - Pair setup = setupForSingleAliveHost(); - Storage storage = setup.first; - AgentInfoDAO agentInfoDao = setup.second; - - HostInfoDAO hostsDAO = new HostInfoDAOImpl(storage, agentInfoDao); - Collection hosts = hostsDAO.getAliveHosts(); - - assertEquals(1, hosts.size()); - assertTrue(hosts.contains(new HostRef("123", "fluffhost1"))); - verify(storage).createQuery(HostInfoDAO.hostInfoCategory); - } - - private Pair setupForSingleAliveHost() { - - // agents - - AgentInformation agentConfig1 = new AgentInformation(); - agentConfig1.setAgentId("123"); - agentConfig1.setAlive(true); - - AgentInformation agentInfo1 = new AgentInformation(); - agentInfo1.setAgentId("123"); - agentInfo1.setAlive(true); - - // hosts - - HostInfo hostConfig1 = new HostInfo(); - hostConfig1.setHostname("fluffhost1"); - hostConfig1.setAgentId("123"); - - HostInfo hostConfig2 = new HostInfo(); - hostConfig2.setHostname("fluffhost2"); - hostConfig2.setAgentId("456"); - - // cursor - - @SuppressWarnings("unchecked") - Cursor cursor1 = mock(Cursor.class); - when(cursor1.hasNext()).thenReturn(true).thenReturn(false); - when(cursor1.next()).thenReturn(hostConfig1); - - // storage - - Storage storage = mock(Storage.class); - Query query = mock(Query.class); - - when(storage.createQuery(any(Category.class))).thenReturn(query); - when(query.execute()).thenReturn(cursor1); - - AgentInfoDAO agentDao = mock(AgentInfoDAO.class); - when(agentDao.getAliveAgents()).thenReturn(Arrays.asList(agentInfo1)); - - return new Pair<>(storage, agentDao); - } - - @Test - public void getAliveHost3() { - Pair setup = setupForAliveHost3(); - Storage storage = setup.first; - AgentInfoDAO agentInfoDao = setup.second; - - HostInfoDAO hostsDAO = new HostInfoDAOImpl(storage, agentInfoDao); - Collection hosts = hostsDAO.getAliveHosts(); - - // cursor 3 from the above storage should not be used - assertEquals(3, hosts.size()); - assertTrue(hosts.contains(new HostRef("123", "fluffhost1"))); - assertTrue(hosts.contains(new HostRef("456", "fluffhost2"))); - assertTrue(hosts.contains(new HostRef("678", "fluffhost3"))); - verify(storage, atLeast(3)).createQuery(HostInfoDAO.hostInfoCategory); - } - - private Pair setupForAliveHost3() { - - // agents - AgentInformation agentInfo1 = new AgentInformation(); - agentInfo1.setAgentId("123"); - agentInfo1.setAlive(true); - - AgentInformation agentInfo2 = new AgentInformation(); - agentInfo2.setAgentId("456"); - agentInfo2.setAlive(true); - - AgentInformation agentInfo3 = new AgentInformation(); - agentInfo3.setAgentId("678"); - agentInfo3.setAlive(true); - - // hosts - - HostInfo hostConfig1 = new HostInfo(); - hostConfig1.setHostname("fluffhost1"); - hostConfig1.setAgentId("123"); - - HostInfo hostConfig2 = new HostInfo(); - hostConfig2.setHostname("fluffhost2"); - hostConfig2.setAgentId("456"); - - HostInfo hostConfig3 = new HostInfo(); - hostConfig3.setHostname("fluffhost3"); - hostConfig3.setAgentId("678"); - - @SuppressWarnings("unchecked") - Cursor cursor1 = mock(Cursor.class); - when(cursor1.hasNext()).thenReturn(true).thenReturn(false); - when(cursor1.next()).thenReturn(hostConfig1); - - @SuppressWarnings("unchecked") - Cursor cursor2 = mock(Cursor.class); - when(cursor2.hasNext()).thenReturn(true).thenReturn(false); - when(cursor2.next()).thenReturn(hostConfig2); - - @SuppressWarnings("unchecked") - Cursor cursor3 = mock(Cursor.class); - when(cursor3.hasNext()).thenReturn(true).thenReturn(false); - when(cursor3.next()).thenReturn(hostConfig3); - - // storage - - Storage storage = mock(Storage.class); - Query query = mock(Query.class); - when(storage.createQuery(any(Category.class))).thenReturn(query); - when(query.execute()).thenReturn(cursor1).thenReturn(cursor2).thenReturn(cursor3); - - AgentInfoDAO agentDao = mock(AgentInfoDAO.class); - when(agentDao.getAliveAgents()).thenReturn(Arrays.asList(agentInfo1, agentInfo2, agentInfo3)); - - return new Pair<>(storage, agentDao); - } -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/test/java/com/redhat/thermostat/common/dao/HostLatestPojoListGetterTest.java --- a/common/core/src/test/java/com/redhat/thermostat/common/dao/HostLatestPojoListGetterTest.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,172 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -import java.util.List; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.redhat.thermostat.storage.core.Category; -import com.redhat.thermostat.storage.core.Cursor; -import com.redhat.thermostat.storage.core.Key; -import com.redhat.thermostat.storage.core.Query; -import com.redhat.thermostat.storage.core.Query.Criteria; -import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.storage.model.CpuStat; - -public class HostLatestPojoListGetterTest { - private static final String AGENT_ID = "agentid"; - private static final String HOSTNAME = "host.example.com"; - private static final String CATEGORY_NAME = "hostcategory"; - // Make this one static so we don't get IllegalStateException from trying - // to make category of same name while running tests in same classloader. - private static final Category cat = new Category<>(CATEGORY_NAME, CpuStat.class); - - private static long t1 = 1; - private static long t2 = 5; - private static long t3 = 10; - - private static Double load5_1 = 2.0; - private static Double load5_2 = 6.0; - private static Double load5_3 = 11.0; - - private static Double load10_1 = 3.0; - private static Double load10_2 = 7.0; - private static Double load10_3 = 12.0; - - private static Double load15_1 = 4.0; - private static Double load15_2 = 8.0; - private static Double load15_3 = 13.0; - - private HostRef ref; - private CpuStat result1, result2, result3; - - @Before - public void setUp() { - ref = new HostRef(AGENT_ID, HOSTNAME); - result1 = new CpuStat(t1, new double[] { load5_1, load10_1, load15_1 } ); - result2 = new CpuStat(t2, new double[] { load5_2, load10_2, load15_2 } ); - result3 = new CpuStat(t3, new double[] { load5_3, load10_3, load15_3 } ); - } - - @Test - public void testBuildQuery() { - Storage storage = mock(Storage.class); - Query query = mock(Query.class); - when (storage.createQuery(any(Category.class))).thenReturn(query); - - HostLatestPojoListGetter getter = new HostLatestPojoListGetter<>(storage, cat); - query = getter.buildQuery(ref, 123); - - assertNotNull(query); - verify(storage).createQuery(cat); - verify(query).where(Key.TIMESTAMP, Criteria.GREATER_THAN, 123l); - verify(query).where(Key.AGENT_ID, Criteria.EQUALS, AGENT_ID); - verify(query).sort(Key.TIMESTAMP, Query.SortDirection.DESCENDING); - verifyNoMoreInteractions(query); - } - - @Test - public void testBuildQueryPopulatesUpdateTimes() { - Storage storage = mock(Storage.class); - Query ignored = mock(Query.class); - Query query = mock(Query.class); - when(storage.createQuery(any(Category.class))).thenReturn(ignored).thenReturn(query); - - HostLatestPojoListGetter getter = new HostLatestPojoListGetter<>(storage, cat); - ignored = getter.buildQuery(ref,Long.MIN_VALUE); // Ignore first return value. - - query = getter.buildQuery(ref, Long.MIN_VALUE); - - assertNotNull(query); - verify(storage, times(2)).createQuery(cat); - verify(query).where(Key.AGENT_ID, Criteria.EQUALS, AGENT_ID); - verify(query).where(Key.TIMESTAMP, Criteria.GREATER_THAN, Long.MIN_VALUE); - verify(query).sort(Key.TIMESTAMP, Query.SortDirection.DESCENDING); - verifyNoMoreInteractions(query); - } - - @Test - public void testGetLatest() { - @SuppressWarnings("unchecked") - Cursor cursor = mock(Cursor.class); - when(cursor.hasNext()).thenReturn(true).thenReturn(true).thenReturn(false); - when(cursor.next()).thenReturn(result1).thenReturn(result2).thenReturn(null); - - Storage storage = mock(Storage.class); - Query query = mock(Query.class); - when(storage.createQuery(any(Category.class))).thenReturn(query); - when(query.execute()).thenReturn(cursor); - - HostLatestPojoListGetter getter = new HostLatestPojoListGetter<>(storage, cat); - - List stats = getter.getLatest(ref, Long.MIN_VALUE); - - verify(query).where(Key.AGENT_ID, Criteria.EQUALS, AGENT_ID); - verify(query).where(Key.TIMESTAMP, Criteria.GREATER_THAN, Long.MIN_VALUE); - - assertNotNull(stats); - assertEquals(2, stats.size()); - CpuStat stat1 = stats.get(0); - assertEquals(t1, stat1.getTimeStamp()); - assertArrayEquals(new double[] {load5_1, load10_1, load15_1}, stat1.getPerProcessorUsage(), 0.001); - CpuStat stat2 = stats.get(1); - assertEquals(t2, stat2.getTimeStamp()); - assertArrayEquals(new double[] {load5_2, load10_2, load15_2}, stat2.getPerProcessorUsage(), 0.001); - } - - @After - public void tearDown() { - ref = null; - result1 = null; - result2 = null; - result3 = null; - } -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/test/java/com/redhat/thermostat/common/dao/MongoDAOFactoryTest.java --- a/common/core/src/test/java/com/redhat/thermostat/common/dao/MongoDAOFactoryTest.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.junit.Before; -import org.junit.Test; - -import com.redhat.thermostat.storage.core.Connection; -import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.storage.core.StorageProvider; -import com.redhat.thermostat.test.StubBundleContext; - -public class MongoDAOFactoryTest { - - private StubBundleContext bundleContext; - private Storage storage; - private Connection connection; - private StorageProvider provider; - private DAOFactory daoFactory; - - @Before - public void setUp() { - bundleContext = new StubBundleContext(); - - storage = mock(Storage.class); - connection = mock(Connection.class); - when(storage.getConnection()).thenReturn(connection); - when(connection.isConnected()).thenReturn(true); - provider = mock(StorageProvider.class); - when(provider.createStorage()).thenReturn(storage); - daoFactory = new DAOFactoryImpl(bundleContext, provider); - ((DAOFactoryImpl)daoFactory).createDAOs(); - } - - @Test - public void testGetConnection() { - assertSame(storage, daoFactory.getStorage()); - } - - @Test - public void testGetAgentInfoDAO() { - AgentInfoDAO dao = daoFactory.getAgentInfoDAO(); - assertNotNull(dao); - } - - @Test - public void testGetBackendInfoDAO() { - BackendInfoDAO dao = daoFactory.getBackendInfoDAO(); - assertNotNull(dao); - } - - @Test - public void testGetVmInfoDAO() { - VmInfoDAO dao = daoFactory.getVmInfoDAO(); - assertNotNull(dao); - } - - @Test - public void testGetHostInfoDAO() { - HostInfoDAO dao = daoFactory.getHostInfoDAO(); - assertNotNull(dao); - } - - @Test - public void testGetNetworkInterfaceInfoDAO() { - NetworkInterfaceInfoDAO dao = daoFactory.getNetworkInterfaceInfoDAO(); - assertNotNull(dao); - } - - @Test - public void testServiceRegistration() { - assertEquals(0, bundleContext.getAllServices().size()); - - daoFactory.registerDAOsAndStorageAsOSGiServices(); - - // currently 6 DAOs and Storage are registered - assertEquals(6, bundleContext.getAllServices().size()); - } - - @Test - public void testServiceDeregistration() { - daoFactory.registerDAOsAndStorageAsOSGiServices(); - daoFactory.unregisterDAOsAndStorageAsOSGiServices(); - - assertEquals(0, bundleContext.getAllServices().size()); - assertEquals(0, bundleContext.getServiceListeners().size()); - } -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/test/java/com/redhat/thermostat/common/dao/NetworkInterfaceInfoDAOTest.java --- a/common/core/src/test/java/com/redhat/thermostat/common/dao/NetworkInterfaceInfoDAOTest.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,133 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -import java.util.Collection; -import java.util.List; - -import org.junit.Test; - -import com.redhat.thermostat.storage.core.Category; -import com.redhat.thermostat.storage.core.Cursor; -import com.redhat.thermostat.storage.core.Key; -import com.redhat.thermostat.storage.core.Query; -import com.redhat.thermostat.storage.core.Query.Criteria; -import com.redhat.thermostat.storage.core.Replace; -import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.storage.model.NetworkInterfaceInfo; - -public class NetworkInterfaceInfoDAOTest { - - private static final String INTERFACE_NAME = "some interface. maybe eth0"; - private static final String IPV4_ADDR = "256.256.256.256"; - private static final String IPV6_ADDR = "100:100:100::::1"; - - @Test - public void testCategory() { - Collection> keys; - - assertEquals("network-info", NetworkInterfaceInfoDAO.networkInfoCategory.getName()); - keys = NetworkInterfaceInfoDAO.networkInfoCategory.getKeys(); - assertTrue(keys.contains(new Key<>("agentId", true))); - assertTrue(keys.contains(new Key("interfaceName", true))); - assertTrue(keys.contains(new Key("ip4Addr", false))); - assertTrue(keys.contains(new Key("ip6Addr", false))); - assertEquals(4, keys.size()); - } - - @Test - public void testGetNetworkInterfaces() { - - NetworkInterfaceInfo niInfo = new NetworkInterfaceInfo(INTERFACE_NAME); - niInfo.setIp4Addr(IPV4_ADDR); - niInfo.setIp6Addr(IPV6_ADDR); - - @SuppressWarnings("unchecked") - Cursor cursor = mock(Cursor.class); - when(cursor.hasNext()).thenReturn(true).thenReturn(false); - when(cursor.next()).thenReturn(niInfo); - - Storage storage = mock(Storage.class); - Query query = mock(Query.class); - when(storage.createQuery(any(Category.class))).thenReturn(query); - when(query.execute()).thenReturn(cursor); - - HostRef hostRef = mock(HostRef.class); - when(hostRef.getAgentId()).thenReturn("system"); - - NetworkInterfaceInfoDAO dao = new NetworkInterfaceInfoDAOImpl(storage); - List netInfo = dao.getNetworkInterfaces(hostRef); - - verify(query).where(Key.AGENT_ID, Criteria.EQUALS, "system"); - verify(query).execute(); - verifyNoMoreInteractions(query); - - assertEquals(1, netInfo.size()); - - NetworkInterfaceInfo info = netInfo.get(0); - - assertEquals(INTERFACE_NAME, info.getInterfaceName()); - assertEquals(IPV4_ADDR, info.getIp4Addr()); - assertEquals(IPV6_ADDR, info.getIp6Addr()); - } - - @Test - public void testPutNetworkInterfaceInfo() { - Storage storage = mock(Storage.class); - Replace replace = mock(Replace.class); - when(storage.createReplace(any(Category.class))).thenReturn(replace); - - NetworkInterfaceInfo info = new NetworkInterfaceInfo(INTERFACE_NAME); - info.setIp4Addr(IPV4_ADDR); - info.setIp6Addr(IPV6_ADDR); - NetworkInterfaceInfoDAO dao = new NetworkInterfaceInfoDAOImpl(storage); - dao.putNetworkInterfaceInfo(info); - - verify(storage).createReplace(NetworkInterfaceInfoDAO.networkInfoCategory); - verify(replace).setPojo(info); - verify(replace).apply(); - } -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/test/java/com/redhat/thermostat/common/dao/QueryTestHelper.java --- a/common/core/src/test/java/com/redhat/thermostat/common/dao/QueryTestHelper.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - - -package com.redhat.thermostat.common.dao; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.redhat.thermostat.storage.core.Category; -import com.redhat.thermostat.storage.core.Key; -import com.redhat.thermostat.storage.core.Remove; - -public class QueryTestHelper { - - @SuppressWarnings("unchecked") - public static Remove createMockRemove() { - Remove mockRemove = mock(Remove.class); - when(mockRemove.from(any(Category.class))).thenReturn(mockRemove); - when(mockRemove.where(any(Key.class), any())).thenReturn(mockRemove); - return mockRemove; - } - -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/test/java/com/redhat/thermostat/common/dao/VmInfoDAOTest.java --- a/common/core/src/test/java/com/redhat/thermostat/common/dao/VmInfoDAOTest.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,286 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; - -import com.redhat.thermostat.storage.core.Category; -import com.redhat.thermostat.storage.core.Cursor; -import com.redhat.thermostat.storage.core.Key; -import com.redhat.thermostat.storage.core.Query; -import com.redhat.thermostat.storage.core.Replace; -import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.storage.core.Update; -import com.redhat.thermostat.storage.model.VmInfo; - -public class VmInfoDAOTest { - - private int vmId; - private long startTime; - private long stopTime; - private String jVersion; - private String jHome; - private String mainClass; - private String commandLine; - private String vmName; - private String vmInfo; - private String vmVersion; - private String vmArgs; - private Map props; - private Map env; - private String[] libs; - - @Before - public void setUp() { - vmId = 1; - startTime = 2; - stopTime = 3; - jVersion = "java 1.0"; - jHome = "/path/to/jdk/home"; - mainClass = "Hello.class"; - commandLine = "World"; - vmArgs = "-XX=+FastestJITPossible"; - vmName = "Hotspot"; - vmInfo = "Some info"; - vmVersion = "1.0"; - props = new HashMap<>(); - env = new HashMap<>(); - libs = new String[0]; - } - - @Test - public void testCategory() { - assertEquals("vm-info", VmInfoDAO.vmInfoCategory.getName()); - Collection> keys = VmInfoDAO.vmInfoCategory.getKeys(); - assertTrue(keys.contains(new Key<>("agentId", true))); - assertTrue(keys.contains(new Key("vmId", true))); - assertTrue(keys.contains(new Key("vmPid", false))); - assertTrue(keys.contains(new Key("javaVersion", false))); - assertTrue(keys.contains(new Key("javaHome", false))); - assertTrue(keys.contains(new Key("mainClass", false))); - assertTrue(keys.contains(new Key("javaCommandLine", false))); - assertTrue(keys.contains(new Key("vmArguments", false))); - assertTrue(keys.contains(new Key("vmName", false))); - assertTrue(keys.contains(new Key("vmInfo", false))); - assertTrue(keys.contains(new Key("vmVersion", false))); - assertTrue(keys.contains(new Key>("properties", false))); - assertTrue(keys.contains(new Key>("environment", false))); - assertTrue(keys.contains(new Key>("loadedNativeLibraries", false))); - assertTrue(keys.contains(new Key("startTimeStamp", false))); - assertTrue(keys.contains(new Key("stopTimeStamp", false))); - assertEquals(16, keys.size()); - } - - @Test - public void testGetVmInfo() { - - Storage storage = mock(Storage.class); - Query query = mock(Query.class); - when(storage.createQuery(any(Category.class))).thenReturn(query); - VmInfo expected = new VmInfo(vmId, startTime, stopTime, jVersion, jHome, mainClass, commandLine, vmName, vmInfo, vmVersion, vmArgs, props, env, libs); - Cursor cursor = mock(Cursor.class); - when(cursor.hasNext()).thenReturn(true).thenReturn(false); - when(cursor.next()).thenReturn(expected).thenReturn(null); - when(query.execute()).thenReturn(cursor); - - HostRef hostRef = mock(HostRef.class); - when(hostRef.getAgentId()).thenReturn("system"); - - VmRef vmRef = mock(VmRef.class); - when(vmRef.getAgent()).thenReturn(hostRef); - when(vmRef.getId()).thenReturn(321); - - VmInfoDAO dao = new VmInfoDAOImpl(storage); - VmInfo info = dao.getVmInfo(vmRef); - assertEquals(expected, info); - } - - @Test - public void testGetVmInfoUnknownVM() { - - Storage storage = mock(Storage.class); - Query query = mock(Query.class); - when(storage.createQuery(any(Category.class))).thenReturn(query); - Cursor cursor = mock(Cursor.class); - when(query.execute()).thenReturn(cursor); - - HostRef hostRef = mock(HostRef.class); - when(hostRef.getAgentId()).thenReturn("system"); - - VmRef vmRef = mock(VmRef.class); - when(vmRef.getAgent()).thenReturn(hostRef); - when(vmRef.getId()).thenReturn(321); - - VmInfoDAO dao = new VmInfoDAOImpl(storage); - try { - dao.getVmInfo(vmRef); - fail(); - } catch (DAOException ex) { - assertEquals("Unknown VM: host:system;vm:321", ex.getMessage()); - } - - } - - @Test - public void testSingleVM() { - Storage storage = setupStorageForSingleVM(); - VmInfoDAO dao = new VmInfoDAOImpl(storage); - HostRef host = new HostRef("123", "fluffhost"); - - Collection vms = dao.getVMs(host); - - assertCollection(vms, new VmRef(host, 123, "mainClass1")); - } - - private Storage setupStorageForSingleVM() { - - VmInfo vm1 = new VmInfo(); - vm1.setVmPid(123); - vm1.setMainClass("mainClass1"); - - @SuppressWarnings("unchecked") - Cursor singleVMCursor = mock(Cursor.class); - when(singleVMCursor.hasNext()).thenReturn(true).thenReturn(false); - when(singleVMCursor.next()).thenReturn(vm1); - - Storage storage = mock(Storage.class); - Query query = mock(Query.class); - when(storage.createQuery(any(Category.class))).thenReturn(query); - when(query.execute()).thenReturn(singleVMCursor); - return storage; - } - - @Test - public void testMultiVMs() { - Storage storage = setupStorageForMultiVM(); - VmInfoDAO dao = new VmInfoDAOImpl(storage); - - HostRef host = new HostRef("456", "fluffhost"); - - Collection vms = dao.getVMs(host); - - assertCollection(vms, new VmRef(host, 123, "mainClass1"), new VmRef(host, 456, "mainClass2")); - } - - private Storage setupStorageForMultiVM() { - - VmInfo vm1 = new VmInfo(); - vm1.setVmPid(123); - vm1.setMainClass("mainClass1"); - - VmInfo vm2 = new VmInfo(); - vm2.setVmPid(456); - vm2.setMainClass("mainClass2"); - - @SuppressWarnings("unchecked") - Cursor multiVMsCursor = mock(Cursor.class); - when(multiVMsCursor.hasNext()).thenReturn(true).thenReturn(true).thenReturn(false); - when(multiVMsCursor.next()).thenReturn(vm1).thenReturn(vm2); - - Storage storage = mock(Storage.class); - Query query = mock(Query.class); - when(storage.createQuery(any(Category.class))).thenReturn(query); - when(query.execute()).thenReturn(multiVMsCursor); - return storage; - } - - private void assertCollection(Collection vms, VmRef... expectedVMs) { - assertEquals(expectedVMs.length, vms.size()); - for (VmRef expectedVM : expectedVMs) { - assertTrue(vms.contains(expectedVM)); - } - } - - @Test - public void testGetCount() { - Storage storage = mock(Storage.class); - when(storage.getCount(any(Category.class))).thenReturn(5L); - VmInfoDAO dao = new VmInfoDAOImpl(storage); - Long count = dao.getCount(); - assertEquals((Long) 5L, count); - } - - @Test - public void testPutVmInfo() { - - Storage storage = mock(Storage.class); - Replace replace = mock(Replace.class); - when(storage.createReplace(any(Category.class))).thenReturn(replace); - - VmInfo info = new VmInfo(vmId, startTime, stopTime, jVersion, jHome, - mainClass, commandLine, vmName, vmInfo, vmVersion, vmArgs, - props, env, libs); - VmInfoDAO dao = new VmInfoDAOImpl(storage); - dao.putVmInfo(info); - - verify(storage).createReplace(VmInfoDAO.vmInfoCategory); - verify(replace).setPojo(info); - verify(replace).apply(); - } - - @Test - public void testPutVmStoppedTime() { - Update mockUpdate = mock(Update.class); - Storage storage = mock(Storage.class); - when(storage.createUpdate(any(Category.class))).thenReturn(mockUpdate); - - VmInfoDAO dao = new VmInfoDAOImpl(storage); - dao.putVmStoppedTime(vmId, stopTime); - - verify(storage).createUpdate(VmInfoDAO.vmInfoCategory); - verify(mockUpdate).where(Key.VM_ID, 1); - verify(mockUpdate).set(VmInfoDAO.stopTimeKey, 3L); - verify(mockUpdate).apply(); - verifyNoMoreInteractions(mockUpdate); - } -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/test/java/com/redhat/thermostat/common/dao/VmLatestPojoListGetterTest.java --- a/common/core/src/test/java/com/redhat/thermostat/common/dao/VmLatestPojoListGetterTest.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,165 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.dao; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -import java.util.List; - -import org.junit.Before; -import org.junit.Test; - -import com.redhat.thermostat.storage.core.Category; -import com.redhat.thermostat.storage.core.Cursor; -import com.redhat.thermostat.storage.core.Key; -import com.redhat.thermostat.storage.core.Query; -import com.redhat.thermostat.storage.core.Query.Criteria; -import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.storage.model.VmClassStat; - -public class VmLatestPojoListGetterTest { - private static final String AGENT_ID = "agentid"; - private static final String HOSTNAME = "host.example.com"; - private static final int VM_PID = 123; - private static final String MAIN_CLASS = "Foo.class"; - private static final String CATEGORY_NAME = "vmcategory"; - // Make this one static so we don't get IllegalStateException from trying - // to make category of same name while running tests in same classloader. - private static final Category cat = new Category<>(CATEGORY_NAME, VmClassStat.class); - - private static long t1 = 1; - private static long t2 = 5; - private static long t3 = 10; - - private static long lc1 = 10; - private static long lc2 = 20; - private static long lc3 = 30; - - private HostRef hostRef; - private VmRef vmRef; - private VmClassStat result1, result2, result3; - - @Before - public void setUp() { - hostRef = new HostRef(AGENT_ID, HOSTNAME); - vmRef = new VmRef(hostRef, VM_PID, MAIN_CLASS); - result1 = new VmClassStat(VM_PID, t1, lc1); - result2 = new VmClassStat(VM_PID, t2, lc2); - result3 = new VmClassStat(VM_PID, t3, lc3); - } - - @Test - public void testBuildQuery() { - Storage storage = mock(Storage.class); - Query query = mock(Query.class); - when(storage.createQuery(any(Category.class))).thenReturn(query); - - VmLatestPojoListGetter getter = new VmLatestPojoListGetter<>(storage, cat); - query = getter.buildQuery(vmRef, 123l); - - assertNotNull(query); - verify(storage).createQuery(cat); - verify(query).where(Key.AGENT_ID, Criteria.EQUALS, AGENT_ID); - verify(query).where(Key.VM_ID, Criteria.EQUALS, VM_PID); - verify(query).where(Key.TIMESTAMP, Criteria.GREATER_THAN, 123l); - verify(query).sort(Key.TIMESTAMP, Query.SortDirection.DESCENDING); - verifyNoMoreInteractions(query); - } - - @Test - public void testBuildQueryPopulatesUpdateTimes() { - Storage storage = mock(Storage.class); - Query ignored = mock(Query.class); - Query query = mock(Query.class); - when(storage.createQuery(any(Category.class))).thenReturn(ignored).thenReturn(query); - - VmLatestPojoListGetter getter = new VmLatestPojoListGetter<>(storage, cat); - getter.buildQuery(vmRef, Long.MIN_VALUE); // Ignore first return value. - query = getter.buildQuery(vmRef, Long.MIN_VALUE); - - assertNotNull(query); - verify(storage, times(2)).createQuery(cat); - verify(query).where(Key.AGENT_ID, Criteria.EQUALS, AGENT_ID); - verify(query).where(Key.VM_ID, Criteria.EQUALS, VM_PID); - verify(query).where(Key.TIMESTAMP, Criteria.GREATER_THAN, Long.MIN_VALUE); - verify(query).sort(Key.TIMESTAMP, Query.SortDirection.DESCENDING); - verifyNoMoreInteractions(query); - } - - @Test - public void testGetLatest() { - @SuppressWarnings("unchecked") - Cursor cursor = mock(Cursor.class); - when(cursor.hasNext()).thenReturn(true).thenReturn(true).thenReturn(false); - when(cursor.next()).thenReturn(result1).thenReturn(result2).thenReturn(null); - - Storage storage = mock(Storage.class); - Query query = mock(Query.class); - when(storage.createQuery(any(Category.class))).thenReturn(query); - when(query.execute()).thenReturn(cursor); - - VmLatestPojoListGetter getter = new VmLatestPojoListGetter<>(storage, cat); - - List stats = getter.getLatest(vmRef, t2); - - verify(storage).createQuery(cat); - verify(query).where(Key.AGENT_ID, Criteria.EQUALS, AGENT_ID); - verify(query).where(Key.VM_ID, Criteria.EQUALS, VM_PID); - verify(query).where(Key.TIMESTAMP, Criteria.GREATER_THAN, t2); - verify(query).sort(Key.TIMESTAMP, Query.SortDirection.DESCENDING); - verify(query).execute(); - verifyNoMoreInteractions(query); - - assertNotNull(stats); - assertEquals(2, stats.size()); - VmClassStat stat1 = stats.get(0); - assertEquals(t1, stat1.getTimeStamp()); - assertEquals(lc1, stat1.getLoadedClasses()); - VmClassStat stat2 = stats.get(1); - assertEquals(t2, stat2.getTimeStamp()); - assertEquals(lc2, stat2.getLoadedClasses()); - } - -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/test/java/com/redhat/thermostat/common/internal/DbServiceTest.java --- a/common/core/src/test/java/com/redhat/thermostat/common/internal/DbServiceTest.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,135 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.internal; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.osgi.framework.ServiceReference; - -import com.redhat.thermostat.common.DbService; -import com.redhat.thermostat.common.dao.DAOFactory; -import com.redhat.thermostat.storage.core.Connection; -import com.redhat.thermostat.test.StubBundleContext; - -public class DbServiceTest { - - private Connection connection; - private DAOFactory daoFactory; - private DbService dbService; - private StubBundleContext context; - - @Before - public void setup() { - context = new StubBundleContext(); - connection = mock(Connection.class); - - daoFactory = mock(DAOFactory.class); - when(daoFactory.getConnection()).thenReturn(connection); - - dbService = new DbServiceImpl(context, daoFactory, "http://someUrl.ignored.com"); - } - - @After - public void teardown() { - dbService = null; - context = null; - } - - @Test - public void testConnect() { - dbService.connect(); - - verify(connection).connect(); - verify(daoFactory).registerDAOsAndStorageAsOSGiServices(); - } - - @Test - public void testConnectRegistersDbService() { - dbService.connect(); - - verify(connection).connect(); - @SuppressWarnings("rawtypes") - ServiceReference dbServiceRef = context.getServiceReference(DbService.class); - // connect registers DbService - assertNotNull(dbServiceRef); - // make sure we really get the same instance - assertTrue(dbService.equals(context.getService(dbServiceRef))); - verify(daoFactory).registerDAOsAndStorageAsOSGiServices(); - } - - @Test - public void testDisconnect() { - dbService.connect(); - assertNotNull(context.getServiceReference(DbService.class)); - - dbService.disconnect(); - - verify(daoFactory).unregisterDAOsAndStorageAsOSGiServices(); - verify(connection).disconnect(); - } - - @Test - public void testDisconnectUnregistersService() { - dbService.connect(); - assertNotNull(context.getServiceReference(DbService.class)); - - dbService.disconnect(); - - verify(daoFactory).unregisterDAOsAndStorageAsOSGiServices(); - verify(connection).disconnect(); - // disconnect unregisters DbService - assertNull(context.getServiceReference(DbService.class)); - } - - @Test - public void canGetStorageUrl() { - String connectionURL = "http://test.example.com:8082"; - - dbService = new DbServiceImpl(context, null, connectionURL); - assertEquals(connectionURL, dbService.getConnectionUrl()); - } -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/test/java/com/redhat/thermostat/common/tools/BasicCommandTest.java --- a/common/core/src/test/java/com/redhat/thermostat/common/tools/BasicCommandTest.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.common.tools; - -import static org.junit.Assert.assertNotNull; - -import org.apache.commons.cli.Options; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.redhat.thermostat.common.cli.CommandContext; -import com.redhat.thermostat.common.cli.CommandException; -import com.redhat.thermostat.common.tools.BasicCommand; -import com.redhat.thermostat.storage.config.StartupConfiguration; - -public class BasicCommandTest { - - private BasicCommand application; - - @Before - public void setUp() { - application = new BasicCommand() { - - @Override - public void run(CommandContext ctx) throws CommandException { - // Nothing to do here. - } - - @Override - public String getName() { - return null; - } - - @Override - public String getDescription() { - return null; - } - - @Override - public String getUsage() { - return null; - } - - @Override - public StartupConfiguration getConfiguration() { - return null; - } - - @Override - public Options getOptions() { - return new Options(); - } - - @Override - public boolean isStorageRequired() { - return false; - } - }; - } - - @After - public void tearDown() { - application = null; - } - - @Test - public void testNotfier() { - assertNotNull(application.getNotifier()); - } -} - diff -r 4290490a2e05 -r 186115da601f common/core/src/test/java/com/redhat/thermostat/test/StubBundleContextTest.java --- a/common/core/src/test/java/com/redhat/thermostat/test/StubBundleContextTest.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,574 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.test; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.isA; -import static org.mockito.Mockito.atLeast; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; - -import java.io.ByteArrayInputStream; -import java.util.Collection; -import java.util.Hashtable; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleException; -import org.osgi.framework.BundleListener; -import org.osgi.framework.Constants; -import org.osgi.framework.Filter; -import org.osgi.framework.FrameworkListener; -import org.osgi.framework.InvalidSyntaxException; -import org.osgi.framework.ServiceEvent; -import org.osgi.framework.ServiceListener; -import org.osgi.framework.ServiceReference; -import org.osgi.framework.ServiceRegistration; - -import com.redhat.thermostat.common.NotImplementedException; -import com.redhat.thermostat.test.StubBundleContext.ServiceInformation; - -/** - * Test that StubBundleContext behaves like a BundleContext, based on what is - * specified in the OSGi spec. Other optional methods to help in testing are - * great, but adherence to spec is most important. - */ -public class StubBundleContextTest { - - private StubBundleContext bundleContext; - - @Before - public void setUp() { - bundleContext = new StubBundleContext(); - assertNotNull(bundleContext); - } - - @Test - public void testSetAndGetContextBundle() { - assertEquals(null, bundleContext.getBundle()); - - Bundle bundle = mock(Bundle.class); - bundleContext.setBundle(bundle); - assertSame(bundle, bundleContext.getBundle()); - } - - @Test(expected = NotImplementedException.class) - public void testInstallBundleFromLocation() throws BundleException { - bundleContext.installBundle(""); - } - - @Test(expected = NotImplementedException.class) - public void testInstallBundleFromInputStream() throws BundleException { - bundleContext.installBundle("", new ByteArrayInputStream(new byte[0])); - } - - @Test - public void testSetAndGetBundles() { - assertEquals(null, bundleContext.getBundle(0)); - - Bundle systemBundle = mock(Bundle.class); - bundleContext.setBundle(0, systemBundle); - - assertEquals(systemBundle, bundleContext.getBundle(0)); - - assertArrayEquals(new Bundle[] { systemBundle }, bundleContext.getBundles()); - } - - @Test(expected = NotImplementedException.class) - public void testGetBundleByLargeId() { - bundleContext.getBundle(Long.MAX_VALUE); - } - - @Test(expected = NotImplementedException.class) - public void testGetBundleByLocation() { - bundleContext.getBundle(""); - } - - @Test - public void testAddRemoveFrameworkListener() { - try { - bundleContext.addFrameworkListener(mock(FrameworkListener.class)); - fail("not expected"); - } catch (NotImplementedException notImplemented) { - /* okay: expected */ - } - - try { - bundleContext.removeFrameworkListener(mock(FrameworkListener.class)); - fail("not expected"); - } catch (NotImplementedException notImplemented) { - /* okay: expected */ - } - } - - @Test - public void testAddRemoveBundleListener() { - try { - bundleContext.addBundleListener(mock(BundleListener.class)); - fail("not expected"); - } catch (NotImplementedException notImplemented) { - /* okay: expected */ - } - - try { - bundleContext.removeBundleListener(mock(BundleListener.class)); - fail("not expected"); - } catch (NotImplementedException notImplemented) { - /* okay: expected */ - } - } - - @Test - public void testGetPropertyDelegatesToSystemProperties() { - assertEquals(System.getProperty("user.name"), bundleContext.getProperty("user.name")); - } - - @Test - public void testGetAndSetProperty() { - final String PROPERTY_NAME = "foo.bar.baz"; - final String PROPERTY_NEW_VALUE = "spam.eggs"; - - assertEquals(null, bundleContext.getProperty(PROPERTY_NAME)); - - bundleContext.setProperty(PROPERTY_NAME, PROPERTY_NEW_VALUE); - - assertEquals(PROPERTY_NEW_VALUE, bundleContext.getProperty(PROPERTY_NAME)); - } - - @Test - public void testFilterCreationReturnsASaneFilter() throws InvalidSyntaxException { - Filter filter = bundleContext.createFilter("(foo=bar)"); - assertNotNull(filter); - - Hashtable dict = new Hashtable<>(); - dict.put("foo", "bar"); - - assertTrue(filter.match(dict)); - } - - @Test - public void testAddRemoveService() { - TestService service = mock(TestService.class); - - assertEquals(0, bundleContext.getAllServices().size()); - assertFalse(bundleContext.isServiceRegistered(TestService.class.getName(), service.getClass())); - - ServiceRegistration registration = bundleContext.registerService(TestService.class, service, null); - - assertEquals(1, bundleContext.getAllServices().size()); - assertTrue(bundleContext.isServiceRegistered(TestService.class.getName(), service.getClass())); - - registration.unregister(); - - assertEquals(0, bundleContext.getAllServices().size()); - assertFalse(bundleContext.isServiceRegistered(TestService.class.getName(), service.getClass())); - } - - @Test(expected = IllegalArgumentException.class) - public void testAddServiceThatDoesNotImplementInterfaceClass() { - AnotherTestService service = mock(AnotherTestService.class); - - bundleContext.registerService(TestService.class.getName(), service, null); - } - - @Test(expected = IllegalArgumentException.class) - public void testAddServiceThatDoesNotImplementInterfaceClass2() { - AnotherTestService service = mock(AnotherTestService.class); - - bundleContext.registerService("foo.bar.Baz", service, null); - } - - @Test - public void testAddServiceWithProperties() { - TestService service = mock(TestService.class); - - Hashtable props = new Hashtable(); - props.put(Constants.SERVICE_ID, -10); - props.put(Constants.SERVICE_RANKING, 10); - props.put(Constants.OBJECTCLASS, AnotherTestService.class.getName()); - - ServiceRegistration reg = bundleContext.registerService(TestService.class, service, props); - - ServiceReference serviceRef = reg.getReference(); - - assertArrayEquals(new String[] { TestService.class.getName() }, - (String[]) serviceRef.getProperty(Constants.OBJECTCLASS)); - - assertEquals(10, serviceRef.getProperty(Constants.SERVICE_RANKING)); - assertEquals(0, serviceRef.getProperty(Constants.SERVICE_ID)); - } - - @Test - public void testAddServiceWithNonIntegerRanking() { - TestService service = mock(TestService.class); - - Hashtable props = new Hashtable(); - props.put(Constants.SERVICE_RANKING, new Object()); - - ServiceRegistration reg = bundleContext.registerService(TestService.class, service, props); - - ServiceReference serviceRef = reg.getReference(); - - assertEquals(0, serviceRef.getProperty(Constants.SERVICE_RANKING)); - } - - @Test(expected = IllegalArgumentException.class) - public void testRemoveUnknownService() { - bundleContext.removeService(new ServiceInformation(mock(TestService.class), new Hashtable())); - } - - @Test - public void testAddingAndRemovingListenerWorks() { - assertEquals(0, bundleContext.getServiceListeners().size()); - - ServiceListener listener = mock(ServiceListener.class); - - bundleContext.addServiceListener(listener); - - assertEquals(1, bundleContext.getServiceListeners().size()); - assertEquals(listener, bundleContext.getServiceListeners().toArray()[0]); - - bundleContext.removeServiceListener(listener); - - assertEquals(0, bundleContext.getServiceListeners().size()); - } - - @Test - public void testAddingSameListenerReplacedTheOldOne() { - assertEquals(0, bundleContext.getServiceListeners().size()); - - ServiceListener listener = mock(ServiceListener.class); - - bundleContext.addServiceListener(listener); - - assertEquals(1, bundleContext.getServiceListeners().size()); - - bundleContext.addServiceListener(listener); - - assertEquals(1, bundleContext.getServiceListeners().size()); - } - - @Test - public void testRemovingAnUnknownListenerIsANoOp() { - ServiceListener listener = mock(ServiceListener.class); - bundleContext.addServiceListener(listener); - assertEquals(1, bundleContext.getServiceListeners().size()); - - ServiceListener unknownListener = mock(ServiceListener.class); - bundleContext.removeServiceListener(unknownListener); - - assertEquals(1, bundleContext.getServiceListeners().size()); - } - - @Test - public void testServiceListenersWithoutFiltersWork() { - ServiceListener listener = mock(ServiceListener.class); - bundleContext.addServiceListener(listener); - - bundleContext.registerService(TestService.class, mock(TestService.class), null); - - assertListenerRecievedRegisteredEvent(listener); - } - - @Test - public void testServiceListenersWithFiltersWork() throws InvalidSyntaxException { - ServiceListener specificListener = mock(ServiceListener.class); - String specificFilter = "(" + Constants.OBJECTCLASS + "=" + TestService.class.getName() + ")"; - bundleContext.addServiceListener(specificListener, specificFilter); - - ServiceListener allListener = mock(ServiceListener.class); - String allListenerFilter = "(" + Constants.OBJECTCLASS + "=*)"; - bundleContext.addServiceListener(allListener, allListenerFilter); - - ServiceListener otherListener = mock(ServiceListener.class); - String otherListenerFilter = "(" + Constants.OBJECTCLASS + "=foo.bar.Baz)"; - bundleContext.addServiceListener(otherListener, otherListenerFilter); - - ServiceRegistration registration = bundleContext.registerService(TestService.class, mock(TestService.class), null); - - assertListenerRecievedRegisteredEvent(specificListener); - assertListenerRecievedRegisteredEvent(allListener); - - registration.unregister(); - - assertListenerRecievedUnregisteringEvent(specificListener); - assertListenerRecievedUnregisteringEvent(allListener); - - verify(otherListener, never()).serviceChanged(isA(ServiceEvent.class)); - - } - - private void assertListenerRecievedRegisteredEvent(ServiceListener listener) { - ArgumentCaptor eventCaptor = ArgumentCaptor.forClass(ServiceEvent.class); - verify(listener).serviceChanged(eventCaptor.capture()); - assertEquals(1, eventCaptor.getAllValues().size()); - ServiceEvent event = eventCaptor.getValue(); - assertEquals(ServiceEvent.REGISTERED, event.getType()); - ServiceReference ref = event.getServiceReference(); - assertTrue(ref instanceof StubServiceReference); - } - - private void assertListenerRecievedUnregisteringEvent(ServiceListener listener) { - ArgumentCaptor eventCaptor = ArgumentCaptor.forClass(ServiceEvent.class); - verify(listener, atLeast(1)).serviceChanged(eventCaptor.capture()); - - ServiceEvent event = eventCaptor.getValue(); - assertEquals(ServiceEvent.UNREGISTERING, event.getType()); - ServiceReference ref = event.getServiceReference(); - assertTrue(ref instanceof StubServiceReference); - } - - @Test - public void testGetServiceReferenceReturnsNullForNoMatch() { - assertNull(bundleContext.getServiceReference(TestService.class)); - } - - @Test - public void testGetServiceReferenceReturnsServiceWithHighestServiceRanking() { - TestService service1 = mock(TestService.class); - TestService service2 = mock(TestService.class); - - Hashtable service2Props = new Hashtable(); - service2Props.put(Constants.SERVICE_RANKING, 1000); - - bundleContext.registerService(TestService.class, service1, null); - bundleContext.registerService(TestService.class, service2, service2Props); - - ServiceReference ref = bundleContext.getServiceReference(TestService.class); - - assertSame(service2, bundleContext.getService(ref)); - } - - @Test - public void testGetServiceReferenceReturnsServiceWithLowerServiceId() { - TestService service1 = mock(TestService.class); - TestService service2 = mock(TestService.class); - - bundleContext.registerService(TestService.class, service1, null); - bundleContext.registerService(TestService.class, service2, null); - - ServiceReference ref = bundleContext.getServiceReference(TestService.class); - - assertSame(service1, bundleContext.getService(ref)); - } - - @Test - public void testGetServiceReferences() throws InvalidSyntaxException { - TestService service = mock(TestService.class); - - bundleContext.registerService(TestService.class, service, null); - bundleContext.registerService(AnotherTestService.class, mock(AnotherTestService.class), null); - - Collection refs = bundleContext.getServiceReferences(TestService.class, null); - - assertEquals(1, refs.size()); - assertEquals(service, ((StubServiceReference) refs.toArray()[0]).getInformation().implementation); - } - - @Test - public void testGetAllServiceReferencesNoMatch() throws InvalidSyntaxException { - TestService service = mock(TestService.class); - - bundleContext.registerService(TestService.class, service, null); - bundleContext.registerService(TestService.class, mock(TestService.class), null); - - ServiceReference[] refs = bundleContext.getAllServiceReferences(AnotherTestService.class.getName(), null); - - assertEquals(null, (Object) refs); - } - - @Test - public void testGetAllServiceReferencesWithoutFilter() throws InvalidSyntaxException { - TestService service = mock(TestService.class); - - bundleContext.registerService(TestService.class, service, null); - bundleContext.registerService(AnotherTestService.class, mock(AnotherTestService.class), null); - - ServiceReference[] refs = bundleContext.getAllServiceReferences(TestService.class.getName(), null); - - assertEquals(1, refs.length); - assertEquals(service, ((StubServiceReference) refs[0]).getInformation().implementation); - } - - @Test - public void testGetAllServiceReferencesWithFilter() throws InvalidSyntaxException { - TestService service = mock(TestService.class); - - bundleContext.registerService(TestService.class, service, null); - bundleContext.registerService(AnotherTestService.class, mock(AnotherTestService.class), null); - - String filter = "(" + Constants.OBJECTCLASS + "=" + TestService.class.getName() + ")"; - ServiceReference[] refs = bundleContext.getAllServiceReferences(TestService.class.getName(), filter); - - assertEquals(1, refs.length); - assertEquals(service, ((StubServiceReference) refs[0]).getInformation().implementation); - } - - @Test - public void testGetAllServiceReferencesWithNoClassNameJustFilter() throws InvalidSyntaxException { - TestService service = mock(TestService.class); - - bundleContext.registerService(TestService.class, service, null); - bundleContext.registerService(AnotherTestService.class, mock(AnotherTestService.class), null); - - String filter = "(" + Constants.OBJECTCLASS + "=" + TestService.class.getName() + ")"; - ServiceReference[] refs = bundleContext.getAllServiceReferences(null, filter); - - assertEquals(1, refs.length); - assertEquals(service, ((StubServiceReference) refs[0]).getInformation().implementation); - } - - @Test - public void testGetServiceUsingClassObject() { - TestService service = mock(TestService.class); - - bundleContext.registerService(TestService.class, service, null); - - ServiceReference ref = bundleContext.getServiceReference(TestService.class); - assertNotNull(ref); - - Object returnedService = bundleContext.getService(ref); - - assertSame(service, returnedService); - } - - @Test - public void testGetServiceUsingClassName() { - TestService service = mock(TestService.class); - - bundleContext.registerService(TestService.class, service, null); - - ServiceReference ref = bundleContext.getServiceReference(TestService.class.getName()); - assertNotNull(ref); - - Object returnedService = bundleContext.getService(ref); - - assertSame(service, returnedService); - } - - @Test - public void testUngetService() { - bundleContext.registerService(TestService.class, mock(TestService.class), null); - - ServiceReference ref = bundleContext.getServiceReference(TestService.class.getName()); - Object returnedService = bundleContext.getService(ref); - - assertTrue(bundleContext.ungetService(ref)); - - assertFalse(bundleContext.ungetService(ref)); - } - - @Test - public void testUngetServiceOnUnregisteredService() { - ServiceRegistration registration = bundleContext.registerService(TestService.class, mock(TestService.class), null); - - ServiceReference ref = bundleContext.getServiceReference(TestService.class.getName()); - Object returnedService = bundleContext.getService(ref); - - registration.unregister(); - - assertFalse(bundleContext.ungetService(ref)); - } - - @Test - public void testReferenceExportCountIsCorrect() { - TestService service = mock(TestService.class); - - ServiceRegistration reg = bundleContext.registerService(TestService.class, service, null); - - ServiceReference ref = bundleContext.getServiceReference(TestService.class); - assertNotNull(ref); - - assertEquals(0, bundleContext.getExportedServiceCount(reg)); - - Object returnedService = bundleContext.getService(ref); - - assertEquals(1, bundleContext.getExportedServiceCount(reg)); - - bundleContext.ungetService(ref); - - assertEquals(0, bundleContext.getExportedServiceCount(reg)); - } - - @Test(expected = NotImplementedException.class) - public void testGetDataFile() { - bundleContext.getDataFile(""); - } - - @Test - public void testIsServiceRegisteredForRegisteredService() { - ComplexService service = mock(ComplexService.class); - - String[] ifaces = new String[] { TestService.class.getName(), AnotherTestService.class.getName() }; - ServiceRegistration reg = bundleContext.registerService(ifaces, service, null); - - assertTrue(bundleContext.isServiceRegistered(AnotherTestService.class.getName(), service.getClass())); - - } - - @Test - public void testIsServiceRegisteredForUnregisteredService() { - ComplexService service = mock(ComplexService.class); - TestService someOtherService = mock(TestService.class); - - String[] ifaces = new String[] { TestService.class.getName(), AnotherTestService.class.getName() }; - ServiceRegistration reg = bundleContext.registerService(ifaces, service, null); - - assertFalse(bundleContext.isServiceRegistered(AnotherTestService.class.getName(), someOtherService.getClass())); - } - - /* - * Dummy service interfaces - */ - - static interface TestService { /* just a marker */} - - static interface AnotherTestService { /* just a marker */} - - static interface ComplexService extends TestService, AnotherTestService { /* ditto */} -} - diff -r 4290490a2e05 -r 186115da601f common/test/pom.xml --- a/common/test/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/common/test/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -53,13 +53,17 @@ - com.redhat.thermostat - thermostat-common-core - ${project.version} + junit + junit - junit - junit + org.apache.felix + org.apache.felix.framework + + + org.mockito + mockito-core + test @@ -74,8 +78,7 @@ Red Hat, Inc. com.redhat.thermostat.common.test - com.redhat.thermostat.test.cli, - com.redhat.thermostat.test.locale + com.redhat.thermostat.testutils <_nouses>true diff -r 4290490a2e05 -r 186115da601f common/test/src/main/java/com/redhat/thermostat/test/cli/TestCommand.java --- a/common/test/src/main/java/com/redhat/thermostat/test/cli/TestCommand.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,140 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.test.cli; - -import org.apache.commons.cli.Option; -import org.apache.commons.cli.Options; - -import com.redhat.thermostat.common.cli.Command; -import com.redhat.thermostat.common.cli.CommandContext; -import com.redhat.thermostat.common.cli.CommandException; - - -public class TestCommand implements Command { - - private String name; - private Handle handle; - private String description; - private String usage; - private boolean storageRequired; - private boolean availableInShell = true; - private boolean availableOutsideShell = true; - - private Options options = new Options(); - - public static interface Handle { - public void run(CommandContext ctx) throws CommandException; - } - - public TestCommand(String name) { - this(name, null); - } - - public TestCommand(String name, Handle r) { - this.name = name; - this.handle = r; - } - - @Override - public void run(CommandContext ctx) throws CommandException { - if (handle != null) { - handle.run(ctx); - } - } - - @Override - public String getName() { - return name; - } - - @Override - public String getDescription() { - return description; - } - - public void setDescription(String desc) { - description = desc; - } - - @Override - public String getUsage() { - return usage; - } - - public void setUsage(String usage) { - this.usage = usage; - } - - @Override - public Options getOptions() { - return options; - } - - public void addOptions(Option... options) { - for (Option option : options) { - this.options.addOption(option); - } - } - - @Override - public boolean isStorageRequired() { - return storageRequired; - } - - public void setStorageRequired(boolean storageRequired) { - this.storageRequired = storageRequired; - } - - @Override - public boolean isAvailableInShell() { - return availableInShell; - } - - void setAvailableInShell(boolean avaiable) { - this.availableInShell = avaiable; - } - - @Override - public boolean isAvailableOutsideShell() { - return availableOutsideShell; - } - - void setAvailableOutsideShell(boolean available) { - this.availableOutsideShell = available; - } -} - diff -r 4290490a2e05 -r 186115da601f common/test/src/main/java/com/redhat/thermostat/test/locale/AbstractLocaleResourcesTest.java --- a/common/test/src/main/java/com/redhat/thermostat/test/locale/AbstractLocaleResourcesTest.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.test.locale; - -import java.io.IOException; -import java.util.Properties; - -import org.junit.Assert; -import org.junit.Test; - -public abstract class AbstractLocaleResourcesTest> { - - @Test - public void testLocalizedStringsArePresent() throws IOException { - - String stringsResource = "/" + getResourceBundle().replace(".", "/") + ".properties"; - - Properties props = new Properties(); - props.load(getClass().getResourceAsStream(stringsResource)); - - Assert.assertEquals(values().length, props.values().size()); - for (T resource : values()) { - Assert.assertTrue("missing property from resource bound file: " + resource, - props.containsKey(resource.name())); - } - } - - private T[] values() { - return getEnumClass().getEnumConstants(); - } - - protected abstract Class getEnumClass(); - - protected abstract String getResourceBundle(); - -} - diff -r 4290490a2e05 -r 186115da601f common/test/src/main/java/com/redhat/thermostat/testutils/AbstractLocaleResourcesTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/test/src/main/java/com/redhat/thermostat/testutils/AbstractLocaleResourcesTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,71 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.testutils; + +import java.io.IOException; +import java.util.Properties; + +import org.junit.Assert; +import org.junit.Test; + +public abstract class AbstractLocaleResourcesTest> { + + @Test + public void testLocalizedStringsArePresent() throws IOException { + + String stringsResource = "/" + getResourceBundle().replace(".", "/") + ".properties"; + + Properties props = new Properties(); + props.load(getClass().getResourceAsStream(stringsResource)); + + Assert.assertEquals(values().length, props.values().size()); + for (T resource : values()) { + Assert.assertTrue("missing property from resource bound file: " + resource, + props.containsKey(resource.name())); + } + } + + private T[] values() { + return getEnumClass().getEnumConstants(); + } + + protected abstract Class getEnumClass(); + + protected abstract String getResourceBundle(); + +} + diff -r 4290490a2e05 -r 186115da601f common/test/src/main/java/com/redhat/thermostat/testutils/NotImplementedException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/test/src/main/java/com/redhat/thermostat/testutils/NotImplementedException.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,55 @@ +/* + * Copyright 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.testutils; + +public class NotImplementedException extends RuntimeException { + + private static final long serialVersionUID = -1620198443624195618L; + + public NotImplementedException() { + super(); + } + + public NotImplementedException(String message) { + super(message); + } + + public NotImplementedException(String message, Throwable cause) { + super(message, cause); + } + +} diff -r 4290490a2e05 -r 186115da601f common/test/src/main/java/com/redhat/thermostat/testutils/StubBundleContext.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/test/src/main/java/com/redhat/thermostat/testutils/StubBundleContext.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,402 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.testutils; + +import java.io.File; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Dictionary; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleException; +import org.osgi.framework.BundleListener; +import org.osgi.framework.Constants; +import org.osgi.framework.Filter; +import org.osgi.framework.FrameworkListener; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceEvent; +import org.osgi.framework.ServiceFactory; +import org.osgi.framework.ServiceListener; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.ServiceRegistration; + +/** + * An implementation of BundleContext that's useful for writing unit tests. + *

+ * WARNING: if you static mock {@link FrameworkUtil#createFilter(String)}, you + * are going to have a bad time. + */ +public class StubBundleContext implements BundleContext { + + static class ServiceInformation { + public Object implementation; + public Dictionary properties; + public int exportedReferences; + + public ServiceInformation(Object impl, Dictionary props) { + this.implementation = impl; + this.properties = props; + } + } + + private int nextServiceId = 0; + + private Map frameworkProperties = new HashMap<>(); + private List bundles = new ArrayList<>(); + private List registeredServices = new ArrayList<>(); + private Map registeredListeners = new HashMap<>(); + private Bundle contextBundle = null; + + /* + * Interface methods + */ + + @Override + public String getProperty(String key) { + String result = null; + result = frameworkProperties.get(key); + if (result == null) { + result = System.getProperty(key); + } + return result; + } + + @Override + public Bundle getBundle() { + return contextBundle; + } + + @Override + public Bundle installBundle(String location, InputStream input) throws BundleException { + throw new NotImplementedException(); + } + + @Override + public Bundle installBundle(String location) throws BundleException { + throw new NotImplementedException(); + } + + @Override + public Bundle getBundle(long id) { + if (id > Integer.MAX_VALUE) { + throw new NotImplementedException(); + } + if (id >= bundles.size()) { + return null; + } + + return bundles.get((int) id); + } + + @Override + public Bundle getBundle(String location) { + throw new NotImplementedException(); + } + + @Override + public Bundle[] getBundles() { + return bundles.toArray(new Bundle[bundles.size()]); + } + + @Override + public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException { + registeredListeners.put(listener, filter == null ? null : createFilter(filter)); + } + + @Override + public void addServiceListener(ServiceListener listener) { + try { + addServiceListener(listener, null); + } catch (InvalidSyntaxException e) { + throw new AssertionError("a null filter can not have invalid systax"); + } + } + + @Override + public void removeServiceListener(ServiceListener listener) { + registeredListeners.remove(listener); + } + + @Override + public void addBundleListener(BundleListener listener) { + throw new NotImplementedException(); + } + + @Override + public void removeBundleListener(BundleListener listener) { + throw new NotImplementedException(); + } + + @Override + public void addFrameworkListener(FrameworkListener listener) { + throw new NotImplementedException(); + } + + @Override + public void removeFrameworkListener(FrameworkListener listener) { + throw new NotImplementedException(); + } + + @Override + public ServiceRegistration registerService(Class clazz, Object service, Dictionary properties) { + return registerService(clazz.getName(), service, properties); + } + + @Override + public ServiceRegistration registerService(String className, Object service, Dictionary properties) { + return registerService(new String[] { className }, service, properties); + } + + @Override + public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties) { + if (service instanceof ServiceFactory) { + throw new NotImplementedException("support for service factories is not implemented"); + } + + for (String className : clazzes) { + try { + Class clazz = Class.forName(className); + if (!clazz.isAssignableFrom(service.getClass())) { + throw new IllegalArgumentException("service is not a subclass of " + className); + } + } catch (ClassNotFoundException classNotFound) { + throw new IllegalArgumentException("not a valid class: " + className); + } + } + + Object specifiedRanking = null; + Hashtable newProperties = new Hashtable<>(); + if (properties != null) { + Enumeration enumeration = properties.keys(); + while (enumeration.hasMoreElements()) { + Object key = enumeration.nextElement(); + newProperties.put((String)key, properties.get(key)); + } + specifiedRanking = properties.get(Constants.SERVICE_RANKING); + } + + newProperties.put(Constants.OBJECTCLASS, clazzes); + newProperties.put(Constants.SERVICE_ID, nextServiceId); + nextServiceId++; + if (specifiedRanking == null || !(specifiedRanking instanceof Integer)) { + specifiedRanking = 0; + } + newProperties.put(Constants.SERVICE_RANKING, (Integer) specifiedRanking); + + ServiceInformation info = new ServiceInformation(service, newProperties); + registeredServices.add(info); + + notifyServiceChange(new StubServiceReference(info, contextBundle), true); + + return new StubServiceRegistration(this, info); + } + + @Override + public ServiceReference getServiceReference(Class clazz) { + return getServiceReference(clazz.getName()); + } + + @Override + public ServiceReference getServiceReference(String clazz) { + try { + ServiceReference[] initial = getServiceReferences(clazz, null); + if (initial == null) { + return null; + } + + Arrays.sort(initial); + return initial[initial.length-1]; + } catch (InvalidSyntaxException invalidFilterSyntax) { + throw new AssertionError("a null filter can not have an invalid syntax"); + } + } + + @Override + public Collection getServiceReferences(Class clazz, String filter) throws InvalidSyntaxException { + return Arrays.asList(getServiceReferences(clazz.getName(), filter)); + } + + @Override + public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException { + ServiceReference[] allRefs = getAllServiceReferences(clazz, filter); + if (allRefs == null) { + return null; + } + + List result = new ArrayList<>(); + for (ServiceReference ref : allRefs) { + if (ref.isAssignableTo(contextBundle, clazz)) { + result.add(ref); + } + } + return result.toArray(new ServiceReference[0]); + } + + @Override + public ServiceReference[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException { + List toReturn = new ArrayList<>(); + + Filter toMatch = (filter == null) ? null : createFilter(filter); + + for (ServiceInformation info : registeredServices) { + for (String serviceInterface : (String[]) info.properties.get(Constants.OBJECTCLASS)) { + if (clazz == null || serviceInterface.equals(clazz)) { + if (toMatch == null || toMatch.match(info.properties)) { + toReturn.add(new StubServiceReference(info, contextBundle)); + } + } + } + } + + if (toReturn.size() == 0) { + return null; + } + return toReturn.toArray(new ServiceReference[0]); + } + + + @Override + public Filter createFilter(String filter) throws InvalidSyntaxException { + // FIXME this will break service trackers if FrameworkUtil is mocked. + // The following call will return null if FrameworkUtil is mocked. + // that's a problem because this is meant to be used (mostly) in test + // environments and that's where FrameworkUtil is likely to be mocked. + return FrameworkUtil.createFilter(filter); + } + + @Override + public Object getService(ServiceReference reference) { + StubServiceReference ref = (StubServiceReference) reference; + ServiceInformation info = ref.getInformation(); + info.exportedReferences++; + return info.implementation; + } + + @Override + public boolean ungetService(ServiceReference reference) { + StubServiceReference ref = (StubServiceReference) reference; + ServiceInformation info = ref.getInformation(); + if (info.exportedReferences == 0) { + return false; + } + if (!registeredServices.contains(info)) { + return false; + } + info.exportedReferences--; + return true; + } + + @Override + public File getDataFile(String filename) { + throw new NotImplementedException(); + } + + /* + * Our custom methods + */ + public void setProperty(String key, String value) { + frameworkProperties.put(key, value); + } + + /** Set the context bundle */ + public void setBundle(Bundle bundle) { + this.contextBundle = bundle; + } + + /** Set the bundle associated with an id */ + public void setBundle(int i, Bundle bundle) { + bundles.add(i, bundle); + } + + public boolean isServiceRegistered(String serviceName, Class implementationClass) { + for (ServiceInformation info : registeredServices) { + for (String serviceInterface : (String[]) info.properties.get(Constants.OBJECTCLASS)) { + if (serviceInterface.equals(serviceName) + && info.implementation.getClass().equals(implementationClass)) { + return true; + } + } + } + return false; + } + + public Collection getAllServices() { + return registeredServices; + } + + public Collection getServiceListeners() { + return registeredListeners.keySet(); + } + + public void removeService(ServiceInformation info) { + if (!registeredServices.contains(info)) { + throw new IllegalArgumentException("service not registered"); + } + registeredServices.remove(info); + notifyServiceChange(new StubServiceReference(info, contextBundle), false); + } + + private void notifyServiceChange(ServiceReference serviceReference, boolean registered) { + int eventType = registered ? ServiceEvent.REGISTERED : ServiceEvent.UNREGISTERING; + ServiceEvent event = new ServiceEvent(eventType, serviceReference); + for (Entry entry : registeredListeners.entrySet()) { + ServiceListener listener = entry.getKey(); + Filter filter = entry.getValue(); + if (filter == null || filter.match(serviceReference)) { + listener.serviceChanged(event); + } + } + } + + public int getExportedServiceCount(ServiceRegistration registration) { + StubServiceRegistration reg = (StubServiceRegistration) registration; + return reg.getInfo().exportedReferences; + } + + +} + diff -r 4290490a2e05 -r 186115da601f common/test/src/main/java/com/redhat/thermostat/testutils/StubServiceReference.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/test/src/main/java/com/redhat/thermostat/testutils/StubServiceReference.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,129 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.testutils; + +import java.util.ArrayList; +import java.util.Dictionary; +import java.util.Enumeration; +import java.util.List; + +import org.osgi.framework.Bundle; +import org.osgi.framework.Constants; +import org.osgi.framework.ServiceReference; + +import com.redhat.thermostat.testutils.StubBundleContext.ServiceInformation; + +@SuppressWarnings({"rawtypes"}) +public class StubServiceReference implements ServiceReference { + + private final Bundle sourceBundle; + private final ServiceInformation information; + + public StubServiceReference(ServiceInformation info, Bundle sourceBundle) { + this.information = info; + this.sourceBundle = sourceBundle; + } + + @Override + public Object getProperty(String key) { + return information.properties.get(key); + } + + @Override + public String[] getPropertyKeys() { + Dictionary props = information.properties; + List toReturn = new ArrayList<>(props.size()); + Enumeration keyEnumeration = props.keys(); + while (keyEnumeration.hasMoreElements()) { + toReturn.add((String) keyEnumeration.nextElement()); + } + return toReturn.toArray(new String[0]); + } + + @Override + public Bundle getBundle() { + return sourceBundle; + } + + @Override + public Bundle[] getUsingBundles() { + throw new NotImplementedException(); + } + + @Override + public boolean isAssignableTo(Bundle bundle, String className) { + if (sourceBundle == bundle) { + return true; + } + throw new NotImplementedException(); + } + + @Override + public int compareTo(Object reference) { + if (!(reference instanceof ServiceReference)) { + throw new NotImplementedException(); + } + + ServiceReference ref = (ServiceReference) reference; + + Integer myRanking = (Integer) getProperty(Constants.SERVICE_RANKING); + Integer otherRanking = (Integer) ref.getProperty(Constants.SERVICE_RANKING); + + if (myRanking > otherRanking) { + return 1; + } else if (myRanking < otherRanking) { + return -1; + } else { + Integer myServiceId = (Integer) getProperty(Constants.SERVICE_ID); + Integer otherServiceId = (Integer) ref.getProperty(Constants.SERVICE_ID); + + if (myServiceId < otherServiceId) { + return 1; + } else if (myServiceId > otherServiceId) { + return -1; + } else { + return 0; + } + } + } + + public ServiceInformation getInformation() { + return information; + } + +} + diff -r 4290490a2e05 -r 186115da601f common/test/src/main/java/com/redhat/thermostat/testutils/StubServiceRegistration.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/test/src/main/java/com/redhat/thermostat/testutils/StubServiceRegistration.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,77 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.testutils; + +import java.util.Dictionary; + +import org.osgi.framework.ServiceReference; +import org.osgi.framework.ServiceRegistration; + +import com.redhat.thermostat.testutils.StubBundleContext.ServiceInformation; + +@SuppressWarnings({"rawtypes"}) +public class StubServiceRegistration implements ServiceRegistration { + + private StubBundleContext bundleContext; + private ServiceInformation info; + + public StubServiceRegistration(StubBundleContext ctx, ServiceInformation info) { + this.bundleContext = ctx; + this.info = info; + } + + @Override + public ServiceReference getReference() { + return new StubServiceReference(info, bundleContext.getBundle()); + } + + @Override + public void setProperties(Dictionary properties) { + throw new NotImplementedException(); + } + + @Override + public void unregister() { + bundleContext.removeService(info); + } + + public ServiceInformation getInfo() { + return info; + } + +} + diff -r 4290490a2e05 -r 186115da601f common/test/src/test/java/com/redhat/thermostat/testutils/StubBundleContextTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/test/src/test/java/com/redhat/thermostat/testutils/StubBundleContextTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,573 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.testutils; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Matchers.isA; +import static org.mockito.Mockito.atLeast; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; + +import java.io.ByteArrayInputStream; +import java.util.Collection; +import java.util.Hashtable; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.ArgumentCaptor; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleException; +import org.osgi.framework.BundleListener; +import org.osgi.framework.Constants; +import org.osgi.framework.Filter; +import org.osgi.framework.FrameworkListener; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceEvent; +import org.osgi.framework.ServiceListener; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.ServiceRegistration; + +import com.redhat.thermostat.testutils.StubBundleContext.ServiceInformation; + +/** + * Test that StubBundleContext behaves like a BundleContext, based on what is + * specified in the OSGi spec. Other optional methods to help in testing are + * great, but adherence to spec is most important. + */ +public class StubBundleContextTest { + + private StubBundleContext bundleContext; + + @Before + public void setUp() { + bundleContext = new StubBundleContext(); + assertNotNull(bundleContext); + } + + @Test + public void testSetAndGetContextBundle() { + assertEquals(null, bundleContext.getBundle()); + + Bundle bundle = mock(Bundle.class); + bundleContext.setBundle(bundle); + assertSame(bundle, bundleContext.getBundle()); + } + + @Test(expected = NotImplementedException.class) + public void testInstallBundleFromLocation() throws BundleException { + bundleContext.installBundle(""); + } + + @Test(expected = NotImplementedException.class) + public void testInstallBundleFromInputStream() throws BundleException { + bundleContext.installBundle("", new ByteArrayInputStream(new byte[0])); + } + + @Test + public void testSetAndGetBundles() { + assertEquals(null, bundleContext.getBundle(0)); + + Bundle systemBundle = mock(Bundle.class); + bundleContext.setBundle(0, systemBundle); + + assertEquals(systemBundle, bundleContext.getBundle(0)); + + assertArrayEquals(new Bundle[] { systemBundle }, bundleContext.getBundles()); + } + + @Test(expected = NotImplementedException.class) + public void testGetBundleByLargeId() { + bundleContext.getBundle(Long.MAX_VALUE); + } + + @Test(expected = NotImplementedException.class) + public void testGetBundleByLocation() { + bundleContext.getBundle(""); + } + + @Test + public void testAddRemoveFrameworkListener() { + try { + bundleContext.addFrameworkListener(mock(FrameworkListener.class)); + fail("not expected"); + } catch (NotImplementedException notImplemented) { + /* okay: expected */ + } + + try { + bundleContext.removeFrameworkListener(mock(FrameworkListener.class)); + fail("not expected"); + } catch (NotImplementedException notImplemented) { + /* okay: expected */ + } + } + + @Test + public void testAddRemoveBundleListener() { + try { + bundleContext.addBundleListener(mock(BundleListener.class)); + fail("not expected"); + } catch (NotImplementedException notImplemented) { + /* okay: expected */ + } + + try { + bundleContext.removeBundleListener(mock(BundleListener.class)); + fail("not expected"); + } catch (NotImplementedException notImplemented) { + /* okay: expected */ + } + } + + @Test + public void testGetPropertyDelegatesToSystemProperties() { + assertEquals(System.getProperty("user.name"), bundleContext.getProperty("user.name")); + } + + @Test + public void testGetAndSetProperty() { + final String PROPERTY_NAME = "foo.bar.baz"; + final String PROPERTY_NEW_VALUE = "spam.eggs"; + + assertEquals(null, bundleContext.getProperty(PROPERTY_NAME)); + + bundleContext.setProperty(PROPERTY_NAME, PROPERTY_NEW_VALUE); + + assertEquals(PROPERTY_NEW_VALUE, bundleContext.getProperty(PROPERTY_NAME)); + } + + @Test + public void testFilterCreationReturnsASaneFilter() throws InvalidSyntaxException { + Filter filter = bundleContext.createFilter("(foo=bar)"); + assertNotNull(filter); + + Hashtable dict = new Hashtable<>(); + dict.put("foo", "bar"); + + assertTrue(filter.match(dict)); + } + + @Test + public void testAddRemoveService() { + TestService service = mock(TestService.class); + + assertEquals(0, bundleContext.getAllServices().size()); + assertFalse(bundleContext.isServiceRegistered(TestService.class.getName(), service.getClass())); + + ServiceRegistration registration = bundleContext.registerService(TestService.class, service, null); + + assertEquals(1, bundleContext.getAllServices().size()); + assertTrue(bundleContext.isServiceRegistered(TestService.class.getName(), service.getClass())); + + registration.unregister(); + + assertEquals(0, bundleContext.getAllServices().size()); + assertFalse(bundleContext.isServiceRegistered(TestService.class.getName(), service.getClass())); + } + + @Test(expected = IllegalArgumentException.class) + public void testAddServiceThatDoesNotImplementInterfaceClass() { + AnotherTestService service = mock(AnotherTestService.class); + + bundleContext.registerService(TestService.class.getName(), service, null); + } + + @Test(expected = IllegalArgumentException.class) + public void testAddServiceThatDoesNotImplementInterfaceClass2() { + AnotherTestService service = mock(AnotherTestService.class); + + bundleContext.registerService("foo.bar.Baz", service, null); + } + + @Test + public void testAddServiceWithProperties() { + TestService service = mock(TestService.class); + + Hashtable props = new Hashtable(); + props.put(Constants.SERVICE_ID, -10); + props.put(Constants.SERVICE_RANKING, 10); + props.put(Constants.OBJECTCLASS, AnotherTestService.class.getName()); + + ServiceRegistration reg = bundleContext.registerService(TestService.class, service, props); + + ServiceReference serviceRef = reg.getReference(); + + assertArrayEquals(new String[] { TestService.class.getName() }, + (String[]) serviceRef.getProperty(Constants.OBJECTCLASS)); + + assertEquals(10, serviceRef.getProperty(Constants.SERVICE_RANKING)); + assertEquals(0, serviceRef.getProperty(Constants.SERVICE_ID)); + } + + @Test + public void testAddServiceWithNonIntegerRanking() { + TestService service = mock(TestService.class); + + Hashtable props = new Hashtable(); + props.put(Constants.SERVICE_RANKING, new Object()); + + ServiceRegistration reg = bundleContext.registerService(TestService.class, service, props); + + ServiceReference serviceRef = reg.getReference(); + + assertEquals(0, serviceRef.getProperty(Constants.SERVICE_RANKING)); + } + + @Test(expected = IllegalArgumentException.class) + public void testRemoveUnknownService() { + bundleContext.removeService(new ServiceInformation(mock(TestService.class), new Hashtable())); + } + + @Test + public void testAddingAndRemovingListenerWorks() { + assertEquals(0, bundleContext.getServiceListeners().size()); + + ServiceListener listener = mock(ServiceListener.class); + + bundleContext.addServiceListener(listener); + + assertEquals(1, bundleContext.getServiceListeners().size()); + assertEquals(listener, bundleContext.getServiceListeners().toArray()[0]); + + bundleContext.removeServiceListener(listener); + + assertEquals(0, bundleContext.getServiceListeners().size()); + } + + @Test + public void testAddingSameListenerReplacedTheOldOne() { + assertEquals(0, bundleContext.getServiceListeners().size()); + + ServiceListener listener = mock(ServiceListener.class); + + bundleContext.addServiceListener(listener); + + assertEquals(1, bundleContext.getServiceListeners().size()); + + bundleContext.addServiceListener(listener); + + assertEquals(1, bundleContext.getServiceListeners().size()); + } + + @Test + public void testRemovingAnUnknownListenerIsANoOp() { + ServiceListener listener = mock(ServiceListener.class); + bundleContext.addServiceListener(listener); + assertEquals(1, bundleContext.getServiceListeners().size()); + + ServiceListener unknownListener = mock(ServiceListener.class); + bundleContext.removeServiceListener(unknownListener); + + assertEquals(1, bundleContext.getServiceListeners().size()); + } + + @Test + public void testServiceListenersWithoutFiltersWork() { + ServiceListener listener = mock(ServiceListener.class); + bundleContext.addServiceListener(listener); + + bundleContext.registerService(TestService.class, mock(TestService.class), null); + + assertListenerRecievedRegisteredEvent(listener); + } + + @Test + public void testServiceListenersWithFiltersWork() throws InvalidSyntaxException { + ServiceListener specificListener = mock(ServiceListener.class); + String specificFilter = "(" + Constants.OBJECTCLASS + "=" + TestService.class.getName() + ")"; + bundleContext.addServiceListener(specificListener, specificFilter); + + ServiceListener allListener = mock(ServiceListener.class); + String allListenerFilter = "(" + Constants.OBJECTCLASS + "=*)"; + bundleContext.addServiceListener(allListener, allListenerFilter); + + ServiceListener otherListener = mock(ServiceListener.class); + String otherListenerFilter = "(" + Constants.OBJECTCLASS + "=foo.bar.Baz)"; + bundleContext.addServiceListener(otherListener, otherListenerFilter); + + ServiceRegistration registration = bundleContext.registerService(TestService.class, mock(TestService.class), null); + + assertListenerRecievedRegisteredEvent(specificListener); + assertListenerRecievedRegisteredEvent(allListener); + + registration.unregister(); + + assertListenerRecievedUnregisteringEvent(specificListener); + assertListenerRecievedUnregisteringEvent(allListener); + + verify(otherListener, never()).serviceChanged(isA(ServiceEvent.class)); + + } + + private void assertListenerRecievedRegisteredEvent(ServiceListener listener) { + ArgumentCaptor eventCaptor = ArgumentCaptor.forClass(ServiceEvent.class); + verify(listener).serviceChanged(eventCaptor.capture()); + assertEquals(1, eventCaptor.getAllValues().size()); + ServiceEvent event = eventCaptor.getValue(); + assertEquals(ServiceEvent.REGISTERED, event.getType()); + ServiceReference ref = event.getServiceReference(); + assertTrue(ref instanceof StubServiceReference); + } + + private void assertListenerRecievedUnregisteringEvent(ServiceListener listener) { + ArgumentCaptor eventCaptor = ArgumentCaptor.forClass(ServiceEvent.class); + verify(listener, atLeast(1)).serviceChanged(eventCaptor.capture()); + + ServiceEvent event = eventCaptor.getValue(); + assertEquals(ServiceEvent.UNREGISTERING, event.getType()); + ServiceReference ref = event.getServiceReference(); + assertTrue(ref instanceof StubServiceReference); + } + + @Test + public void testGetServiceReferenceReturnsNullForNoMatch() { + assertNull(bundleContext.getServiceReference(TestService.class)); + } + + @Test + public void testGetServiceReferenceReturnsServiceWithHighestServiceRanking() { + TestService service1 = mock(TestService.class); + TestService service2 = mock(TestService.class); + + Hashtable service2Props = new Hashtable(); + service2Props.put(Constants.SERVICE_RANKING, 1000); + + bundleContext.registerService(TestService.class, service1, null); + bundleContext.registerService(TestService.class, service2, service2Props); + + ServiceReference ref = bundleContext.getServiceReference(TestService.class); + + assertSame(service2, bundleContext.getService(ref)); + } + + @Test + public void testGetServiceReferenceReturnsServiceWithLowerServiceId() { + TestService service1 = mock(TestService.class); + TestService service2 = mock(TestService.class); + + bundleContext.registerService(TestService.class, service1, null); + bundleContext.registerService(TestService.class, service2, null); + + ServiceReference ref = bundleContext.getServiceReference(TestService.class); + + assertSame(service1, bundleContext.getService(ref)); + } + + @Test + public void testGetServiceReferences() throws InvalidSyntaxException { + TestService service = mock(TestService.class); + + bundleContext.registerService(TestService.class, service, null); + bundleContext.registerService(AnotherTestService.class, mock(AnotherTestService.class), null); + + Collection refs = bundleContext.getServiceReferences(TestService.class, null); + + assertEquals(1, refs.size()); + assertEquals(service, ((StubServiceReference) refs.toArray()[0]).getInformation().implementation); + } + + @Test + public void testGetAllServiceReferencesNoMatch() throws InvalidSyntaxException { + TestService service = mock(TestService.class); + + bundleContext.registerService(TestService.class, service, null); + bundleContext.registerService(TestService.class, mock(TestService.class), null); + + ServiceReference[] refs = bundleContext.getAllServiceReferences(AnotherTestService.class.getName(), null); + + assertEquals(null, (Object) refs); + } + + @Test + public void testGetAllServiceReferencesWithoutFilter() throws InvalidSyntaxException { + TestService service = mock(TestService.class); + + bundleContext.registerService(TestService.class, service, null); + bundleContext.registerService(AnotherTestService.class, mock(AnotherTestService.class), null); + + ServiceReference[] refs = bundleContext.getAllServiceReferences(TestService.class.getName(), null); + + assertEquals(1, refs.length); + assertEquals(service, ((StubServiceReference) refs[0]).getInformation().implementation); + } + + @Test + public void testGetAllServiceReferencesWithFilter() throws InvalidSyntaxException { + TestService service = mock(TestService.class); + + bundleContext.registerService(TestService.class, service, null); + bundleContext.registerService(AnotherTestService.class, mock(AnotherTestService.class), null); + + String filter = "(" + Constants.OBJECTCLASS + "=" + TestService.class.getName() + ")"; + ServiceReference[] refs = bundleContext.getAllServiceReferences(TestService.class.getName(), filter); + + assertEquals(1, refs.length); + assertEquals(service, ((StubServiceReference) refs[0]).getInformation().implementation); + } + + @Test + public void testGetAllServiceReferencesWithNoClassNameJustFilter() throws InvalidSyntaxException { + TestService service = mock(TestService.class); + + bundleContext.registerService(TestService.class, service, null); + bundleContext.registerService(AnotherTestService.class, mock(AnotherTestService.class), null); + + String filter = "(" + Constants.OBJECTCLASS + "=" + TestService.class.getName() + ")"; + ServiceReference[] refs = bundleContext.getAllServiceReferences(null, filter); + + assertEquals(1, refs.length); + assertEquals(service, ((StubServiceReference) refs[0]).getInformation().implementation); + } + + @Test + public void testGetServiceUsingClassObject() { + TestService service = mock(TestService.class); + + bundleContext.registerService(TestService.class, service, null); + + ServiceReference ref = bundleContext.getServiceReference(TestService.class); + assertNotNull(ref); + + Object returnedService = bundleContext.getService(ref); + + assertSame(service, returnedService); + } + + @Test + public void testGetServiceUsingClassName() { + TestService service = mock(TestService.class); + + bundleContext.registerService(TestService.class, service, null); + + ServiceReference ref = bundleContext.getServiceReference(TestService.class.getName()); + assertNotNull(ref); + + Object returnedService = bundleContext.getService(ref); + + assertSame(service, returnedService); + } + + @Test + public void testUngetService() { + bundleContext.registerService(TestService.class, mock(TestService.class), null); + + ServiceReference ref = bundleContext.getServiceReference(TestService.class.getName()); + Object returnedService = bundleContext.getService(ref); + + assertTrue(bundleContext.ungetService(ref)); + + assertFalse(bundleContext.ungetService(ref)); + } + + @Test + public void testUngetServiceOnUnregisteredService() { + ServiceRegistration registration = bundleContext.registerService(TestService.class, mock(TestService.class), null); + + ServiceReference ref = bundleContext.getServiceReference(TestService.class.getName()); + Object returnedService = bundleContext.getService(ref); + + registration.unregister(); + + assertFalse(bundleContext.ungetService(ref)); + } + + @Test + public void testReferenceExportCountIsCorrect() { + TestService service = mock(TestService.class); + + ServiceRegistration reg = bundleContext.registerService(TestService.class, service, null); + + ServiceReference ref = bundleContext.getServiceReference(TestService.class); + assertNotNull(ref); + + assertEquals(0, bundleContext.getExportedServiceCount(reg)); + + Object returnedService = bundleContext.getService(ref); + + assertEquals(1, bundleContext.getExportedServiceCount(reg)); + + bundleContext.ungetService(ref); + + assertEquals(0, bundleContext.getExportedServiceCount(reg)); + } + + @Test(expected = NotImplementedException.class) + public void testGetDataFile() { + bundleContext.getDataFile(""); + } + + @Test + public void testIsServiceRegisteredForRegisteredService() { + ComplexService service = mock(ComplexService.class); + + String[] ifaces = new String[] { TestService.class.getName(), AnotherTestService.class.getName() }; + ServiceRegistration reg = bundleContext.registerService(ifaces, service, null); + + assertTrue(bundleContext.isServiceRegistered(AnotherTestService.class.getName(), service.getClass())); + + } + + @Test + public void testIsServiceRegisteredForUnregisteredService() { + ComplexService service = mock(ComplexService.class); + TestService someOtherService = mock(TestService.class); + + String[] ifaces = new String[] { TestService.class.getName(), AnotherTestService.class.getName() }; + ServiceRegistration reg = bundleContext.registerService(ifaces, service, null); + + assertFalse(bundleContext.isServiceRegistered(AnotherTestService.class.getName(), someOtherService.getClass())); + } + + /* + * Dummy service interfaces + */ + + static interface TestService { /* just a marker */} + + static interface AnotherTestService { /* just a marker */} + + static interface ComplexService extends TestService, AnotherTestService { /* ditto */} +} + diff -r 4290490a2e05 -r 186115da601f distribution/config/commands/dump-heap.properties --- a/distribution/config/commands/dump-heap.properties Fri Jan 25 16:33:19 2013 -0500 +++ b/distribution/config/commands/dump-heap.properties Wed Jan 16 18:58:59 2013 +0100 @@ -1,5 +1,6 @@ bundles = thermostat-common-core-@project.version@.jar, \ thermostat-client-core-@project.version@.jar, \ + thermostat-client-cli-@project.version@.jar, \ thermostat-common-command-@project.version@.jar, \ thermostat-client-command-@project.version@.jar, \ thermostat-vm-heap-analysis-common-@project.version@.jar, \ diff -r 4290490a2e05 -r 186115da601f distribution/config/commands/find-objects.properties --- a/distribution/config/commands/find-objects.properties Fri Jan 25 16:33:19 2013 -0500 +++ b/distribution/config/commands/find-objects.properties Wed Jan 16 18:58:59 2013 +0100 @@ -1,6 +1,7 @@ bundles = thermostat-client-core-@project.version@.jar, \ thermostat-common-command-@project.version@.jar, \ thermostat-client-command-@project.version@.jar, \ + thermostat-client-cli-@project.version@.jar, \ thermostat-vm-heap-analysis-common-@project.version@.jar, \ thermostat-vm-heap-analysis-command-@project.version@.jar, \ thermostat-storage-mongodb-${project.version}.jar, \ diff -r 4290490a2e05 -r 186115da601f distribution/config/commands/find-root.properties --- a/distribution/config/commands/find-root.properties Fri Jan 25 16:33:19 2013 -0500 +++ b/distribution/config/commands/find-root.properties Wed Jan 16 18:58:59 2013 +0100 @@ -1,6 +1,7 @@ bundles = thermostat-client-core-@project.version@.jar, \ thermostat-common-command-@project.version@.jar, \ thermostat-client-command-@project.version@.jar, \ + thermostat-client-cli-@project.version@.jar, \ thermostat-vm-heap-analysis-common-@project.version@.jar, \ thermostat-vm-heap-analysis-command-@project.version@.jar, \ thermostat-storage-mongodb-${project.version}.jar, \ diff -r 4290490a2e05 -r 186115da601f distribution/config/commands/gui.properties --- a/distribution/config/commands/gui.properties Fri Jan 25 16:33:19 2013 -0500 +++ b/distribution/config/commands/gui.properties Wed Jan 16 18:58:59 2013 +0100 @@ -9,6 +9,7 @@ thermostat-web-client-@project.version@.jar, \ thermostat-common-command-@project.version@.jar, \ thermostat-client-core-@project.version@.jar, \ + thermostat-client-cli-@project.version@.jar, \ thermostat-client-swing-@project.version@.jar, \ thermostat-swing-components-@project.version@.jar, \ thermostat-client-command-@project.version@.jar, \ diff -r 4290490a2e05 -r 186115da601f distribution/config/commands/list-heap-dumps.properties --- a/distribution/config/commands/list-heap-dumps.properties Fri Jan 25 16:33:19 2013 -0500 +++ b/distribution/config/commands/list-heap-dumps.properties Wed Jan 16 18:58:59 2013 +0100 @@ -5,6 +5,7 @@ commons-collections.jar, \ commons-logging.jar, \ thermostat-client-core-@project.version@.jar, \ + thermostat-client-cli-@project.version@.jar, \ thermostat-common-command-@project.version@.jar, \ thermostat-client-command-@project.version@.jar, \ thermostat-vm-heap-analysis-common-@project.version@.jar, \ diff -r 4290490a2e05 -r 186115da601f distribution/config/commands/object-info.properties --- a/distribution/config/commands/object-info.properties Fri Jan 25 16:33:19 2013 -0500 +++ b/distribution/config/commands/object-info.properties Wed Jan 16 18:58:59 2013 +0100 @@ -5,6 +5,7 @@ commons-collections.jar, \ commons-logging.jar, \ thermostat-client-core-@project.version@.jar, \ + thermostat-client-cli-@project.version@.jar, \ thermostat-common-command-@project.version@.jar, \ thermostat-client-command-@project.version@.jar, \ thermostat-vm-heap-analysis-common-@project.version@.jar, \ diff -r 4290490a2e05 -r 186115da601f distribution/config/commands/save-heap-dump-to-file.properties --- a/distribution/config/commands/save-heap-dump-to-file.properties Fri Jan 25 16:33:19 2013 -0500 +++ b/distribution/config/commands/save-heap-dump-to-file.properties Wed Jan 16 18:58:59 2013 +0100 @@ -5,6 +5,7 @@ commons-collections.jar, \ commons-logging.jar, \ thermostat-client-core-@project.version@.jar, \ + thermostat-client-cli-@project.version@.jar, \ thermostat-common-command-@project.version@.jar, \ thermostat-client-command-@project.version@.jar, \ thermostat-vm-heap-analysis-common-@project.version@.jar, \ diff -r 4290490a2e05 -r 186115da601f distribution/config/commands/show-heap-histogram.properties --- a/distribution/config/commands/show-heap-histogram.properties Fri Jan 25 16:33:19 2013 -0500 +++ b/distribution/config/commands/show-heap-histogram.properties Wed Jan 16 18:58:59 2013 +0100 @@ -7,6 +7,7 @@ thermostat-client-core-@project.version@.jar, \ thermostat-common-command-@project.version@.jar, \ thermostat-client-command-@project.version@.jar, \ + thermostat-client-cli-@project.version@.jar, \ thermostat-vm-heap-analysis-common-@project.version@.jar, \ thermostat-vm-heap-analysis-command-@project.version@.jar, \ thermostat-web-common-${project.version}.jar, \ diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse.chart.common/META-INF/MANIFEST.MF --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/META-INF/MANIFEST.MF Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.chart.common/META-INF/MANIFEST.MF Wed Jan 16 18:58:59 2013 +0100 @@ -12,7 +12,6 @@ com.redhat.thermostat.client.osgi.service, com.redhat.thermostat.client.ui, com.redhat.thermostat.common, - com.redhat.thermostat.common.dao, com.redhat.thermostat.common.locale, com.redhat.thermostat.common.utils, com.redhat.thermostat.eclipse, @@ -22,6 +21,7 @@ com.redhat.thermostat.host.memory.client.core, com.redhat.thermostat.host.memory.client.locale, com.redhat.thermostat.storage.core, + com.redhat.thermostat.storage.dao, com.redhat.thermostat.storage.model, com.redhat.thermostat.vm.cpu.client.core, com.redhat.thermostat.vm.cpu.client.locale, diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/HostCpuViewPart.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/HostCpuViewPart.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/HostCpuViewPart.java Wed Jan 16 18:58:59 2013 +0100 @@ -39,12 +39,12 @@ import org.eclipse.swt.widgets.Composite; import com.redhat.thermostat.client.core.controllers.InformationServiceController; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.eclipse.SWTComponent; import com.redhat.thermostat.eclipse.views.HostRefViewPart; import com.redhat.thermostat.host.cpu.client.core.HostCpuService; import com.redhat.thermostat.host.cpu.client.core.HostCpuViewProvider; +import com.redhat.thermostat.storage.core.HostRef; public class HostCpuViewPart extends HostRefViewPart { diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/HostMemoryViewPart.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/HostMemoryViewPart.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/HostMemoryViewPart.java Wed Jan 16 18:58:59 2013 +0100 @@ -39,12 +39,12 @@ import org.eclipse.swt.widgets.Composite; import com.redhat.thermostat.client.core.controllers.InformationServiceController; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.eclipse.SWTComponent; import com.redhat.thermostat.eclipse.views.HostRefViewPart; import com.redhat.thermostat.host.memory.client.core.HostMemoryService; import com.redhat.thermostat.host.memory.client.core.HostMemoryViewProvider; +import com.redhat.thermostat.storage.core.HostRef; public class HostMemoryViewPart extends HostRefViewPart { diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/VmCpuViewPart.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/VmCpuViewPart.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/VmCpuViewPart.java Wed Jan 16 18:58:59 2013 +0100 @@ -39,10 +39,10 @@ import org.eclipse.swt.widgets.Composite; import com.redhat.thermostat.client.core.controllers.InformationServiceController; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.eclipse.SWTComponent; import com.redhat.thermostat.eclipse.views.VmRefViewPart; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.vm.cpu.client.core.VmCpuService; import com.redhat.thermostat.vm.cpu.client.core.VmCpuViewProvider; diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/VmGcViewPart.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/VmGcViewPart.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/VmGcViewPart.java Wed Jan 16 18:58:59 2013 +0100 @@ -39,10 +39,10 @@ import org.eclipse.swt.widgets.Composite; import com.redhat.thermostat.client.core.controllers.InformationServiceController; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.eclipse.SWTComponent; import com.redhat.thermostat.eclipse.views.VmRefViewPart; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.vm.gc.client.core.VmGcService; import com.redhat.thermostat.vm.gc.client.core.VmGcViewProvider; diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/META-INF/MANIFEST.MF --- a/eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/META-INF/MANIFEST.MF Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/META-INF/MANIFEST.MF Wed Jan 16 18:58:59 2013 +0100 @@ -14,13 +14,14 @@ com.redhat.thermostat.client.osgi.service, com.redhat.thermostat.client.ui, com.redhat.thermostat.common, - com.redhat.thermostat.common.dao, + com.redhat.thermostat.storage.dao, com.redhat.thermostat.common.locale, com.redhat.thermostat.common.utils, com.redhat.thermostat.eclipse, com.redhat.thermostat.eclipse.chart.common, com.redhat.thermostat.eclipse.internal.views, com.redhat.thermostat.eclipse.views, + com.redhat.thermostat.storage.core, com.redhat.thermostat.storage.model, com.redhat.thermostat.vm.classstat.client.core, com.redhat.thermostat.vm.classstat.client.locale, diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/src/com/redhat/thermostat/eclipse/chart/vmclassstat/VmClassStatViewPart.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/src/com/redhat/thermostat/eclipse/chart/vmclassstat/VmClassStatViewPart.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/src/com/redhat/thermostat/eclipse/chart/vmclassstat/VmClassStatViewPart.java Wed Jan 16 18:58:59 2013 +0100 @@ -39,10 +39,10 @@ import org.eclipse.swt.widgets.Composite; import com.redhat.thermostat.client.core.controllers.InformationServiceController; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.eclipse.SWTComponent; import com.redhat.thermostat.eclipse.views.VmRefViewPart; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.vm.classstat.client.core.VmClassStatService; import com.redhat.thermostat.vm.classstat.client.core.VmClassStatViewProvider; diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse.test/META-INF/MANIFEST.MF --- a/eclipse/com.redhat.thermostat.eclipse.test/META-INF/MANIFEST.MF Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.test/META-INF/MANIFEST.MF Wed Jan 16 18:58:59 2013 +0100 @@ -17,7 +17,7 @@ com.redhat.thermostat.client.osgi.service, com.redhat.thermostat.client.ui, com.redhat.thermostat.common, - com.redhat.thermostat.common.dao, + com.redhat.thermostat.storage.dao, com.redhat.thermostat.common.utils, com.redhat.thermostat.eclipse, com.redhat.thermostat.eclipse.chart.common, diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/model/HostVmsTreeContentProviderTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/model/HostVmsTreeContentProviderTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/model/HostVmsTreeContentProviderTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -50,11 +50,11 @@ import org.junit.Before; import org.junit.Test; -import com.redhat.thermostat.common.HostsVMsLoader; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.eclipse.internal.model.HostsVmsTreeContentProvider; import com.redhat.thermostat.eclipse.internal.model.HostsVmsTreeRoot; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.HostsVMsLoader; +import com.redhat.thermostat.storage.core.VmRef; public class HostVmsTreeContentProviderTest { diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/model/HostsVmsLabelProviderTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/model/HostsVmsLabelProviderTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/model/HostsVmsLabelProviderTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -45,10 +45,10 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.eclipse.internal.model.HostsVmsLabelProvider; import com.redhat.thermostat.eclipse.internal.model.HostsVmsTreeRoot; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; public class HostsVmsLabelProviderTest { diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/AbstractRefViewPartTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/AbstractRefViewPartTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/AbstractRefViewPartTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -51,12 +51,12 @@ import org.eclipse.ui.IWorkbenchWindow; import org.junit.Before; -import com.redhat.thermostat.common.dao.Ref; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.eclipse.SWTComponent; import com.redhat.thermostat.eclipse.ThermostatConstants; import com.redhat.thermostat.eclipse.internal.views.HostsVmsTreeViewPart; import com.redhat.thermostat.eclipse.internal.views.RefViewPart; +import com.redhat.thermostat.storage.core.Ref; public abstract class AbstractRefViewPartTest { diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/HostCpuViewPartTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/HostCpuViewPartTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/HostCpuViewPartTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -50,8 +50,6 @@ import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.views.UIComponent; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.eclipse.ThermostatConstants; import com.redhat.thermostat.eclipse.chart.common.HostCpuViewPart; import com.redhat.thermostat.eclipse.chart.common.SWTHostCpuView; @@ -59,6 +57,8 @@ import com.redhat.thermostat.eclipse.internal.views.RefViewPart; import com.redhat.thermostat.host.cpu.client.core.HostCpuService; import com.redhat.thermostat.host.cpu.client.core.HostCpuViewProvider; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; public class HostCpuViewPartTest extends AbstractRefViewPartTest { diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/HostMemoryViewPartTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/HostMemoryViewPartTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/HostMemoryViewPartTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -48,7 +48,6 @@ import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.views.UIComponent; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.eclipse.ThermostatConstants; import com.redhat.thermostat.eclipse.chart.common.HostMemoryViewPart; import com.redhat.thermostat.eclipse.chart.common.SWTHostMemoryView; @@ -56,6 +55,7 @@ import com.redhat.thermostat.eclipse.internal.views.RefViewPart; import com.redhat.thermostat.host.memory.client.core.HostMemoryService; import com.redhat.thermostat.host.memory.client.core.HostMemoryViewProvider; +import com.redhat.thermostat.storage.core.HostRef; public class HostMemoryViewPartTest extends AbstractRefViewPartTest { diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/HostOverviewViewPartTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/HostOverviewViewPartTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/HostOverviewViewPartTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -48,7 +48,6 @@ import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.views.UIComponent; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.eclipse.ThermostatConstants; import com.redhat.thermostat.eclipse.internal.views.HostOverviewViewPart; import com.redhat.thermostat.eclipse.internal.views.RefViewPart; @@ -56,6 +55,7 @@ import com.redhat.thermostat.eclipse.internal.views.SWTHostOverviewViewProvider; import com.redhat.thermostat.host.overview.client.core.HostOverviewService; import com.redhat.thermostat.host.overview.client.core.HostOverviewViewProvider; +import com.redhat.thermostat.storage.core.HostRef; public class HostOverviewViewPartTest extends AbstractRefViewPartTest { diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmClassStatViewPartTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmClassStatViewPartTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmClassStatViewPartTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -47,13 +47,13 @@ import org.mockito.InOrder; import com.redhat.thermostat.client.core.controllers.InformationServiceController; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.eclipse.chart.vmclassstat.Activator; import com.redhat.thermostat.eclipse.chart.vmclassstat.SWTVmClassStatView; import com.redhat.thermostat.eclipse.chart.vmclassstat.SWTVmClassStatViewProvider; import com.redhat.thermostat.eclipse.chart.vmclassstat.VmClassStatViewPart; import com.redhat.thermostat.eclipse.internal.views.RefViewPart; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.vm.classstat.client.core.VmClassStatService; import com.redhat.thermostat.vm.classstat.client.core.VmClassStatViewProvider; diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmCpuViewPartTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmCpuViewPartTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmCpuViewPartTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -49,13 +49,13 @@ import org.mockito.InOrder; import com.redhat.thermostat.client.core.controllers.InformationServiceController; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.eclipse.ThermostatConstants; import com.redhat.thermostat.eclipse.chart.common.SWTVmCpuView; import com.redhat.thermostat.eclipse.chart.common.SWTVmCpuViewProvider; import com.redhat.thermostat.eclipse.chart.common.VmCpuViewPart; import com.redhat.thermostat.eclipse.internal.views.RefViewPart; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.vm.cpu.client.core.VmCpuService; import com.redhat.thermostat.vm.cpu.client.core.VmCpuViewProvider; diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmGcViewPartTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmGcViewPartTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmGcViewPartTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -47,13 +47,13 @@ import org.mockito.InOrder; import com.redhat.thermostat.client.core.controllers.InformationServiceController; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.eclipse.ThermostatConstants; import com.redhat.thermostat.eclipse.chart.common.SWTVmGcView; import com.redhat.thermostat.eclipse.chart.common.SWTVmGcViewProvider; import com.redhat.thermostat.eclipse.chart.common.VmGcViewPart; import com.redhat.thermostat.eclipse.internal.views.RefViewPart; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.vm.gc.client.core.VmGcService; import com.redhat.thermostat.vm.gc.client.core.VmGcViewProvider; diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse/META-INF/MANIFEST.MF --- a/eclipse/com.redhat.thermostat.eclipse/META-INF/MANIFEST.MF Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse/META-INF/MANIFEST.MF Wed Jan 16 18:58:59 2013 +0100 @@ -14,14 +14,14 @@ com.redhat.thermostat.client.locale, com.redhat.thermostat.client.ui, com.redhat.thermostat.common, - com.redhat.thermostat.common.dao, com.redhat.thermostat.common.locale, com.redhat.thermostat.common.utils, com.redhat.thermostat.host.overview.client.core, com.redhat.thermostat.host.overview.client.locale, com.redhat.thermostat.storage.config, com.redhat.thermostat.storage.core, - com.redhat.thermostat.storage.model + com.redhat.thermostat.storage.model, + com.redhat.thermostat.storage.dao Export-Package: com.redhat.thermostat.eclipse, com.redhat.thermostat.eclipse.internal;x-friends:="com.redhat.thermostat.eclipse.test,com.redhat.thermostat.eclipse.test.ui", com.redhat.thermostat.eclipse.internal.controllers;x-friends:="com.redhat.thermostat.eclipse.test,com.redhat.thermostat.eclipse.test.ui", diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/Activator.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/Activator.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/Activator.java Wed Jan 16 18:58:59 2013 +0100 @@ -44,12 +44,12 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import com.redhat.thermostat.common.DbService; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.eclipse.LoggerFacility; import com.redhat.thermostat.eclipse.internal.views.SWTHostOverviewViewProvider; import com.redhat.thermostat.host.overview.client.core.HostOverviewViewProvider; import com.redhat.thermostat.storage.core.ConnectionException; +import com.redhat.thermostat.storage.core.DbService; /** * The activator class controls the plug-in life cycle diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/jobs/ConnectDbJob.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/jobs/ConnectDbJob.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/jobs/ConnectDbJob.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,13 +41,13 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; -import com.redhat.thermostat.common.DbService; -import com.redhat.thermostat.common.DbServiceFactory; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.eclipse.LoggerFacility; import com.redhat.thermostat.eclipse.internal.Activator; import com.redhat.thermostat.eclipse.internal.ConnectionConfiguration; import com.redhat.thermostat.storage.core.ConnectionException; +import com.redhat.thermostat.storage.core.DbService; +import com.redhat.thermostat.storage.core.DbServiceFactory; public class ConnectDbJob extends Job { diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/model/HostsVmsLabelProvider.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/model/HostsVmsLabelProvider.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/model/HostsVmsLabelProvider.java Wed Jan 16 18:58:59 2013 +0100 @@ -39,8 +39,8 @@ import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.graphics.Image; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; public class HostsVmsLabelProvider extends LabelProvider { diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/model/HostsVmsTreeContentProvider.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/model/HostsVmsTreeContentProvider.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/model/HostsVmsTreeContentProvider.java Wed Jan 16 18:58:59 2013 +0100 @@ -42,9 +42,9 @@ import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.Viewer; -import com.redhat.thermostat.common.HostsVMsLoader; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.HostsVMsLoader; +import com.redhat.thermostat.storage.core.VmRef; public class HostsVmsTreeContentProvider implements ITreeContentProvider { diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/HostOverviewViewPart.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/HostOverviewViewPart.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/HostOverviewViewPart.java Wed Jan 16 18:58:59 2013 +0100 @@ -39,12 +39,12 @@ import org.eclipse.swt.widgets.Composite; import com.redhat.thermostat.client.core.controllers.InformationServiceController; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.eclipse.SWTComponent; import com.redhat.thermostat.eclipse.views.HostRefViewPart; import com.redhat.thermostat.host.overview.client.core.HostOverviewService; import com.redhat.thermostat.host.overview.client.core.HostOverviewViewProvider; +import com.redhat.thermostat.storage.core.HostRef; public class HostOverviewViewPart extends HostRefViewPart { diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/HostsVmsTreeViewPart.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/HostsVmsTreeViewPart.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/HostsVmsTreeViewPart.java Wed Jan 16 18:58:59 2013 +0100 @@ -51,10 +51,6 @@ import org.eclipse.ui.part.PageBook; import org.eclipse.ui.part.ViewPart; -import com.redhat.thermostat.common.DefaultHostsVMsLoader; -import com.redhat.thermostat.common.HostsVMsLoader; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.VmInfoDAO; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.eclipse.internal.Activator; import com.redhat.thermostat.eclipse.internal.ConnectionConfiguration; @@ -64,6 +60,10 @@ import com.redhat.thermostat.eclipse.internal.model.HostsVmsLabelProvider; import com.redhat.thermostat.eclipse.internal.model.HostsVmsTreeContentProvider; import com.redhat.thermostat.eclipse.internal.model.HostsVmsTreeRoot; +import com.redhat.thermostat.storage.core.DefaultHostsVMsLoader; +import com.redhat.thermostat.storage.core.HostsVMsLoader; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.dao.VmInfoDAO; /** * diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/RefViewPart.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/RefViewPart.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/RefViewPart.java Wed Jan 16 18:58:59 2013 +0100 @@ -50,9 +50,9 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.ViewPart; -import com.redhat.thermostat.common.dao.Ref; import com.redhat.thermostat.eclipse.SWTComponent; import com.redhat.thermostat.eclipse.ThermostatConstants; +import com.redhat.thermostat.storage.core.Ref; public abstract class RefViewPart extends ViewPart implements ISelectionListener { diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/views/HostRefViewPart.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/views/HostRefViewPart.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/views/HostRefViewPart.java Wed Jan 16 18:58:59 2013 +0100 @@ -36,9 +36,9 @@ package com.redhat.thermostat.eclipse.views; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.eclipse.internal.views.RefViewPart; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; public abstract class HostRefViewPart extends RefViewPart { diff -r 4290490a2e05 -r 186115da601f eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/views/VmRefViewPart.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/views/VmRefViewPart.java Fri Jan 25 16:33:19 2013 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/views/VmRefViewPart.java Wed Jan 16 18:58:59 2013 +0100 @@ -36,8 +36,8 @@ package com.redhat.thermostat.eclipse.views; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.eclipse.internal.views.RefViewPart; +import com.redhat.thermostat.storage.core.VmRef; public abstract class VmRefViewPart extends RefViewPart { diff -r 4290490a2e05 -r 186115da601f host-cpu/agent/pom.xml --- a/host-cpu/agent/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/host-cpu/agent/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -74,5 +74,11 @@ thermostat-storage-core ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f host-cpu/agent/src/test/java/com/redhat/thermostat/host/cpu/agent/internal/ActivatorTest.java --- a/host-cpu/agent/src/test/java/com/redhat/thermostat/host/cpu/agent/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-cpu/agent/src/test/java/com/redhat/thermostat/host/cpu/agent/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -50,7 +50,7 @@ import com.redhat.thermostat.backend.Backend; import com.redhat.thermostat.backend.BackendService; import com.redhat.thermostat.host.cpu.common.CpuStatDAO; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/HostCpuService.java --- a/host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/HostCpuService.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/HostCpuService.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,11 +41,11 @@ import com.redhat.thermostat.client.core.NameMatchingRefFilter; import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.host.cpu.client.core.internal.HostCpuController; import com.redhat.thermostat.host.cpu.common.CpuStatDAO; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.dao.HostInfoDAO; public class HostCpuService implements InformationService { diff -r 4290490a2e05 -r 186115da601f host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/internal/Activator.java --- a/host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/internal/Activator.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/internal/Activator.java Wed Jan 16 18:58:59 2013 +0100 @@ -50,10 +50,10 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.host.cpu.client.core.HostCpuService; import com.redhat.thermostat.host.cpu.common.CpuStatDAO; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.dao.HostInfoDAO; public class Activator implements BundleActivator { diff -r 4290490a2e05 -r 186115da601f host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/internal/HostCpuController.java --- a/host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/internal/HostCpuController.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/internal/HostCpuController.java Wed Jan 16 18:58:59 2013 +0100 @@ -49,13 +49,13 @@ import com.redhat.thermostat.common.NotImplementedException; import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.Timer.SchedulingType; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.host.cpu.client.core.HostCpuView; import com.redhat.thermostat.host.cpu.client.core.HostCpuViewProvider; import com.redhat.thermostat.host.cpu.client.locale.LocaleResources; import com.redhat.thermostat.host.cpu.common.CpuStatDAO; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.dao.HostInfoDAO; import com.redhat.thermostat.storage.model.CpuStat; import com.redhat.thermostat.storage.model.DiscreteTimeData; import com.redhat.thermostat.storage.model.HostInfo; diff -r 4290490a2e05 -r 186115da601f host-cpu/client-core/src/test/java/com/redhat/thermostat/host/cpu/client/core/internal/ActivatorTest.java --- a/host-cpu/client-core/src/test/java/com/redhat/thermostat/host/cpu/client/core/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-cpu/client-core/src/test/java/com/redhat/thermostat/host/cpu/client/core/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -45,10 +45,10 @@ import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.dao.HostInfoDAO; import com.redhat.thermostat.host.cpu.client.core.HostCpuService; import com.redhat.thermostat.host.cpu.common.CpuStatDAO; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.testutils.StubBundleContext; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f host-cpu/client-core/src/test/java/com/redhat/thermostat/host/cpu/client/core/internal/HostCpuControllerTest.java --- a/host-cpu/client-core/src/test/java/com/redhat/thermostat/host/cpu/client/core/internal/HostCpuControllerTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-cpu/client-core/src/test/java/com/redhat/thermostat/host/cpu/client/core/internal/HostCpuControllerTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -62,12 +62,12 @@ import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.Timer.SchedulingType; import com.redhat.thermostat.common.TimerFactory; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.host.cpu.client.core.HostCpuView; import com.redhat.thermostat.host.cpu.client.core.HostCpuViewProvider; import com.redhat.thermostat.host.cpu.client.core.internal.HostCpuController; import com.redhat.thermostat.host.cpu.common.CpuStatDAO; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.dao.HostInfoDAO; import com.redhat.thermostat.storage.model.CpuStat; import com.redhat.thermostat.storage.model.DiscreteTimeData; import com.redhat.thermostat.storage.model.HostInfo; diff -r 4290490a2e05 -r 186115da601f host-cpu/client-core/src/test/java/com/redhat/thermostat/host/cpu/client/locale/LocaleResourcesTest.java --- a/host-cpu/client-core/src/test/java/com/redhat/thermostat/host/cpu/client/locale/LocaleResourcesTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-cpu/client-core/src/test/java/com/redhat/thermostat/host/cpu/client/locale/LocaleResourcesTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -36,7 +36,7 @@ package com.redhat.thermostat.host.cpu.client.locale; -import com.redhat.thermostat.test.locale.AbstractLocaleResourcesTest; +import com.redhat.thermostat.testutils.AbstractLocaleResourcesTest; public class LocaleResourcesTest extends AbstractLocaleResourcesTest { diff -r 4290490a2e05 -r 186115da601f host-cpu/client-swing/pom.xml --- a/host-cpu/client-swing/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/host-cpu/client-swing/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -83,5 +83,11 @@ thermostat-host-cpu-client-core ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f host-cpu/client-swing/src/test/java/com/redhat/thermostat/host/cpu/client/swing/internal/ActivatorTest.java --- a/host-cpu/client-swing/src/test/java/com/redhat/thermostat/host/cpu/client/swing/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-cpu/client-swing/src/test/java/com/redhat/thermostat/host/cpu/client/swing/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -42,7 +42,7 @@ import org.junit.Test; import com.redhat.thermostat.host.cpu.client.core.HostCpuViewProvider; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f host-cpu/common/pom.xml --- a/host-cpu/common/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/host-cpu/common/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -64,5 +64,11 @@ thermostat-storage-core ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f host-cpu/common/src/main/java/com/redhat/thermostat/host/cpu/common/CpuStatDAO.java --- a/host-cpu/common/src/main/java/com/redhat/thermostat/host/cpu/common/CpuStatDAO.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-cpu/common/src/main/java/com/redhat/thermostat/host/cpu/common/CpuStatDAO.java Wed Jan 16 18:58:59 2013 +0100 @@ -39,8 +39,8 @@ import java.util.List; import com.redhat.thermostat.annotations.Service; -import com.redhat.thermostat.common.dao.Countable; -import com.redhat.thermostat.common.dao.HostRef; +import com.redhat.thermostat.storage.core.Countable; +import com.redhat.thermostat.storage.core.HostRef; import com.redhat.thermostat.storage.core.Category; import com.redhat.thermostat.storage.core.Key; import com.redhat.thermostat.storage.model.CpuStat; diff -r 4290490a2e05 -r 186115da601f host-cpu/common/src/main/java/com/redhat/thermostat/host/cpu/common/internal/CpuStatDAOImpl.java --- a/host-cpu/common/src/main/java/com/redhat/thermostat/host/cpu/common/internal/CpuStatDAOImpl.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-cpu/common/src/main/java/com/redhat/thermostat/host/cpu/common/internal/CpuStatDAOImpl.java Wed Jan 16 18:58:59 2013 +0100 @@ -38,8 +38,8 @@ import java.util.List; -import com.redhat.thermostat.common.dao.HostLatestPojoListGetter; -import com.redhat.thermostat.common.dao.HostRef; +import com.redhat.thermostat.storage.core.HostLatestPojoListGetter; +import com.redhat.thermostat.storage.core.HostRef; import com.redhat.thermostat.host.cpu.common.CpuStatDAO; import com.redhat.thermostat.storage.core.Put; import com.redhat.thermostat.storage.core.Storage; diff -r 4290490a2e05 -r 186115da601f host-cpu/common/src/test/java/com/redhat/thermostat/host/cpu/common/internal/ActivatorTest.java --- a/host-cpu/common/src/test/java/com/redhat/thermostat/host/cpu/common/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-cpu/common/src/test/java/com/redhat/thermostat/host/cpu/common/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -44,7 +44,7 @@ import com.redhat.thermostat.host.cpu.common.CpuStatDAO; import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f host-cpu/common/src/test/java/com/redhat/thermostat/host/cpu/common/internal/CpuStatDAOTest.java --- a/host-cpu/common/src/test/java/com/redhat/thermostat/host/cpu/common/internal/CpuStatDAOTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-cpu/common/src/test/java/com/redhat/thermostat/host/cpu/common/internal/CpuStatDAOTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -53,7 +53,7 @@ import org.junit.Test; -import com.redhat.thermostat.common.dao.HostRef; +import com.redhat.thermostat.storage.core.HostRef; import com.redhat.thermostat.host.cpu.common.CpuStatDAO; import com.redhat.thermostat.storage.core.Add; import com.redhat.thermostat.storage.core.Category; diff -r 4290490a2e05 -r 186115da601f host-memory/agent/pom.xml --- a/host-memory/agent/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/host-memory/agent/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -74,5 +74,11 @@ thermostat-storage-core ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f host-memory/agent/src/test/java/com/redhat/thermostat/host/memory/agent/internal/ActivatorTest.java --- a/host-memory/agent/src/test/java/com/redhat/thermostat/host/memory/agent/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-memory/agent/src/test/java/com/redhat/thermostat/host/memory/agent/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -50,7 +50,7 @@ import com.redhat.thermostat.backend.Backend; import com.redhat.thermostat.backend.BackendService; import com.redhat.thermostat.host.memory.common.MemoryStatDAO; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f host-memory/client-core/pom.xml --- a/host-memory/client-core/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/host-memory/client-core/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -76,5 +76,11 @@ thermostat-host-memory-common ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/HostMemoryService.java --- a/host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/HostMemoryService.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/HostMemoryService.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,11 +41,11 @@ import com.redhat.thermostat.client.core.NameMatchingRefFilter; import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.host.memory.client.core.internal.HostMemoryController; import com.redhat.thermostat.host.memory.common.MemoryStatDAO; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.dao.HostInfoDAO; public class HostMemoryService implements InformationService { diff -r 4290490a2e05 -r 186115da601f host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/internal/Activator.java --- a/host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/internal/Activator.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/internal/Activator.java Wed Jan 16 18:58:59 2013 +0100 @@ -50,10 +50,10 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.host.memory.client.core.HostMemoryService; import com.redhat.thermostat.host.memory.common.MemoryStatDAO; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.dao.HostInfoDAO; public class Activator implements BundleActivator { diff -r 4290490a2e05 -r 186115da601f host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/internal/HostMemoryController.java --- a/host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/internal/HostMemoryController.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/internal/HostMemoryController.java Wed Jan 16 18:58:59 2013 +0100 @@ -50,14 +50,14 @@ import com.redhat.thermostat.common.Size; import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.Timer.SchedulingType; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.host.memory.client.core.HostMemoryView; import com.redhat.thermostat.host.memory.client.core.HostMemoryViewProvider; import com.redhat.thermostat.host.memory.client.core.HostMemoryView.GraphVisibilityChangeListener; import com.redhat.thermostat.host.memory.client.locale.LocaleResources; import com.redhat.thermostat.host.memory.common.MemoryStatDAO; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.dao.HostInfoDAO; import com.redhat.thermostat.storage.model.DiscreteTimeData; import com.redhat.thermostat.storage.model.MemoryStat; import com.redhat.thermostat.storage.model.MemoryType; diff -r 4290490a2e05 -r 186115da601f host-memory/client-core/src/test/java/com/redhat/thermostat/host/memory/client/core/internal/ActivatorTest.java --- a/host-memory/client-core/src/test/java/com/redhat/thermostat/host/memory/client/core/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-memory/client-core/src/test/java/com/redhat/thermostat/host/memory/client/core/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -45,10 +45,10 @@ import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.dao.HostInfoDAO; import com.redhat.thermostat.host.memory.client.core.HostMemoryService; import com.redhat.thermostat.host.memory.common.MemoryStatDAO; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.testutils.StubBundleContext; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f host-memory/client-core/src/test/java/com/redhat/thermostat/host/memory/client/core/internal/HostMemoryControllerTest.java --- a/host-memory/client-core/src/test/java/com/redhat/thermostat/host/memory/client/core/internal/HostMemoryControllerTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-memory/client-core/src/test/java/com/redhat/thermostat/host/memory/client/core/internal/HostMemoryControllerTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -56,12 +56,12 @@ import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.TimerFactory; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.host.memory.client.core.HostMemoryView; import com.redhat.thermostat.host.memory.client.core.HostMemoryViewProvider; import com.redhat.thermostat.host.memory.client.core.internal.HostMemoryController; import com.redhat.thermostat.host.memory.common.MemoryStatDAO; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.dao.HostInfoDAO; import com.redhat.thermostat.storage.model.HostInfo; import com.redhat.thermostat.storage.model.MemoryStat; diff -r 4290490a2e05 -r 186115da601f host-memory/client-core/src/test/java/com/redhat/thermostat/host/memory/client/locale/LocaleResourcesTest.java --- a/host-memory/client-core/src/test/java/com/redhat/thermostat/host/memory/client/locale/LocaleResourcesTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-memory/client-core/src/test/java/com/redhat/thermostat/host/memory/client/locale/LocaleResourcesTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -36,7 +36,7 @@ package com.redhat.thermostat.host.memory.client.locale; -import com.redhat.thermostat.test.locale.AbstractLocaleResourcesTest; +import com.redhat.thermostat.testutils.AbstractLocaleResourcesTest; public class LocaleResourcesTest extends AbstractLocaleResourcesTest { diff -r 4290490a2e05 -r 186115da601f host-memory/client-swing/pom.xml --- a/host-memory/client-swing/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/host-memory/client-swing/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -83,5 +83,11 @@ thermostat-host-memory-client-core ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f host-memory/client-swing/src/test/java/com/redhat/thermostat/host/memory/client/swing/internal/ActivatorTest.java --- a/host-memory/client-swing/src/test/java/com/redhat/thermostat/host/memory/client/swing/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-memory/client-swing/src/test/java/com/redhat/thermostat/host/memory/client/swing/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -42,7 +42,7 @@ import org.junit.Test; import com.redhat.thermostat.host.memory.client.core.HostMemoryViewProvider; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f host-memory/common/pom.xml --- a/host-memory/common/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/host-memory/common/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -64,5 +64,11 @@ thermostat-storage-core ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f host-memory/common/src/main/java/com/redhat/thermostat/host/memory/common/MemoryStatDAO.java --- a/host-memory/common/src/main/java/com/redhat/thermostat/host/memory/common/MemoryStatDAO.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-memory/common/src/main/java/com/redhat/thermostat/host/memory/common/MemoryStatDAO.java Wed Jan 16 18:58:59 2013 +0100 @@ -39,8 +39,8 @@ import java.util.List; import com.redhat.thermostat.annotations.Service; -import com.redhat.thermostat.common.dao.Countable; -import com.redhat.thermostat.common.dao.HostRef; +import com.redhat.thermostat.storage.core.Countable; +import com.redhat.thermostat.storage.core.HostRef; import com.redhat.thermostat.storage.core.Category; import com.redhat.thermostat.storage.core.Key; import com.redhat.thermostat.storage.model.MemoryStat; diff -r 4290490a2e05 -r 186115da601f host-memory/common/src/main/java/com/redhat/thermostat/host/memory/common/internal/MemoryStatDAOImpl.java --- a/host-memory/common/src/main/java/com/redhat/thermostat/host/memory/common/internal/MemoryStatDAOImpl.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-memory/common/src/main/java/com/redhat/thermostat/host/memory/common/internal/MemoryStatDAOImpl.java Wed Jan 16 18:58:59 2013 +0100 @@ -38,8 +38,8 @@ import java.util.List; -import com.redhat.thermostat.common.dao.HostLatestPojoListGetter; -import com.redhat.thermostat.common.dao.HostRef; +import com.redhat.thermostat.storage.core.HostLatestPojoListGetter; +import com.redhat.thermostat.storage.core.HostRef; import com.redhat.thermostat.host.memory.common.MemoryStatDAO; import com.redhat.thermostat.storage.core.Put; import com.redhat.thermostat.storage.core.Storage; diff -r 4290490a2e05 -r 186115da601f host-memory/common/src/test/java/com/redhat/thermostat/host/memory/common/internal/ActivatorTest.java --- a/host-memory/common/src/test/java/com/redhat/thermostat/host/memory/common/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-memory/common/src/test/java/com/redhat/thermostat/host/memory/common/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -44,7 +44,7 @@ import com.redhat.thermostat.host.memory.common.MemoryStatDAO; import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f host-memory/common/src/test/java/com/redhat/thermostat/host/memory/common/internal/MemoryStatDAOTest.java --- a/host-memory/common/src/test/java/com/redhat/thermostat/host/memory/common/internal/MemoryStatDAOTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-memory/common/src/test/java/com/redhat/thermostat/host/memory/common/internal/MemoryStatDAOTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -39,7 +39,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; -import static org.mockito.Matchers.same; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; @@ -49,11 +48,8 @@ import java.util.List; import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; -import com.redhat.thermostat.common.dao.HostRef; +import com.redhat.thermostat.storage.core.HostRef; import com.redhat.thermostat.host.memory.common.MemoryStatDAO; import com.redhat.thermostat.storage.core.Add; import com.redhat.thermostat.storage.core.Category; diff -r 4290490a2e05 -r 186115da601f host-overview/client-core/pom.xml --- a/host-overview/client-core/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/host-overview/client-core/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -71,5 +71,11 @@ ${project.version} test + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/HostOverviewService.java --- a/host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/HostOverviewService.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/HostOverviewService.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,11 +41,11 @@ import com.redhat.thermostat.client.core.NameMatchingRefFilter; import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.NetworkInterfaceInfoDAO; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.host.overview.client.core.internal.HostOverviewController; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.dao.NetworkInterfaceInfoDAO; public class HostOverviewService implements InformationService { diff -r 4290490a2e05 -r 186115da601f host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/internal/Activator.java --- a/host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/internal/Activator.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/internal/Activator.java Wed Jan 16 18:58:59 2013 +0100 @@ -50,10 +50,10 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.NetworkInterfaceInfoDAO; import com.redhat.thermostat.host.overview.client.core.HostOverviewService; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.dao.NetworkInterfaceInfoDAO; public class Activator implements BundleActivator { diff -r 4290490a2e05 -r 186115da601f host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/internal/HostOverviewController.java --- a/host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/internal/HostOverviewController.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/internal/HostOverviewController.java Wed Jan 16 18:58:59 2013 +0100 @@ -51,13 +51,13 @@ import com.redhat.thermostat.common.Size; import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.Timer.SchedulingType; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.NetworkInterfaceInfoDAO; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.host.overview.client.core.HostOverviewView; import com.redhat.thermostat.host.overview.client.core.HostOverviewViewProvider; import com.redhat.thermostat.host.overview.client.locale.LocaleResources; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.dao.NetworkInterfaceInfoDAO; import com.redhat.thermostat.storage.model.HostInfo; import com.redhat.thermostat.storage.model.NetworkInterfaceInfo; diff -r 4290490a2e05 -r 186115da601f host-overview/client-core/src/test/java/com/redhat/thermostat/host/overview/client/core/internal/ActivatorTest.java --- a/host-overview/client-core/src/test/java/com/redhat/thermostat/host/overview/client/core/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-overview/client-core/src/test/java/com/redhat/thermostat/host/overview/client/core/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -45,10 +45,10 @@ import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.NetworkInterfaceInfoDAO; import com.redhat.thermostat.host.overview.client.core.HostOverviewService; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.dao.NetworkInterfaceInfoDAO; +import com.redhat.thermostat.testutils.StubBundleContext; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f host-overview/client-core/src/test/java/com/redhat/thermostat/host/overview/client/core/internal/HostOverviewControllerTest.java --- a/host-overview/client-core/src/test/java/com/redhat/thermostat/host/overview/client/core/internal/HostOverviewControllerTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-overview/client-core/src/test/java/com/redhat/thermostat/host/overview/client/core/internal/HostOverviewControllerTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -60,11 +60,11 @@ import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.Timer.SchedulingType; import com.redhat.thermostat.common.TimerFactory; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.NetworkInterfaceInfoDAO; import com.redhat.thermostat.host.overview.client.core.HostOverviewView; import com.redhat.thermostat.host.overview.client.core.HostOverviewViewProvider; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.dao.NetworkInterfaceInfoDAO; import com.redhat.thermostat.storage.model.HostInfo; import com.redhat.thermostat.storage.model.NetworkInterfaceInfo; diff -r 4290490a2e05 -r 186115da601f host-overview/client-core/src/test/java/com/redhat/thermostat/host/overview/client/locale/LocaleResourcesTest.java --- a/host-overview/client-core/src/test/java/com/redhat/thermostat/host/overview/client/locale/LocaleResourcesTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-overview/client-core/src/test/java/com/redhat/thermostat/host/overview/client/locale/LocaleResourcesTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -36,7 +36,7 @@ package com.redhat.thermostat.host.overview.client.locale; -import com.redhat.thermostat.test.locale.AbstractLocaleResourcesTest; +import com.redhat.thermostat.testutils.AbstractLocaleResourcesTest; public class LocaleResourcesTest extends AbstractLocaleResourcesTest { diff -r 4290490a2e05 -r 186115da601f host-overview/client-swing/pom.xml --- a/host-overview/client-swing/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/host-overview/client-swing/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -78,5 +78,11 @@ thermostat-host-overview-client-core ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f host-overview/client-swing/src/test/java/com/redhat/thermostat/host/overview/client/swing/internal/ActivatorTest.java --- a/host-overview/client-swing/src/test/java/com/redhat/thermostat/host/overview/client/swing/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/host-overview/client-swing/src/test/java/com/redhat/thermostat/host/overview/client/swing/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -42,7 +42,7 @@ import org.junit.Test; import com.redhat.thermostat.host.overview.client.core.HostOverviewViewProvider; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f killvm/client-swing/pom.xml --- a/killvm/client-swing/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/killvm/client-swing/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -91,6 +91,11 @@ ${project.version} + com.redhat.thermostat + thermostat-storage-core + ${project.version} + + com.redhat.thermostat thermostat-osgi-process-handler ${project.version} diff -r 4290490a2e05 -r 186115da601f killvm/client-swing/src/main/java/com/redhat/thermostat/killvm/client/internal/Activator.java --- a/killvm/client-swing/src/main/java/com/redhat/thermostat/killvm/client/internal/Activator.java Fri Jan 25 16:33:19 2013 -0500 +++ b/killvm/client-swing/src/main/java/com/redhat/thermostat/killvm/client/internal/Activator.java Wed Jan 16 18:58:59 2013 +0100 @@ -45,8 +45,8 @@ import com.redhat.thermostat.client.osgi.service.VMContextAction; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.VmInfoDAO; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; +import com.redhat.thermostat.storage.dao.VmInfoDAO; public class Activator implements BundleActivator { diff -r 4290490a2e05 -r 186115da601f killvm/client-swing/src/main/java/com/redhat/thermostat/killvm/client/internal/KillVMAction.java --- a/killvm/client-swing/src/main/java/com/redhat/thermostat/killvm/client/internal/KillVMAction.java Fri Jan 25 16:33:19 2013 -0500 +++ b/killvm/client-swing/src/main/java/com/redhat/thermostat/killvm/client/internal/KillVMAction.java Wed Jan 16 18:58:59 2013 +0100 @@ -45,12 +45,12 @@ import com.redhat.thermostat.common.command.Request; import com.redhat.thermostat.common.command.Request.RequestType; import com.redhat.thermostat.common.command.RequestResponseListener; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.killvm.client.locale.LocaleResources; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.storage.model.VmInfo; /** diff -r 4290490a2e05 -r 186115da601f killvm/client-swing/src/test/java/com/redhat/thermostat/killvm/client/internal/KillVMActionTest.java --- a/killvm/client-swing/src/test/java/com/redhat/thermostat/killvm/client/internal/KillVMActionTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/killvm/client-swing/src/test/java/com/redhat/thermostat/killvm/client/internal/KillVMActionTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -57,12 +57,12 @@ import com.redhat.thermostat.client.core.Filter; import com.redhat.thermostat.common.command.Request; import com.redhat.thermostat.common.command.RequestResponseListener; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.killvm.client.internal.KillVMAction; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.storage.model.AgentInformation; import com.redhat.thermostat.storage.model.VmInfo; diff -r 4290490a2e05 -r 186115da601f launcher/pom.xml --- a/launcher/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/launcher/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -110,6 +110,11 @@ com.redhat.thermostat + thermostat-storage-core + ${project.version} + + + com.redhat.thermostat thermostat-common-test ${project.version} test diff -r 4290490a2e05 -r 186115da601f launcher/src/main/java/com/redhat/thermostat/launcher/Launcher.java --- a/launcher/src/main/java/com/redhat/thermostat/launcher/Launcher.java Fri Jan 25 16:33:19 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* - * Copyright 2012, 2013 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.launcher; - -import java.util.Collection; - -import com.redhat.thermostat.annotations.Service; -import com.redhat.thermostat.common.ActionListener; -import com.redhat.thermostat.common.tools.ApplicationState; - -/** - * Launcher is the main entry point for all Thermostat commands. - */ -@Service -public interface Launcher { - - /** - * Invoked in order to start a command, either when Thermostat starts, or within - * the thermostat shell. Equivalent to calling run(null). - */ - void run(); - - /** - * Invoked in order to start a command, either when Thermostat starts, or within - * the thermostat shell. If the command being run happens to be a BasicCommand, - * and the argument is non-null, the listeners will be added to the command for - * life cycle notifications. Otherwise, the argument is ignored. - */ - void run(Collection> listeners); - - /** - * Should be set before calling run() - * @param command line arguments to the program - */ - void setArgs(String[] args); - -} - diff -r 4290490a2e05 -r 186115da601f launcher/src/main/java/com/redhat/thermostat/launcher/internal/Activator.java --- a/launcher/src/main/java/com/redhat/thermostat/launcher/internal/Activator.java Fri Jan 25 16:33:19 2013 -0500 +++ b/launcher/src/main/java/com/redhat/thermostat/launcher/internal/Activator.java Wed Jan 16 18:58:59 2013 +0100 @@ -45,11 +45,11 @@ import org.osgi.util.tracker.ServiceTrackerCustomizer; import com.redhat.thermostat.common.CommandLoadingBundleActivator; +import com.redhat.thermostat.common.Launcher; import com.redhat.thermostat.common.cli.CommandContextFactory; import com.redhat.thermostat.common.cli.CommandInfoSource; import com.redhat.thermostat.common.config.Configuration; import com.redhat.thermostat.launcher.BundleManager; -import com.redhat.thermostat.launcher.Launcher; import com.redhat.thermostat.utils.keyring.Keyring; public class Activator extends CommandLoadingBundleActivator { diff -r 4290490a2e05 -r 186115da601f launcher/src/main/java/com/redhat/thermostat/launcher/internal/LauncherImpl.java --- a/launcher/src/main/java/com/redhat/thermostat/launcher/internal/LauncherImpl.java Fri Jan 25 16:33:19 2013 -0500 +++ b/launcher/src/main/java/com/redhat/thermostat/launcher/internal/LauncherImpl.java Wed Jan 16 18:58:59 2013 +0100 @@ -50,11 +50,11 @@ import org.osgi.framework.FrameworkUtil; import org.osgi.framework.ServiceReference; +import com.redhat.thermostat.common.cli.BasicCommand; import com.redhat.thermostat.common.ActionListener; import com.redhat.thermostat.common.ActionNotifier; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.DbService; -import com.redhat.thermostat.common.DbServiceFactory; +import com.redhat.thermostat.common.Launcher; import com.redhat.thermostat.common.Version; import com.redhat.thermostat.common.cli.Arguments; import com.redhat.thermostat.common.cli.Command; @@ -66,12 +66,12 @@ import com.redhat.thermostat.common.config.ClientPreferences; import com.redhat.thermostat.common.config.InvalidConfigurationException; import com.redhat.thermostat.common.tools.ApplicationState; -import com.redhat.thermostat.common.tools.BasicCommand; import com.redhat.thermostat.common.utils.LoggingUtils; import com.redhat.thermostat.common.utils.OSGIUtils; -import com.redhat.thermostat.launcher.Launcher; import com.redhat.thermostat.launcher.BundleManager; import com.redhat.thermostat.storage.core.ConnectionException; +import com.redhat.thermostat.storage.core.DbService; +import com.redhat.thermostat.storage.core.DbServiceFactory; import com.redhat.thermostat.storage.core.Storage; import com.redhat.thermostat.storage.core.StorageException; import com.redhat.thermostat.utils.keyring.Keyring; diff -r 4290490a2e05 -r 186115da601f launcher/src/test/java/com/redhat/thermostat/launcher/TestCommand.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/launcher/src/test/java/com/redhat/thermostat/launcher/TestCommand.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,140 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.launcher; + +import org.apache.commons.cli.Option; +import org.apache.commons.cli.Options; + +import com.redhat.thermostat.common.cli.Command; +import com.redhat.thermostat.common.cli.CommandContext; +import com.redhat.thermostat.common.cli.CommandException; + + +public class TestCommand implements Command { + + private String name; + private Handle handle; + private String description; + private String usage; + private boolean storageRequired; + private boolean availableInShell = true; + private boolean availableOutsideShell = true; + + private Options options = new Options(); + + public static interface Handle { + public void run(CommandContext ctx) throws CommandException; + } + + public TestCommand(String name) { + this(name, null); + } + + public TestCommand(String name, Handle r) { + this.name = name; + this.handle = r; + } + + @Override + public void run(CommandContext ctx) throws CommandException { + if (handle != null) { + handle.run(ctx); + } + } + + @Override + public String getName() { + return name; + } + + @Override + public String getDescription() { + return description; + } + + public void setDescription(String desc) { + description = desc; + } + + @Override + public String getUsage() { + return usage; + } + + public void setUsage(String usage) { + this.usage = usage; + } + + @Override + public Options getOptions() { + return options; + } + + public void addOptions(Option... options) { + for (Option option : options) { + this.options.addOption(option); + } + } + + @Override + public boolean isStorageRequired() { + return storageRequired; + } + + public void setStorageRequired(boolean storageRequired) { + this.storageRequired = storageRequired; + } + + @Override + public boolean isAvailableInShell() { + return availableInShell; + } + + void setAvailableInShell(boolean avaiable) { + this.availableInShell = avaiable; + } + + @Override + public boolean isAvailableOutsideShell() { + return availableOutsideShell; + } + + void setAvailableOutsideShell(boolean available) { + this.availableOutsideShell = available; + } +} + diff -r 4290490a2e05 -r 186115da601f launcher/src/test/java/com/redhat/thermostat/launcher/internal/ActivatorTest.java --- a/launcher/src/test/java/com/redhat/thermostat/launcher/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/launcher/src/test/java/com/redhat/thermostat/launcher/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -71,6 +71,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import com.redhat.thermostat.common.Launcher; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; import com.redhat.thermostat.common.cli.Command; @@ -79,9 +80,8 @@ import com.redhat.thermostat.common.config.Configuration; import com.redhat.thermostat.common.utils.ServiceRegistry; import com.redhat.thermostat.launcher.BundleManager; -import com.redhat.thermostat.launcher.Launcher; import com.redhat.thermostat.launcher.internal.Activator.RegisterLauncherCustomizer; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.utils.keyring.Keyring; @RunWith(PowerMockRunner.class) diff -r 4290490a2e05 -r 186115da601f launcher/src/test/java/com/redhat/thermostat/launcher/internal/HelpCommandTest.java --- a/launcher/src/test/java/com/redhat/thermostat/launcher/internal/HelpCommandTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/launcher/src/test/java/com/redhat/thermostat/launcher/internal/HelpCommandTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -64,9 +64,9 @@ import com.redhat.thermostat.common.cli.CommandInfoNotFoundException; import com.redhat.thermostat.common.cli.CommandInfoSource; import com.redhat.thermostat.common.cli.SimpleArguments; +import com.redhat.thermostat.launcher.TestCommand; import com.redhat.thermostat.launcher.internal.HelpCommand; import com.redhat.thermostat.test.TestCommandContextFactory; -import com.redhat.thermostat.test.cli.TestCommand; @RunWith(PowerMockRunner.class) @PrepareForTest({HelpCommand.class, FrameworkUtil.class}) diff -r 4290490a2e05 -r 186115da601f launcher/src/test/java/com/redhat/thermostat/launcher/internal/LauncherTest.java --- a/launcher/src/test/java/com/redhat/thermostat/launcher/internal/LauncherTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/launcher/src/test/java/com/redhat/thermostat/launcher/internal/LauncherTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -72,12 +72,11 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import com.redhat.thermostat.common.cli.BasicCommand; import com.redhat.thermostat.common.ActionListener; import com.redhat.thermostat.common.ActionNotifier; import com.redhat.thermostat.common.ApplicationInfo; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.DbService; -import com.redhat.thermostat.common.DbServiceFactory; import com.redhat.thermostat.common.Version; import com.redhat.thermostat.common.cli.Arguments; import com.redhat.thermostat.common.cli.Command; @@ -90,15 +89,19 @@ import com.redhat.thermostat.common.locale.LocaleResources; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.common.tools.ApplicationState; -import com.redhat.thermostat.common.tools.BasicCommand; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.launcher.BundleManager; +import com.redhat.thermostat.launcher.TestCommand; +import com.redhat.thermostat.launcher.TestCommand.Handle; +import com.redhat.thermostat.launcher.internal.HelpCommand; +import com.redhat.thermostat.launcher.internal.LauncherImpl; import com.redhat.thermostat.launcher.internal.LauncherImpl.LoggingInitializer; +import com.redhat.thermostat.storage.core.DbService; +import com.redhat.thermostat.storage.core.DbServiceFactory; import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.test.StubBundleContext; import com.redhat.thermostat.test.TestCommandContextFactory; import com.redhat.thermostat.test.TestTimerFactory; -import com.redhat.thermostat.test.cli.TestCommand; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.utils.keyring.Keyring; import com.redhat.thermostat.utils.keyring.KeyringProvider; diff -r 4290490a2e05 -r 186115da601f main/src/main/java/com/redhat/thermostat/main/Thermostat.java --- a/main/src/main/java/com/redhat/thermostat/main/Thermostat.java Fri Jan 25 16:33:19 2013 -0500 +++ b/main/src/main/java/com/redhat/thermostat/main/Thermostat.java Wed Jan 16 18:58:59 2013 +0100 @@ -48,8 +48,8 @@ import org.osgi.framework.BundleException; import org.osgi.util.tracker.ServiceTracker; +import com.redhat.thermostat.common.Launcher; import com.redhat.thermostat.common.config.Configuration; -import com.redhat.thermostat.launcher.Launcher; import com.redhat.thermostat.main.impl.FrameworkProvider; public class Thermostat implements Runnable { diff -r 4290490a2e05 -r 186115da601f main/src/main/java/com/redhat/thermostat/main/impl/FrameworkProvider.java --- a/main/src/main/java/com/redhat/thermostat/main/impl/FrameworkProvider.java Fri Jan 25 16:33:19 2013 -0500 +++ b/main/src/main/java/com/redhat/thermostat/main/impl/FrameworkProvider.java Wed Jan 16 18:58:59 2013 +0100 @@ -59,9 +59,9 @@ import org.osgi.framework.launch.FrameworkFactory; import org.osgi.util.tracker.ServiceTracker; +import com.redhat.thermostat.common.Launcher; import com.redhat.thermostat.common.config.Configuration; import com.redhat.thermostat.launcher.BundleManager; -import com.redhat.thermostat.launcher.Launcher; public class FrameworkProvider { diff -r 4290490a2e05 -r 186115da601f main/src/test/java/com/redhat/thermostat/main/ThermostatTest.java --- a/main/src/test/java/com/redhat/thermostat/main/ThermostatTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/main/src/test/java/com/redhat/thermostat/main/ThermostatTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -60,7 +60,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import com.redhat.thermostat.launcher.Launcher; +import com.redhat.thermostat.common.Launcher; import com.redhat.thermostat.launcher.BundleManager; import com.redhat.thermostat.main.impl.FrameworkProvider; diff -r 4290490a2e05 -r 186115da601f numa/agent/pom.xml --- a/numa/agent/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/numa/agent/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -69,5 +69,11 @@ thermostat-storage-core ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f numa/agent/src/test/java/com/redhat/thermostat/numa/agent/internal/ActivatorTest.java --- a/numa/agent/src/test/java/com/redhat/thermostat/numa/agent/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/numa/agent/src/test/java/com/redhat/thermostat/numa/agent/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -54,7 +54,7 @@ import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.TimerFactory; import com.redhat.thermostat.numa.common.NumaDAO; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f numa/client-core/src/main/java/com/redhat/thermostat/numa/client/core/NumaInformationService.java --- a/numa/client-core/src/main/java/com/redhat/thermostat/numa/client/core/NumaInformationService.java Fri Jan 25 16:33:19 2013 -0500 +++ b/numa/client-core/src/main/java/com/redhat/thermostat/numa/client/core/NumaInformationService.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,9 +41,9 @@ import com.redhat.thermostat.client.core.NameMatchingRefFilter; import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.numa.client.core.internal.NumaController; import com.redhat.thermostat.numa.common.NumaDAO; +import com.redhat.thermostat.storage.core.HostRef; public class NumaInformationService implements InformationService { diff -r 4290490a2e05 -r 186115da601f numa/client-core/src/main/java/com/redhat/thermostat/numa/client/core/internal/Activator.java --- a/numa/client-core/src/main/java/com/redhat/thermostat/numa/client/core/internal/Activator.java Fri Jan 25 16:33:19 2013 -0500 +++ b/numa/client-core/src/main/java/com/redhat/thermostat/numa/client/core/internal/Activator.java Wed Jan 16 18:58:59 2013 +0100 @@ -50,10 +50,10 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.numa.client.core.NumaInformationService; import com.redhat.thermostat.numa.client.core.NumaViewProvider; import com.redhat.thermostat.numa.common.NumaDAO; +import com.redhat.thermostat.storage.core.HostRef; public class Activator implements BundleActivator { diff -r 4290490a2e05 -r 186115da601f numa/client-core/src/main/java/com/redhat/thermostat/numa/client/core/internal/NumaController.java --- a/numa/client-core/src/main/java/com/redhat/thermostat/numa/client/core/internal/NumaController.java Fri Jan 25 16:33:19 2013 -0500 +++ b/numa/client-core/src/main/java/com/redhat/thermostat/numa/client/core/internal/NumaController.java Wed Jan 16 18:58:59 2013 +0100 @@ -48,7 +48,6 @@ import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.Timer.SchedulingType; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.numa.client.core.NumaView; import com.redhat.thermostat.numa.client.core.NumaView.GraphVisibilityChangeListener; @@ -56,6 +55,7 @@ import com.redhat.thermostat.numa.client.locale.LocaleResources; import com.redhat.thermostat.numa.common.NumaDAO; import com.redhat.thermostat.numa.common.NumaStat; +import com.redhat.thermostat.storage.core.HostRef; import com.redhat.thermostat.storage.model.DiscreteTimeData; public class NumaController implements InformationServiceController { diff -r 4290490a2e05 -r 186115da601f numa/client-core/src/test/java/com/redhat/thermostat/numa/client/core/NumaInformationServiceTest.java --- a/numa/client-core/src/test/java/com/redhat/thermostat/numa/client/core/NumaInformationServiceTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/numa/client-core/src/test/java/com/redhat/thermostat/numa/client/core/NumaInformationServiceTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -44,9 +44,9 @@ import com.redhat.thermostat.common.Ordered; import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.TimerFactory; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.numa.client.core.internal.NumaController; import com.redhat.thermostat.numa.common.NumaDAO; +import com.redhat.thermostat.storage.core.HostRef; import static org.mockito.Mockito.*; diff -r 4290490a2e05 -r 186115da601f numa/client-core/src/test/java/com/redhat/thermostat/numa/client/core/internal/ActivatorTest.java --- a/numa/client-core/src/test/java/com/redhat/thermostat/numa/client/core/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/numa/client-core/src/test/java/com/redhat/thermostat/numa/client/core/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -48,7 +48,7 @@ import com.redhat.thermostat.numa.client.core.NumaInformationService; import com.redhat.thermostat.numa.client.core.NumaViewProvider; import com.redhat.thermostat.numa.common.NumaDAO; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f numa/client-core/src/test/java/com/redhat/thermostat/numa/client/core/internal/NumaControllerTest.java --- a/numa/client-core/src/test/java/com/redhat/thermostat/numa/client/core/internal/NumaControllerTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/numa/client-core/src/test/java/com/redhat/thermostat/numa/client/core/internal/NumaControllerTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -64,13 +64,13 @@ import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.Timer.SchedulingType; import com.redhat.thermostat.common.TimerFactory; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.numa.client.core.NumaView; import com.redhat.thermostat.numa.client.core.NumaView.GraphVisibilityChangeListener; import com.redhat.thermostat.numa.client.core.NumaViewProvider; import com.redhat.thermostat.numa.common.NumaDAO; import com.redhat.thermostat.numa.common.NumaNodeStat; import com.redhat.thermostat.numa.common.NumaStat; +import com.redhat.thermostat.storage.core.HostRef; import com.redhat.thermostat.storage.model.DiscreteTimeData; public class NumaControllerTest { diff -r 4290490a2e05 -r 186115da601f numa/client-core/src/test/java/com/redhat/thermostat/numa/client/locale/LocaleResourcesTest.java --- a/numa/client-core/src/test/java/com/redhat/thermostat/numa/client/locale/LocaleResourcesTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/numa/client-core/src/test/java/com/redhat/thermostat/numa/client/locale/LocaleResourcesTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -37,7 +37,7 @@ package com.redhat.thermostat.numa.client.locale; import com.redhat.thermostat.numa.client.locale.LocaleResources; -import com.redhat.thermostat.test.locale.AbstractLocaleResourcesTest; +import com.redhat.thermostat.testutils.AbstractLocaleResourcesTest; public class LocaleResourcesTest extends AbstractLocaleResourcesTest { diff -r 4290490a2e05 -r 186115da601f numa/client-swing/pom.xml --- a/numa/client-swing/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/numa/client-swing/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -70,6 +70,12 @@ com.redhat.thermostat + thermostat-common-test + ${project.version} + test + + + com.redhat.thermostat thermostat-client-swing ${project.version} diff -r 4290490a2e05 -r 186115da601f numa/client-swing/src/test/java/com/redhat/thermostat/numa/client/swing/internal/ActivatorTest.java --- a/numa/client-swing/src/test/java/com/redhat/thermostat/numa/client/swing/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/numa/client-swing/src/test/java/com/redhat/thermostat/numa/client/swing/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -44,7 +44,7 @@ import com.redhat.thermostat.numa.client.core.NumaViewProvider; import com.redhat.thermostat.numa.client.swing.internal.Activator; import com.redhat.thermostat.numa.client.swing.internal.SwingNumaViewProvider; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f numa/common/pom.xml --- a/numa/common/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/numa/common/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -64,5 +64,11 @@ thermostat-storage-core ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f numa/common/src/main/java/com/redhat/thermostat/numa/common/NumaDAO.java --- a/numa/common/src/main/java/com/redhat/thermostat/numa/common/NumaDAO.java Fri Jan 25 16:33:19 2013 -0500 +++ b/numa/common/src/main/java/com/redhat/thermostat/numa/common/NumaDAO.java Wed Jan 16 18:58:59 2013 +0100 @@ -38,8 +38,8 @@ import java.util.List; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.storage.core.Category; +import com.redhat.thermostat.storage.core.HostRef; import com.redhat.thermostat.storage.core.Key; public interface NumaDAO { diff -r 4290490a2e05 -r 186115da601f numa/common/src/main/java/com/redhat/thermostat/numa/common/internal/NumaDAOImpl.java --- a/numa/common/src/main/java/com/redhat/thermostat/numa/common/internal/NumaDAOImpl.java Fri Jan 25 16:33:19 2013 -0500 +++ b/numa/common/src/main/java/com/redhat/thermostat/numa/common/internal/NumaDAOImpl.java Wed Jan 16 18:58:59 2013 +0100 @@ -38,12 +38,12 @@ import java.util.List; -import com.redhat.thermostat.common.dao.HostLatestPojoListGetter; -import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.numa.common.NumaDAO; import com.redhat.thermostat.numa.common.NumaHostInfo; import com.redhat.thermostat.numa.common.NumaStat; import com.redhat.thermostat.storage.core.Cursor; +import com.redhat.thermostat.storage.core.HostLatestPojoListGetter; +import com.redhat.thermostat.storage.core.HostRef; import com.redhat.thermostat.storage.core.Key; import com.redhat.thermostat.storage.core.Put; import com.redhat.thermostat.storage.core.Query; diff -r 4290490a2e05 -r 186115da601f numa/common/src/test/java/com/redhat/thermostat/numa/common/internal/ActivatorTest.java --- a/numa/common/src/test/java/com/redhat/thermostat/numa/common/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/numa/common/src/test/java/com/redhat/thermostat/numa/common/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -46,7 +46,7 @@ import com.redhat.thermostat.numa.common.internal.Activator; import com.redhat.thermostat.numa.common.internal.NumaDAOImpl; import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f storage/core/pom.xml --- a/storage/core/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/storage/core/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -65,6 +65,7 @@ com.redhat.thermostat.storage.core, com.redhat.thermostat.storage.config, com.redhat.thermostat.storage.model, + com.redhat.thermostat.storage.dao, com.redhat.thermostat.* + + com.redhat.thermostat.storage.internal.dao, + com.redhat.thermostat.storage.internal, + com.redhat.thermostat.storage.internal.test, + <_nouses>true @@ -99,6 +105,12 @@ ${project.version} compile + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/config/ConnectionConfiguration.java --- a/storage/core/src/main/java/com/redhat/thermostat/storage/config/ConnectionConfiguration.java Fri Jan 25 16:33:19 2013 -0500 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/config/ConnectionConfiguration.java Wed Jan 16 18:58:59 2013 +0100 @@ -36,7 +36,6 @@ package com.redhat.thermostat.storage.config; - public class ConnectionConfiguration implements StartupConfiguration, AuthenticationConfiguration { private String dbUrl; diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/core/Countable.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/Countable.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,44 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.core; + +public interface Countable { + + public long getCount(); + +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/core/DbService.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/DbService.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,68 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.core; + +import com.redhat.thermostat.annotations.Service; +import com.redhat.thermostat.storage.core.ConnectionException; + +@Service +public interface DbService { + + /** + * Connects to the given database. + * + * @throws ConnectionException + * If DB connection cannot be established. + */ + void connect() throws ConnectionException; + + /** + * Disconnects from the database. + * + * @throws ConnectionException + */ + void disconnect() throws ConnectionException; + + /** + * @returns the storage URL which was used for connection. + * + * @throws IllegalStateException + * if not connected to storage. + */ + String getConnectionUrl(); +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/core/DbServiceFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/DbServiceFactory.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,53 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.core; + +import com.redhat.thermostat.storage.internal.DbServiceImpl; + +/* + * Factory in order to be able to hide the DbService implementation. Note that + * this package will be part of Export-Package whereas the package where *Impl + * classes are won't be. + * + */ +public class DbServiceFactory { + + public DbService createDbService(String username, String password, String dbUrl) { + return DbServiceImpl.create(username, password, dbUrl); + } +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/core/DefaultHostsVMsLoader.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/DefaultHostsVMsLoader.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,77 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.core; + +import java.util.Collection; + +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.dao.VmInfoDAO; + +public class DefaultHostsVMsLoader implements HostsVMsLoader { + + private HostInfoDAO hostsDAO; + private VmInfoDAO vmsDAO; + private boolean liveHosts; + + /** + * + * @param hostDAO + * @param vmsDAO + * @param liveHosts {@code true} if only alive agent documents should get retrieved. + */ + public DefaultHostsVMsLoader(HostInfoDAO hostDAO, VmInfoDAO vmsDAO, boolean liveHosts) { + this.hostsDAO = hostDAO; + this.vmsDAO = vmsDAO; + this.liveHosts = liveHosts; + } + + @Override + public Collection getHosts() { + if (liveHosts) { + return hostsDAO.getAliveHosts(); + } else { + return hostsDAO.getHosts(); + } + } + + @Override + public Collection getVMs(HostRef host) { + return vmsDAO.getVMs(host); + } + +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/core/HostLatestPojoListGetter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/HostLatestPojoListGetter.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,83 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.core; + +import java.util.ArrayList; +import java.util.List; + +import com.redhat.thermostat.storage.core.Category; +import com.redhat.thermostat.storage.core.Cursor; +import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.core.Query; +import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.core.Query.Criteria; +import com.redhat.thermostat.storage.model.TimeStampedPojo; + +public class HostLatestPojoListGetter { + + private final Storage storage; + private final Category cat; + + public HostLatestPojoListGetter(Storage storage, Category cat) { + this.storage = storage; + this.cat = cat; + } + + public List getLatest(HostRef hostRef, long since) { + Query query = buildQuery(hostRef, since); + return getLatest(query); + } + + private List getLatest(Query query) { + Cursor cursor = query.execute(); + List result = new ArrayList<>(); + while (cursor.hasNext()) { + T pojo = cursor.next(); + result.add(pojo); + } + return result; + } + + protected Query buildQuery(HostRef hostRef, long since) { + Query query = storage.createQuery(cat); + query.where(Key.AGENT_ID, Criteria.EQUALS, hostRef.getAgentId()); + query.where(Key.TIMESTAMP, Criteria.GREATER_THAN, since); + query.sort(Key.TIMESTAMP, Query.SortDirection.DESCENDING); + return query; + } +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/core/HostRef.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/HostRef.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,99 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.core; + +public class HostRef implements Ref { + + private final String uid; + private final String name; + + public HostRef(String id, String name) { + this.uid = id; + this.name = name; + } + + @Override + public String toString() { + return name; + } + + public String getAgentId() { + return uid; + } + + public String getHostName() { + return name; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (obj == this) { + return true; + } + if (obj.getClass() != this.getClass()) { + return false; + } + HostRef other = (HostRef) obj; + if (equals(this.uid, other.uid) && equals(this.name, other.name)) { + return true; + } + return false; + } + + private static boolean equals(Object obj1, Object obj2) { + return (obj1 == null && obj2 == null) || (obj1 != null && obj1.equals(obj2)); + } + + @Override + public int hashCode() { + return uid.hashCode(); + } + + @Override + public String getStringID() { + return getAgentId(); + } + + @Override + public String getName() { + return getHostName(); + } +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/core/HostsVMsLoader.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/HostsVMsLoader.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,50 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.core; + +import java.util.Collection; + + +/** + * Provides a way to load the current hosts and VMs. + */ +public interface HostsVMsLoader { + + Collection getHosts(); + Collection getVMs(HostRef host); +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/core/Ref.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/Ref.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,44 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.core; + +public interface Ref { + + String getStringID(); + String getName(); +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/core/VmLatestPojoListGetter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/VmLatestPojoListGetter.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,85 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.core; + +import java.util.ArrayList; +import java.util.List; + +import com.redhat.thermostat.storage.core.Category; +import com.redhat.thermostat.storage.core.Cursor; +import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.core.Query; +import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.core.Query.Criteria; +import com.redhat.thermostat.storage.model.TimeStampedPojo; + +public class VmLatestPojoListGetter { + + private final Storage storage; + private final Category cat; + + public VmLatestPojoListGetter(Storage storage, Category cat) { + this.storage = storage; + this.cat = cat; + } + + public List getLatest(VmRef vmRef, long since) { + Query query = buildQuery(vmRef, since); + return getLatest(query); + } + + private List getLatest(Query query) { + Cursor cursor = query.execute(); + List result = new ArrayList<>(); + while (cursor.hasNext()) { + T pojo = cursor.next(); + result.add(pojo); + } + return result; + } + + protected Query buildQuery(VmRef vmRef, long since) { + Query query = storage.createQuery(cat); + query.where(Key.AGENT_ID, Criteria.EQUALS, vmRef.getAgent().getAgentId()); + query.where(Key.VM_ID, Criteria.EQUALS, vmRef.getId()); + query.where(Key.TIMESTAMP, Criteria.GREATER_THAN, since); + query.sort(Key.TIMESTAMP, Query.SortDirection.DESCENDING); + return query; + } + +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/core/VmRef.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/VmRef.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,109 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.core; + +public class VmRef implements Ref { + + private final HostRef hostRef; + private final Integer uid; + private final String uidString; + private final String name; + + public VmRef(HostRef hostRef, Integer id, String name) { + this.hostRef = hostRef; + this.uid = id; + this.uidString = id.toString(); + this.name = name; + } + + @Override + public String toString() { + return name; + } + + public HostRef getAgent() { + return hostRef; + } + + public Integer getId() { + return uid; + } + + /** + * Equivalent to {@link #getStringID()}. + */ + public String getIdString() { + return uidString; + } + + public String getName() { + return name; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (obj == this) { + return true; + } + if (obj.getClass() != this.getClass()) { + return false; + } + VmRef other = (VmRef) obj; + if (equals(this.hostRef, other.hostRef) && equals(this.uid, other.uid) && equals(this.name, other.name)) { + return true; + } + return false; + } + + private static boolean equals(Object obj1, Object obj2) { + return (obj1 == null && obj2 == null) || (obj1 != null && obj1.equals(obj2)); + } + + @Override + public int hashCode() { + return uid.hashCode(); + } + + @Override + public String getStringID() { + return getIdString(); + } +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/dao/AgentInfoDAO.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/dao/AgentInfoDAO.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,76 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.dao; + +import java.util.List; + +import com.redhat.thermostat.annotations.Service; +import com.redhat.thermostat.storage.core.Category; +import com.redhat.thermostat.storage.core.Countable; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.model.AgentInformation; + +@Service +public interface AgentInfoDAO extends Countable { + + static final Key START_TIME_KEY = new Key<>("startTime", false); + static final Key STOP_TIME_KEY = new Key<>("stopTime", false); + static final Key ALIVE_KEY = new Key<>("alive", false); + static final Key CONFIG_LISTEN_ADDRESS = new Key<>("configListenAddress", false); + + static final Category CATEGORY = new Category<>("agent-config", AgentInformation.class, + Key.AGENT_ID, + START_TIME_KEY, + STOP_TIME_KEY, + ALIVE_KEY, + CONFIG_LISTEN_ADDRESS); + + List getAllAgentInformation(); + + List getAliveAgents(); + + AgentInformation getAgentInformation(HostRef agentRef); + + void addAgentInformation(AgentInformation agentInfo); + + void updateAgentInformation(AgentInformation agentInfo); + + void removeAgentInformation(AgentInformation agentInfo); + +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/dao/BackendInfoDAO.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/dao/BackendInfoDAO.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,73 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.dao; + +import java.util.List; + +import com.redhat.thermostat.annotations.Service; +import com.redhat.thermostat.storage.core.Category; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.model.BackendInformation; + +@Service +public interface BackendInfoDAO { + + static final Key BACKEND_NAME = new Key<>("name", true); + static final Key BACKEND_DESCRIPTION = new Key<>("description", false); + static final Key IS_ACTIVE = new Key<>("active", false); + static final Key SHOULD_MONITOR_NEW_PROCESSES = new Key<>("observeNewJvm", false); + static final Key> PIDS_TO_MONITOR = new Key<>("pids", false); + static final Key ORDER_VALUE = new Key<>("orderValue", false); + + static final Category CATEGORY = new Category<>("backend-info", BackendInformation.class, + Key.AGENT_ID, + BACKEND_NAME, + BACKEND_DESCRIPTION, + IS_ACTIVE, + SHOULD_MONITOR_NEW_PROCESSES, + PIDS_TO_MONITOR, + ORDER_VALUE); + + List getBackendInformation(HostRef host); + + void addBackendInformation(BackendInformation info); + + void removeBackendInformation(BackendInformation info); + +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/dao/DAOException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/dao/DAOException.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,58 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.dao; + +public class DAOException extends RuntimeException { + + public DAOException() { + super(); + } + + public DAOException(String message) { + super(message); + } + + public DAOException(Throwable cause) { + super(cause); + } + + public DAOException(String message, Throwable cause) { + super(message, cause); + } + +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/dao/DAOFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/dao/DAOFactory.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,63 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.dao; + +import com.redhat.thermostat.storage.core.Connection; +import com.redhat.thermostat.storage.core.Storage; + +public interface DAOFactory { + + // TODO this is temporary until DAO is made for those that are still using Storage directly. + public Storage getStorage(); + + public Connection getConnection(); + + public AgentInfoDAO getAgentInfoDAO(); + + public BackendInfoDAO getBackendInfoDAO(); + + public HostInfoDAO getHostInfoDAO(); + + public NetworkInterfaceInfoDAO getNetworkInterfaceInfoDAO(); + + public VmInfoDAO getVmInfoDAO(); + + public void registerDAOsAndStorageAsOSGiServices(); + public void unregisterDAOsAndStorageAsOSGiServices(); + +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/dao/DAOFactoryImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/dao/DAOFactoryImpl.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,166 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.dao; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceRegistration; + +import com.redhat.thermostat.storage.core.Connection; +import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.core.StorageProvider; +import com.redhat.thermostat.storage.internal.dao.AgentInfoDAOImpl; +import com.redhat.thermostat.storage.internal.dao.BackendInfoDAOImpl; +import com.redhat.thermostat.storage.internal.dao.HostInfoDAOImpl; +import com.redhat.thermostat.storage.internal.dao.NetworkInterfaceInfoDAOImpl; +import com.redhat.thermostat.storage.internal.dao.VmInfoDAOImpl; + +/* + * TODO: This class should go away, but is still used in AgentApplication and (client) Main classes. + */ +public class DAOFactoryImpl implements DAOFactory { + + private final Storage storage; + private final BundleContext bundleContext; + @SuppressWarnings("rawtypes") + private final List registeredServices = new ArrayList<>(); + private AgentInfoDAO agentDAO; + private BackendInfoDAO backendInfoDAO; + private HostInfoDAO hostInfoDAO; + private NetworkInterfaceInfoDAO networkInfoDAO; + private VmInfoDAO vmInfoDAO; + + public DAOFactoryImpl(StorageProvider prov) { + this(FrameworkUtil.getBundle(DAOFactoryImpl.class).getBundleContext(), prov); + } + + public DAOFactoryImpl(BundleContext bundleContext, StorageProvider prov) { + this.bundleContext = bundleContext; + storage = prov.createStorage(); + } + + @Override + public Connection getConnection() { + return storage.getConnection(); + } + + @Override + public AgentInfoDAO getAgentInfoDAO() { + ensureStorageConnected(); + return agentDAO; + } + + @Override + public BackendInfoDAO getBackendInfoDAO() { + ensureStorageConnected(); + return backendInfoDAO; + } + + @Override + public HostInfoDAO getHostInfoDAO() { + ensureStorageConnected(); + return hostInfoDAO; + } + + @Override + public NetworkInterfaceInfoDAO getNetworkInterfaceInfoDAO() { + ensureStorageConnected(); + return networkInfoDAO; + } + + @Override + public VmInfoDAO getVmInfoDAO() { + ensureStorageConnected(); + return vmInfoDAO; + } + + @Override + public Storage getStorage() { + return storage; + } + + private void ensureStorageConnected() { + if (!storage.getConnection().isConnected()) { + throw new IllegalStateException("Set up connection before accessing DAO"); + } + } + + @Override + public void registerDAOsAndStorageAsOSGiServices() { + ensureStorageConnected(); + createDAOs(); + registerAndRecordService(Storage.class, getStorage()); + + registerAndRecordService(AgentInfoDAO.class, getAgentInfoDAO()); + registerAndRecordService(BackendInfoDAO.class, getBackendInfoDAO()); + + registerAndRecordService(HostInfoDAO.class, getHostInfoDAO()); + registerAndRecordService(NetworkInterfaceInfoDAO.class, getNetworkInterfaceInfoDAO()); + + registerAndRecordService(VmInfoDAO.class, getVmInfoDAO()); + } + + /* + * Pre: Db connected + */ + void createDAOs() { + agentDAO = new AgentInfoDAOImpl(storage); + backendInfoDAO = new BackendInfoDAOImpl(storage); + hostInfoDAO = new HostInfoDAOImpl(storage, agentDAO); + networkInfoDAO = new NetworkInterfaceInfoDAOImpl(storage); + vmInfoDAO = new VmInfoDAOImpl(storage); + } + + private void registerAndRecordService(Class serviceType, K serviceImplementation) { + registeredServices.add(bundleContext.registerService(serviceType, serviceImplementation, null)); + } + + public void unregisterDAOsAndStorageAsOSGiServices() { + Iterator iter = registeredServices.iterator(); + while (iter.hasNext()) { + ServiceRegistration registration = iter.next(); + registration.unregister(); + iter.remove(); + } + } + +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/dao/HostInfoDAO.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/dao/HostInfoDAO.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,69 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.dao; + +import java.util.Collection; + +import com.redhat.thermostat.annotations.Service; +import com.redhat.thermostat.storage.core.Category; +import com.redhat.thermostat.storage.core.Countable; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.model.HostInfo; + +@Service +public interface HostInfoDAO extends Countable { + + static Key hostNameKey = new Key<>("hostname", true); + static Key osNameKey = new Key<>("osName", false); + static Key osKernelKey = new Key<>("osKernel", false); + static Key cpuCountKey = new Key<>("cpuCount", false); + static Key cpuModelKey = new Key<>("cpuModel", false); + static Key hostMemoryTotalKey = new Key<>("totalMemory", false); + + static final Category hostInfoCategory = new Category<>("host-info", HostInfo.class, + Key.AGENT_ID, hostNameKey, osNameKey, osKernelKey, + cpuCountKey, cpuModelKey, hostMemoryTotalKey); + + HostInfo getHostInfo(HostRef ref); + + void putHostInfo(HostInfo info); + + Collection getHosts(); + Collection getAliveHosts(); +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/dao/NetworkInterfaceInfoDAO.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/dao/NetworkInterfaceInfoDAO.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,61 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.dao; + +import java.util.List; + +import com.redhat.thermostat.annotations.Service; +import com.redhat.thermostat.storage.core.Category; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.model.NetworkInterfaceInfo; + +@Service +public interface NetworkInterfaceInfoDAO { + + static Key ifaceKey = new Key<>("interfaceName", true); + static Key ip4AddrKey = new Key<>("ip4Addr", false); + static Key ip6AddrKey = new Key<>("ip6Addr", false); + + static final Category networkInfoCategory = new Category<>("network-info", NetworkInterfaceInfo.class, + Key.AGENT_ID, ifaceKey, ip4AddrKey, ip6AddrKey); + + public List getNetworkInterfaces(HostRef ref); + + public void putNetworkInterfaceInfo(NetworkInterfaceInfo info); +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/dao/VmInfoDAO.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/dao/VmInfoDAO.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,84 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.dao; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import com.redhat.thermostat.annotations.Service; +import com.redhat.thermostat.storage.core.Category; +import com.redhat.thermostat.storage.core.Countable; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.model.VmInfo; + +@Service +public interface VmInfoDAO extends Countable { + + static final Key vmPidKey = new Key<>("vmPid", false); + static final Key runtimeVersionKey = new Key<>("javaVersion", false); + static final Key javaHomeKey = new Key<>("javaHome", false); + static final Key mainClassKey = new Key<>("mainClass", false); + static final Key commandLineKey = new Key<>("javaCommandLine", false); + static final Key vmArgumentsKey = new Key<>("vmArguments", false); + static final Key vmNameKey = new Key<>("vmName", false); + static final Key vmInfoKey = new Key<>("vmInfo", false); + static final Key vmVersionKey = new Key<>("vmVersion", false); + static final Key> propertiesKey = new Key<>("properties", false); + static final Key> environmentKey = new Key<>("environment", false); + static final Key> librariesKey = new Key<>("loadedNativeLibraries", false); + static final Key startTimeKey = new Key<>("startTimeStamp", false); + static final Key stopTimeKey = new Key<>("stopTimeStamp", false); + + static final Category vmInfoCategory = new Category<>("vm-info", VmInfo.class, + Key.AGENT_ID, Key.VM_ID, vmPidKey, runtimeVersionKey, javaHomeKey, + mainClassKey, commandLineKey, + vmArgumentsKey, vmNameKey, vmInfoKey, vmVersionKey, + propertiesKey, environmentKey, librariesKey, + startTimeKey, stopTimeKey); + + public VmInfo getVmInfo(VmRef ref); + + Collection getVMs(HostRef host); + + public void putVmInfo(VmInfo info); + + public void putVmStoppedTime(int vmId, long since); +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/internal/DbServiceImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/internal/DbServiceImpl.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,122 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.internal; + +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceRegistration; + +import com.redhat.thermostat.storage.config.ConnectionConfiguration; +import com.redhat.thermostat.storage.config.StartupConfiguration; +import com.redhat.thermostat.storage.core.ConnectionException; +import com.redhat.thermostat.storage.core.DbService; +import com.redhat.thermostat.storage.core.StorageException; +import com.redhat.thermostat.storage.core.StorageProvider; +import com.redhat.thermostat.storage.core.StorageProviderUtil; +import com.redhat.thermostat.storage.dao.DAOFactory; +import com.redhat.thermostat.storage.dao.DAOFactoryImpl; + +public class DbServiceImpl implements DbService { + + @SuppressWarnings("rawtypes") + private ServiceRegistration registration; + + private DAOFactory daoFactory; + private BundleContext context; + private String dbUrl; + + DbServiceImpl(String username, String password, String dbUrl) throws StorageException { + this(FrameworkUtil.getBundle(DbService.class).getBundleContext(), getDAOFactory(username, password, dbUrl), dbUrl); + } + + // for testing + DbServiceImpl(BundleContext context, DAOFactory daoFactory, String dbUrl) { + this.daoFactory = daoFactory; + this.context = context; + this.dbUrl = dbUrl; + } + + public void connect() throws ConnectionException { + try { + daoFactory.getConnection().connect(); + registration = context.registerService(DbService.class, this, null); + daoFactory.registerDAOsAndStorageAsOSGiServices(); + } catch (Exception cause) { + throw new ConnectionException(cause); + } + } + + public void disconnect() throws ConnectionException { + try { + daoFactory.unregisterDAOsAndStorageAsOSGiServices(); + daoFactory.getConnection().disconnect(); + registration.unregister(); + } catch (Exception cause) { + throw new ConnectionException(cause); + } + } + + @Override + public String getConnectionUrl() { + return dbUrl; + } + + /** + * Factory method for creating a DbService instance. + * + * @param username + * @param password + * @param dbUrl + * @return a DbService instance + * @throws StorageException if no storage provider exists for the given {@code dbUrl}. + */ + public static DbService create(String username, String password, String dbUrl) throws StorageException { + return new DbServiceImpl(username, password, dbUrl); + } + + private static DAOFactory getDAOFactory(String username, String password, String dbUrl) throws StorageException { + StartupConfiguration config = new ConnectionConfiguration(dbUrl, username, password); + StorageProvider prov = StorageProviderUtil.getStorageProvider(config); + if (prov == null) { + // no suitable provider found + throw new StorageException("No storage found for URL " + dbUrl); + } + return new DAOFactoryImpl(prov); + } + +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/AgentInfoDAOImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/AgentInfoDAOImpl.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,131 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.internal.dao; + +import java.util.ArrayList; +import java.util.List; + +import com.redhat.thermostat.storage.core.Cursor; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.core.Put; +import com.redhat.thermostat.storage.core.Query; +import com.redhat.thermostat.storage.core.Remove; +import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.core.Update; +import com.redhat.thermostat.storage.core.Query.Criteria; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; +import com.redhat.thermostat.storage.model.AgentInformation; + +public class AgentInfoDAOImpl implements AgentInfoDAO { + + private final Storage storage; + + public AgentInfoDAOImpl(Storage storage) { + this.storage = storage; + storage.registerCategory(CATEGORY); + } + + @Override + public long getCount() { + return storage.getCount(CATEGORY); + } + + @Override + public List getAllAgentInformation() { + Query query = storage.createQuery(CATEGORY); + Cursor agentCursor = query.execute(); + + List results = new ArrayList<>(); + + while (agentCursor.hasNext()) { + AgentInformation agentInfo = agentCursor.next(); + results.add(agentInfo); + } + return results; + } + + @Override + public List getAliveAgents() { + Query query = storage.createQuery(CATEGORY); + query.where(AgentInfoDAO.ALIVE_KEY, Criteria.EQUALS, true); + + Cursor agentCursor = query.execute(); + + List results = new ArrayList<>(); + + while (agentCursor.hasNext()) { + AgentInformation agentInfo = agentCursor.next(); + results.add(agentInfo); + } + return results; + } + + @Override + public AgentInformation getAgentInformation(HostRef agentRef) { + Query query = storage.createQuery(CATEGORY); + query.where(Key.AGENT_ID, Criteria.EQUALS, agentRef.getAgentId()); + query.limit(1); + return query.execute().next(); + } + + @Override + public void addAgentInformation(AgentInformation agentInfo) { + Put replace = storage.createReplace(CATEGORY); + replace.setPojo(agentInfo); + replace.apply(); + } + + @Override + public void removeAgentInformation(AgentInformation agentInfo) { + Remove remove = storage.createRemove().from(CATEGORY).where(Key.AGENT_ID, agentInfo.getAgentId()); + storage.removePojo(remove); + } + + @Override + public void updateAgentInformation(AgentInformation agentInfo) { + Update update = storage.createUpdate(CATEGORY); + update.where(Key.AGENT_ID, agentInfo.getAgentId()); + update.set(START_TIME_KEY, agentInfo.getStartTime()); + update.set(STOP_TIME_KEY, agentInfo.getStopTime()); + update.set(ALIVE_KEY, agentInfo.isAlive()); + update.set(CONFIG_LISTEN_ADDRESS, agentInfo.getConfigListenAddress()); + update.apply(); + } + +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/BackendInfoDAOImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/BackendInfoDAOImpl.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,110 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.internal.dao; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +import com.redhat.thermostat.storage.core.Cursor; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.core.Put; +import com.redhat.thermostat.storage.core.Query; +import com.redhat.thermostat.storage.core.Query.Criteria; +import com.redhat.thermostat.storage.core.Remove; +import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.dao.BackendInfoDAO; +import com.redhat.thermostat.storage.model.BackendInformation; + +public class BackendInfoDAOImpl implements BackendInfoDAO { + + private final Storage storage; + + public BackendInfoDAOImpl(Storage storage) { + this.storage = storage; + storage.registerCategory(CATEGORY); + } + + @Override + public List getBackendInformation(HostRef host) { + // Sort by order value + Query query = storage.createQuery(CATEGORY); + query.where(Key.AGENT_ID, Criteria.EQUALS, host.getAgentId()); + + List results = new ArrayList<>(); + Cursor cursor = query.execute(); + while (cursor.hasNext()) { + BackendInformation backendInfo = cursor.next(); + results.add(backendInfo); + } + + // Sort before returning + Collections.sort(results, new Comparator() { + + // TODO Use OrderedComparator when common-core + // doesn't depend on storage-core + @Override + public int compare(BackendInformation o1, BackendInformation o2) { + int result = o1.getOrderValue() - o2.getOrderValue(); + // Break ties using class name + if (result == 0) { + result = o1.getClass().getName().compareTo(o2.getClass().getName()); + } + return result; + } + }); + + return results; + } + + @Override + public void addBackendInformation(BackendInformation info) { + Put add = storage.createAdd(BackendInfoDAO.CATEGORY); + add.setPojo(info); + add.apply(); + } + + @Override + public void removeBackendInformation(BackendInformation info) { + Remove remove = storage.createRemove().from(CATEGORY).where(BACKEND_NAME, info.getName()); + storage.removePojo(remove); + } + +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/HostInfoDAOImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/HostInfoDAOImpl.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,121 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.internal.dao; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import com.redhat.thermostat.storage.core.Cursor; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.core.Put; +import com.redhat.thermostat.storage.core.Query; +import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.core.Query.Criteria; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.model.AgentInformation; +import com.redhat.thermostat.storage.model.HostInfo; + +public class HostInfoDAOImpl implements HostInfoDAO { + + private final Storage storage; + private final AgentInfoDAO agentInfoDao; + + + public HostInfoDAOImpl(Storage storage, AgentInfoDAO agentInfo) { + this.storage = storage; + this.agentInfoDao = agentInfo; + storage.registerCategory(hostInfoCategory); + } + + @Override + public HostInfo getHostInfo(HostRef ref) { + Query query = storage.createQuery(hostInfoCategory); + query.where(Key.AGENT_ID, Criteria.EQUALS, ref.getAgentId()); + query.limit(1); + HostInfo result = query.execute().next(); + return result; + } + + @Override + public void putHostInfo(HostInfo info) { + Put add = storage.createAdd(hostInfoCategory); + add.setPojo(info); + add.apply(); + } + + @Override + public Collection getHosts() { + Query allHosts = storage.createQuery(hostInfoCategory); + return getHosts(allHosts); + } + + @Override + public Collection getAliveHosts() { + List hosts = new ArrayList<>(); + List agentInfos = agentInfoDao.getAliveAgents(); + for (AgentInformation agentInfo : agentInfos) { + Query filter = storage.createQuery(hostInfoCategory); + filter.where(Key.AGENT_ID, Criteria.EQUALS, agentInfo.getAgentId()); + hosts.addAll(getHosts(filter)); + } + + return hosts; + } + + + private Collection getHosts(Query filter) { + Collection hosts = new ArrayList(); + + Cursor hostsCursor = filter.execute(); + while(hostsCursor.hasNext()) { + HostInfo host = hostsCursor.next(); + String agentId = host.getAgentId(); + String hostName = host.getHostname(); + hosts.add(new HostRef(agentId, hostName)); + } + return hosts; + } + + @Override + public long getCount() { + return storage.getCount(hostInfoCategory); + } +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/NetworkInterfaceInfoDAOImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/NetworkInterfaceInfoDAOImpl.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,83 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.internal.dao; + +import java.util.ArrayList; +import java.util.List; + +import com.redhat.thermostat.storage.core.Cursor; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.core.Put; +import com.redhat.thermostat.storage.core.Query; +import com.redhat.thermostat.storage.core.Query.Criteria; +import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.dao.NetworkInterfaceInfoDAO; +import com.redhat.thermostat.storage.model.NetworkInterfaceInfo; + +public class NetworkInterfaceInfoDAOImpl implements NetworkInterfaceInfoDAO { + + private Storage storage; + + public NetworkInterfaceInfoDAOImpl(Storage storage) { + this.storage = storage; + storage.registerCategory(networkInfoCategory); + } + + @Override + public List getNetworkInterfaces(HostRef ref) { + Query allHostNetworkInterfaces = storage.createQuery(networkInfoCategory); + allHostNetworkInterfaces.where(Key.AGENT_ID, Criteria.EQUALS, ref.getAgentId()); + + Cursor cursor = allHostNetworkInterfaces.execute(); + List result = new ArrayList<>(); + while (cursor.hasNext()) { + NetworkInterfaceInfo stat = cursor.next(); + result.add(stat); + } + return result; + } + + @Override + public void putNetworkInterfaceInfo(NetworkInterfaceInfo info) { + Put replace = storage.createReplace(networkInfoCategory); + replace.setPojo(info); + replace.apply(); + } + +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/VmInfoDAOImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/VmInfoDAOImpl.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,132 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.internal.dao; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import com.redhat.thermostat.storage.core.Cursor; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.core.Put; +import com.redhat.thermostat.storage.core.Query; +import com.redhat.thermostat.storage.core.Query.Criteria; +import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.core.Update; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.DAOException; +import com.redhat.thermostat.storage.dao.VmInfoDAO; +import com.redhat.thermostat.storage.model.VmInfo; + +public class VmInfoDAOImpl implements VmInfoDAO { + + private final Storage storage; + + public VmInfoDAOImpl(Storage storage) { + this.storage = storage; + storage.registerCategory(vmInfoCategory); + } + + @Override + public VmInfo getVmInfo(VmRef ref) { + Query findMatchingVm = storage.createQuery(vmInfoCategory); + findMatchingVm.where(Key.AGENT_ID, Criteria.EQUALS, ref.getAgent().getAgentId()); + findMatchingVm.where(Key.VM_ID, Criteria.EQUALS, ref.getId()); + findMatchingVm.limit(1); + VmInfo result = findMatchingVm.execute().next(); + if (result == null) { + throw new DAOException("Unknown VM: host:" + ref.getAgent().getAgentId() + ";vm:" + ref.getId()); + } + return result; + } + + @Override + public Collection getVMs(HostRef host) { + + Query query = buildQuery(host); + Cursor cursor = query.execute(); + return buildVMsFromQuery(cursor, host); + } + + private Query buildQuery(HostRef host) { + Query query = storage.createQuery(vmInfoCategory); + query.where(Key.AGENT_ID, Criteria.EQUALS, host.getAgentId()); + return query; + } + + private Collection buildVMsFromQuery(Cursor cursor, HostRef host) { + List vmRefs = new ArrayList(); + while (cursor.hasNext()) { + VmInfo vmInfo = cursor.next(); + VmRef vm = buildVmRefFromChunk(vmInfo, host); + vmRefs.add(vm); + } + + return vmRefs; + } + + private VmRef buildVmRefFromChunk(VmInfo vmInfo, HostRef host) { + Integer id = vmInfo.getVmId(); + // TODO can we do better than the main class? + String mainClass = vmInfo.getMainClass(); + VmRef ref = new VmRef(host, id, mainClass); + return ref; + } + + @Override + public long getCount() { + return storage.getCount(vmInfoCategory); + } + + @Override + public void putVmInfo(VmInfo info) { + Put replace = storage.createReplace(vmInfoCategory); + replace.setPojo(info); + replace.apply(); + } + + @Override + public void putVmStoppedTime(int vmId, long timestamp) { + Update update = storage.createUpdate(vmInfoCategory); + update.where(Key.VM_ID, vmId); + update.set(VmInfoDAO.stopTimeKey, timestamp); + update.apply(); + } + +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/test/java/com/redhat/thermostat/storage/core/DefaultHostsVMsLoaderTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/test/java/com/redhat/thermostat/storage/core/DefaultHostsVMsLoaderTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,109 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.core; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.Collection; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.redhat.thermostat.storage.core.DefaultHostsVMsLoader; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.dao.VmInfoDAO; + +public class DefaultHostsVMsLoaderTest { + + private HostInfoDAO mockHostsDAO; + private VmInfoDAO mockVmsDAO; + private DefaultHostsVMsLoader loader; + + @Before + public void setUp() throws Exception { + mockHostsDAO = mock(HostInfoDAO.class); + mockVmsDAO = mock(VmInfoDAO.class); + } + + @After + public void tearDown() throws Exception { + mockHostsDAO = null; + mockVmsDAO = null; + loader = null; + } + + @Test + public void canGetHosts() { + Collection expectedHosts = new ArrayList<>(); + expectedHosts.add(new HostRef("123", "fluffhost1")); + expectedHosts.add(new HostRef("456", "fluffhost2")); + expectedHosts.add(new HostRef("007", "deadHost")); + + loader = new DefaultHostsVMsLoader(mockHostsDAO, mockVmsDAO, false); + when(mockHostsDAO.getHosts()).thenReturn(expectedHosts); + assertEquals(loader.getHosts(), expectedHosts); + + loader = new DefaultHostsVMsLoader(mockHostsDAO, mockVmsDAO, true); + Collection aliveHosts = new ArrayList<>(); + expectedHosts.add(new HostRef("123", "fluffhost1")); + expectedHosts.add(new HostRef("456", "fluffhost2")); + when(mockHostsDAO.getAliveHosts()).thenReturn(aliveHosts); + assertEquals(loader.getHosts(), aliveHosts); + } + + @Test + public void canGetVms() { + HostRef hostR = mock(HostRef.class); + Collection expectedVms = new ArrayList<>(); + expectedVms.add(new VmRef(hostR, 1, "test1")); + expectedVms.add(new VmRef(hostR, 2, "test2")); + + loader = new DefaultHostsVMsLoader(mockHostsDAO, mockVmsDAO, false /* irrelevant */); + when(mockVmsDAO.getVMs(hostR)).thenReturn(expectedVms); + assertEquals(loader.getVMs(hostR), expectedVms); + + assertEquals(0, loader.getVMs(mock(HostRef.class)).size()); + } + +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/test/java/com/redhat/thermostat/storage/core/HostLatestPojoListGetterTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/test/java/com/redhat/thermostat/storage/core/HostLatestPojoListGetterTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,172 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.core; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +import java.util.List; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.redhat.thermostat.storage.core.Category; +import com.redhat.thermostat.storage.core.Cursor; +import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.core.Query; +import com.redhat.thermostat.storage.core.Query.Criteria; +import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.model.CpuStat; + +public class HostLatestPojoListGetterTest { + private static final String AGENT_ID = "agentid"; + private static final String HOSTNAME = "host.example.com"; + private static final String CATEGORY_NAME = "hostcategory"; + // Make this one static so we don't get IllegalStateException from trying + // to make category of same name while running tests in same classloader. + private static final Category cat = new Category<>(CATEGORY_NAME, CpuStat.class); + + private static long t1 = 1; + private static long t2 = 5; + private static long t3 = 10; + + private static Double load5_1 = 2.0; + private static Double load5_2 = 6.0; + private static Double load5_3 = 11.0; + + private static Double load10_1 = 3.0; + private static Double load10_2 = 7.0; + private static Double load10_3 = 12.0; + + private static Double load15_1 = 4.0; + private static Double load15_2 = 8.0; + private static Double load15_3 = 13.0; + + private HostRef ref; + private CpuStat result1, result2, result3; + + @Before + public void setUp() { + ref = new HostRef(AGENT_ID, HOSTNAME); + result1 = new CpuStat(t1, new double[] { load5_1, load10_1, load15_1 } ); + result2 = new CpuStat(t2, new double[] { load5_2, load10_2, load15_2 } ); + result3 = new CpuStat(t3, new double[] { load5_3, load10_3, load15_3 } ); + } + + @Test + public void testBuildQuery() { + Storage storage = mock(Storage.class); + Query query = mock(Query.class); + when (storage.createQuery(any(Category.class))).thenReturn(query); + + HostLatestPojoListGetter getter = new HostLatestPojoListGetter<>(storage, cat); + query = getter.buildQuery(ref, 123); + + assertNotNull(query); + verify(storage).createQuery(cat); + verify(query).where(Key.TIMESTAMP, Criteria.GREATER_THAN, 123l); + verify(query).where(Key.AGENT_ID, Criteria.EQUALS, AGENT_ID); + verify(query).sort(Key.TIMESTAMP, Query.SortDirection.DESCENDING); + verifyNoMoreInteractions(query); + } + + @Test + public void testBuildQueryPopulatesUpdateTimes() { + Storage storage = mock(Storage.class); + Query ignored = mock(Query.class); + Query query = mock(Query.class); + when(storage.createQuery(any(Category.class))).thenReturn(ignored).thenReturn(query); + + HostLatestPojoListGetter getter = new HostLatestPojoListGetter<>(storage, cat); + ignored = getter.buildQuery(ref,Long.MIN_VALUE); // Ignore first return value. + + query = getter.buildQuery(ref, Long.MIN_VALUE); + + assertNotNull(query); + verify(storage, times(2)).createQuery(cat); + verify(query).where(Key.AGENT_ID, Criteria.EQUALS, AGENT_ID); + verify(query).where(Key.TIMESTAMP, Criteria.GREATER_THAN, Long.MIN_VALUE); + verify(query).sort(Key.TIMESTAMP, Query.SortDirection.DESCENDING); + verifyNoMoreInteractions(query); + } + + @Test + public void testGetLatest() { + @SuppressWarnings("unchecked") + Cursor cursor = mock(Cursor.class); + when(cursor.hasNext()).thenReturn(true).thenReturn(true).thenReturn(false); + when(cursor.next()).thenReturn(result1).thenReturn(result2).thenReturn(null); + + Storage storage = mock(Storage.class); + Query query = mock(Query.class); + when(storage.createQuery(any(Category.class))).thenReturn(query); + when(query.execute()).thenReturn(cursor); + + HostLatestPojoListGetter getter = new HostLatestPojoListGetter<>(storage, cat); + + List stats = getter.getLatest(ref, Long.MIN_VALUE); + + verify(query).where(Key.AGENT_ID, Criteria.EQUALS, AGENT_ID); + verify(query).where(Key.TIMESTAMP, Criteria.GREATER_THAN, Long.MIN_VALUE); + + assertNotNull(stats); + assertEquals(2, stats.size()); + CpuStat stat1 = stats.get(0); + assertEquals(t1, stat1.getTimeStamp()); + assertArrayEquals(new double[] {load5_1, load10_1, load15_1}, stat1.getPerProcessorUsage(), 0.001); + CpuStat stat2 = stats.get(1); + assertEquals(t2, stat2.getTimeStamp()); + assertArrayEquals(new double[] {load5_2, load10_2, load15_2}, stat2.getPerProcessorUsage(), 0.001); + } + + @After + public void tearDown() { + ref = null; + result1 = null; + result2 = null; + result3 = null; + } +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/test/java/com/redhat/thermostat/storage/core/VmLatestPojoListGetterTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/test/java/com/redhat/thermostat/storage/core/VmLatestPojoListGetterTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,165 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.core; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +import java.util.List; + +import org.junit.Before; +import org.junit.Test; + +import com.redhat.thermostat.storage.core.Category; +import com.redhat.thermostat.storage.core.Cursor; +import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.core.Query; +import com.redhat.thermostat.storage.core.Query.Criteria; +import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.model.VmClassStat; + +public class VmLatestPojoListGetterTest { + private static final String AGENT_ID = "agentid"; + private static final String HOSTNAME = "host.example.com"; + private static final int VM_PID = 123; + private static final String MAIN_CLASS = "Foo.class"; + private static final String CATEGORY_NAME = "vmcategory"; + // Make this one static so we don't get IllegalStateException from trying + // to make category of same name while running tests in same classloader. + private static final Category cat = new Category<>(CATEGORY_NAME, VmClassStat.class); + + private static long t1 = 1; + private static long t2 = 5; + private static long t3 = 10; + + private static long lc1 = 10; + private static long lc2 = 20; + private static long lc3 = 30; + + private HostRef hostRef; + private VmRef vmRef; + private VmClassStat result1, result2, result3; + + @Before + public void setUp() { + hostRef = new HostRef(AGENT_ID, HOSTNAME); + vmRef = new VmRef(hostRef, VM_PID, MAIN_CLASS); + result1 = new VmClassStat(VM_PID, t1, lc1); + result2 = new VmClassStat(VM_PID, t2, lc2); + result3 = new VmClassStat(VM_PID, t3, lc3); + } + + @Test + public void testBuildQuery() { + Storage storage = mock(Storage.class); + Query query = mock(Query.class); + when(storage.createQuery(any(Category.class))).thenReturn(query); + + VmLatestPojoListGetter getter = new VmLatestPojoListGetter<>(storage, cat); + query = getter.buildQuery(vmRef, 123l); + + assertNotNull(query); + verify(storage).createQuery(cat); + verify(query).where(Key.AGENT_ID, Criteria.EQUALS, AGENT_ID); + verify(query).where(Key.VM_ID, Criteria.EQUALS, VM_PID); + verify(query).where(Key.TIMESTAMP, Criteria.GREATER_THAN, 123l); + verify(query).sort(Key.TIMESTAMP, Query.SortDirection.DESCENDING); + verifyNoMoreInteractions(query); + } + + @Test + public void testBuildQueryPopulatesUpdateTimes() { + Storage storage = mock(Storage.class); + Query ignored = mock(Query.class); + Query query = mock(Query.class); + when(storage.createQuery(any(Category.class))).thenReturn(ignored).thenReturn(query); + + VmLatestPojoListGetter getter = new VmLatestPojoListGetter<>(storage, cat); + getter.buildQuery(vmRef, Long.MIN_VALUE); // Ignore first return value. + query = getter.buildQuery(vmRef, Long.MIN_VALUE); + + assertNotNull(query); + verify(storage, times(2)).createQuery(cat); + verify(query).where(Key.AGENT_ID, Criteria.EQUALS, AGENT_ID); + verify(query).where(Key.VM_ID, Criteria.EQUALS, VM_PID); + verify(query).where(Key.TIMESTAMP, Criteria.GREATER_THAN, Long.MIN_VALUE); + verify(query).sort(Key.TIMESTAMP, Query.SortDirection.DESCENDING); + verifyNoMoreInteractions(query); + } + + @Test + public void testGetLatest() { + @SuppressWarnings("unchecked") + Cursor cursor = mock(Cursor.class); + when(cursor.hasNext()).thenReturn(true).thenReturn(true).thenReturn(false); + when(cursor.next()).thenReturn(result1).thenReturn(result2).thenReturn(null); + + Storage storage = mock(Storage.class); + Query query = mock(Query.class); + when(storage.createQuery(any(Category.class))).thenReturn(query); + when(query.execute()).thenReturn(cursor); + + VmLatestPojoListGetter getter = new VmLatestPojoListGetter<>(storage, cat); + + List stats = getter.getLatest(vmRef, t2); + + verify(storage).createQuery(cat); + verify(query).where(Key.AGENT_ID, Criteria.EQUALS, AGENT_ID); + verify(query).where(Key.VM_ID, Criteria.EQUALS, VM_PID); + verify(query).where(Key.TIMESTAMP, Criteria.GREATER_THAN, t2); + verify(query).sort(Key.TIMESTAMP, Query.SortDirection.DESCENDING); + verify(query).execute(); + verifyNoMoreInteractions(query); + + assertNotNull(stats); + assertEquals(2, stats.size()); + VmClassStat stat1 = stats.get(0); + assertEquals(t1, stat1.getTimeStamp()); + assertEquals(lc1, stat1.getLoadedClasses()); + VmClassStat stat2 = stats.get(1); + assertEquals(t2, stat2.getTimeStamp()); + assertEquals(lc2, stat2.getLoadedClasses()); + } + +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/test/java/com/redhat/thermostat/storage/dao/DAOFactoryTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/test/java/com/redhat/thermostat/storage/dao/DAOFactoryTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,136 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.dao; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.junit.Before; +import org.junit.Test; + +import com.redhat.thermostat.storage.core.Connection; +import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.core.StorageProvider; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; +import com.redhat.thermostat.storage.dao.BackendInfoDAO; +import com.redhat.thermostat.storage.dao.DAOFactory; +import com.redhat.thermostat.storage.dao.DAOFactoryImpl; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.dao.NetworkInterfaceInfoDAO; +import com.redhat.thermostat.storage.dao.VmInfoDAO; +import com.redhat.thermostat.testutils.StubBundleContext; + +public class DAOFactoryTest { + + private StubBundleContext bundleContext; + private Storage storage; + private Connection connection; + private StorageProvider provider; + private DAOFactory daoFactory; + + @Before + public void setUp() { + bundleContext = new StubBundleContext(); + + storage = mock(Storage.class); + connection = mock(Connection.class); + when(storage.getConnection()).thenReturn(connection); + when(connection.isConnected()).thenReturn(true); + provider = mock(StorageProvider.class); + when(provider.createStorage()).thenReturn(storage); + daoFactory = new DAOFactoryImpl(bundleContext, provider); + ((DAOFactoryImpl)daoFactory).createDAOs(); + } + + @Test + public void testGetConnection() { + assertSame(storage, daoFactory.getStorage()); + } + + @Test + public void testGetAgentInfoDAO() { + AgentInfoDAO dao = daoFactory.getAgentInfoDAO(); + assertNotNull(dao); + } + + @Test + public void testGetBackendInfoDAO() { + BackendInfoDAO dao = daoFactory.getBackendInfoDAO(); + assertNotNull(dao); + } + + @Test + public void testGetVmInfoDAO() { + VmInfoDAO dao = daoFactory.getVmInfoDAO(); + assertNotNull(dao); + } + + @Test + public void testGetHostInfoDAO() { + HostInfoDAO dao = daoFactory.getHostInfoDAO(); + assertNotNull(dao); + } + + @Test + public void testGetNetworkInterfaceInfoDAO() { + NetworkInterfaceInfoDAO dao = daoFactory.getNetworkInterfaceInfoDAO(); + assertNotNull(dao); + } + + @Test + public void testServiceRegistration() { + assertEquals(0, bundleContext.getAllServices().size()); + + daoFactory.registerDAOsAndStorageAsOSGiServices(); + + // currently 6 DAOs and Storage are registered + assertEquals(6, bundleContext.getAllServices().size()); + } + + @Test + public void testServiceDeregistration() { + daoFactory.registerDAOsAndStorageAsOSGiServices(); + daoFactory.unregisterDAOsAndStorageAsOSGiServices(); + + assertEquals(0, bundleContext.getAllServices().size()); + assertEquals(0, bundleContext.getServiceListeners().size()); + } +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/test/java/com/redhat/thermostat/storage/internal/DbServiceTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/test/java/com/redhat/thermostat/storage/internal/DbServiceTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,135 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.internal; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.osgi.framework.ServiceReference; + +import com.redhat.thermostat.storage.core.Connection; +import com.redhat.thermostat.storage.core.DbService; +import com.redhat.thermostat.storage.dao.DAOFactory; +import com.redhat.thermostat.testutils.StubBundleContext; + +public class DbServiceTest { + + private Connection connection; + private DAOFactory daoFactory; + private DbService dbService; + private StubBundleContext context; + + @Before + public void setup() { + context = new StubBundleContext(); + connection = mock(Connection.class); + + daoFactory = mock(DAOFactory.class); + when(daoFactory.getConnection()).thenReturn(connection); + + dbService = new DbServiceImpl(context, daoFactory, "http://someUrl.ignored.com"); + } + + @After + public void teardown() { + dbService = null; + context = null; + } + + @Test + public void testConnect() { + dbService.connect(); + + verify(connection).connect(); + verify(daoFactory).registerDAOsAndStorageAsOSGiServices(); + } + + @Test + public void testConnectRegistersDbService() { + dbService.connect(); + + verify(connection).connect(); + @SuppressWarnings("rawtypes") + ServiceReference dbServiceRef = context.getServiceReference(DbService.class); + // connect registers DbService + assertNotNull(dbServiceRef); + // make sure we really get the same instance + assertTrue(dbService.equals(context.getService(dbServiceRef))); + verify(daoFactory).registerDAOsAndStorageAsOSGiServices(); + } + + @Test + public void testDisconnect() { + dbService.connect(); + assertNotNull(context.getServiceReference(DbService.class)); + + dbService.disconnect(); + + verify(daoFactory).unregisterDAOsAndStorageAsOSGiServices(); + verify(connection).disconnect(); + } + + @Test + public void testDisconnectUnregistersService() { + dbService.connect(); + assertNotNull(context.getServiceReference(DbService.class)); + + dbService.disconnect(); + + verify(daoFactory).unregisterDAOsAndStorageAsOSGiServices(); + verify(connection).disconnect(); + // disconnect unregisters DbService + assertNull(context.getServiceReference(DbService.class)); + } + + @Test + public void canGetStorageUrl() { + String connectionURL = "http://test.example.com:8082"; + + dbService = new DbServiceImpl(context, null, connectionURL); + assertEquals(connectionURL, dbService.getConnectionUrl()); + } +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/AgentInfoDAOTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/AgentInfoDAOTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,260 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.internal.dao; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +import java.util.Collection; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; + +import com.redhat.thermostat.storage.core.Category; +import com.redhat.thermostat.storage.core.Cursor; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.core.Query; +import com.redhat.thermostat.storage.core.Query.Criteria; +import com.redhat.thermostat.storage.core.Remove; +import com.redhat.thermostat.storage.core.Replace; +import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.core.Update; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; +import com.redhat.thermostat.storage.model.AgentInformation; + +public class AgentInfoDAOTest { + + private AgentInformation agentInfo1; + private AgentInformation agent1; + + @Before + public void setUp() { + agentInfo1 = new AgentInformation(); + agentInfo1.setAgentId("1234"); + agentInfo1.setAlive(true); + agentInfo1.setConfigListenAddress("foobar:666"); + agentInfo1.setStartTime(100); + agentInfo1.setStopTime(10); + + agent1 = new AgentInformation(); + agent1.setAgentId("1234"); + agent1.setAlive(true); + agent1.setConfigListenAddress("foobar:666"); + agent1.setStartTime(100); + agent1.setStopTime(10); + } + + @Test + public void verifyCategoryName() { + Category category = AgentInfoDAO.CATEGORY; + assertEquals("agent-config", category.getName()); + } + + @Test + public void verifyKeyNames() { + assertEquals("agentId", Key.AGENT_ID.getName()); + assertEquals("alive", AgentInfoDAO.ALIVE_KEY.getName()); + assertEquals("startTime", AgentInfoDAO.START_TIME_KEY.getName()); + assertEquals("stopTime", AgentInfoDAO.STOP_TIME_KEY.getName()); + assertEquals("configListenAddress", AgentInfoDAO.CONFIG_LISTEN_ADDRESS.getName()); + } + + @Test + public void verifyCategoryHasAllKeys() { + Collection> keys = AgentInfoDAO.CATEGORY.getKeys(); + + assertTrue(keys.contains(Key.AGENT_ID)); + assertTrue(keys.contains(AgentInfoDAO.ALIVE_KEY)); + assertTrue(keys.contains(AgentInfoDAO.START_TIME_KEY)); + assertTrue(keys.contains(AgentInfoDAO.STOP_TIME_KEY)); + assertTrue(keys.contains(AgentInfoDAO.CONFIG_LISTEN_ADDRESS)); + } + + @Test + public void verifyGetAllAgentInformationWithOneAgentInStorage() { + @SuppressWarnings("unchecked") + Cursor agentCursor = mock(Cursor.class); + when(agentCursor.hasNext()).thenReturn(true).thenReturn(false); + when(agentCursor.next()).thenReturn(agent1).thenReturn(null); + + Storage storage = mock(Storage.class); + Query query = mock(Query.class); + when(query.execute()).thenReturn(agentCursor); + when(storage.createQuery(any(Category.class))).thenReturn(query); + AgentInfoDAOImpl dao = new AgentInfoDAOImpl(storage); + + List allAgentInfo = dao.getAllAgentInformation(); + + assertEquals(1, allAgentInfo.size()); + + AgentInformation result = allAgentInfo.get(0); + AgentInformation expected = agentInfo1; + assertEquals(expected, result); + } + + @Test + public void verifyGetAliveAgent() { + @SuppressWarnings("unchecked") + Cursor agentCursor = mock(Cursor.class); + when(agentCursor.hasNext()).thenReturn(true).thenReturn(false); + when(agentCursor.next()).thenReturn(agent1).thenReturn(null); + + Query query = mock(Query.class); + Storage storage = mock(Storage.class); + when(storage.createQuery(any(Category.class))).thenReturn(query); + when(query.execute()).thenReturn(agentCursor); + + AgentInfoDAO dao = new AgentInfoDAOImpl(storage); + List aliveAgents = dao.getAliveAgents(); + + verify(storage).createQuery(AgentInfoDAO.CATEGORY); + verify(query).where(AgentInfoDAO.ALIVE_KEY, Criteria.EQUALS, true); + verify(query).execute(); + verifyNoMoreInteractions(query); + + assertEquals(1, aliveAgents.size()); + + AgentInformation result = aliveAgents.get(0); + AgentInformation expected = agentInfo1; + assertEquals(expected, result); + } + + @Test + public void verifyGetAgentInformationWhenStorageCantFindIt() { + HostRef agentRef = mock(HostRef.class); + + Query query = mock(Query.class); + Cursor cursor = mock(Cursor.class); + when(cursor.hasNext()).thenReturn(false); + when(cursor.next()).thenReturn(null); + when(query.execute()).thenReturn(cursor); + + Storage storage = mock(Storage.class); + when(storage.createQuery(any(Category.class))).thenReturn(query); + + AgentInfoDAO dao = new AgentInfoDAOImpl(storage); + + AgentInformation computed = dao.getAgentInformation(agentRef); + + assertEquals(null, computed); + } + + @Test + public void verifyGetAgentInformation() { + HostRef agentRef = mock(HostRef.class); + when(agentRef.getAgentId()).thenReturn(agentInfo1.getAgentId()); + + Storage storage = mock(Storage.class); + Query query = mock(Query.class); + when(storage.createQuery(any(Category.class))).thenReturn(query); + Cursor cursor = mock(Cursor.class); + when(cursor.hasNext()).thenReturn(true).thenReturn(false); + when(cursor.next()).thenReturn(agentInfo1).thenReturn(null); + when(query.execute()).thenReturn(cursor); + AgentInfoDAO dao = new AgentInfoDAOImpl(storage); + + AgentInformation computed = dao.getAgentInformation(agentRef); + + verify(storage).createQuery(AgentInfoDAO.CATEGORY); + verify(query).where(Key.AGENT_ID, Criteria.EQUALS, agentInfo1.getAgentId()); + verify(query).limit(1); + verify(query).execute(); + verifyNoMoreInteractions(query); + AgentInformation expected = agentInfo1; + assertSame(expected, computed); + } + + @Test + public void verifyAddAgentInformation() { + Storage storage = mock(Storage.class); + Replace replace = mock(Replace.class); + when(storage.createReplace(any(Category.class))).thenReturn(replace); + + AgentInfoDAO dao = new AgentInfoDAOImpl(storage); + + dao.addAgentInformation(agentInfo1); + + verify(storage).createReplace(AgentInfoDAO.CATEGORY); + verify(replace).setPojo(agentInfo1); + verify(replace).apply(); + } + + @Test + public void verifyUpdateAgentInformation() { + + Update mockUpdate = mock(Update.class); + Storage storage = mock(Storage.class); + when(storage.createUpdate(any(Category.class))).thenReturn(mockUpdate); + AgentInfoDAO dao = new AgentInfoDAOImpl(storage); + + dao.updateAgentInformation(agentInfo1); + + verify(storage).createUpdate(AgentInfoDAO.CATEGORY); + verify(mockUpdate).where(Key.AGENT_ID, "1234"); + verify(mockUpdate).set(AgentInfoDAO.START_TIME_KEY, 100L); + verify(mockUpdate).set(AgentInfoDAO.STOP_TIME_KEY, 10L); + verify(mockUpdate).set(AgentInfoDAO.CONFIG_LISTEN_ADDRESS, "foobar:666"); + verify(mockUpdate).set(AgentInfoDAO.ALIVE_KEY, true); + verify(mockUpdate).apply(); + verifyNoMoreInteractions(mockUpdate); + + } + + @Test + public void verifyRemoveAgentInformation() { + Remove mockRemove = QueryTestHelper.createMockRemove(); + Storage storage = mock(Storage.class); + when(storage.createRemove()).thenReturn(mockRemove); + AgentInfoDAO dao = new AgentInfoDAOImpl(storage); + + dao.removeAgentInformation(agentInfo1); + + verify(storage).removePojo(mockRemove); + verify(mockRemove).from(AgentInfoDAO.CATEGORY); + verify(mockRemove).where(Key.AGENT_ID, "1234"); + } + +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/BackendInfoDAOTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/BackendInfoDAOTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,173 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.internal.dao; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.inOrder; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.InOrder; + +import com.redhat.thermostat.storage.core.Add; +import com.redhat.thermostat.storage.core.Category; +import com.redhat.thermostat.storage.core.Cursor; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.core.Query; +import com.redhat.thermostat.storage.core.Query.Criteria; +import com.redhat.thermostat.storage.core.Remove; +import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.dao.BackendInfoDAO; +import com.redhat.thermostat.storage.model.BackendInformation; + +public class BackendInfoDAOTest { + + private BackendInformation backendInfo1; + private BackendInformation backend1; + + @Before + public void setUp() { + + backendInfo1 = new BackendInformation(); + + backendInfo1.setName("backend-name"); + backendInfo1.setDescription("description"); + backendInfo1.setActive(true); + backendInfo1.setObserveNewJvm(true); + backendInfo1.setPids(new int[] { -1, 0, 1}); + backendInfo1.setOrderValue(100); + + backend1 = new BackendInformation(); + backend1.setName("backend-name"); + backend1.setDescription("description"); + backend1.setActive(true); + backend1.setObserveNewJvm(true); + backend1.setPids(new int[] { -1, 0, 1}); + backend1.setOrderValue(100); + } + + @Test + public void verifyCategoryName() { + Category c = BackendInfoDAO.CATEGORY; + assertEquals("backend-info", c.getName()); + } + + @Test + public void verifyCategoryHasAllKeys() { + Category c = BackendInfoDAO.CATEGORY; + Collection> keys = c.getKeys(); + + assertTrue(keys.contains(Key.AGENT_ID)); + assertTrue(keys.contains(BackendInfoDAO.BACKEND_NAME)); + assertTrue(keys.contains(BackendInfoDAO.BACKEND_DESCRIPTION)); + assertTrue(keys.contains(BackendInfoDAO.IS_ACTIVE)); + assertTrue(keys.contains(BackendInfoDAO.PIDS_TO_MONITOR)); + assertTrue(keys.contains(BackendInfoDAO.SHOULD_MONITOR_NEW_PROCESSES)); + assertTrue(keys.contains(BackendInfoDAO.ORDER_VALUE)); + } + + @Test + public void verifyAddBackendInformation() { + Storage storage = mock(Storage.class); + Add add = mock(Add.class); + when(storage.createAdd(any(Category.class))).thenReturn(add); + + BackendInfoDAO dao = new BackendInfoDAOImpl(storage); + + dao.addBackendInformation(backendInfo1); + + verify(storage).createAdd(BackendInfoDAO.CATEGORY); + verify(add).setPojo(backendInfo1); + verify(add).apply(); + } + + @Test + public void verifyGetBackendInformation() { + final String AGENT_ID = "agent-id"; + HostRef agentref = mock(HostRef.class); + when(agentref.getAgentId()).thenReturn(AGENT_ID); + + @SuppressWarnings("unchecked") + Cursor backendCursor = mock(Cursor.class); + when(backendCursor.hasNext()).thenReturn(true).thenReturn(false); + when(backendCursor.next()).thenReturn(backend1).thenReturn(null); + + Query query = mock(Query.class); + Storage storage = mock(Storage.class); + when(storage.createQuery(any(Category.class))).thenReturn(query); + when(query.execute()).thenReturn(backendCursor); + + BackendInfoDAO dao = new BackendInfoDAOImpl(storage); + + List result = dao.getBackendInformation(agentref); + + verify(storage).createQuery(BackendInfoDAO.CATEGORY); + verify(query).where(Key.AGENT_ID, Criteria.EQUALS, AGENT_ID); + verify(query).execute(); + verifyNoMoreInteractions(query); + + assertEquals(Arrays.asList(backendInfo1), result); + } + + @Test + public void verifyRemoveBackendInformation() { + Remove remove = QueryTestHelper.createMockRemove(); + Storage storage = mock(Storage.class); + when(storage.createRemove()).thenReturn(remove); + BackendInfoDAO dao = new BackendInfoDAOImpl(storage); + + dao.removeBackendInformation(backendInfo1); + + verify(storage).removePojo(remove); + InOrder inOrder = inOrder(remove); + inOrder.verify(remove).from(BackendInfoDAO.CATEGORY); + inOrder.verify(remove).where(BackendInfoDAO.BACKEND_NAME, "backend-name"); + } + +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/HostInfoDAOTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/HostInfoDAOTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,344 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.internal.dao; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.atLeast; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.Arrays; +import java.util.Collection; + +import org.junit.Test; + +import com.redhat.thermostat.storage.core.Add; +import com.redhat.thermostat.storage.core.Category; +import com.redhat.thermostat.storage.core.Cursor; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.core.Query; +import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.model.AgentInformation; +import com.redhat.thermostat.storage.model.HostInfo; + + +public class HostInfoDAOTest { + + static class Pair { + final T first; + final U second; + + public Pair(T first, U second) { + this.first = first; + this.second = second; + } + } + + private static final String HOST_NAME = "a host name"; + private static final String OS_NAME = "some os"; + private static final String OS_KERNEL = "some kernel"; + private static final String CPU_MODEL = "some cpu that runs fast"; + private static final int CPU_NUM = -1; + private static final long MEMORY_TOTAL = 0xCAFEBABEl; + + @Test + public void testCategory() { + assertEquals("host-info", HostInfoDAO.hostInfoCategory.getName()); + Collection> keys = HostInfoDAO.hostInfoCategory.getKeys(); + assertTrue(keys.contains(new Key<>("agentId", true))); + assertTrue(keys.contains(new Key("hostname", true))); + assertTrue(keys.contains(new Key("osName", false))); + assertTrue(keys.contains(new Key("osKernel", false))); + assertTrue(keys.contains(new Key("cpuModel", false))); + assertTrue(keys.contains(new Key("cpuCount", false))); + assertTrue(keys.contains(new Key("totalMemory", false))); + assertEquals(7, keys.size()); + } + + @Test + public void testGetHostInfo() { + + Storage storage = mock(Storage.class); + Query query = mock(Query.class); + when(storage.createQuery(any(Category.class))).thenReturn(query); + HostInfo info = new HostInfo(HOST_NAME, OS_NAME, OS_KERNEL, CPU_MODEL, CPU_NUM, MEMORY_TOTAL); + Cursor cursor = mock(Cursor.class); + when(cursor.hasNext()).thenReturn(true).thenReturn(false); + when(cursor.next()).thenReturn(info).thenReturn(null); + when(query.execute()).thenReturn(cursor); + AgentInfoDAO agentInfoDao = mock(AgentInfoDAO.class); + + HostInfo result = new HostInfoDAOImpl(storage, agentInfoDao).getHostInfo(new HostRef("some uid", HOST_NAME)); + assertSame(result, info); + } + + @Test + public void testGetHostsSingleHost() { + + Storage storage = setupStorageForSingleHost(); + AgentInfoDAO agentInfo = mock(AgentInfoDAO.class); + + HostInfoDAO hostsDAO = new HostInfoDAOImpl(storage, agentInfo); + Collection hosts = hostsDAO.getHosts(); + + assertEquals(1, hosts.size()); + assertTrue(hosts.contains(new HostRef("123", "fluffhost1"))); + } + + private Storage setupStorageForSingleHost() { + + HostInfo hostConfig = new HostInfo("fluffhost1", OS_NAME, OS_KERNEL, CPU_MODEL, CPU_NUM, MEMORY_TOTAL); + hostConfig.setAgentId("123"); + + @SuppressWarnings("unchecked") + Cursor cursor = mock(Cursor.class); + when(cursor.hasNext()).thenReturn(true).thenReturn(false); + when(cursor.next()).thenReturn(hostConfig); + + Storage storage = mock(Storage.class); + Query query = mock(Query.class); + when(storage.createQuery(any(Category.class))).thenReturn(query); + when(query.execute()).thenReturn(cursor); + + return storage; + } + + @Test + public void testGetHosts3Hosts() { + + Storage storage = setupStorageFor3Hosts(); + AgentInfoDAO agentInfo = mock(AgentInfoDAO.class); + + HostInfoDAO hostsDAO = new HostInfoDAOImpl(storage, agentInfo); + Collection hosts = hostsDAO.getHosts(); + + assertEquals(3, hosts.size()); + assertTrue(hosts.contains(new HostRef("123", "fluffhost1"))); + assertTrue(hosts.contains(new HostRef("456", "fluffhost2"))); + assertTrue(hosts.contains(new HostRef("789", "fluffhost3"))); + } + + private Storage setupStorageFor3Hosts() { + + HostInfo hostConfig1 = new HostInfo("fluffhost1", OS_NAME, OS_KERNEL, CPU_MODEL, CPU_NUM, MEMORY_TOTAL); + hostConfig1.setAgentId("123"); + HostInfo hostConfig2 = new HostInfo("fluffhost2", OS_NAME, OS_KERNEL, CPU_MODEL, CPU_NUM, MEMORY_TOTAL); + hostConfig2.setAgentId("456"); + HostInfo hostConfig3 = new HostInfo("fluffhost3", OS_NAME, OS_KERNEL, CPU_MODEL, CPU_NUM, MEMORY_TOTAL); + hostConfig3.setAgentId("789"); + + + @SuppressWarnings("unchecked") + Cursor cursor = mock(Cursor.class); + when(cursor.hasNext()).thenReturn(true).thenReturn(true).thenReturn(true).thenReturn(false); + when(cursor.next()).thenReturn(hostConfig1).thenReturn(hostConfig2).thenReturn(hostConfig3); + + Storage storage = mock(Storage.class); + Query query = mock(Query.class); + when(storage.createQuery(any(Category.class))).thenReturn(query); + when(query.execute()).thenReturn(cursor); + + return storage; + } + + @Test + public void testPutHostInfo() { + Storage storage = mock(Storage.class); + Add add = mock(Add.class); + when(storage.createAdd(any(Category.class))).thenReturn(add); + + AgentInfoDAO agentInfo = mock(AgentInfoDAO.class); + + HostInfo info = new HostInfo(HOST_NAME, OS_NAME, OS_KERNEL, CPU_MODEL, CPU_NUM, MEMORY_TOTAL); + HostInfoDAO dao = new HostInfoDAOImpl(storage, agentInfo); + dao.putHostInfo(info); + + verify(storage).createAdd(HostInfoDAO.hostInfoCategory); + verify(add).setPojo(info); + verify(add).apply(); + } + + @Test + public void testGetCount() { + Storage storage = mock(Storage.class); + when(storage.getCount(any(Category.class))).thenReturn(5L); + AgentInfoDAO agentInfoDao = mock(AgentInfoDAO.class); + + HostInfoDAO dao = new HostInfoDAOImpl(storage, agentInfoDao); + Long count = dao.getCount(); + assertEquals((Long) 5L, count); + } + + @Test + public void getAliveHostSingle() { + Pair setup = setupForSingleAliveHost(); + Storage storage = setup.first; + AgentInfoDAO agentInfoDao = setup.second; + + HostInfoDAO hostsDAO = new HostInfoDAOImpl(storage, agentInfoDao); + Collection hosts = hostsDAO.getAliveHosts(); + + assertEquals(1, hosts.size()); + assertTrue(hosts.contains(new HostRef("123", "fluffhost1"))); + verify(storage).createQuery(HostInfoDAO.hostInfoCategory); + } + + private Pair setupForSingleAliveHost() { + + // agents + + AgentInformation agentConfig1 = new AgentInformation(); + agentConfig1.setAgentId("123"); + agentConfig1.setAlive(true); + + AgentInformation agentInfo1 = new AgentInformation(); + agentInfo1.setAgentId("123"); + agentInfo1.setAlive(true); + + // hosts + + HostInfo hostConfig1 = new HostInfo(); + hostConfig1.setHostname("fluffhost1"); + hostConfig1.setAgentId("123"); + + HostInfo hostConfig2 = new HostInfo(); + hostConfig2.setHostname("fluffhost2"); + hostConfig2.setAgentId("456"); + + // cursor + + @SuppressWarnings("unchecked") + Cursor cursor1 = mock(Cursor.class); + when(cursor1.hasNext()).thenReturn(true).thenReturn(false); + when(cursor1.next()).thenReturn(hostConfig1); + + // storage + + Storage storage = mock(Storage.class); + Query query = mock(Query.class); + + when(storage.createQuery(any(Category.class))).thenReturn(query); + when(query.execute()).thenReturn(cursor1); + + AgentInfoDAO agentDao = mock(AgentInfoDAO.class); + when(agentDao.getAliveAgents()).thenReturn(Arrays.asList(agentInfo1)); + + return new Pair<>(storage, agentDao); + } + + @Test + public void getAliveHost3() { + Pair setup = setupForAliveHost3(); + Storage storage = setup.first; + AgentInfoDAO agentInfoDao = setup.second; + + HostInfoDAO hostsDAO = new HostInfoDAOImpl(storage, agentInfoDao); + Collection hosts = hostsDAO.getAliveHosts(); + + // cursor 3 from the above storage should not be used + assertEquals(3, hosts.size()); + assertTrue(hosts.contains(new HostRef("123", "fluffhost1"))); + assertTrue(hosts.contains(new HostRef("456", "fluffhost2"))); + assertTrue(hosts.contains(new HostRef("678", "fluffhost3"))); + verify(storage, atLeast(3)).createQuery(HostInfoDAO.hostInfoCategory); + } + + private Pair setupForAliveHost3() { + + // agents + AgentInformation agentInfo1 = new AgentInformation(); + agentInfo1.setAgentId("123"); + agentInfo1.setAlive(true); + + AgentInformation agentInfo2 = new AgentInformation(); + agentInfo2.setAgentId("456"); + agentInfo2.setAlive(true); + + AgentInformation agentInfo3 = new AgentInformation(); + agentInfo3.setAgentId("678"); + agentInfo3.setAlive(true); + + // hosts + + HostInfo hostConfig1 = new HostInfo(); + hostConfig1.setHostname("fluffhost1"); + hostConfig1.setAgentId("123"); + + HostInfo hostConfig2 = new HostInfo(); + hostConfig2.setHostname("fluffhost2"); + hostConfig2.setAgentId("456"); + + HostInfo hostConfig3 = new HostInfo(); + hostConfig3.setHostname("fluffhost3"); + hostConfig3.setAgentId("678"); + + @SuppressWarnings("unchecked") + Cursor cursor1 = mock(Cursor.class); + when(cursor1.hasNext()).thenReturn(true).thenReturn(false); + when(cursor1.next()).thenReturn(hostConfig1); + + @SuppressWarnings("unchecked") + Cursor cursor2 = mock(Cursor.class); + when(cursor2.hasNext()).thenReturn(true).thenReturn(false); + when(cursor2.next()).thenReturn(hostConfig2); + + @SuppressWarnings("unchecked") + Cursor cursor3 = mock(Cursor.class); + when(cursor3.hasNext()).thenReturn(true).thenReturn(false); + when(cursor3.next()).thenReturn(hostConfig3); + + // storage + + Storage storage = mock(Storage.class); + Query query = mock(Query.class); + when(storage.createQuery(any(Category.class))).thenReturn(query); + when(query.execute()).thenReturn(cursor1).thenReturn(cursor2).thenReturn(cursor3); + + AgentInfoDAO agentDao = mock(AgentInfoDAO.class); + when(agentDao.getAliveAgents()).thenReturn(Arrays.asList(agentInfo1, agentInfo2, agentInfo3)); + + return new Pair<>(storage, agentDao); + } +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/NetworkInterfaceInfoDAOTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/NetworkInterfaceInfoDAOTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,135 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.internal.dao; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +import java.util.Collection; +import java.util.List; + +import org.junit.Test; + +import com.redhat.thermostat.storage.core.Category; +import com.redhat.thermostat.storage.core.Cursor; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.core.Query; +import com.redhat.thermostat.storage.core.Query.Criteria; +import com.redhat.thermostat.storage.core.Replace; +import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.dao.NetworkInterfaceInfoDAO; +import com.redhat.thermostat.storage.model.NetworkInterfaceInfo; + +public class NetworkInterfaceInfoDAOTest { + + private static final String INTERFACE_NAME = "some interface. maybe eth0"; + private static final String IPV4_ADDR = "256.256.256.256"; + private static final String IPV6_ADDR = "100:100:100::::1"; + + @Test + public void testCategory() { + Collection> keys; + + assertEquals("network-info", NetworkInterfaceInfoDAO.networkInfoCategory.getName()); + keys = NetworkInterfaceInfoDAO.networkInfoCategory.getKeys(); + assertTrue(keys.contains(new Key<>("agentId", true))); + assertTrue(keys.contains(new Key("interfaceName", true))); + assertTrue(keys.contains(new Key("ip4Addr", false))); + assertTrue(keys.contains(new Key("ip6Addr", false))); + assertEquals(4, keys.size()); + } + + @Test + public void testGetNetworkInterfaces() { + + NetworkInterfaceInfo niInfo = new NetworkInterfaceInfo(INTERFACE_NAME); + niInfo.setIp4Addr(IPV4_ADDR); + niInfo.setIp6Addr(IPV6_ADDR); + + @SuppressWarnings("unchecked") + Cursor cursor = mock(Cursor.class); + when(cursor.hasNext()).thenReturn(true).thenReturn(false); + when(cursor.next()).thenReturn(niInfo); + + Storage storage = mock(Storage.class); + Query query = mock(Query.class); + when(storage.createQuery(any(Category.class))).thenReturn(query); + when(query.execute()).thenReturn(cursor); + + HostRef hostRef = mock(HostRef.class); + when(hostRef.getAgentId()).thenReturn("system"); + + NetworkInterfaceInfoDAO dao = new NetworkInterfaceInfoDAOImpl(storage); + List netInfo = dao.getNetworkInterfaces(hostRef); + + verify(query).where(Key.AGENT_ID, Criteria.EQUALS, "system"); + verify(query).execute(); + verifyNoMoreInteractions(query); + + assertEquals(1, netInfo.size()); + + NetworkInterfaceInfo info = netInfo.get(0); + + assertEquals(INTERFACE_NAME, info.getInterfaceName()); + assertEquals(IPV4_ADDR, info.getIp4Addr()); + assertEquals(IPV6_ADDR, info.getIp6Addr()); + } + + @Test + public void testPutNetworkInterfaceInfo() { + Storage storage = mock(Storage.class); + Replace replace = mock(Replace.class); + when(storage.createReplace(any(Category.class))).thenReturn(replace); + + NetworkInterfaceInfo info = new NetworkInterfaceInfo(INTERFACE_NAME); + info.setIp4Addr(IPV4_ADDR); + info.setIp6Addr(IPV6_ADDR); + NetworkInterfaceInfoDAO dao = new NetworkInterfaceInfoDAOImpl(storage); + dao.putNetworkInterfaceInfo(info); + + verify(storage).createReplace(NetworkInterfaceInfoDAO.networkInfoCategory); + verify(replace).setPojo(info); + verify(replace).apply(); + } +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/QueryTestHelper.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/QueryTestHelper.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,59 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + + +package com.redhat.thermostat.storage.internal.dao; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import com.redhat.thermostat.storage.core.Category; +import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.core.Remove; + +public class QueryTestHelper { + + @SuppressWarnings("unchecked") + public static Remove createMockRemove() { + Remove mockRemove = mock(Remove.class); + when(mockRemove.from(any(Category.class))).thenReturn(mockRemove); + when(mockRemove.where(any(Key.class), any())).thenReturn(mockRemove); + return mockRemove; + } + +} + diff -r 4290490a2e05 -r 186115da601f storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/VmInfoDAOTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/VmInfoDAOTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -0,0 +1,290 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.storage.internal.dao; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.redhat.thermostat.storage.core.Category; +import com.redhat.thermostat.storage.core.Cursor; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.core.Query; +import com.redhat.thermostat.storage.core.Replace; +import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.core.Update; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.DAOException; +import com.redhat.thermostat.storage.dao.VmInfoDAO; +import com.redhat.thermostat.storage.model.VmInfo; + +public class VmInfoDAOTest { + + private int vmId; + private long startTime; + private long stopTime; + private String jVersion; + private String jHome; + private String mainClass; + private String commandLine; + private String vmName; + private String vmInfo; + private String vmVersion; + private String vmArgs; + private Map props; + private Map env; + private String[] libs; + + @Before + public void setUp() { + vmId = 1; + startTime = 2; + stopTime = 3; + jVersion = "java 1.0"; + jHome = "/path/to/jdk/home"; + mainClass = "Hello.class"; + commandLine = "World"; + vmArgs = "-XX=+FastestJITPossible"; + vmName = "Hotspot"; + vmInfo = "Some info"; + vmVersion = "1.0"; + props = new HashMap<>(); + env = new HashMap<>(); + libs = new String[0]; + } + + @Test + public void testCategory() { + assertEquals("vm-info", VmInfoDAO.vmInfoCategory.getName()); + Collection> keys = VmInfoDAO.vmInfoCategory.getKeys(); + assertTrue(keys.contains(new Key<>("agentId", true))); + assertTrue(keys.contains(new Key("vmId", true))); + assertTrue(keys.contains(new Key("vmPid", false))); + assertTrue(keys.contains(new Key("javaVersion", false))); + assertTrue(keys.contains(new Key("javaHome", false))); + assertTrue(keys.contains(new Key("mainClass", false))); + assertTrue(keys.contains(new Key("javaCommandLine", false))); + assertTrue(keys.contains(new Key("vmArguments", false))); + assertTrue(keys.contains(new Key("vmName", false))); + assertTrue(keys.contains(new Key("vmInfo", false))); + assertTrue(keys.contains(new Key("vmVersion", false))); + assertTrue(keys.contains(new Key>("properties", false))); + assertTrue(keys.contains(new Key>("environment", false))); + assertTrue(keys.contains(new Key>("loadedNativeLibraries", false))); + assertTrue(keys.contains(new Key("startTimeStamp", false))); + assertTrue(keys.contains(new Key("stopTimeStamp", false))); + assertEquals(16, keys.size()); + } + + @Test + public void testGetVmInfo() { + + Storage storage = mock(Storage.class); + Query query = mock(Query.class); + when(storage.createQuery(any(Category.class))).thenReturn(query); + VmInfo expected = new VmInfo(vmId, startTime, stopTime, jVersion, jHome, mainClass, commandLine, vmName, vmInfo, vmVersion, vmArgs, props, env, libs); + Cursor cursor = mock(Cursor.class); + when(cursor.hasNext()).thenReturn(true).thenReturn(false); + when(cursor.next()).thenReturn(expected).thenReturn(null); + when(query.execute()).thenReturn(cursor); + + HostRef hostRef = mock(HostRef.class); + when(hostRef.getAgentId()).thenReturn("system"); + + VmRef vmRef = mock(VmRef.class); + when(vmRef.getAgent()).thenReturn(hostRef); + when(vmRef.getId()).thenReturn(321); + + VmInfoDAO dao = new VmInfoDAOImpl(storage); + VmInfo info = dao.getVmInfo(vmRef); + assertEquals(expected, info); + } + + @Test + public void testGetVmInfoUnknownVM() { + + Storage storage = mock(Storage.class); + Query query = mock(Query.class); + when(storage.createQuery(any(Category.class))).thenReturn(query); + Cursor cursor = mock(Cursor.class); + when(query.execute()).thenReturn(cursor); + + HostRef hostRef = mock(HostRef.class); + when(hostRef.getAgentId()).thenReturn("system"); + + VmRef vmRef = mock(VmRef.class); + when(vmRef.getAgent()).thenReturn(hostRef); + when(vmRef.getId()).thenReturn(321); + + VmInfoDAO dao = new VmInfoDAOImpl(storage); + try { + dao.getVmInfo(vmRef); + fail(); + } catch (DAOException ex) { + assertEquals("Unknown VM: host:system;vm:321", ex.getMessage()); + } + + } + + @Test + public void testSingleVM() { + Storage storage = setupStorageForSingleVM(); + VmInfoDAO dao = new VmInfoDAOImpl(storage); + HostRef host = new HostRef("123", "fluffhost"); + + Collection vms = dao.getVMs(host); + + assertCollection(vms, new VmRef(host, 123, "mainClass1")); + } + + private Storage setupStorageForSingleVM() { + + VmInfo vm1 = new VmInfo(); + vm1.setVmPid(123); + vm1.setMainClass("mainClass1"); + + @SuppressWarnings("unchecked") + Cursor singleVMCursor = mock(Cursor.class); + when(singleVMCursor.hasNext()).thenReturn(true).thenReturn(false); + when(singleVMCursor.next()).thenReturn(vm1); + + Storage storage = mock(Storage.class); + Query query = mock(Query.class); + when(storage.createQuery(any(Category.class))).thenReturn(query); + when(query.execute()).thenReturn(singleVMCursor); + return storage; + } + + @Test + public void testMultiVMs() { + Storage storage = setupStorageForMultiVM(); + VmInfoDAO dao = new VmInfoDAOImpl(storage); + + HostRef host = new HostRef("456", "fluffhost"); + + Collection vms = dao.getVMs(host); + + assertCollection(vms, new VmRef(host, 123, "mainClass1"), new VmRef(host, 456, "mainClass2")); + } + + private Storage setupStorageForMultiVM() { + + VmInfo vm1 = new VmInfo(); + vm1.setVmPid(123); + vm1.setMainClass("mainClass1"); + + VmInfo vm2 = new VmInfo(); + vm2.setVmPid(456); + vm2.setMainClass("mainClass2"); + + @SuppressWarnings("unchecked") + Cursor multiVMsCursor = mock(Cursor.class); + when(multiVMsCursor.hasNext()).thenReturn(true).thenReturn(true).thenReturn(false); + when(multiVMsCursor.next()).thenReturn(vm1).thenReturn(vm2); + + Storage storage = mock(Storage.class); + Query query = mock(Query.class); + when(storage.createQuery(any(Category.class))).thenReturn(query); + when(query.execute()).thenReturn(multiVMsCursor); + return storage; + } + + private void assertCollection(Collection vms, VmRef... expectedVMs) { + assertEquals(expectedVMs.length, vms.size()); + for (VmRef expectedVM : expectedVMs) { + assertTrue(vms.contains(expectedVM)); + } + } + + @Test + public void testGetCount() { + Storage storage = mock(Storage.class); + when(storage.getCount(any(Category.class))).thenReturn(5L); + VmInfoDAO dao = new VmInfoDAOImpl(storage); + Long count = dao.getCount(); + assertEquals((Long) 5L, count); + } + + @Test + public void testPutVmInfo() { + + Storage storage = mock(Storage.class); + Replace replace = mock(Replace.class); + when(storage.createReplace(any(Category.class))).thenReturn(replace); + + VmInfo info = new VmInfo(vmId, startTime, stopTime, jVersion, jHome, + mainClass, commandLine, vmName, vmInfo, vmVersion, vmArgs, + props, env, libs); + VmInfoDAO dao = new VmInfoDAOImpl(storage); + dao.putVmInfo(info); + + verify(storage).createReplace(VmInfoDAO.vmInfoCategory); + verify(replace).setPojo(info); + verify(replace).apply(); + } + + @Test + public void testPutVmStoppedTime() { + Update mockUpdate = mock(Update.class); + Storage storage = mock(Storage.class); + when(storage.createUpdate(any(Category.class))).thenReturn(mockUpdate); + + VmInfoDAO dao = new VmInfoDAOImpl(storage); + dao.putVmStoppedTime(vmId, stopTime); + + verify(storage).createUpdate(VmInfoDAO.vmInfoCategory); + verify(mockUpdate).where(Key.VM_ID, 1); + verify(mockUpdate).set(VmInfoDAO.stopTimeKey, 3L); + verify(mockUpdate).apply(); + verifyNoMoreInteractions(mockUpdate); + } +} + diff -r 4290490a2e05 -r 186115da601f storage/mongo/src/main/java/com/redhat/thermostat/storage/mongodb/internal/MongoConnection.java --- a/storage/mongo/src/main/java/com/redhat/thermostat/storage/mongodb/internal/MongoConnection.java Fri Jan 25 16:33:19 2013 -0500 +++ b/storage/mongo/src/main/java/com/redhat/thermostat/storage/mongodb/internal/MongoConnection.java Wed Jan 16 18:58:59 2013 +0100 @@ -70,6 +70,7 @@ connected = true; } catch (IOException | MongoException | IllegalArgumentException e) { + e.printStackTrace(); fireChanged(ConnectionStatus.FAILED_TO_CONNECT); throw new ConnectionException(e.getMessage(), e); } diff -r 4290490a2e05 -r 186115da601f system-backend/pom.xml --- a/system-backend/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/system-backend/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -73,6 +73,19 @@ thermostat-agent-core ${project.version} + + + com.redhat.thermostat + thermostat-storage-core + ${project.version} + + + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + org.osgi diff -r 4290490a2e05 -r 186115da601f system-backend/src/main/java/com/redhat/thermostat/backend/system/JvmStatHostListener.java --- a/system-backend/src/main/java/com/redhat/thermostat/backend/system/JvmStatHostListener.java Fri Jan 25 16:33:19 2013 -0500 +++ b/system-backend/src/main/java/com/redhat/thermostat/backend/system/JvmStatHostListener.java Wed Jan 16 18:58:59 2013 +0100 @@ -54,8 +54,8 @@ import com.redhat.thermostat.agent.VmStatusListener; import com.redhat.thermostat.agent.VmStatusListener.Status; -import com.redhat.thermostat.common.dao.VmInfoDAO; import com.redhat.thermostat.common.utils.LoggingUtils; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.storage.model.VmInfo; import com.redhat.thermostat.utils.ProcDataSource; diff -r 4290490a2e05 -r 186115da601f system-backend/src/main/java/com/redhat/thermostat/backend/system/SystemBackend.java --- a/system-backend/src/main/java/com/redhat/thermostat/backend/system/SystemBackend.java Fri Jan 25 16:33:19 2013 -0500 +++ b/system-backend/src/main/java/com/redhat/thermostat/backend/system/SystemBackend.java Wed Jan 16 18:58:59 2013 +0100 @@ -48,13 +48,12 @@ import sun.jvmstat.monitor.MonitorException; import sun.jvmstat.monitor.MonitoredHost; -import com.redhat.thermostat.agent.VmStatusListener; import com.redhat.thermostat.backend.Backend; import com.redhat.thermostat.backend.BackendID; import com.redhat.thermostat.backend.BackendsProperties; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.NetworkInterfaceInfoDAO; import com.redhat.thermostat.common.utils.LoggingUtils; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.dao.NetworkInterfaceInfoDAO; import com.redhat.thermostat.storage.model.NetworkInterfaceInfo; import com.redhat.thermostat.utils.ProcDataSource; diff -r 4290490a2e05 -r 186115da601f system-backend/src/test/java/com/redhat/thermostat/backend/system/JvmStatHostListenerTest.java --- a/system-backend/src/test/java/com/redhat/thermostat/backend/system/JvmStatHostListenerTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/system-backend/src/test/java/com/redhat/thermostat/backend/system/JvmStatHostListenerTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -65,8 +65,8 @@ import sun.jvmstat.monitor.event.VmStatusChangeEvent; import com.redhat.thermostat.agent.VmStatusListener.Status; -import com.redhat.thermostat.common.dao.VmInfoDAO; import com.redhat.thermostat.storage.model.VmInfo; +import com.redhat.thermostat.storage.dao.VmInfoDAO; public class JvmStatHostListenerTest { @@ -197,4 +197,3 @@ assertEquals(INFO_VMVER, info.getVmVersion()); } } - diff -r 4290490a2e05 -r 186115da601f system-backend/src/test/java/com/redhat/thermostat/backend/system/SystemBackendTest.java --- a/system-backend/src/test/java/com/redhat/thermostat/backend/system/SystemBackendTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/system-backend/src/test/java/com/redhat/thermostat/backend/system/SystemBackendTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -44,10 +44,10 @@ import org.junit.Before; import org.junit.Test; -import com.redhat.thermostat.common.dao.DAOFactory; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.NetworkInterfaceInfoDAO; import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.dao.DAOFactory; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.dao.NetworkInterfaceInfoDAO; public class SystemBackendTest { diff -r 4290490a2e05 -r 186115da601f system-backend/src/test/java/com/redhat/thermostat/backend/system/VmStatusChangeNotifierTest.java --- a/system-backend/src/test/java/com/redhat/thermostat/backend/system/VmStatusChangeNotifierTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/system-backend/src/test/java/com/redhat/thermostat/backend/system/VmStatusChangeNotifierTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -43,7 +43,7 @@ import com.redhat.thermostat.agent.VmStatusListener; import com.redhat.thermostat.agent.VmStatusListener.Status; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; public class VmStatusChangeNotifierTest { diff -r 4290490a2e05 -r 186115da601f thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/collector/ThreadCollector.java --- a/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/collector/ThreadCollector.java Fri Jan 25 16:33:19 2013 -0500 +++ b/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/collector/ThreadCollector.java Wed Jan 16 18:58:59 2013 +0100 @@ -38,7 +38,7 @@ import java.util.List; -import com.redhat.thermostat.common.dao.AgentInfoDAO; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; import com.redhat.thermostat.thread.dao.ThreadDao; import com.redhat.thermostat.thread.model.ThreadInfoData; import com.redhat.thermostat.thread.model.ThreadSummary; diff -r 4290490a2e05 -r 186115da601f thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/collector/ThreadCollectorFactory.java --- a/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/collector/ThreadCollectorFactory.java Fri Jan 25 16:33:19 2013 -0500 +++ b/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/collector/ThreadCollectorFactory.java Wed Jan 16 18:58:59 2013 +0100 @@ -36,8 +36,8 @@ package com.redhat.thermostat.thread.client.common.collector; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; import com.redhat.thermostat.thread.dao.ThreadDao; public interface ThreadCollectorFactory { diff -r 4290490a2e05 -r 186115da601f thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/collector/impl/ThreadCollectorFactoryImpl.java --- a/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/collector/impl/ThreadCollectorFactoryImpl.java Fri Jan 25 16:33:19 2013 -0500 +++ b/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/collector/impl/ThreadCollectorFactoryImpl.java Wed Jan 16 18:58:59 2013 +0100 @@ -36,8 +36,8 @@ package com.redhat.thermostat.thread.client.common.collector.impl; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; import com.redhat.thermostat.thread.client.common.collector.ThreadCollector; import com.redhat.thermostat.thread.client.common.collector.ThreadCollectorFactory; import com.redhat.thermostat.thread.dao.ThreadDao; diff -r 4290490a2e05 -r 186115da601f thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/collector/impl/ThreadMXBeanCollector.java --- a/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/collector/impl/ThreadMXBeanCollector.java Fri Jan 25 16:33:19 2013 -0500 +++ b/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/collector/impl/ThreadMXBeanCollector.java Wed Jan 16 18:58:59 2013 +0100 @@ -45,10 +45,10 @@ import com.redhat.thermostat.common.command.RequestResponseListener; import com.redhat.thermostat.common.command.Response; import com.redhat.thermostat.common.command.Request.RequestType; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; import com.redhat.thermostat.thread.client.common.collector.ThreadCollector; import com.redhat.thermostat.thread.collector.HarvesterCommand; import com.redhat.thermostat.thread.dao.ThreadDao; diff -r 4290490a2e05 -r 186115da601f thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/osgi/Activator.java --- a/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/osgi/Activator.java Fri Jan 25 16:33:19 2013 -0500 +++ b/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/osgi/Activator.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,7 +41,7 @@ import org.osgi.framework.ServiceReference; import org.osgi.util.tracker.ServiceTracker; -import com.redhat.thermostat.common.dao.AgentInfoDAO; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; import com.redhat.thermostat.thread.client.common.collector.ThreadCollectorFactory; import com.redhat.thermostat.thread.client.common.collector.impl.ThreadCollectorFactoryImpl; import com.redhat.thermostat.thread.dao.ThreadDao; diff -r 4290490a2e05 -r 186115da601f thread/client-common/src/test/java/com/redhat/thermostat/thread/client/common/collector/ThreadCollectorFactoryTest.java --- a/thread/client-common/src/test/java/com/redhat/thermostat/thread/client/common/collector/ThreadCollectorFactoryTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/thread/client-common/src/test/java/com/redhat/thermostat/thread/client/common/collector/ThreadCollectorFactoryTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,8 +41,8 @@ import org.junit.Test; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; import com.redhat.thermostat.thread.client.common.collector.impl.ThreadCollectorFactoryImpl; import com.redhat.thermostat.thread.dao.ThreadDao; diff -r 4290490a2e05 -r 186115da601f thread/client-common/src/test/java/com/redhat/thermostat/thread/client/common/collector/impl/ThreadCollectorTest.java --- a/thread/client-common/src/test/java/com/redhat/thermostat/thread/client/common/collector/impl/ThreadCollectorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/thread/client-common/src/test/java/com/redhat/thermostat/thread/client/common/collector/impl/ThreadCollectorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -56,9 +56,9 @@ import com.redhat.thermostat.common.command.RequestResponseListener; import com.redhat.thermostat.common.command.Response; import com.redhat.thermostat.common.command.Response.ResponseType; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; import com.redhat.thermostat.thread.client.common.collector.ThreadCollector; import com.redhat.thermostat.thread.client.common.collector.impl.ThreadMXBeanCollector; import com.redhat.thermostat.thread.collector.HarvesterCommand; diff -r 4290490a2e05 -r 186115da601f thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationController.java --- a/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationController.java Fri Jan 25 16:33:19 2013 -0500 +++ b/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationController.java Wed Jan 16 18:58:59 2013 +0100 @@ -45,9 +45,9 @@ import com.redhat.thermostat.common.ActionListener; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.TimerFactory; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.LoggingUtils; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.thread.client.common.ThreadTableBean; import com.redhat.thermostat.thread.client.common.ThreadViewProvider; import com.redhat.thermostat.thread.client.common.collector.ThreadCollector; diff -r 4290490a2e05 -r 186115da601f thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationService.java --- a/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationService.java Fri Jan 25 16:33:19 2013 -0500 +++ b/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationService.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,8 +41,8 @@ import com.redhat.thermostat.client.core.NameMatchingRefFilter; import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.thread.client.common.ThreadViewProvider; import com.redhat.thermostat.thread.client.common.collector.ThreadCollectorFactory; diff -r 4290490a2e05 -r 186115da601f thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/osgi/Activator.java --- a/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/osgi/Activator.java Fri Jan 25 16:33:19 2013 -0500 +++ b/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/osgi/Activator.java Wed Jan 16 18:58:59 2013 +0100 @@ -50,8 +50,8 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.thread.client.common.ThreadViewProvider; import com.redhat.thermostat.thread.client.common.collector.ThreadCollectorFactory; import com.redhat.thermostat.thread.client.controller.impl.ThreadInformationService; diff -r 4290490a2e05 -r 186115da601f thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationControllerTest.java --- a/thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationControllerTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationControllerTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -55,9 +55,9 @@ import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.TimerFactory; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.storage.model.VmInfo; import com.redhat.thermostat.thread.client.common.ThreadTableBean; import com.redhat.thermostat.thread.client.common.ThreadViewProvider; diff -r 4290490a2e05 -r 186115da601f thread/collector/src/main/java/com/redhat/thermostat/thread/dao/ThreadDao.java --- a/thread/collector/src/main/java/com/redhat/thermostat/thread/dao/ThreadDao.java Fri Jan 25 16:33:19 2013 -0500 +++ b/thread/collector/src/main/java/com/redhat/thermostat/thread/dao/ThreadDao.java Wed Jan 16 18:58:59 2013 +0100 @@ -38,10 +38,10 @@ import java.util.List; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.storage.core.Category; import com.redhat.thermostat.storage.core.Key; import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.thread.model.ThreadInfoData; import com.redhat.thermostat.thread.model.ThreadSummary; import com.redhat.thermostat.thread.model.VMThreadCapabilities; diff -r 4290490a2e05 -r 186115da601f thread/collector/src/main/java/com/redhat/thermostat/thread/dao/impl/ThreadDaoImpl.java --- a/thread/collector/src/main/java/com/redhat/thermostat/thread/dao/impl/ThreadDaoImpl.java Fri Jan 25 16:33:19 2013 -0500 +++ b/thread/collector/src/main/java/com/redhat/thermostat/thread/dao/impl/ThreadDaoImpl.java Wed Jan 16 18:58:59 2013 +0100 @@ -39,7 +39,6 @@ import java.util.ArrayList; import java.util.List; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.storage.core.Category; import com.redhat.thermostat.storage.core.Cursor; import com.redhat.thermostat.storage.core.Key; @@ -47,6 +46,7 @@ import com.redhat.thermostat.storage.core.Query; import com.redhat.thermostat.storage.core.Query.Criteria; import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.model.Pojo; import com.redhat.thermostat.thread.dao.ThreadDao; import com.redhat.thermostat.thread.model.ThreadInfoData; diff -r 4290490a2e05 -r 186115da601f thread/collector/src/test/java/com/redhat/thermostat/thread/dao/impl/ThreadDaoImplTest.java --- a/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/impl/ThreadDaoImplTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/impl/ThreadDaoImplTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -46,15 +46,16 @@ import org.junit.Test; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.storage.core.Category; import com.redhat.thermostat.storage.core.Cursor; +import com.redhat.thermostat.storage.core.HostRef; import com.redhat.thermostat.storage.core.Key; import com.redhat.thermostat.storage.core.Query; import com.redhat.thermostat.storage.core.Query.Criteria; import com.redhat.thermostat.storage.core.Replace; import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.core.Query.Criteria; import com.redhat.thermostat.thread.dao.ThreadDao; import com.redhat.thermostat.thread.model.VMThreadCapabilities; diff -r 4290490a2e05 -r 186115da601f vm-classstat/agent/pom.xml --- a/vm-classstat/agent/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-classstat/agent/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -74,5 +74,11 @@ thermostat-storage-core ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f vm-classstat/agent/src/test/java/com/redhat/thermostat/vm/classstat/agent/internal/ActivatorTest.java --- a/vm-classstat/agent/src/test/java/com/redhat/thermostat/vm/classstat/agent/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-classstat/agent/src/test/java/com/redhat/thermostat/vm/classstat/agent/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -49,7 +49,7 @@ import com.redhat.thermostat.backend.Backend; import com.redhat.thermostat.backend.BackendService; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.classstat.common.VmClassStatDAO; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f vm-classstat/client-core/pom.xml --- a/vm-classstat/client-core/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-classstat/client-core/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -76,5 +76,11 @@ ${project.version} test + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f vm-classstat/client-core/src/main/java/com/redhat/thermostat/vm/classstat/client/core/VmClassStatService.java --- a/vm-classstat/client-core/src/main/java/com/redhat/thermostat/vm/classstat/client/core/VmClassStatService.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-classstat/client-core/src/main/java/com/redhat/thermostat/vm/classstat/client/core/VmClassStatService.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,8 +41,8 @@ import com.redhat.thermostat.client.core.NameMatchingRefFilter; import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.vm.classstat.client.core.internal.VmClassStatController; import com.redhat.thermostat.vm.classstat.common.VmClassStatDAO; diff -r 4290490a2e05 -r 186115da601f vm-classstat/client-core/src/main/java/com/redhat/thermostat/vm/classstat/client/core/internal/Activator.java --- a/vm-classstat/client-core/src/main/java/com/redhat/thermostat/vm/classstat/client/core/internal/Activator.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-classstat/client-core/src/main/java/com/redhat/thermostat/vm/classstat/client/core/internal/Activator.java Wed Jan 16 18:58:59 2013 +0100 @@ -50,7 +50,7 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.vm.classstat.client.core.VmClassStatService; import com.redhat.thermostat.vm.classstat.common.VmClassStatDAO; diff -r 4290490a2e05 -r 186115da601f vm-classstat/client-core/src/main/java/com/redhat/thermostat/vm/classstat/client/core/internal/VmClassStatController.java --- a/vm-classstat/client-core/src/main/java/com/redhat/thermostat/vm/classstat/client/core/internal/VmClassStatController.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-classstat/client-core/src/main/java/com/redhat/thermostat/vm/classstat/client/core/internal/VmClassStatController.java Wed Jan 16 18:58:59 2013 +0100 @@ -49,8 +49,8 @@ import com.redhat.thermostat.common.NotImplementedException; import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.Timer.SchedulingType; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.locale.Translate; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.model.DiscreteTimeData; import com.redhat.thermostat.storage.model.VmClassStat; import com.redhat.thermostat.vm.classstat.client.core.VmClassStatView; diff -r 4290490a2e05 -r 186115da601f vm-classstat/client-core/src/test/java/com/redhat/thermostat/vm/classstat/client/core/internal/ActivatorTest.java --- a/vm-classstat/client-core/src/test/java/com/redhat/thermostat/vm/classstat/client/core/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-classstat/client-core/src/test/java/com/redhat/thermostat/vm/classstat/client/core/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -45,7 +45,7 @@ import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.classstat.client.core.VmClassStatService; import com.redhat.thermostat.vm.classstat.common.VmClassStatDAO; diff -r 4290490a2e05 -r 186115da601f vm-classstat/client-core/src/test/java/com/redhat/thermostat/vm/classstat/client/core/internal/VmClassStatControllerTest.java --- a/vm-classstat/client-core/src/test/java/com/redhat/thermostat/vm/classstat/client/core/internal/VmClassStatControllerTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-classstat/client-core/src/test/java/com/redhat/thermostat/vm/classstat/client/core/internal/VmClassStatControllerTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -54,7 +54,7 @@ import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.TimerFactory; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.model.VmClassStat; import com.redhat.thermostat.vm.classstat.client.core.VmClassStatView; import com.redhat.thermostat.vm.classstat.client.core.VmClassStatViewProvider; diff -r 4290490a2e05 -r 186115da601f vm-classstat/client-core/src/test/java/com/redhat/thermostat/vm/classstat/client/locale/LocaleResourcesTest.java --- a/vm-classstat/client-core/src/test/java/com/redhat/thermostat/vm/classstat/client/locale/LocaleResourcesTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-classstat/client-core/src/test/java/com/redhat/thermostat/vm/classstat/client/locale/LocaleResourcesTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -36,7 +36,7 @@ package com.redhat.thermostat.vm.classstat.client.locale; -import com.redhat.thermostat.test.locale.AbstractLocaleResourcesTest; +import com.redhat.thermostat.testutils.AbstractLocaleResourcesTest; public class LocaleResourcesTest extends AbstractLocaleResourcesTest { diff -r 4290490a2e05 -r 186115da601f vm-classstat/client-swing/pom.xml --- a/vm-classstat/client-swing/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-classstat/client-swing/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -78,5 +78,11 @@ thermostat-vm-classstat-client-core ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f vm-classstat/client-swing/src/test/java/com/redhat/thermostat/vm/classstat/client/swing/ActivatorTest.java --- a/vm-classstat/client-swing/src/test/java/com/redhat/thermostat/vm/classstat/client/swing/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-classstat/client-swing/src/test/java/com/redhat/thermostat/vm/classstat/client/swing/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,7 +41,7 @@ import org.junit.Test; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.classstat.client.core.VmClassStatViewProvider; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f vm-classstat/common/pom.xml --- a/vm-classstat/common/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-classstat/common/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -64,5 +64,11 @@ thermostat-storage-core ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f vm-classstat/common/src/main/java/com/redhat/thermostat/vm/classstat/common/VmClassStatDAO.java --- a/vm-classstat/common/src/main/java/com/redhat/thermostat/vm/classstat/common/VmClassStatDAO.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-classstat/common/src/main/java/com/redhat/thermostat/vm/classstat/common/VmClassStatDAO.java Wed Jan 16 18:58:59 2013 +0100 @@ -39,9 +39,9 @@ import java.util.List; import com.redhat.thermostat.annotations.Service; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.storage.core.Category; import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.model.VmClassStat; @Service diff -r 4290490a2e05 -r 186115da601f vm-classstat/common/src/main/java/com/redhat/thermostat/vm/classstat/common/internal/VmClassStatDAOImpl.java --- a/vm-classstat/common/src/main/java/com/redhat/thermostat/vm/classstat/common/internal/VmClassStatDAOImpl.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-classstat/common/src/main/java/com/redhat/thermostat/vm/classstat/common/internal/VmClassStatDAOImpl.java Wed Jan 16 18:58:59 2013 +0100 @@ -38,10 +38,10 @@ import java.util.List; -import com.redhat.thermostat.common.dao.VmLatestPojoListGetter; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.storage.core.Put; import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.core.VmLatestPojoListGetter; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.model.VmClassStat; import com.redhat.thermostat.vm.classstat.common.VmClassStatDAO; diff -r 4290490a2e05 -r 186115da601f vm-classstat/common/src/test/java/com/redhat/thermostat/vm/classstat/common/internal/ActivatorTest.java --- a/vm-classstat/common/src/test/java/com/redhat/thermostat/vm/classstat/common/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-classstat/common/src/test/java/com/redhat/thermostat/vm/classstat/common/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -43,7 +43,7 @@ import org.junit.Test; import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.classstat.common.VmClassStatDAO; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f vm-classstat/common/src/test/java/com/redhat/thermostat/vm/classstat/common/internal/VmClassStatDAOTest.java --- a/vm-classstat/common/src/test/java/com/redhat/thermostat/vm/classstat/common/internal/VmClassStatDAOTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-classstat/common/src/test/java/com/redhat/thermostat/vm/classstat/common/internal/VmClassStatDAOTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -49,10 +49,10 @@ import org.junit.Test; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.storage.core.Add; import com.redhat.thermostat.storage.core.Category; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.core.Cursor; import com.redhat.thermostat.storage.core.Key; import com.redhat.thermostat.storage.core.Query; diff -r 4290490a2e05 -r 186115da601f vm-cpu/agent/pom.xml --- a/vm-cpu/agent/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-cpu/agent/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -74,5 +74,11 @@ thermostat-storage-core ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f vm-cpu/agent/src/test/java/com/redhat/thermostat/vm/cpu/agent/internal/ActivatorTest.java --- a/vm-cpu/agent/src/test/java/com/redhat/thermostat/vm/cpu/agent/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-cpu/agent/src/test/java/com/redhat/thermostat/vm/cpu/agent/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -49,7 +49,7 @@ import com.redhat.thermostat.backend.Backend; import com.redhat.thermostat.backend.BackendService; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.cpu.common.VmCpuStatDAO; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f vm-cpu/client-cli/src/main/java/com/redhat/thermostat/vm/cpu/client/cli/internal/VmCpuStatPrintDelegate.java --- a/vm-cpu/client-cli/src/main/java/com/redhat/thermostat/vm/cpu/client/cli/internal/VmCpuStatPrintDelegate.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-cpu/client-cli/src/main/java/com/redhat/thermostat/vm/cpu/client/cli/internal/VmCpuStatPrintDelegate.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,8 +41,8 @@ import java.util.List; import com.redhat.thermostat.client.cli.VMStatPrintDelegate; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.locale.Translate; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.model.TimeStampedPojo; import com.redhat.thermostat.storage.model.VmCpuStat; import com.redhat.thermostat.vm.cpu.common.VmCpuStatDAO; diff -r 4290490a2e05 -r 186115da601f vm-cpu/client-cli/src/test/java/com/redhat/thermostat/vm/cpu/client/cli/internal/ActivatorTest.java --- a/vm-cpu/client-cli/src/test/java/com/redhat/thermostat/vm/cpu/client/cli/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-cpu/client-cli/src/test/java/com/redhat/thermostat/vm/cpu/client/cli/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -43,7 +43,7 @@ import org.junit.Test; import com.redhat.thermostat.client.cli.VMStatPrintDelegate; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.cpu.common.VmCpuStatDAO; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f vm-cpu/client-cli/src/test/java/com/redhat/thermostat/vm/cpu/client/cli/internal/LocaleResourcesTest.java --- a/vm-cpu/client-cli/src/test/java/com/redhat/thermostat/vm/cpu/client/cli/internal/LocaleResourcesTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-cpu/client-cli/src/test/java/com/redhat/thermostat/vm/cpu/client/cli/internal/LocaleResourcesTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -36,7 +36,7 @@ package com.redhat.thermostat.vm.cpu.client.cli.internal; -import com.redhat.thermostat.test.locale.AbstractLocaleResourcesTest; +import com.redhat.thermostat.testutils.AbstractLocaleResourcesTest; public class LocaleResourcesTest extends AbstractLocaleResourcesTest { diff -r 4290490a2e05 -r 186115da601f vm-cpu/client-cli/src/test/java/com/redhat/thermostat/vm/cpu/client/cli/internal/VmCpuStatPrintDelegateTest.java --- a/vm-cpu/client-cli/src/test/java/com/redhat/thermostat/vm/cpu/client/cli/internal/VmCpuStatPrintDelegateTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-cpu/client-cli/src/test/java/com/redhat/thermostat/vm/cpu/client/cli/internal/VmCpuStatPrintDelegateTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -51,8 +51,8 @@ import org.junit.Test; import com.redhat.thermostat.common.cli.CommandException; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.model.TimeStampedPojo; import com.redhat.thermostat.storage.model.VmCpuStat; import com.redhat.thermostat.vm.cpu.common.VmCpuStatDAO; diff -r 4290490a2e05 -r 186115da601f vm-cpu/client-core/pom.xml --- a/vm-cpu/client-core/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-cpu/client-core/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -76,5 +76,11 @@ thermostat-vm-cpu-common ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/VmCpuService.java --- a/vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/VmCpuService.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/VmCpuService.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,8 +41,8 @@ import com.redhat.thermostat.client.core.NameMatchingRefFilter; import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.vm.cpu.client.core.internal.VmCpuController; import com.redhat.thermostat.vm.cpu.common.VmCpuStatDAO; diff -r 4290490a2e05 -r 186115da601f vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/internal/Activator.java --- a/vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/internal/Activator.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/internal/Activator.java Wed Jan 16 18:58:59 2013 +0100 @@ -50,7 +50,7 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.vm.cpu.client.core.VmCpuService; import com.redhat.thermostat.vm.cpu.common.VmCpuStatDAO; diff -r 4290490a2e05 -r 186115da601f vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/internal/VmCpuController.java --- a/vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/internal/VmCpuController.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/internal/VmCpuController.java Wed Jan 16 18:58:59 2013 +0100 @@ -49,8 +49,8 @@ import com.redhat.thermostat.common.NotImplementedException; import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.Timer.SchedulingType; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.locale.Translate; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.model.DiscreteTimeData; import com.redhat.thermostat.storage.model.VmCpuStat; import com.redhat.thermostat.vm.cpu.client.core.VmCpuView; diff -r 4290490a2e05 -r 186115da601f vm-cpu/client-core/src/test/java/com/redhat/thermostat/vm/cpu/client/core/internal/ActivatorTest.java --- a/vm-cpu/client-core/src/test/java/com/redhat/thermostat/vm/cpu/client/core/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-cpu/client-core/src/test/java/com/redhat/thermostat/vm/cpu/client/core/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -45,7 +45,7 @@ import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.cpu.client.core.VmCpuService; import com.redhat.thermostat.vm.cpu.common.VmCpuStatDAO; diff -r 4290490a2e05 -r 186115da601f vm-cpu/client-core/src/test/java/com/redhat/thermostat/vm/cpu/client/core/internal/VmCpuControllerTest.java --- a/vm-cpu/client-core/src/test/java/com/redhat/thermostat/vm/cpu/client/core/internal/VmCpuControllerTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-cpu/client-core/src/test/java/com/redhat/thermostat/vm/cpu/client/core/internal/VmCpuControllerTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -54,7 +54,7 @@ import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.TimerFactory; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.model.VmCpuStat; import com.redhat.thermostat.vm.cpu.client.core.VmCpuView; import com.redhat.thermostat.vm.cpu.client.core.VmCpuViewProvider; diff -r 4290490a2e05 -r 186115da601f vm-cpu/client-core/src/test/java/com/redhat/thermostat/vm/cpu/client/locale/LocaleResourcesTest.java --- a/vm-cpu/client-core/src/test/java/com/redhat/thermostat/vm/cpu/client/locale/LocaleResourcesTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-cpu/client-core/src/test/java/com/redhat/thermostat/vm/cpu/client/locale/LocaleResourcesTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -36,7 +36,7 @@ package com.redhat.thermostat.vm.cpu.client.locale; -import com.redhat.thermostat.test.locale.AbstractLocaleResourcesTest; +import com.redhat.thermostat.testutils.AbstractLocaleResourcesTest; public class LocaleResourcesTest extends AbstractLocaleResourcesTest { diff -r 4290490a2e05 -r 186115da601f vm-cpu/client-swing/pom.xml --- a/vm-cpu/client-swing/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-cpu/client-swing/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -78,5 +78,11 @@ thermostat-vm-cpu-client-core ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f vm-cpu/client-swing/src/test/java/com/redhat/thermostat/vm/cpu/client/swing/internal/ActivatorTest.java --- a/vm-cpu/client-swing/src/test/java/com/redhat/thermostat/vm/cpu/client/swing/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-cpu/client-swing/src/test/java/com/redhat/thermostat/vm/cpu/client/swing/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,7 +41,7 @@ import org.junit.Test; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.cpu.client.core.VmCpuViewProvider; import com.redhat.thermostat.vm.cpu.client.swing.internal.Activator; import com.redhat.thermostat.vm.cpu.client.swing.internal.SwingVmCpuViewProvider; diff -r 4290490a2e05 -r 186115da601f vm-cpu/common/pom.xml --- a/vm-cpu/common/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-cpu/common/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -64,5 +64,11 @@ thermostat-storage-core ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f vm-cpu/common/src/main/java/com/redhat/thermostat/vm/cpu/common/VmCpuStatDAO.java --- a/vm-cpu/common/src/main/java/com/redhat/thermostat/vm/cpu/common/VmCpuStatDAO.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-cpu/common/src/main/java/com/redhat/thermostat/vm/cpu/common/VmCpuStatDAO.java Wed Jan 16 18:58:59 2013 +0100 @@ -39,7 +39,7 @@ import java.util.List; import com.redhat.thermostat.annotations.Service; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.core.Category; import com.redhat.thermostat.storage.core.Key; import com.redhat.thermostat.storage.model.VmCpuStat; diff -r 4290490a2e05 -r 186115da601f vm-cpu/common/src/main/java/com/redhat/thermostat/vm/cpu/common/internal/VmCpuStatDAOImpl.java --- a/vm-cpu/common/src/main/java/com/redhat/thermostat/vm/cpu/common/internal/VmCpuStatDAOImpl.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-cpu/common/src/main/java/com/redhat/thermostat/vm/cpu/common/internal/VmCpuStatDAOImpl.java Wed Jan 16 18:58:59 2013 +0100 @@ -38,9 +38,9 @@ import java.util.List; -import com.redhat.thermostat.common.dao.VmLatestPojoListGetter; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.storage.core.Put; +import com.redhat.thermostat.storage.core.VmLatestPojoListGetter; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.core.Storage; import com.redhat.thermostat.storage.model.VmCpuStat; import com.redhat.thermostat.vm.cpu.common.VmCpuStatDAO; diff -r 4290490a2e05 -r 186115da601f vm-cpu/common/src/test/java/com/redhat/thermostat/vm/cpu/common/internal/ActivatorTest.java --- a/vm-cpu/common/src/test/java/com/redhat/thermostat/vm/cpu/common/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-cpu/common/src/test/java/com/redhat/thermostat/vm/cpu/common/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -43,7 +43,7 @@ import org.junit.Test; import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.cpu.common.VmCpuStatDAO; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f vm-cpu/common/src/test/java/com/redhat/thermostat/vm/cpu/common/internal/VmCpuStatDAOTest.java --- a/vm-cpu/common/src/test/java/com/redhat/thermostat/vm/cpu/common/internal/VmCpuStatDAOTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-cpu/common/src/test/java/com/redhat/thermostat/vm/cpu/common/internal/VmCpuStatDAOTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -50,10 +50,10 @@ import org.junit.Before; import org.junit.Test; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.storage.core.Add; import com.redhat.thermostat.storage.core.Category; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.core.Cursor; import com.redhat.thermostat.storage.core.Key; import com.redhat.thermostat.storage.core.Query; diff -r 4290490a2e05 -r 186115da601f vm-gc/agent/pom.xml --- a/vm-gc/agent/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-gc/agent/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -74,5 +74,11 @@ thermostat-storage-core ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f vm-gc/agent/src/test/java/com/redhat/thermostat/vm/gc/agent/internal/ActivatorTest.java --- a/vm-gc/agent/src/test/java/com/redhat/thermostat/vm/gc/agent/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-gc/agent/src/test/java/com/redhat/thermostat/vm/gc/agent/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -49,7 +49,7 @@ import com.redhat.thermostat.backend.Backend; import com.redhat.thermostat.backend.BackendService; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.gc.common.VmGcStatDAO; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f vm-gc/client-core/pom.xml --- a/vm-gc/client-core/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-gc/client-core/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -81,5 +81,11 @@ ${project.version} test + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/VmGcService.java --- a/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/VmGcService.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/VmGcService.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,8 +41,8 @@ import com.redhat.thermostat.client.core.NameMatchingRefFilter; import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.vm.gc.client.core.internal.VmGcController; import com.redhat.thermostat.vm.gc.common.VmGcStatDAO; import com.redhat.thermostat.vm.memory.common.VmMemoryStatDAO; diff -r 4290490a2e05 -r 186115da601f vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/internal/Activator.java --- a/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/internal/Activator.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/internal/Activator.java Wed Jan 16 18:58:59 2013 +0100 @@ -50,7 +50,7 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.vm.gc.client.core.VmGcService; import com.redhat.thermostat.vm.gc.common.VmGcStatDAO; import com.redhat.thermostat.vm.memory.common.VmMemoryStatDAO; diff -r 4290490a2e05 -r 186115da601f vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/internal/VmGcController.java --- a/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/internal/VmGcController.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/internal/VmGcController.java Wed Jan 16 18:58:59 2013 +0100 @@ -55,8 +55,8 @@ import com.redhat.thermostat.common.NotImplementedException; import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.Timer.SchedulingType; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.locale.Translate; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.model.IntervalTimeData; import com.redhat.thermostat.storage.model.TimeStampedPojoComparator; import com.redhat.thermostat.storage.model.VmGcStat; diff -r 4290490a2e05 -r 186115da601f vm-gc/client-core/src/test/java/com/redhat/thermostat/vm/gc/client/core/internal/ActivatorTest.java --- a/vm-gc/client-core/src/test/java/com/redhat/thermostat/vm/gc/client/core/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-gc/client-core/src/test/java/com/redhat/thermostat/vm/gc/client/core/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -45,7 +45,7 @@ import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.gc.client.core.VmGcService; import com.redhat.thermostat.vm.gc.common.VmGcStatDAO; import com.redhat.thermostat.vm.memory.common.VmMemoryStatDAO; diff -r 4290490a2e05 -r 186115da601f vm-gc/client-core/src/test/java/com/redhat/thermostat/vm/gc/client/core/internal/VmGcControllerTest.java --- a/vm-gc/client-core/src/test/java/com/redhat/thermostat/vm/gc/client/core/internal/VmGcControllerTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-gc/client-core/src/test/java/com/redhat/thermostat/vm/gc/client/core/internal/VmGcControllerTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -58,7 +58,7 @@ import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.Timer.SchedulingType; import com.redhat.thermostat.common.TimerFactory; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.model.VmGcStat; import com.redhat.thermostat.storage.model.VmMemoryStat; import com.redhat.thermostat.storage.model.VmMemoryStat.Generation; diff -r 4290490a2e05 -r 186115da601f vm-gc/client-core/src/test/java/com/redhat/thermostat/vm/gc/client/locale/LocaleResourcesTest.java --- a/vm-gc/client-core/src/test/java/com/redhat/thermostat/vm/gc/client/locale/LocaleResourcesTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-gc/client-core/src/test/java/com/redhat/thermostat/vm/gc/client/locale/LocaleResourcesTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -36,7 +36,7 @@ package com.redhat.thermostat.vm.gc.client.locale; -import com.redhat.thermostat.test.locale.AbstractLocaleResourcesTest; +import com.redhat.thermostat.testutils.AbstractLocaleResourcesTest; public class LocaleResourcesTest extends AbstractLocaleResourcesTest { diff -r 4290490a2e05 -r 186115da601f vm-gc/client-swing/pom.xml --- a/vm-gc/client-swing/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-gc/client-swing/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -78,5 +78,11 @@ thermostat-vm-gc-client-core ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f vm-gc/client-swing/src/test/java/com/redhat/thermostat/vm/gc/client/swing/internal/ActivatorTest.java --- a/vm-gc/client-swing/src/test/java/com/redhat/thermostat/vm/gc/client/swing/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-gc/client-swing/src/test/java/com/redhat/thermostat/vm/gc/client/swing/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,7 +41,7 @@ import org.junit.Test; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.gc.client.core.VmGcViewProvider; import com.redhat.thermostat.vm.gc.client.swing.internal.Activator; import com.redhat.thermostat.vm.gc.client.swing.internal.SwingVmGcViewProvider; diff -r 4290490a2e05 -r 186115da601f vm-gc/common/pom.xml --- a/vm-gc/common/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-gc/common/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -64,5 +64,11 @@ thermostat-storage-core ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f vm-gc/common/src/main/java/com/redhat/thermostat/vm/gc/common/VmGcStatDAO.java --- a/vm-gc/common/src/main/java/com/redhat/thermostat/vm/gc/common/VmGcStatDAO.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-gc/common/src/main/java/com/redhat/thermostat/vm/gc/common/VmGcStatDAO.java Wed Jan 16 18:58:59 2013 +0100 @@ -39,9 +39,9 @@ import java.util.List; import com.redhat.thermostat.annotations.Service; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.storage.core.Category; import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.model.VmGcStat; @Service diff -r 4290490a2e05 -r 186115da601f vm-gc/common/src/main/java/com/redhat/thermostat/vm/gc/common/internal/VmGcStatDAOImpl.java --- a/vm-gc/common/src/main/java/com/redhat/thermostat/vm/gc/common/internal/VmGcStatDAOImpl.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-gc/common/src/main/java/com/redhat/thermostat/vm/gc/common/internal/VmGcStatDAOImpl.java Wed Jan 16 18:58:59 2013 +0100 @@ -38,10 +38,10 @@ import java.util.List; -import com.redhat.thermostat.common.dao.VmLatestPojoListGetter; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.storage.core.Put; import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.core.VmLatestPojoListGetter; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.model.VmGcStat; import com.redhat.thermostat.vm.gc.common.VmGcStatDAO; diff -r 4290490a2e05 -r 186115da601f vm-gc/common/src/test/java/com/redhat/thermostat/vm/gc/common/internal/ActivatorTest.java --- a/vm-gc/common/src/test/java/com/redhat/thermostat/vm/gc/common/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-gc/common/src/test/java/com/redhat/thermostat/vm/gc/common/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -43,7 +43,7 @@ import org.junit.Test; import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.gc.common.VmGcStatDAO; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f vm-gc/common/src/test/java/com/redhat/thermostat/vm/gc/common/internal/VmGcStatDAOTest.java --- a/vm-gc/common/src/test/java/com/redhat/thermostat/vm/gc/common/internal/VmGcStatDAOTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-gc/common/src/test/java/com/redhat/thermostat/vm/gc/common/internal/VmGcStatDAOTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -49,10 +49,10 @@ import org.junit.Test; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.storage.core.Add; import com.redhat.thermostat.storage.core.Category; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.core.Cursor; import com.redhat.thermostat.storage.core.Key; import com.redhat.thermostat.storage.core.Query; diff -r 4290490a2e05 -r 186115da601f vm-gc/remote-collector-client-common/src/main/java/com/redhat/thermostat/gc/remote/common/GCRequest.java --- a/vm-gc/remote-collector-client-common/src/main/java/com/redhat/thermostat/gc/remote/common/GCRequest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-gc/remote-collector-client-common/src/main/java/com/redhat/thermostat/gc/remote/common/GCRequest.java Wed Jan 16 18:58:59 2013 +0100 @@ -42,10 +42,10 @@ import com.redhat.thermostat.common.command.Request; import com.redhat.thermostat.common.command.RequestResponseListener; import com.redhat.thermostat.common.command.Request.RequestType; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.gc.remote.common.command.GCCommand; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; public class GCRequest { diff -r 4290490a2e05 -r 186115da601f vm-gc/remote-collector-client-common/src/test/java/com/redhat/thermostat/gc/remote/common/GCRequestTest.java --- a/vm-gc/remote-collector-client-common/src/test/java/com/redhat/thermostat/gc/remote/common/GCRequestTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-gc/remote-collector-client-common/src/test/java/com/redhat/thermostat/gc/remote/common/GCRequestTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -49,10 +49,10 @@ import com.redhat.thermostat.client.command.RequestQueue; import com.redhat.thermostat.common.command.Request; import com.redhat.thermostat.common.command.RequestResponseListener; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.gc.remote.common.command.GCCommand; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; import com.redhat.thermostat.storage.model.AgentInformation; public class GCRequestTest { diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/agent/pom.xml --- a/vm-heap-analysis/agent/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/agent/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -94,6 +94,13 @@ ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + + diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/agent/src/test/java/com/redhat/thermostat/vm/heap/analysis/agent/internal/ActivatorTest.java --- a/vm-heap-analysis/agent/src/test/java/com/redhat/thermostat/vm/heap/analysis/agent/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/agent/src/test/java/com/redhat/thermostat/vm/heap/analysis/agent/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -46,7 +46,7 @@ import org.osgi.framework.ServiceRegistration; import com.redhat.thermostat.agent.command.RequestReceiver; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.heap.analysis.agent.internal.Activator; import com.redhat.thermostat.vm.heap.analysis.agent.internal.HeapDumpReceiver; import com.redhat.thermostat.vm.heap.analysis.common.HeapDAO; diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/client-core/pom.xml --- a/vm-heap-analysis/client-core/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/client-core/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -157,6 +157,12 @@ system ${java.home}/../lib/tools.jar + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/HeapDumperService.java --- a/vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/HeapDumperService.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/HeapDumperService.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,9 +41,9 @@ import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.NameMatchingRefFilter; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.vm.heap.analysis.client.core.internal.HeapDumpController; import com.redhat.thermostat.vm.heap.analysis.common.HeapDAO; import com.redhat.thermostat.vm.memory.common.VmMemoryStatDAO; diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/Activator.java --- a/vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/Activator.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/Activator.java Wed Jan 16 18:58:59 2013 +0100 @@ -50,8 +50,8 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.vm.heap.analysis.client.core.HeapDumperService; import com.redhat.thermostat.vm.heap.analysis.common.HeapDAO; import com.redhat.thermostat.vm.memory.common.VmMemoryStatDAO; diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/HeapDumpController.java --- a/vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/HeapDumpController.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/HeapDumpController.java Wed Jan 16 18:58:59 2013 +0100 @@ -36,8 +36,6 @@ package com.redhat.thermostat.vm.heap.analysis.client.core.internal; -import java.text.DecimalFormat; -import java.text.NumberFormat; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -54,9 +52,9 @@ import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.Timer.SchedulingType; import com.redhat.thermostat.common.cli.CommandException; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.locale.Translate; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.storage.model.HeapInfo; import com.redhat.thermostat.storage.model.VmMemoryStat; import com.redhat.thermostat.storage.model.VmMemoryStat.Generation; @@ -79,7 +77,6 @@ private static final Translate translator = LocaleResources.createLocalizer(); - private final VmInfoDAO vmInfoDao; private final VmMemoryStatDAO vmDao; private final VmRef ref; @@ -124,7 +121,6 @@ this.detailsViewProvider = detailsViewProvider; this.appService = appService; this.ref = ref; - this.vmInfoDao = vmInfoDao; this.vmDao = vmMemoryStatDao; this.heapDAO = heapDao; diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/HeapDumper.java --- a/vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/HeapDumper.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/HeapDumper.java Wed Jan 16 18:58:59 2013 +0100 @@ -44,7 +44,7 @@ import com.redhat.thermostat.common.cli.CommandContextFactory; import com.redhat.thermostat.common.cli.CommandException; import com.redhat.thermostat.common.cli.SimpleArguments; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; public class HeapDumper { diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/client-core/src/test/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/ActivatorTest.java --- a/vm-heap-analysis/client-core/src/test/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/client-core/src/test/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -45,8 +45,8 @@ import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.storage.dao.VmInfoDAO; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.heap.analysis.client.core.HeapDumperService; import com.redhat.thermostat.vm.heap.analysis.common.HeapDAO; import com.redhat.thermostat.vm.memory.common.VmMemoryStatDAO; diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/client-core/src/test/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/HeapDumpControllerTest.java --- a/vm-heap-analysis/client-core/src/test/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/HeapDumpControllerTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/client-core/src/test/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/HeapDumpControllerTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -70,9 +70,9 @@ import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.TimerFactory; import com.redhat.thermostat.common.cli.CommandException; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.storage.model.HeapInfo; import com.redhat.thermostat.storage.model.VmInfo; import com.redhat.thermostat.storage.model.VmMemoryStat; diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/client-core/src/test/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/HeapDumperTest.java --- a/vm-heap-analysis/client-core/src/test/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/HeapDumperTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/client-core/src/test/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/HeapDumperTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -53,8 +53,8 @@ import com.redhat.thermostat.common.cli.CommandContextFactory; import com.redhat.thermostat.common.cli.CommandException; import com.redhat.thermostat.common.cli.CommandRegistry; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; public class HeapDumperTest { private static final String TEST_HOST_ID = "1111111"; diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/client-core/src/test/java/com/redhat/thermostat/vm/heap/analysis/client/locale/LocaleResourcesTest.java --- a/vm-heap-analysis/client-core/src/test/java/com/redhat/thermostat/vm/heap/analysis/client/locale/LocaleResourcesTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/client-core/src/test/java/com/redhat/thermostat/vm/heap/analysis/client/locale/LocaleResourcesTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -36,7 +36,7 @@ package com.redhat.thermostat.vm.heap.analysis.client.locale; -import com.redhat.thermostat.test.locale.AbstractLocaleResourcesTest; +import com.redhat.thermostat.testutils.AbstractLocaleResourcesTest; public class LocaleResourcesTest extends AbstractLocaleResourcesTest { diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/client-swing/pom.xml --- a/vm-heap-analysis/client-swing/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/client-swing/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -137,6 +137,12 @@ system ${java.home}/../lib/tools.jar + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/client-swing/src/test/java/com/redhat/thermostat/vm/heap/analysis/client/swing/internal/ActivatorTest.java --- a/vm-heap-analysis/client-swing/src/test/java/com/redhat/thermostat/vm/heap/analysis/client/swing/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/client-swing/src/test/java/com/redhat/thermostat/vm/heap/analysis/client/swing/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,7 +41,7 @@ import org.junit.Test; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.heap.analysis.client.core.HeapDumpDetailsViewProvider; import com.redhat.thermostat.vm.heap.analysis.client.core.HeapHistogramViewProvider; import com.redhat.thermostat.vm.heap.analysis.client.core.HeapViewProvider; diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/command/pom.xml --- a/vm-heap-analysis/command/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/command/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -83,6 +83,16 @@ test + org.powermock + powermock-api-mockito + test + + + org.powermock + powermock-module-junit4 + test + + org.osgi org.osgi.core provided @@ -103,11 +113,11 @@ thermostat-client-command ${project.version} + com.redhat.thermostat - thermostat-common-test + thermostat-client-cli ${project.version} - test @@ -121,6 +131,12 @@ ${project.version} test + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + com.sun diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/command/src/main/java/com/redhat/thermostat/vm/heap/analysis/command/internal/DumpHeapCommand.java --- a/vm-heap-analysis/command/src/main/java/com/redhat/thermostat/vm/heap/analysis/command/internal/DumpHeapCommand.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/command/src/main/java/com/redhat/thermostat/vm/heap/analysis/command/internal/DumpHeapCommand.java Wed Jan 16 18:58:59 2013 +0100 @@ -38,13 +38,13 @@ import java.util.concurrent.Semaphore; +import com.redhat.thermostat.client.cli.HostVMArguments; import com.redhat.thermostat.common.cli.CommandContext; import com.redhat.thermostat.common.cli.CommandException; -import com.redhat.thermostat.common.cli.HostVMArguments; import com.redhat.thermostat.common.cli.SimpleCommand; -import com.redhat.thermostat.common.dao.AgentInfoDAO; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; import com.redhat.thermostat.vm.heap.analysis.command.locale.LocaleResources; diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/command/src/main/java/com/redhat/thermostat/vm/heap/analysis/command/internal/DumpHeapHelper.java --- a/vm-heap-analysis/command/src/main/java/com/redhat/thermostat/vm/heap/analysis/command/internal/DumpHeapHelper.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/command/src/main/java/com/redhat/thermostat/vm/heap/analysis/command/internal/DumpHeapHelper.java Wed Jan 16 18:58:59 2013 +0100 @@ -44,10 +44,10 @@ import com.redhat.thermostat.common.command.RequestResponseListener; import com.redhat.thermostat.common.command.Response; import com.redhat.thermostat.common.command.Response.ResponseType; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; public class DumpHeapHelper { diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/command/src/main/java/com/redhat/thermostat/vm/heap/analysis/command/internal/ListHeapDumpsCommand.java --- a/vm-heap-analysis/command/src/main/java/com/redhat/thermostat/vm/heap/analysis/command/internal/ListHeapDumpsCommand.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/command/src/main/java/com/redhat/thermostat/vm/heap/analysis/command/internal/ListHeapDumpsCommand.java Wed Jan 16 18:58:59 2013 +0100 @@ -40,17 +40,17 @@ import java.util.Collection; import java.util.Date; +import com.redhat.thermostat.client.cli.HostVMArguments; import com.redhat.thermostat.common.cli.CommandContext; import com.redhat.thermostat.common.cli.CommandException; -import com.redhat.thermostat.common.cli.HostVMArguments; import com.redhat.thermostat.common.cli.SimpleCommand; import com.redhat.thermostat.common.cli.TableRenderer; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.storage.model.HeapInfo; import com.redhat.thermostat.vm.heap.analysis.command.locale.LocaleResources; import com.redhat.thermostat.vm.heap.analysis.common.HeapDAO; diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/command/src/test/java/com/redhat/thermostat/vm/heap/analysis/command/internal/ActivatorTest.java --- a/vm-heap-analysis/command/src/test/java/com/redhat/thermostat/vm/heap/analysis/command/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/command/src/test/java/com/redhat/thermostat/vm/heap/analysis/command/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -38,17 +38,33 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.when; +import static org.mockito.Mockito.mock; import org.junit.Test; +import org.junit.runner.RunWith; +import org.osgi.framework.Bundle; +import org.osgi.framework.Filter; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.InvalidSyntaxException; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; import com.redhat.thermostat.common.cli.Command; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; +@RunWith(PowerMockRunner.class) +@PrepareForTest({FrameworkUtil.class}) public class ActivatorTest { @Test public void testCommandsRegistered() throws Exception { StubBundleContext ctx = new StubBundleContext(); + + makeServiceLoaderHappy(ctx); + Activator activator = new Activator(); activator.start(ctx); @@ -65,5 +81,25 @@ assertEquals(0, ctx.getAllServices().size()); } + + private void makeServiceLoaderHappy(StubBundleContext ctx) { + // ShellCommands no-arg constructor uses FrameworkUtil to get + // the bundle context. This results in NPEs when ServiceLoader + // attempts to load Command classes. Note that client-cli is + // a dep of this bundle and hence ServiceLoader wants to instantiate + // Command classes from there too. + PowerMockito.mockStatic(FrameworkUtil.class); + Bundle mockBundle = mock(Bundle.class); + when(FrameworkUtil.getBundle(any(Class.class))).thenReturn(mockBundle); + when(mockBundle.getBundleContext()).thenReturn(ctx); + Filter mockFilter = mock(Filter.class); + // StubBundleContext.createFilter() returns null if FrameworkUtil is + // mocked, so mock the offending static call too. + try { + when(FrameworkUtil.createFilter(any(String.class))).thenReturn(mockFilter); + } catch (InvalidSyntaxException e) { + // ignored + } + } } diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/command/src/test/java/com/redhat/thermostat/vm/heap/analysis/command/internal/DumpHeapCommandTest.java --- a/vm-heap-analysis/command/src/test/java/com/redhat/thermostat/vm/heap/analysis/command/internal/DumpHeapCommandTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/command/src/test/java/com/redhat/thermostat/vm/heap/analysis/command/internal/DumpHeapCommandTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -56,10 +56,10 @@ import com.redhat.thermostat.common.cli.Command; import com.redhat.thermostat.common.cli.CommandException; import com.redhat.thermostat.common.cli.SimpleArguments; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; import com.redhat.thermostat.test.TestCommandContextFactory; import com.redhat.thermostat.vm.heap.analysis.command.locale.LocaleResources; diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/command/src/test/java/com/redhat/thermostat/vm/heap/analysis/command/internal/DumpHeapHelperTest.java --- a/vm-heap-analysis/command/src/test/java/com/redhat/thermostat/vm/heap/analysis/command/internal/DumpHeapHelperTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/command/src/test/java/com/redhat/thermostat/vm/heap/analysis/command/internal/DumpHeapHelperTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -58,10 +58,10 @@ import com.redhat.thermostat.common.command.RequestResponseListener; import com.redhat.thermostat.common.command.Response; import com.redhat.thermostat.common.command.Response.ResponseType; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; import com.redhat.thermostat.storage.model.AgentInformation; import com.redhat.thermostat.vm.heap.analysis.command.internal.DumpHeapHelper; diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/command/src/test/java/com/redhat/thermostat/vm/heap/analysis/command/internal/ListHeapDumpsCommandTest.java --- a/vm-heap-analysis/command/src/test/java/com/redhat/thermostat/vm/heap/analysis/command/internal/ListHeapDumpsCommandTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/command/src/test/java/com/redhat/thermostat/vm/heap/analysis/command/internal/ListHeapDumpsCommandTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -55,11 +55,11 @@ import com.redhat.thermostat.common.cli.Command; import com.redhat.thermostat.common.cli.CommandException; import com.redhat.thermostat.common.cli.SimpleArguments; -import com.redhat.thermostat.common.dao.HostInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.HostInfoDAO; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.storage.model.HeapInfo; import com.redhat.thermostat.test.TestCommandContextFactory; import com.redhat.thermostat.vm.heap.analysis.command.internal.ListHeapDumpsCommand; diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/command/src/test/java/com/redhat/thermostat/vm/heap/analysis/command/locale/LocaleResourcesTest.java --- a/vm-heap-analysis/command/src/test/java/com/redhat/thermostat/vm/heap/analysis/command/locale/LocaleResourcesTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/command/src/test/java/com/redhat/thermostat/vm/heap/analysis/command/locale/LocaleResourcesTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -36,7 +36,7 @@ package com.redhat.thermostat.vm.heap.analysis.command.locale; -import com.redhat.thermostat.test.locale.AbstractLocaleResourcesTest; +import com.redhat.thermostat.testutils.AbstractLocaleResourcesTest; public class LocaleResourcesTest extends AbstractLocaleResourcesTest { diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/common/pom.xml --- a/vm-heap-analysis/common/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/common/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -107,6 +107,11 @@ thermostat-common-core ${project.version} + + com.redhat.thermostat + thermostat-storage-core + ${project.version} + diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/common/src/main/java/com/redhat/thermostat/vm/heap/analysis/common/HeapDAO.java --- a/vm-heap-analysis/common/src/main/java/com/redhat/thermostat/vm/heap/analysis/common/HeapDAO.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/common/src/main/java/com/redhat/thermostat/vm/heap/analysis/common/HeapDAO.java Wed Jan 16 18:58:59 2013 +0100 @@ -42,9 +42,9 @@ import java.util.Collection; import com.redhat.thermostat.annotations.Service; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.storage.core.Category; import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.model.HeapInfo; @Service diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/common/src/main/java/com/redhat/thermostat/vm/heap/analysis/common/internal/HeapDAOImpl.java --- a/vm-heap-analysis/common/src/main/java/com/redhat/thermostat/vm/heap/analysis/common/internal/HeapDAOImpl.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/common/src/main/java/com/redhat/thermostat/vm/heap/analysis/common/internal/HeapDAOImpl.java Wed Jan 16 18:58:59 2013 +0100 @@ -49,12 +49,12 @@ import java.util.logging.Level; import java.util.logging.Logger; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.LoggingUtils; import com.redhat.thermostat.storage.core.Cursor; import com.redhat.thermostat.storage.core.Key; import com.redhat.thermostat.storage.core.Put; import com.redhat.thermostat.storage.core.Query; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.core.Query.Criteria; import com.redhat.thermostat.storage.core.Storage; import com.redhat.thermostat.storage.model.HeapInfo; diff -r 4290490a2e05 -r 186115da601f vm-heap-analysis/common/src/test/java/com/redhat/thermostat/vm/heap/analysis/common/internal/HeapDAOTest.java --- a/vm-heap-analysis/common/src/test/java/com/redhat/thermostat/vm/heap/analysis/common/internal/HeapDAOTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-heap-analysis/common/src/test/java/com/redhat/thermostat/vm/heap/analysis/common/internal/HeapDAOTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -61,13 +61,14 @@ import org.junit.Test; import org.mockito.ArgumentCaptor; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.storage.core.Add; import com.redhat.thermostat.storage.core.Category; import com.redhat.thermostat.storage.core.Cursor; +import com.redhat.thermostat.storage.core.HostRef; import com.redhat.thermostat.storage.core.Key; import com.redhat.thermostat.storage.core.Query; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.core.Query.Criteria; import com.redhat.thermostat.storage.core.Storage; import com.redhat.thermostat.storage.model.HeapInfo; import com.redhat.thermostat.vm.heap.analysis.common.HeapDAO; diff -r 4290490a2e05 -r 186115da601f vm-memory/agent/pom.xml --- a/vm-memory/agent/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-memory/agent/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -74,5 +74,11 @@ thermostat-storage-core ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/ActivatorTest.java --- a/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -49,7 +49,7 @@ import com.redhat.thermostat.backend.Backend; import com.redhat.thermostat.backend.BackendService; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.memory.common.VmMemoryStatDAO; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f vm-memory/client-cli/src/main/java/com/redhat/thermostat/vm/memory/client/cli/internal/VmMemoryStatPrintDelegate.java --- a/vm-memory/client-cli/src/main/java/com/redhat/thermostat/vm/memory/client/cli/internal/VmMemoryStatPrintDelegate.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-memory/client-cli/src/main/java/com/redhat/thermostat/vm/memory/client/cli/internal/VmMemoryStatPrintDelegate.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,8 +41,8 @@ import com.redhat.thermostat.client.cli.VMStatPrintDelegate; import com.redhat.thermostat.common.Size; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.locale.Translate; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.model.TimeStampedPojo; import com.redhat.thermostat.storage.model.VmMemoryStat; import com.redhat.thermostat.vm.memory.common.VmMemoryStatDAO; diff -r 4290490a2e05 -r 186115da601f vm-memory/client-cli/src/test/java/com/redhat/thermostat/vm/memory/client/cli/internal/ActivatorTest.java --- a/vm-memory/client-cli/src/test/java/com/redhat/thermostat/vm/memory/client/cli/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-memory/client-cli/src/test/java/com/redhat/thermostat/vm/memory/client/cli/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -43,7 +43,7 @@ import org.junit.Test; import com.redhat.thermostat.client.cli.VMStatPrintDelegate; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.memory.common.VmMemoryStatDAO; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f vm-memory/client-cli/src/test/java/com/redhat/thermostat/vm/memory/client/cli/internal/LocaleResourcesTest.java --- a/vm-memory/client-cli/src/test/java/com/redhat/thermostat/vm/memory/client/cli/internal/LocaleResourcesTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-memory/client-cli/src/test/java/com/redhat/thermostat/vm/memory/client/cli/internal/LocaleResourcesTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -36,7 +36,7 @@ package com.redhat.thermostat.vm.memory.client.cli.internal; -import com.redhat.thermostat.test.locale.AbstractLocaleResourcesTest; +import com.redhat.thermostat.testutils.AbstractLocaleResourcesTest; public class LocaleResourcesTest extends AbstractLocaleResourcesTest { diff -r 4290490a2e05 -r 186115da601f vm-memory/client-cli/src/test/java/com/redhat/thermostat/vm/memory/client/cli/internal/VmMemoryStatPrintDelegateTest.java --- a/vm-memory/client-cli/src/test/java/com/redhat/thermostat/vm/memory/client/cli/internal/VmMemoryStatPrintDelegateTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-memory/client-cli/src/test/java/com/redhat/thermostat/vm/memory/client/cli/internal/VmMemoryStatPrintDelegateTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -49,8 +49,8 @@ import com.redhat.thermostat.client.cli.VMStatPrintDelegate; import com.redhat.thermostat.common.cli.CommandException; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.model.TimeStampedPojo; import com.redhat.thermostat.storage.model.VmMemoryStat; import com.redhat.thermostat.storage.model.VmMemoryStat.Generation; diff -r 4290490a2e05 -r 186115da601f vm-memory/client-core/pom.xml --- a/vm-memory/client-core/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-memory/client-core/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -86,5 +86,11 @@ thermostat-gc-remote-collector-client-common ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f vm-memory/client-core/src/main/java/com/redhat/thermostat/vm/memory/client/core/MemoryStatsService.java --- a/vm-memory/client-core/src/main/java/com/redhat/thermostat/vm/memory/client/core/MemoryStatsService.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-memory/client-core/src/main/java/com/redhat/thermostat/vm/memory/client/core/MemoryStatsService.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,11 +41,11 @@ import com.redhat.thermostat.client.core.NameMatchingRefFilter; import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.gc.remote.common.GCRequest; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.vm.memory.client.core.internal.MemoryStatsController; import com.redhat.thermostat.vm.memory.common.VmMemoryStatDAO; diff -r 4290490a2e05 -r 186115da601f vm-memory/client-core/src/main/java/com/redhat/thermostat/vm/memory/client/core/internal/Activator.java --- a/vm-memory/client-core/src/main/java/com/redhat/thermostat/vm/memory/client/core/internal/Activator.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-memory/client-core/src/main/java/com/redhat/thermostat/vm/memory/client/core/internal/Activator.java Wed Jan 16 18:58:59 2013 +0100 @@ -49,10 +49,10 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.gc.remote.common.GCRequest; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.vm.memory.client.core.MemoryStatsService; import com.redhat.thermostat.vm.memory.common.VmMemoryStatDAO; diff -r 4290490a2e05 -r 186115da601f vm-memory/client-core/src/main/java/com/redhat/thermostat/vm/memory/client/core/internal/MemoryStatsController.java --- a/vm-memory/client-core/src/main/java/com/redhat/thermostat/vm/memory/client/core/internal/MemoryStatsController.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-memory/client-core/src/main/java/com/redhat/thermostat/vm/memory/client/core/internal/MemoryStatsController.java Wed Jan 16 18:58:59 2013 +0100 @@ -56,12 +56,12 @@ import com.redhat.thermostat.common.command.RequestResponseListener; import com.redhat.thermostat.common.command.Response; import com.redhat.thermostat.common.command.Response.ResponseType; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.gc.remote.common.GCRequest; import com.redhat.thermostat.gc.remote.common.command.GCCommand; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.storage.model.VmMemoryStat; import com.redhat.thermostat.storage.model.VmMemoryStat.Generation; import com.redhat.thermostat.storage.model.VmMemoryStat.Space; diff -r 4290490a2e05 -r 186115da601f vm-memory/client-core/src/test/java/com/redhat/thermostat/vm/memory/client/core/internal/ActivatorTest.java --- a/vm-memory/client-core/src/test/java/com/redhat/thermostat/vm/memory/client/core/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-memory/client-core/src/test/java/com/redhat/thermostat/vm/memory/client/core/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -45,10 +45,10 @@ import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.VmInfoDAO; import com.redhat.thermostat.gc.remote.common.GCRequest; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; +import com.redhat.thermostat.storage.dao.VmInfoDAO; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.memory.client.core.MemoryStatsService; import com.redhat.thermostat.vm.memory.common.VmMemoryStatDAO; diff -r 4290490a2e05 -r 186115da601f vm-memory/client-core/src/test/java/com/redhat/thermostat/vm/memory/client/core/internal/MemoryStatsControllerTest.java --- a/vm-memory/client-core/src/test/java/com/redhat/thermostat/vm/memory/client/core/internal/MemoryStatsControllerTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-memory/client-core/src/test/java/com/redhat/thermostat/vm/memory/client/core/internal/MemoryStatsControllerTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -65,11 +65,11 @@ import com.redhat.thermostat.common.Timer.SchedulingType; import com.redhat.thermostat.common.TimerFactory; import com.redhat.thermostat.common.command.RequestResponseListener; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.gc.remote.common.GCRequest; import com.redhat.thermostat.gc.remote.common.command.GCCommand; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.AgentInfoDAO; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.storage.model.VmInfo; import com.redhat.thermostat.storage.model.VmMemoryStat; import com.redhat.thermostat.storage.model.VmMemoryStat.Generation; diff -r 4290490a2e05 -r 186115da601f vm-memory/client-core/src/test/java/com/redhat/thermostat/vm/memory/client/locale/LocaleResourcesTest.java --- a/vm-memory/client-core/src/test/java/com/redhat/thermostat/vm/memory/client/locale/LocaleResourcesTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-memory/client-core/src/test/java/com/redhat/thermostat/vm/memory/client/locale/LocaleResourcesTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -36,7 +36,7 @@ package com.redhat.thermostat.vm.memory.client.locale; -import com.redhat.thermostat.test.locale.AbstractLocaleResourcesTest; +import com.redhat.thermostat.testutils.AbstractLocaleResourcesTest; public class LocaleResourcesTest extends AbstractLocaleResourcesTest { diff -r 4290490a2e05 -r 186115da601f vm-memory/client-swing/pom.xml --- a/vm-memory/client-swing/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-memory/client-swing/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -92,6 +92,12 @@ thermostat-gc-remote-collector-client-swing ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f vm-memory/client-swing/src/test/java/com/redhat/thermostat/vm/memory/client/swing/internal/ActivatorTest.java --- a/vm-memory/client-swing/src/test/java/com/redhat/thermostat/vm/memory/client/swing/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-memory/client-swing/src/test/java/com/redhat/thermostat/vm/memory/client/swing/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,7 +41,7 @@ import org.junit.Test; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.memory.client.core.MemoryStatsViewProvider; import com.redhat.thermostat.vm.memory.client.swing.internal.Activator; import com.redhat.thermostat.vm.memory.client.swing.internal.SwingMemoryStatsViewProvider; diff -r 4290490a2e05 -r 186115da601f vm-memory/common/pom.xml --- a/vm-memory/common/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-memory/common/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -64,5 +64,11 @@ thermostat-storage-core ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/VmMemoryStatDAO.java --- a/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/VmMemoryStatDAO.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/VmMemoryStatDAO.java Wed Jan 16 18:58:59 2013 +0100 @@ -39,9 +39,9 @@ import java.util.List; import com.redhat.thermostat.annotations.Service; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.storage.core.Category; import com.redhat.thermostat.storage.core.Key; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.model.VmMemoryStat; import com.redhat.thermostat.storage.model.VmMemoryStat.Generation; diff -r 4290490a2e05 -r 186115da601f vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/internal/VmMemoryStatDAOImpl.java --- a/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/internal/VmMemoryStatDAOImpl.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/internal/VmMemoryStatDAOImpl.java Wed Jan 16 18:58:59 2013 +0100 @@ -38,14 +38,14 @@ import java.util.List; -import com.redhat.thermostat.common.dao.VmLatestPojoListGetter; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.storage.core.Cursor; import com.redhat.thermostat.storage.core.Key; import com.redhat.thermostat.storage.core.Put; import com.redhat.thermostat.storage.core.Query; import com.redhat.thermostat.storage.core.Query.Criteria; import com.redhat.thermostat.storage.core.Storage; +import com.redhat.thermostat.storage.core.VmLatestPojoListGetter; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.model.VmMemoryStat; import com.redhat.thermostat.vm.memory.common.VmMemoryStatDAO; diff -r 4290490a2e05 -r 186115da601f vm-memory/common/src/test/java/com/redhat/thermostat/vm/memory/common/internal/ActivatorTest.java --- a/vm-memory/common/src/test/java/com/redhat/thermostat/vm/memory/common/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-memory/common/src/test/java/com/redhat/thermostat/vm/memory/common/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -43,7 +43,7 @@ import org.junit.Test; import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.memory.common.VmMemoryStatDAO; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f vm-memory/common/src/test/java/com/redhat/thermostat/vm/memory/common/internal/VmMemoryStatDAOTest.java --- a/vm-memory/common/src/test/java/com/redhat/thermostat/vm/memory/common/internal/VmMemoryStatDAOTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-memory/common/src/test/java/com/redhat/thermostat/vm/memory/common/internal/VmMemoryStatDAOTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -52,10 +52,10 @@ import org.junit.Before; import org.junit.Test; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.storage.core.Add; import com.redhat.thermostat.storage.core.Category; +import com.redhat.thermostat.storage.core.HostRef; +import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.core.Cursor; import com.redhat.thermostat.storage.core.Key; import com.redhat.thermostat.storage.core.Query; diff -r 4290490a2e05 -r 186115da601f vm-overview/client-core/pom.xml --- a/vm-overview/client-core/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-overview/client-core/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -71,5 +71,11 @@ ${project.version} test + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/VmOverviewService.java --- a/vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/VmOverviewService.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/VmOverviewService.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,9 +41,9 @@ import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.NameMatchingRefFilter; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.vm.overview.client.core.internal.VmOverviewController; public class VmOverviewService implements InformationService { diff -r 4290490a2e05 -r 186115da601f vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/internal/Activator.java --- a/vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/internal/Activator.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/internal/Activator.java Wed Jan 16 18:58:59 2013 +0100 @@ -50,8 +50,8 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.vm.overview.client.core.VmOverviewService; public class Activator implements BundleActivator { diff -r 4290490a2e05 -r 186115da601f vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/internal/VmOverviewController.java --- a/vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/internal/VmOverviewController.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/internal/VmOverviewController.java Wed Jan 16 18:58:59 2013 +0100 @@ -49,9 +49,9 @@ import com.redhat.thermostat.common.NotImplementedException; import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.Timer.SchedulingType; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.locale.Translate; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.storage.model.VmInfo; import com.redhat.thermostat.vm.overview.client.core.VmOverviewView; import com.redhat.thermostat.vm.overview.client.core.VmOverviewViewProvider; diff -r 4290490a2e05 -r 186115da601f vm-overview/client-core/src/test/java/com/redhat/thermostat/vm/overview/client/core/internal/ActivatorTest.java --- a/vm-overview/client-core/src/test/java/com/redhat/thermostat/vm/overview/client/core/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-overview/client-core/src/test/java/com/redhat/thermostat/vm/overview/client/core/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -45,8 +45,8 @@ import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.storage.dao.VmInfoDAO; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.overview.client.core.VmOverviewService; public class ActivatorTest { diff -r 4290490a2e05 -r 186115da601f vm-overview/client-core/src/test/java/com/redhat/thermostat/vm/overview/client/core/internal/VmOverviewControllerTest.java --- a/vm-overview/client-core/src/test/java/com/redhat/thermostat/vm/overview/client/core/internal/VmOverviewControllerTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-overview/client-core/src/test/java/com/redhat/thermostat/vm/overview/client/core/internal/VmOverviewControllerTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -62,9 +62,9 @@ import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.common.Timer.SchedulingType; import com.redhat.thermostat.common.TimerFactory; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.locale.Translate; +import com.redhat.thermostat.storage.core.VmRef; +import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.storage.model.VmInfo; import com.redhat.thermostat.vm.overview.client.core.VmOverviewView; import com.redhat.thermostat.vm.overview.client.core.VmOverviewViewProvider; diff -r 4290490a2e05 -r 186115da601f vm-overview/client-core/src/test/java/com/redhat/thermostat/vm/overview/client/locale/LocaleResourcesTest.java --- a/vm-overview/client-core/src/test/java/com/redhat/thermostat/vm/overview/client/locale/LocaleResourcesTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-overview/client-core/src/test/java/com/redhat/thermostat/vm/overview/client/locale/LocaleResourcesTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -36,7 +36,7 @@ package com.redhat.thermostat.vm.overview.client.locale; -import com.redhat.thermostat.test.locale.AbstractLocaleResourcesTest; +import com.redhat.thermostat.testutils.AbstractLocaleResourcesTest; public class LocaleResourcesTest extends AbstractLocaleResourcesTest { diff -r 4290490a2e05 -r 186115da601f vm-overview/client-swing/pom.xml --- a/vm-overview/client-swing/pom.xml Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-overview/client-swing/pom.xml Wed Jan 16 18:58:59 2013 +0100 @@ -78,5 +78,11 @@ thermostat-vm-overview-client-core ${project.version} + + com.redhat.thermostat + thermostat-common-test + ${project.version} + test + diff -r 4290490a2e05 -r 186115da601f vm-overview/client-swing/src/test/java/com/redhat/thermostat/vm/overview/client/swing/internal/ActivatorTest.java --- a/vm-overview/client-swing/src/test/java/com/redhat/thermostat/vm/overview/client/swing/internal/ActivatorTest.java Fri Jan 25 16:33:19 2013 -0500 +++ b/vm-overview/client-swing/src/test/java/com/redhat/thermostat/vm/overview/client/swing/internal/ActivatorTest.java Wed Jan 16 18:58:59 2013 +0100 @@ -41,7 +41,7 @@ import org.junit.Test; -import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.testutils.StubBundleContext; import com.redhat.thermostat.vm.overview.client.core.VmOverviewViewProvider; import com.redhat.thermostat.vm.overview.client.swing.internal.Activator; import com.redhat.thermostat.vm.overview.client.swing.internal.SwingVmOverviewViewProvider;