Mercurial > hg > thermostat-ng > agent
changeset 2652:f293cef5a741
Remove schema-info plugin and DAO
Reviewed-by: jerboaa
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-May/023132.html
author | Elliott Baron <ebaron@redhat.com> |
---|---|
date | Wed, 17 May 2017 18:11:05 -0400 |
parents | 7be582a246e9 |
children | f2abfc4cfc93 |
files | dev/pom.xml dev/schema-info-command/command/pom.xml dev/schema-info-command/command/src/main/java/com/redhat/thermostat/schemainfo/command/internal/Activator.java dev/schema-info-command/command/src/main/java/com/redhat/thermostat/schemainfo/command/internal/LocaleResources.java dev/schema-info-command/command/src/main/java/com/redhat/thermostat/schemainfo/command/internal/SchemaInfoCommand.java dev/schema-info-command/command/src/main/resources/com/redhat/thermostat/schemainfo/locale/strings.properties dev/schema-info-command/command/src/test/java/com/redhat/thermostat/schemainfo/command/internal/ActivatorTest.java dev/schema-info-command/command/src/test/java/com/redhat/thermostat/schemainfo/command/internal/SchemaInfoCommandTest.java dev/schema-info-command/distribution/pom.xml dev/schema-info-command/distribution/thermostat-plugin.xml dev/schema-info-command/pom.xml distribution/pom.xml storage/core/src/main/java/com/redhat/thermostat/storage/core/SchemaInfo.java storage/core/src/main/java/com/redhat/thermostat/storage/core/SchemaInfoInserter.java storage/core/src/main/java/com/redhat/thermostat/storage/dao/SchemaInfoDAO.java storage/core/src/main/java/com/redhat/thermostat/storage/internal/Activator.java storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/DAOImplCategoryRegistration.java storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/DAOImplStatementDescriptorRegistration.java storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/SchemaInfoDAOImpl.java storage/core/src/main/java/com/redhat/thermostat/storage/model/SchemaInformation.java storage/core/src/test/java/com/redhat/thermostat/storage/internal/ActivatorTest.java storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/DAOImplCategoryRegistrationTest.java storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/DAOImplStatementDescriptorRegistrationTest.java storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/SchemaInfoDAOTest.java |
diffstat | 24 files changed, 3 insertions(+), 1336 deletions(-) [+] |
line wrap: on
line diff
--- a/dev/pom.xml Fri May 12 11:08:29 2017 -0400 +++ b/dev/pom.xml Wed May 17 18:11:05 2017 -0400 @@ -54,7 +54,6 @@ <module>archetype-ext</module> <module>multi-module-plugin-archetype</module> <module>ide-launcher</module> - <module>schema-info-command</module> <module>ipc-test</module> </modules>
--- a/dev/schema-info-command/command/pom.xml Fri May 12 11:08:29 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,112 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Copyright 2012-2017 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 - <http://www.gnu.org/licenses/>. - - 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. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-schema-info</artifactId> - <version>1.99.12-SNAPSHOT</version> - </parent> - - <artifactId>thermostat-schema-info-command</artifactId> - <packaging>bundle</packaging> - - <name>Thermostat Schema Information Command plugin</name> - - <build> - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <extensions>true</extensions> - <configuration> - <instructions> - <Bundle-SymbolicName>com.redhat.thermostat.schemainfo.command</Bundle-SymbolicName> - <Bundle-Vendor>Red Hat, Inc.</Bundle-Vendor> - <Private-Package> - com.redhat.thermostat.schemainfo.command.internal, - </Private-Package> - <Bundle-Activator>com.redhat.thermostat.schemainfo.command.internal.Activator</Bundle-Activator> - <!-- Do not autogenerate uses clauses in Manifests --> - <_nouses>true</_nouses> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-common-test</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-common-core</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-shared-config</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-storage-core</artifactId> - <version>${project.version}</version> - </dependency> - - </dependencies> -</project> -
--- a/dev/schema-info-command/command/src/main/java/com/redhat/thermostat/schemainfo/command/internal/Activator.java Fri May 12 11:08:29 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright 2012-2017 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 - * <http://www.gnu.org/licenses/>. - * - * 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.schemainfo.command.internal; - -import java.util.Hashtable; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; - -import com.redhat.thermostat.common.cli.Command; - -public class Activator implements BundleActivator { - - private ServiceRegistration registration; - - @Override - public void start(final BundleContext context) throws Exception { - Hashtable<String,String> properties = new Hashtable<>(); - properties.put(Command.NAME, SchemaInfoCommand.commandName); - registration = context.registerService(Command.class.getName(), new SchemaInfoCommand(context), properties); - } - - @Override - public void stop(BundleContext context) throws Exception { - registration.unregister(); - } -} -
--- a/dev/schema-info-command/command/src/main/java/com/redhat/thermostat/schemainfo/command/internal/LocaleResources.java Fri May 12 11:08:29 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* - * Copyright 2012-2017 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 - * <http://www.gnu.org/licenses/>. - * - * 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.schemainfo.command.internal; - -import com.redhat.thermostat.shared.locale.Translate; - -public enum LocaleResources { - - SCHEMAINFO_SERVICE_UNAVAILABLE, - NO_CATEGORIES, - ; - - static final String RESOURCE_BUNDLE = - "com.redhat.thermostat.schemainfo.locale.strings"; - - public static Translate<LocaleResources> createLocalizer() { - return new Translate<>(RESOURCE_BUNDLE, LocaleResources.class); - } - -} -
--- a/dev/schema-info-command/command/src/main/java/com/redhat/thermostat/schemainfo/command/internal/SchemaInfoCommand.java Fri May 12 11:08:29 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -/* - * Copyright 2012-2017 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 - * <http://www.gnu.org/licenses/>. - * - * 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.schemainfo.command.internal; - -import java.util.Collection; - -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; - -import com.redhat.thermostat.common.cli.AbstractCommand; -import com.redhat.thermostat.common.cli.CommandContext; -import com.redhat.thermostat.common.cli.CommandException; -import com.redhat.thermostat.shared.locale.Translate; -import com.redhat.thermostat.storage.dao.SchemaInfoDAO; -import com.redhat.thermostat.storage.model.SchemaInformation; - -public class SchemaInfoCommand extends AbstractCommand { - - private static final Translate<LocaleResources> translator = LocaleResources.createLocalizer(); - public static final String commandName = "list-categories"; - - private BundleContext context; - - public SchemaInfoCommand(BundleContext context) { - this.context = context; - } - - public void run(CommandContext ctx) throws CommandException { - ServiceReference<?> schemaInfoDaoRef = context.getServiceReference(SchemaInfoDAO.class.getName()); - requireNonNull(schemaInfoDaoRef, translator.localize(LocaleResources.SCHEMAINFO_SERVICE_UNAVAILABLE)); - - SchemaInfoDAO schemaInfoDao = (SchemaInfoDAO) context.getService(schemaInfoDaoRef); - - Collection<SchemaInformation> categoriesList = schemaInfoDao.getSchemaInfos(); - - if(categoriesList.isEmpty()) { - ctx.getConsole().getOutput().println(translator.localize(LocaleResources.NO_CATEGORIES).getContents()); - } else { - for (SchemaInformation schemaCategory : categoriesList) { - ctx.getConsole().getOutput().println(schemaCategory.getCategoryName()); - } - } - } -} -
--- a/dev/schema-info-command/command/src/main/resources/com/redhat/thermostat/schemainfo/locale/strings.properties Fri May 12 11:08:29 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -SCHEMAINFO_SERVICE_UNAVAILABLE = Service Schema Information unavailable. -NO_CATEGORIES = No categories found.
--- a/dev/schema-info-command/command/src/test/java/com/redhat/thermostat/schemainfo/command/internal/ActivatorTest.java Fri May 12 11:08:29 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* - * Copyright 2012-2017 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 - * <http://www.gnu.org/licenses/>. - * - * 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.schemainfo.command.internal; - -import static com.redhat.thermostat.testutils.Asserts.assertCommandIsRegistered; -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import com.redhat.thermostat.schemainfo.command.internal.Activator; -import com.redhat.thermostat.testutils.StubBundleContext; - -public class ActivatorTest { - - @Test - public void testCommandsRegistered() throws Exception { - StubBundleContext ctx = new StubBundleContext(); - - Activator activator = new Activator(); - - activator.start(ctx); - - assertCommandIsRegistered(ctx, SchemaInfoCommand.commandName, SchemaInfoCommand.class); - - activator.stop(ctx); - - assertEquals(0, ctx.getAllServices().size()); - } - -} -
--- a/dev/schema-info-command/command/src/test/java/com/redhat/thermostat/schemainfo/command/internal/SchemaInfoCommandTest.java Fri May 12 11:08:29 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,136 +0,0 @@ -/* - * Copyright 2012-2017 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 - * <http://www.gnu.org/licenses/>. - * - * 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.schemainfo.command.internal; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -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.cli.Console; -import com.redhat.thermostat.common.cli.SimpleArguments; -import com.redhat.thermostat.common.internal.test.TestCommandContextFactory; -import com.redhat.thermostat.shared.locale.Translate; -import com.redhat.thermostat.storage.dao.SchemaInfoDAO; -import com.redhat.thermostat.storage.model.SchemaInformation; -import com.redhat.thermostat.testutils.StubBundleContext; - -public class SchemaInfoCommandTest { - - private static Translate<LocaleResources> translator; - private SchemaInfoCommand cmd; - private CommandContext ctxt; - private Console console; - private List<SchemaInformation> list; - private PrintStream output; - private PrintStream error; - private SchemaInfoDAO dao; - private SchemaInformation categoryTest1; - private SchemaInformation categoryTest2; - private StubBundleContext context; - - @Before - public void setUp() { - translator = LocaleResources.createLocalizer(); - categoryTest1 = new SchemaInformation(); - categoryTest2 = new SchemaInformation(); - ctxt = mock(CommandContext.class); - console = mock(Console.class); - list = new ArrayList<>(); - - categoryTest1.setCategoryName("category Test 1"); - categoryTest1.setTimeStamp(System.currentTimeMillis()); - categoryTest2.setCategoryName("category Test 2"); - categoryTest2.setTimeStamp(System.currentTimeMillis()); - list.add(categoryTest1); - list.add(categoryTest2); - - dao = mock(SchemaInfoDAO.class); - context = new StubBundleContext(); - context.registerService(SchemaInfoDAO.class, dao, null); - cmd = new SchemaInfoCommand(context); - - when(ctxt.getConsole()).thenReturn(console); - when(console.getError()).thenReturn(error); - when(console.getOutput()).thenReturn(output); - - } - - @Test - public void testStorageRequired() { - assertTrue(cmd.isStorageRequired()); - } - - @Test - public void verifyGetCategories() throws CommandException { - TestCommandContextFactory factory = new TestCommandContextFactory(); - SimpleArguments args = new SimpleArguments(); - when(dao.getSchemaInfos()).thenReturn(list); - - cmd.run(factory.createContext(args)); - - String expected = categoryTest1.getCategoryName() + "\n" + - categoryTest2.getCategoryName() + "\n"; - - assertEquals(expected, factory.getOutput()); - } - - @Test - public void verifyGetNoCategories() throws CommandException { - TestCommandContextFactory factory = new TestCommandContextFactory(); - SimpleArguments args = new SimpleArguments(); - List<SchemaInformation> emptylist = Collections.emptyList(); - - when(dao.getSchemaInfos()).thenReturn(emptylist); - cmd.run(factory.createContext(args)); - - String expected = translator.localize(LocaleResources.NO_CATEGORIES).getContents() + "\n"; - assertEquals(expected, factory.getOutput()); - } - -} -
--- a/dev/schema-info-command/distribution/pom.xml Fri May 12 11:08:29 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,98 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Copyright 2012-2017 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 - <http://www.gnu.org/licenses/>. - - 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. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-schema-info</artifactId> - <version>1.99.12-SNAPSHOT</version> - </parent> - - <artifactId>thermostat-schema-info-distribution</artifactId> - <packaging>pom</packaging> - - <name>Thermostat Schema Information plugin distribution</name> - - <properties> - <thermostat.plugin>schema-info</thermostat.plugin> - </properties> - - <build> - <plugins> - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <dependencies> - <dependency> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-assembly</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - <configuration> - <descriptorRefs> - <descriptorRef>plugin-assembly</descriptorRef> - </descriptorRefs> - <appendAssemblyId>false</appendAssemblyId> - </configuration> - <executions> - <execution> - <id>assemble-plugin</id> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <!-- Explicitly list all plug-in artifacts, transitive dependencies - are not included in assembly. --> - <dependencies> - <dependency> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-schema-info-command</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - -</project> -
--- a/dev/schema-info-command/distribution/thermostat-plugin.xml Fri May 12 11:08:29 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -<?xml version="1.0"?> -<!-- - - Copyright 2012-2017 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 - <http://www.gnu.org/licenses/>. - - 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. - ---> -<plugin xmlns="http://icedtea.classpath.org/thermostat/plugins/v1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://icedtea.classpath.org/thermostat/plugins/v1.0 thermostat-plugin.xsd"> - <commands> - <command> - <name>list-categories</name> - <summary>list all registered categories</summary> - <description>List all registered categories in the Storage.</description> - <command-groups> - <command-group>database-util</command-group> - </command-groups> - <environments> - <environment>cli</environment> - <environment>shell</environment> - </environments> - <bundles> - <bundle><symbolic-name>com.redhat.thermostat.schemainfo.command</symbolic-name><version>${project.version}</version></bundle> - <bundle><symbolic-name>com.redhat.thermostat.storage.mongodb</symbolic-name><version>${project.version}</version></bundle> - <bundle><symbolic-name>com.redhat.thermostat.web.common</symbolic-name><version>${project.version}</version></bundle> - <bundle><symbolic-name>com.redhat.thermostat.web.client</symbolic-name><version>${project.version}</version></bundle> - </bundles> - </command> - </commands> - <command-group-metadatas> - <command-group-metadata> - <name>database-util</name> - <description>Database Utilities</description> - <sort-order>50</sort-order> - </command-group-metadata> - </command-group-metadatas> -</plugin>
--- a/dev/schema-info-command/pom.xml Fri May 12 11:08:29 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Copyright 2012-2017 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 - <http://www.gnu.org/licenses/>. - - 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. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-devel-modules</artifactId> - <version>1.99.12-SNAPSHOT</version> - </parent> - <artifactId>thermostat-schema-info</artifactId> - <packaging>pom</packaging> - - <name>Thermostat Schema Information</name> - - <description>Plugin to get all registered categories in Storage</description> - - <modules> - <module>command</module> - <module>distribution</module> - </modules> -</project> -
--- a/distribution/pom.xml Fri May 12 11:08:29 2017 -0400 +++ b/distribution/pom.xml Wed May 17 18:11:05 2017 -0400 @@ -602,15 +602,6 @@ <version>${project.version}</version> <type>zip</type> </dependency> - - <!-- list-categories command --> - <dependency> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-schema-info-distribution</artifactId> - <version>${project.version}</version> - <type>zip</type> - </dependency> - </dependencies> </project>
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/SchemaInfo.java Fri May 12 11:08:29 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* - * Copyright 2012-2017 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 - * <http://www.gnu.org/licenses/>. - * - * 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.model.SchemaInformation; - -/** - * An interface which contains shared information used in - * {@link SchemaInfoDAO} and {@link SchemaInfoInserter}. - */ -public interface SchemaInfo { - - static final Key<String> NAME = new Key<>("categoryName"); - - static final Category<SchemaInformation> CATEGORY = new Category<>("schema-info", SchemaInformation.class, - Key.TIMESTAMP, - NAME - ); - -}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/SchemaInfoInserter.java Fri May 12 11:08:29 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -/* - * Copyright 2012-2017 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 - * <http://www.gnu.org/licenses/>. - * - * 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.model.Pojo; - -/* - * This interface and {@link BackingStorage} could be merged in a future - * breaking API release. - */ -/** - * This is a buddy interface of {@link BackingStorage}. Implementors of - * {@link BackingStorage} <strong>should</strong> also implement this interface. - * The interface is created to provide a new feature without breaking API release. - * - * A data access object for retrieving schema information {@link Storage} - * knows about irrespective of installed plug-ins. - * - * @see SchemaInfoInserter - * @see SchemaInfo - */ -public interface SchemaInfoInserter { - - void createSchemaInfo(); - - <T extends Pojo> void insertSchemaInfo(Category<T> category); - -}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/dao/SchemaInfoDAO.java Fri May 12 11:08:29 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* - * Copyright 2012-2017 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 - * <http://www.gnu.org/licenses/>. - * - * 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.model.SchemaInformation; - -/* - * BakingStorage has responsibility to create the collection this DAO use for queries because: - * - schema-info is a special collection/category. - * - This DAO can be used from clients. - * - The DAO should work also when schema-info collection doesn't exist. - * - Problem with creating collection. - * - Need a valid Storage instance. - */ -/** - * A data access object for retrieving {@link SchemaInformation} about - * {@link Category}s in Storage. - */ -@Service -public interface SchemaInfoDAO { - /** - * Get all category's names stored in schema-info. - * - * @return a {@link Collection} of {@link SchemaInformation} for all registered - * categories in schema-info.It will be empty if there is no categories or - * no schema-info collection - */ - Collection<SchemaInformation> getSchemaInfos(); - -} \ No newline at end of file
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/internal/Activator.java Fri May 12 11:08:29 2017 -0400 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/internal/Activator.java Wed May 17 18:11:05 2017 -0400 @@ -42,21 +42,16 @@ import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; import org.osgi.framework.ServiceRegistration; -import org.osgi.util.tracker.ServiceTracker; -import com.redhat.thermostat.storage.core.Storage; import com.redhat.thermostat.storage.core.WriterID; import com.redhat.thermostat.storage.dao.AgentInfoDAO; import com.redhat.thermostat.storage.dao.BackendInfoDAO; import com.redhat.thermostat.storage.dao.NetworkInterfaceInfoDAO; -import com.redhat.thermostat.storage.dao.SchemaInfoDAO; import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.storage.internal.dao.AgentInfoDAOImpl; import com.redhat.thermostat.storage.internal.dao.BackendInfoDAOImpl; import com.redhat.thermostat.storage.internal.dao.NetworkInterfaceInfoDAOImpl; -import com.redhat.thermostat.storage.internal.dao.SchemaInfoDAOImpl; import com.redhat.thermostat.storage.internal.dao.VmInfoDAOImpl; public class Activator implements BundleActivator { @@ -78,10 +73,6 @@ ServiceRegistration<?> reg = context.registerService(WriterID.class, writerID, null); regs.add(reg); - SchemaInfoDAO schemaInfoDAO = new SchemaInfoDAOImpl(); - reg = context.registerService(SchemaInfoDAO.class.getName(), schemaInfoDAO, null); - regs.add(reg); - AgentInfoDAO agentInfoDao = new AgentInfoDAOImpl(); reg = context.registerService(AgentInfoDAO.class.getName(), agentInfoDao, null); regs.add(reg);
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/DAOImplCategoryRegistration.java Fri May 12 11:08:29 2017 -0400 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/DAOImplCategoryRegistration.java Wed May 17 18:11:05 2017 -0400 @@ -39,7 +39,6 @@ import java.util.HashSet; import java.util.Set; -import com.redhat.thermostat.storage.core.SchemaInfo; import com.redhat.thermostat.storage.core.auth.CategoryRegistration; import com.redhat.thermostat.storage.dao.AgentInfoDAO; import com.redhat.thermostat.storage.dao.BackendInfoDAO; @@ -61,7 +60,6 @@ categories.add(VmInfoDAO.vmInfoCategory.getName()); categories.add(BackendInfoDAO.CATEGORY.getName()); categories.add(NetworkInterfaceInfoDAO.networkInfoCategory.getName()); - categories.add(SchemaInfo.CATEGORY.getName()); return categories; }
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/DAOImplStatementDescriptorRegistration.java Fri May 12 11:08:29 2017 -0400 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/DAOImplStatementDescriptorRegistration.java Wed May 17 18:11:05 2017 -0400 @@ -36,7 +36,7 @@ package com.redhat.thermostat.storage.internal.dao; -import java.util.HashSet; +import java.util.Collections; import java.util.Set; import com.redhat.thermostat.storage.core.auth.StatementDescriptorRegistration; @@ -51,10 +51,7 @@ @Override public Set<String> getStatementDescriptors() { - Set<String> daoDescs = new HashSet<>(); - daoDescs.add(SchemaInfoDAOImpl.QUERY_ALL_COLLECTIONS); - - return daoDescs; + return Collections.emptySet(); // TODO Remove once plugins no longer depend on this } }
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/SchemaInfoDAOImpl.java Fri May 12 11:08:29 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* - * Copyright 2012-2017 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 - * <http://www.gnu.org/licenses/>. - * - * 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.Collections; -import java.util.List; -import java.util.logging.Logger; - -import com.redhat.thermostat.common.utils.LoggingUtils; -import com.redhat.thermostat.storage.core.SchemaInfo; -import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.storage.dao.AbstractDao; -import com.redhat.thermostat.storage.dao.SchemaInfoDAO; -import com.redhat.thermostat.storage.dao.SimpleDaoQuery; -import com.redhat.thermostat.storage.model.SchemaInformation; - -// TODO Remove this class in the near future -public class SchemaInfoDAOImpl extends AbstractDao implements SchemaInfoDAO { - private static final Logger logger = LoggingUtils.getLogger(SchemaInfoDAOImpl.class); - static final String QUERY_ALL_COLLECTIONS = "QUERY " - + SchemaInfo.CATEGORY.getName(); - - @Override - public List<SchemaInformation> getSchemaInfos() { - return Collections.emptyList(); - } - - @Override - protected Logger getLogger() { - return logger; - } -}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/model/SchemaInformation.java Fri May 12 11:08:29 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -/* - * Copyright 2012-2017 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 - * <http://www.gnu.org/licenses/>. - * - * 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.model; - -import java.util.Objects; - -import com.redhat.thermostat.storage.core.Entity; -import com.redhat.thermostat.storage.core.Persist; - -@Entity -public class SchemaInformation implements TimeStampedPojo { - - private String categoryName; - private long timeStamp; - - public SchemaInformation() { - } - - @Persist - public String getCategoryName() { - return categoryName; - } - - @Persist - public void setCategoryName(String categoryName) { - this.categoryName = categoryName; - } - - @Persist - public long getTimeStamp() { - return this.timeStamp; - } - - @Persist - public void setTimeStamp(long timeStamp) { - this.timeStamp = timeStamp; - } - - @Override - public String toString() { - return "name: " + getCategoryName() + "; timestamp: " + getTimeStamp(); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (obj == this) { - return true; - } - if (!(obj instanceof SchemaInformation)) { - return false; - } - - SchemaInformation other = (SchemaInformation) obj; - return Objects.equals(this.categoryName, other.categoryName) && - Objects.equals(this.timeStamp, other.timeStamp); - } - - @Override - public int hashCode() { - return Objects.hash(categoryName, timeStamp); - } - -} \ No newline at end of file
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/internal/ActivatorTest.java Fri May 12 11:08:29 2017 -0400 +++ b/storage/core/src/test/java/com/redhat/thermostat/storage/internal/ActivatorTest.java Wed May 17 18:11:05 2017 -0400 @@ -52,12 +52,10 @@ import com.redhat.thermostat.storage.dao.AgentInfoDAO; import com.redhat.thermostat.storage.dao.BackendInfoDAO; import com.redhat.thermostat.storage.dao.NetworkInterfaceInfoDAO; -import com.redhat.thermostat.storage.dao.SchemaInfoDAO; import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.storage.internal.dao.AgentInfoDAOImpl; import com.redhat.thermostat.storage.internal.dao.BackendInfoDAOImpl; import com.redhat.thermostat.storage.internal.dao.NetworkInterfaceInfoDAOImpl; -import com.redhat.thermostat.storage.internal.dao.SchemaInfoDAOImpl; import com.redhat.thermostat.storage.internal.dao.VmInfoDAOImpl; import com.redhat.thermostat.testutils.StubBundleContext; @@ -70,7 +68,6 @@ activator.start(context); - assertTrue(context.isServiceRegistered(SchemaInfoDAO.class.getName(), SchemaInfoDAOImpl.class)); assertTrue(context.isServiceRegistered(WriterID.class.getName(), WriterIDImpl.class)); assertTrue(context.isServiceRegistered(NetworkInterfaceInfoDAO.class.getName(), NetworkInterfaceInfoDAOImpl.class)); assertTrue(context.isServiceRegistered(VmInfoDAO.class.getName(), VmInfoDAOImpl.class)); @@ -93,7 +90,6 @@ activator.stop(context); - assertFalse(context.isServiceRegistered(SchemaInfoDAO.class.getName(), SchemaInfoDAOImpl.class)); assertFalse(context.isServiceRegistered(NetworkInterfaceInfoDAO.class.getName(), NetworkInterfaceInfoDAOImpl.class)); assertFalse(context.isServiceRegistered(VmInfoDAO.class.getName(), VmInfoDAOImpl.class)); assertFalse(context.isServiceRegistered(AgentInfoDAO.class.getName(), AgentInfoDAOImpl.class)); @@ -122,7 +118,6 @@ activator.start(context); - assertTrue(context.isServiceRegistered(SchemaInfoDAO.class.getName(), SchemaInfoDAOImpl.class)); assertTrue(context.isServiceRegistered(NetworkInterfaceInfoDAO.class.getName(), NetworkInterfaceInfoDAOImpl.class)); assertTrue(context.isServiceRegistered(VmInfoDAO.class.getName(), VmInfoDAOImpl.class)); assertTrue(context.isServiceRegistered(AgentInfoDAO.class.getName(), AgentInfoDAOImpl.class)); @@ -136,7 +131,6 @@ activator.start(context); - assertTrue(context.isServiceRegistered(SchemaInfoDAO.class.getName(), SchemaInfoDAOImpl.class)); assertTrue(context.isServiceRegistered(NetworkInterfaceInfoDAO.class.getName(), NetworkInterfaceInfoDAOImpl.class)); assertTrue(context.isServiceRegistered(VmInfoDAO.class.getName(), VmInfoDAOImpl.class)); assertTrue(context.isServiceRegistered(AgentInfoDAO.class.getName(), AgentInfoDAOImpl.class));
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/DAOImplCategoryRegistrationTest.java Fri May 12 11:08:29 2017 -0400 +++ b/storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/DAOImplCategoryRegistrationTest.java Wed May 17 18:11:05 2017 -0400 @@ -44,7 +44,6 @@ import org.junit.Test; -import com.redhat.thermostat.storage.core.SchemaInfo; import com.redhat.thermostat.storage.core.auth.CategoryRegistration; import com.redhat.thermostat.storage.dao.AgentInfoDAO; import com.redhat.thermostat.storage.dao.BackendInfoDAO; @@ -62,13 +61,12 @@ public void registersAllCategories() { DAOImplCategoryRegistration reg = new DAOImplCategoryRegistration(); Set<String> categories = reg.getCategoryNames(); - assertEquals(5, categories.size()); + assertEquals(4, categories.size()); assertFalse("null descriptor not allowed", categories.contains(null)); assertTrue(categories.contains(VmInfoDAO.vmInfoCategory.getName())); assertTrue(categories.contains(AgentInfoDAO.CATEGORY.getName())); assertTrue(categories.contains(NetworkInterfaceInfoDAO.networkInfoCategory.getName())); assertTrue(categories.contains(BackendInfoDAO.CATEGORY.getName())); - assertTrue(categories.contains(SchemaInfo.CATEGORY.getName())); } }
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/DAOImplStatementDescriptorRegistrationTest.java Fri May 12 11:08:29 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* - * Copyright 2012-2017 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 - * <http://www.gnu.org/licenses/>. - * - * 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.assertFalse; - -import java.util.Set; - -import org.junit.Test; - -import com.redhat.thermostat.storage.core.auth.StatementDescriptorRegistration; -import com.redhat.thermostat.testutils.ServiceLoaderTest; - -public class DAOImplStatementDescriptorRegistrationTest extends ServiceLoaderTest<StatementDescriptorRegistration> { - - public DAOImplStatementDescriptorRegistrationTest() { - super(StatementDescriptorRegistration.class, NO_EXTRA_SERVICES, DAOImplStatementDescriptorRegistration.class); - } - - @Test - public void registersAllQueries() { - DAOImplStatementDescriptorRegistration reg = new DAOImplStatementDescriptorRegistration(); - Set<String> descriptors = reg.getStatementDescriptors(); - assertEquals(1, descriptors.size()); - assertFalse(descriptors.contains(null)); - } - -} -
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/SchemaInfoDAOTest.java Fri May 12 11:08:29 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,151 +0,0 @@ -/* - * Copyright 2012-2017 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 - * <http://www.gnu.org/licenses/>. - * - * 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.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.Collection; -import java.util.List; - -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.mockito.ArgumentCaptor; - -import com.redhat.thermostat.storage.core.Category; -import com.redhat.thermostat.storage.core.Cursor; -import com.redhat.thermostat.storage.core.DescriptorParsingException; -import com.redhat.thermostat.storage.core.Key; -import com.redhat.thermostat.storage.core.PreparedStatement; -import com.redhat.thermostat.storage.core.SchemaInfo; -import com.redhat.thermostat.storage.core.StatementDescriptor; -import com.redhat.thermostat.storage.core.StatementExecutionException; -import com.redhat.thermostat.storage.core.Storage; -import com.redhat.thermostat.storage.model.SchemaInformation; - -@Ignore // TODO Remove along with SchemaInfoDAO -public class SchemaInfoDAOTest { - - private SchemaInformation schemaInfo; - private SchemaInformation schemaInfo2; - - @Before - public void setUp() { - schemaInfo = new SchemaInformation(); - schemaInfo.setCategoryName("test SchemaInfo 1"); - - schemaInfo2 = new SchemaInformation(); - schemaInfo2.setCategoryName("test SchemaInfo 2"); - } - - @Test - public void preparedQueryDescriptorsAreSane() { - String expectedAllCollections = "QUERY schema-info"; - assertEquals(expectedAllCollections, SchemaInfoDAOImpl.QUERY_ALL_COLLECTIONS); - } - - @Test - public void verifyCategoryName() { - Category<SchemaInformation> category = SchemaInfo.CATEGORY; - assertEquals("schema-info", category.getName()); - } - - @Test - public void verifyKeyNames() { - assertEquals("timeStamp", Key.TIMESTAMP.getName()); - assertEquals("categoryName", SchemaInfo.NAME.getName()); - } - - @Test - public void verifyCategoryHasAllKeys() { - Collection<Key<?>> keys = SchemaInfo.CATEGORY.getKeys(); - - assertEquals(2, keys.size()); - assertTrue(keys.contains(SchemaInfo.NAME)); - assertTrue(keys.contains(Key.TIMESTAMP)); - - } - - @Test - public void verifyGetSchemaInfos() - throws StatementExecutionException, DescriptorParsingException{ - @SuppressWarnings("unchecked") - Cursor<SchemaInformation> schemaCursor = (Cursor<SchemaInformation>) mock(Cursor.class); - Storage storage = mock(Storage.class); - - @SuppressWarnings("unchecked") - PreparedStatement<SchemaInformation> stmt = (PreparedStatement<SchemaInformation>) mock(PreparedStatement.class); - ArgumentCaptor<StatementDescriptor> messageCaptor = ArgumentCaptor.forClass(StatementDescriptor.class); - SchemaInfoDAOImpl dao = new SchemaInfoDAOImpl(); - when(storage.prepareStatement(messageCaptor.capture())).thenReturn(stmt); - when(stmt.executeQuery()).thenReturn(schemaCursor); - - // 0 elements into DB - when(schemaCursor.hasNext()).thenReturn(false); - when(schemaCursor.next()).thenReturn(null); - List<SchemaInformation> listSchemaInfo = dao.getSchemaInfos(); - assertEquals(0, listSchemaInfo.size()); - - @SuppressWarnings("unchecked") - StatementDescriptor<SchemaInformation> arg = messageCaptor.getValue(); - - assertEquals(SchemaInfoDAOImpl.QUERY_ALL_COLLECTIONS, arg.getDescriptor()); - - // One element into DB - when(schemaCursor.hasNext()).thenReturn(true).thenReturn(false); - when(schemaCursor.next()).thenReturn(schemaInfo).thenReturn(null); - listSchemaInfo = dao.getSchemaInfos(); - assertEquals(1, listSchemaInfo.size()); - - SchemaInformation result = listSchemaInfo.get(0); - assertEquals(schemaInfo, result); - - // More elements into DB - when(schemaCursor.hasNext()).thenReturn(true).thenReturn(true).thenReturn(true).thenReturn(false); - when(schemaCursor.next()).thenReturn(schemaInfo).thenReturn(schemaInfo).thenReturn(schemaInfo2).thenReturn(null); - - listSchemaInfo = dao.getSchemaInfos(); - assertEquals(3, listSchemaInfo.size()); - - result = listSchemaInfo.get(2); - assertEquals(schemaInfo2, result); - } - -}