Avoid unit test failures when cfb.properties is not found in the classpath.
authorChris Jaekl <cejaekl@yahoo.com>
Wed, 30 Dec 2015 07:25:11 +0000 (16:25 +0900)
committerChris Jaekl <cejaekl@yahoo.com>
Wed, 30 Dec 2015 07:25:11 +0000 (16:25 +0900)
prod/net/jaekl/cfb/CfbException.java
prod/net/jaekl/cfb/store/DbStore.java
prod/net/jaekl/cfb/store/StoreException.java

index b8a14c0a5cce56ac67597ecf3768139360656f6d..6b46797be126b42a05a4b9446eb3aa676227c640 100644 (file)
@@ -3,6 +3,10 @@ package net.jaekl.cfb;
 public class CfbException extends Exception {
        private static final long serialVersionUID = 1L;
 
+       public CfbException() {
+               super();
+       }
+       
        public CfbException(String msg) {
                super(msg);
        }
index ed22291387c14c8047593d7b1a11932633df6361..e50f7403910830d798e7cd8ca1b3296f056f42bc 100644 (file)
@@ -3,9 +3,7 @@ package net.jaekl.cfb.store;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.List;
-import java.util.Locale;
 
-import net.jaekl.cfb.CfbBundle;
 import net.jaekl.cfb.analyze.Analysis;
 import net.jaekl.cfb.db.CfbSchema;
 import net.jaekl.cfb.db.Column;
@@ -47,8 +45,6 @@ public class DbStore {
        }
        
        public boolean put(Analysis analysis) throws SQLException, TypeMismatchException, StoreException {
-               CfbBundle bundle = CfbBundle.getInst(Locale.getDefault());
-               
                if (null == analysis) {
                        return false;
                }
@@ -89,10 +85,10 @@ public class DbStore {
                        Location thirdLoc  = (locs.size() > 2) ? locs.get(2) : null;
                        
                        if (BugPattern.UNKNOWN.getId() == bugId) {
-                               throw new StoreException(bundle.get(CfbBundle.BUG_TYPE_UNKNOWN, ""+bug.getType()));
+                               throw new StoreException(StoreException.Type.UNKNOWN_PATTERN, ""+bug.getType());
                        }
                        if (BugCategory.UNKNOWN.getId() == categoryId) {
-                               throw new StoreException(bundle.get(CfbBundle.BUG_CATEGORY_UNKNOWN, ""+bug.getCategory()));
+                               throw new StoreException(StoreException.Type.UNKNOWN_CATEGORY, ""+bug.getCategory());
                        }
                        
                        values[row][0] = foundId;
index 5b7544df70f54438d346389f60fab7f02e0eb252..5c0caf43405f3af851fd70a1cfee21e38d27694a 100644 (file)
@@ -1,11 +1,29 @@
 package net.jaekl.cfb.store;
 
+import java.util.Arrays;
+
 import net.jaekl.cfb.CfbException;
 
 public class StoreException extends CfbException {
+       public enum Type {
+               UNKNOWN_PATTERN,        // bug pattern type is not found in the message collection 
+               UNKNOWN_CATEGORY        // bug category is not found in the message collection
+       }
+       
+       private Type m_type;
+       private String[] m_info;
+       
        private static final long serialVersionUID = 1L;
        
-       public StoreException(String msg) {
-               super(msg);
+       public StoreException(Type type, String... info) {
+               super();
+               
+               m_type = type;
+               m_info = info;
+       }
+       
+       @Override
+       public String toString() {
+               return "" + getClass().getName() + ": " + m_type + ": " + Arrays.toString(m_info);
        }
 }