Mercurial > hg > release > thermostat-0.5
changeset 858:af374b51254f
Remove StorageConstants class
Remove c.r.t.storage.core.StorageConstants class. This class contained
a constant that is only being used by the mongo implementation of
Storage. Move the constant to the implementation that uses it.
Reviewed-by: neugens
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-December/004740.html
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Fri, 14 Dec 2012 12:22:29 -0500 |
parents | 8211cecd53df |
children | 1f3597423ee1 |
files | storage/core/src/main/java/com/redhat/thermostat/storage/core/StorageConstants.java storage/mongo/src/main/java/com/redhat/thermostat/storage/mongodb/internal/MongoConnection.java storage/mongo/src/test/java/com/redhat/thermostat/storage/mongodb/internal/MongoConnectionTest.java |
diffstat | 3 files changed, 4 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/StorageConstants.java Fri Dec 14 11:29:10 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* - * Copyright 2012 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; - -public class StorageConstants { - public static final String THERMOSTAT_DB_NAME = "thermostat"; -}
--- a/storage/mongo/src/main/java/com/redhat/thermostat/storage/mongodb/internal/MongoConnection.java Fri Dec 14 11:29:10 2012 -0500 +++ b/storage/mongo/src/main/java/com/redhat/thermostat/storage/mongodb/internal/MongoConnection.java Fri Dec 14 12:22:29 2012 -0500 @@ -47,10 +47,11 @@ import com.redhat.thermostat.storage.config.StartupConfiguration; import com.redhat.thermostat.storage.core.Connection; import com.redhat.thermostat.storage.core.ConnectionException; -import com.redhat.thermostat.storage.core.StorageConstants; class MongoConnection extends Connection { + static final String THERMOSTAT_DB_NAME = "thermostat"; + private Mongo m = null; private DB db = null; private StartupConfiguration conf; @@ -106,7 +107,7 @@ private void createConnection() throws MongoException, UnknownHostException { this.m = new Mongo(getMongoURI()); - this.db = m.getDB(StorageConstants.THERMOSTAT_DB_NAME); + this.db = m.getDB(THERMOSTAT_DB_NAME); } private MongoURI getMongoURI() {
--- a/storage/mongo/src/test/java/com/redhat/thermostat/storage/mongodb/internal/MongoConnectionTest.java Fri Dec 14 11:29:10 2012 -0500 +++ b/storage/mongo/src/test/java/com/redhat/thermostat/storage/mongodb/internal/MongoConnectionTest.java Fri Dec 14 12:22:29 2012 -0500 @@ -59,7 +59,6 @@ import com.mongodb.MongoURI; import com.redhat.thermostat.storage.config.StartupConfiguration; import com.redhat.thermostat.storage.core.ConnectionException; -import com.redhat.thermostat.storage.core.StorageConstants; import com.redhat.thermostat.storage.core.Connection.ConnectionListener; import com.redhat.thermostat.storage.core.Connection.ConnectionStatus; import com.redhat.thermostat.storage.mongodb.internal.MongoConnection; @@ -91,7 +90,7 @@ DB db = mock(DB.class); when(db.getCollection("agent-config")).thenReturn(collection); Mongo m = mock(Mongo.class); - when(m.getDB(StorageConstants.THERMOSTAT_DB_NAME)).thenReturn(db); + when(m.getDB(MongoConnection.THERMOSTAT_DB_NAME)).thenReturn(db); PowerMockito.whenNew(Mongo.class).withParameterTypes(MongoURI.class).withArguments(any(MongoURI.class)).thenReturn(m); conn.connect();