Clover coverage report -
Coverage timestamp: Thu Jul 5 2007 20:02:32 EDT
file stats: LOC: 396   Methods: 43
NCLOC: 324   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AdjListJDBCCacheLoaderConfig.java 90.9% 63.7% 51.2% 67%
coverage coverage
 1    package org.jboss.cache.loader;
 2   
 3    import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
 4   
 5    import java.util.Properties;
 6   
 7    /**
 8    * AdjListJDBCCacheLoaderConfig
 9    *
 10    * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik@jboss.org)</a>
 11    * @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
 12    */
 13    public class AdjListJDBCCacheLoaderConfig extends IndividualCacheLoaderConfig
 14    {
 15    /**
 16    * The serialVersionUID
 17    */
 18    private static final long serialVersionUID = -8371846151643130281L;
 19   
 20    private boolean createTable;
 21    private String createTableDDL;
 22    private String datasourceName;
 23    private String deleteAllSql;
 24    private String deleteNodeSql;
 25    private boolean dropTable;
 26    private String dropTableDDL;
 27    private String driverClass;
 28    private String insertNodeSql;
 29    private String jdbcURL;
 30    private String jdbcUser;
 31    private String jdbcPassword;
 32    private String selectChildFqnsSql;
 33    private String selectChildNamesSql;
 34    private String selectNodeSql;
 35    private String updateNodeSql;
 36    private String updateTableSql;
 37    private String connectionFactoryClass;
 38    protected String table;
 39    protected String nodeColumn;
 40    protected String fqnColumn;
 41   
 42  5 public AdjListJDBCCacheLoaderConfig()
 43    {
 44    }
 45   
 46    /**
 47    * For use by {@link JDBCCacheLoaderOld}.
 48    *
 49    * @param base generic config object created by XML parsing.
 50    */
 51  259 AdjListJDBCCacheLoaderConfig(IndividualCacheLoaderConfig base)
 52    {
 53  259 populateFromBaseConfig(base);
 54    }
 55   
 56  253 public boolean getCreateTable()
 57    {
 58  253 return createTable;
 59    }
 60   
 61  0 public void setCreateTable(boolean createTable)
 62    {
 63  0 testImmutability("createTable");
 64  0 this.createTable = createTable;
 65    }
 66   
 67  247 public String getCreateTableDDL()
 68    {
 69  247 return createTableDDL;
 70    }
 71   
 72  0 public void setCreateTableDDL(String createTableDDL)
 73    {
 74  0 testImmutability("createTableDDL");
 75  0 this.createTableDDL = createTableDDL;
 76    }
 77   
 78  322 public String getDatasourceName()
 79    {
 80  322 return datasourceName;
 81    }
 82   
 83  0 public void setDatasourceName(String datasourceName)
 84    {
 85  0 testImmutability("datasourceName");
 86  0 this.datasourceName = datasourceName;
 87    }
 88   
 89  12 public String getDeleteAllSql()
 90    {
 91  12 return deleteAllSql;
 92    }
 93   
 94  0 public void setDeleteAllSql(String deleteAllSql)
 95    {
 96  0 testImmutability("deleteAllSql");
 97  0 this.deleteAllSql = deleteAllSql;
 98    }
 99   
 100  0 public String getDeleteNodeSql()
 101    {
 102  0 return deleteNodeSql;
 103    }
 104   
 105  0 public void setDeleteNodeSql(String deleteNodeSql)
 106    {
 107  0 testImmutability("deleteNodeSql");
 108  0 this.deleteNodeSql = deleteNodeSql;
 109    }
 110   
 111  198 public String getDriverClass()
 112    {
 113  198 return driverClass;
 114    }
 115   
 116  0 public void setDriverClass(String driverClass)
 117    {
 118  0 testImmutability("driverClass");
 119  0 this.driverClass = driverClass;
 120    }
 121   
 122  253 public boolean getDropTable()
 123    {
 124  253 return dropTable;
 125    }
 126   
 127  0 public void setDropTable(boolean dropTable)
 128    {
 129  0 testImmutability("dropTable");
 130  0 this.dropTable = dropTable;
 131    }
 132   
 133  5300 public String getInsertNodeSql()
 134    {
 135  5300 return insertNodeSql;
 136    }
 137   
 138  0 public void setInsertNodeSql(String insertNodeSql)
 139    {
 140  0 testImmutability("insertNodeSql");
 141  0 this.insertNodeSql = insertNodeSql;
 142    }
 143   
 144  0 public String getSelectChildFqnsSql()
 145    {
 146  0 return selectChildFqnsSql;
 147    }
 148   
 149  0 public void setSelectChildFqnsSql(String selectChildFqnsSql)
 150    {
 151  0 testImmutability("selectChildFqnsSql");
 152  0 this.selectChildFqnsSql = selectChildFqnsSql;
 153    }
 154   
 155  32159 public String getSelectNodeSql()
 156    {
 157  32159 return selectNodeSql;
 158    }
 159   
 160  0 public void setSelectNodeSql(String selectNodeSql)
 161    {
 162  0 testImmutability("selectNodeSql");
 163  0 this.selectNodeSql = selectNodeSql;
 164    }
 165   
 166  253 public String getTable()
 167    {
 168  253 return table;
 169    }
 170   
 171  0 public void setTable(String table)
 172    {
 173  0 testImmutability("table");
 174  0 this.table = table;
 175    }
 176   
 177  0 public String getUpdateTableSql()
 178    {
 179  0 return updateTableSql;
 180    }
 181   
 182  0 public void setUpdateTableSql(String updateTableSql)
 183    {
 184  0 testImmutability("updateTableSql");
 185  0 this.updateTableSql = updateTableSql;
 186    }
 187   
 188  253 public String getDropTableDDL()
 189    {
 190  253 return dropTableDDL;
 191    }
 192   
 193  0 public void setDropTableDDL(String dropTableDDL)
 194    {
 195  0 testImmutability("dropTableDDL");
 196  0 this.dropTableDDL = dropTableDDL;
 197    }
 198   
 199  6203 public String getSelectChildNamesSql()
 200    {
 201  6203 return selectChildNamesSql;
 202    }
 203   
 204  0 public void setSelectChildNamesSql(String selectChildNamesSql)
 205    {
 206  0 testImmutability("selectChildNamesSql");
 207  0 this.selectChildNamesSql = selectChildNamesSql;
 208    }
 209   
 210  11137 public String getUpdateNodeSql()
 211    {
 212  11137 return updateNodeSql;
 213    }
 214   
 215  0 public void setUpdateNodeSql(String updateNodeSql)
 216    {
 217  0 testImmutability("updateNodeSql");
 218  0 this.updateNodeSql = updateNodeSql;
 219    }
 220   
 221  198 public String getJdbcPassword()
 222    {
 223  198 return jdbcPassword;
 224    }
 225   
 226  0 public void setJdbcPassword(String jdbcPassword)
 227    {
 228  0 testImmutability("jdbcPassword");
 229  0 this.jdbcPassword = jdbcPassword;
 230    }
 231   
 232  198 public String getJdbcURL()
 233    {
 234  198 return jdbcURL;
 235    }
 236   
 237  0 public void setJdbcURL(String jdbcURL)
 238    {
 239  0 testImmutability("jdbcURL");
 240  0 this.jdbcURL = jdbcURL;
 241    }
 242   
 243  198 public String getJdbcUser()
 244    {
 245  198 return jdbcUser;
 246    }
 247   
 248  0 public void setJdbcUser(String jdbcUser)
 249    {
 250  0 testImmutability("jdbcUser");
 251  0 this.jdbcUser = jdbcUser;
 252    }
 253   
 254  197 public String getConnectionFactoryClass()
 255    {
 256  197 return connectionFactoryClass;
 257    }
 258   
 259  4 public void setConnectionFactoryClass(String connectionFactoryClass)
 260    {
 261  4 testImmutability("connectionFactoryClass");
 262  4 this.connectionFactoryClass = connectionFactoryClass;
 263    }
 264   
 265  261 public void setProperties(Properties props)
 266    {
 267  261 super.setProperties(props);
 268  261 datasourceName = props.getProperty("cache.jdbc.datasource");
 269  261 if (datasourceName == null)
 270    {
 271  198 this.driverClass = AdjListJDBCCacheLoader.getRequiredProperty(props, "cache.jdbc.driver");
 272  198 this.jdbcURL = AdjListJDBCCacheLoader.getRequiredProperty(props, "cache.jdbc.url");
 273  198 this.jdbcUser = AdjListJDBCCacheLoader.getRequiredProperty(props, "cache.jdbc.user");
 274  198 this.jdbcPassword = AdjListJDBCCacheLoader.getRequiredProperty(props, "cache.jdbc.password");
 275   
 276  198 if (log.isDebugEnabled())
 277    {
 278  0 log.debug("Properties: " +
 279    "cache.jdbc.url=" +
 280    jdbcURL +
 281    ", cache.jdbc.driver=" +
 282    driverClass +
 283    ", cache.jdbc.user=" +
 284    jdbcUser +
 285    ", cache.jdbc.password=" +
 286    jdbcPassword +
 287    ", cache.jdbc.table=" + table);
 288    }
 289    }
 290   
 291  261 String prop = props.getProperty("cache.jdbc.table.create");
 292  261 this.createTable = (prop == null || Boolean.valueOf(prop));
 293  261 prop = props.getProperty("cache.jdbc.table.drop");
 294  261 this.dropTable = (prop == null || Boolean.valueOf(prop));
 295   
 296  261 this.table = props.getProperty("cache.jdbc.table.name", "jbosscache");
 297  261 String primaryKey = props.getProperty("cache.jdbc.table.primarykey", "jbosscache_pk");
 298  261 fqnColumn = props.getProperty("cache.jdbc.fqn.column", "fqn");
 299  261 String fqnType = props.getProperty("cache.jdbc.fqn.type", "varchar(255)");
 300  261 nodeColumn = props.getProperty("cache.jdbc.node.column", "node");
 301  261 String nodeType = props.getProperty("cache.jdbc.node.type", "blob");
 302  261 String parentColumn = props.getProperty("cache.jdbc.parent.column", "parent");
 303   
 304  261 selectChildNamesSql = "select " + fqnColumn + " from " + table + " where " + parentColumn + "=?";
 305  261 deleteNodeSql = "delete from " + table + " where " + fqnColumn + "=?";
 306  261 deleteAllSql = "delete from " + table;
 307  261 selectChildFqnsSql = "select " + fqnColumn + " from " + table + " where " + parentColumn + "=?";
 308  261 insertNodeSql = "insert into " +
 309    table +
 310    " (" +
 311    fqnColumn +
 312    ", " +
 313    nodeColumn +
 314    ", " +
 315    parentColumn +
 316    ") values (?, ?, ?)";
 317  261 updateNodeSql = "update " + table + " set " + nodeColumn + "=? where " + fqnColumn + "=?";
 318  261 selectNodeSql = "select " + nodeColumn + " from " + table + " where " + fqnColumn + "=?";
 319   
 320  261 createTableDDL = "create table " +
 321    table +
 322    "(" +
 323    fqnColumn +
 324    " " +
 325    fqnType +
 326    " not null, " +
 327    nodeColumn +
 328    " " +
 329    nodeType +
 330    ", " +
 331    parentColumn +
 332    " " +
 333    fqnType +
 334    ", constraint " + primaryKey + " primary key (" + fqnColumn + "))";
 335   
 336  261 dropTableDDL = "drop table " + table;
 337  261 connectionFactoryClass = props.getProperty("cache.jdbc.connection.factory", "org.jboss.cache.loader.NonManagedConnectionFactory");
 338    }
 339   
 340  2 public boolean equals(Object obj)
 341    {
 342  2 if (obj instanceof AdjListJDBCCacheLoaderConfig && equalsExcludingProperties(obj))
 343    {
 344  2 AdjListJDBCCacheLoaderConfig other = (AdjListJDBCCacheLoaderConfig) obj;
 345   
 346  2 return (this.createTable == other.createTable)
 347    && safeEquals(createTableDDL, other.createTableDDL)
 348    && safeEquals(datasourceName, other.datasourceName)
 349    && safeEquals(deleteAllSql, other.deleteAllSql)
 350    && safeEquals(deleteNodeSql, other.deleteNodeSql)
 351    && safeEquals(driverClass, other.driverClass)
 352    && (dropTable == other.dropTable)
 353    && safeEquals(dropTableDDL, other.dropTableDDL)
 354    && safeEquals(insertNodeSql, other.insertNodeSql)
 355    && safeEquals(jdbcPassword, other.jdbcPassword)
 356    && safeEquals(jdbcURL, other.jdbcURL)
 357    && safeEquals(jdbcUser, other.jdbcUser)
 358    && safeEquals(selectChildFqnsSql, other.selectChildFqnsSql)
 359    && safeEquals(selectChildNamesSql, other.selectChildNamesSql)
 360    && safeEquals(selectNodeSql, other.selectNodeSql)
 361    && safeEquals(table, other.table)
 362    && safeEquals(updateNodeSql, other.updateNodeSql)
 363    && safeEquals(updateTableSql, other.updateTableSql)
 364    && safeEquals(connectionFactoryClass, other.connectionFactoryClass);
 365    }
 366   
 367  0 return false;
 368    }
 369   
 370  249 public int hashCode()
 371    {
 372  249 int result = hashCodeExcludingProperties();
 373  249 result = 31 * result + (createTable ? 0 : 1);
 374  249 result = 31 * result + (createTableDDL == null ? 0 : createTableDDL.hashCode());
 375  249 result = 31 * result + (datasourceName == null ? 0 : datasourceName.hashCode());
 376  249 result = 31 * result + (deleteAllSql == null ? 0 : deleteAllSql.hashCode());
 377  249 result = 31 * result + (deleteNodeSql == null ? 0 : deleteNodeSql.hashCode());
 378  249 result = 31 * result + (driverClass == null ? 0 : driverClass.hashCode());
 379  249 result = 31 * result + (dropTable ? 0 : 1);
 380  249 result = 31 * result + (dropTableDDL == null ? 0 : dropTableDDL.hashCode());
 381  249 result = 31 * result + (insertNodeSql == null ? 0 : insertNodeSql.hashCode());
 382  249 result = 31 * result + (jdbcPassword == null ? 0 : jdbcPassword.hashCode());
 383  249 result = 31 * result + (jdbcUser == null ? 0 : jdbcUser.hashCode());
 384  249 result = 31 * result + (jdbcURL == null ? 0 : jdbcURL.hashCode());
 385  249 result = 31 * result + (selectChildFqnsSql == null ? 0 : selectChildFqnsSql.hashCode());
 386  249 result = 31 * result + (selectChildNamesSql == null ? 0 : selectChildNamesSql.hashCode());
 387  249 result = 31 * result + (selectNodeSql == null ? 0 : selectNodeSql.hashCode());
 388  249 result = 31 * result + (table == null ? 0 : table.hashCode());
 389  249 result = 31 * result + (updateNodeSql == null ? 0 : updateNodeSql.hashCode());
 390  249 result = 31 * result + (updateTableSql == null ? 0 : updateTableSql.hashCode());
 391  249 result = 31 * result + (connectionFactoryClass == null ? 0 : connectionFactoryClass.hashCode());
 392   
 393  249 return result;
 394    }
 395   
 396    }