empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From franci...@apache.org
Subject svn commit: r1088417 [4/4] - in /incubator/empire-db/branches/EMPIREDB-99: empire-db-codegen/src/main/java/org/apache/empire/db/codegen/ empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/ empire-db-exampl...
Date Sun, 03 Apr 2011 21:12:16 GMT
Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java?rev=1088417&r1=1088416&r2=1088417&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java
(original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java
Sun Apr  3 21:12:14 2011
@@ -23,6 +23,7 @@ import java.sql.SQLException;
 import java.util.GregorianCalendar;
 import java.util.Iterator;
 
+import org.apache.empire.EmpireException;
 import org.apache.empire.commons.Errors;
 import org.apache.empire.commons.ObjectUtils;
 import org.apache.empire.commons.StringUtils;
@@ -68,10 +69,9 @@ public class DBDatabaseDriverMSSQL exten
     	}
         
         @Override
-        public boolean limitRows(int numRows)
+        public void limitRows(int numRows)
         {
             limit = numRows;
-            return success();
         }
          
         @Override
@@ -175,7 +175,7 @@ public class DBDatabaseDriverMSSQL exten
 
     /** {@inheritDoc} */
     @Override
-    public boolean attachDatabase(DBDatabase db, Connection conn)
+    public void attachDatabase(DBDatabase db, Connection conn)
     {
         // Prepare
         try
@@ -194,11 +194,11 @@ public class DBDatabaseDriverMSSQL exten
                 db.setSchema(schema + "." + objectOwner);
             }
             // call Base implementation
-            return super.attachDatabase(db, conn);
+            super.attachDatabase(db, conn);
             
         } catch (SQLException e)
         {
-            return error(e);
+        	throw new EmpireException(e);
         }
     }
 
@@ -377,22 +377,24 @@ public class DBDatabaseDriverMSSQL exten
      * @see DBDatabaseDriver#getDDLScript(DBCmdType, DBObject, DBSQLScript)  
      */
     @Override
-    public boolean getDDLScript(DBCmdType type, DBObject dbo, DBSQLScript script)
+    public void getDDLScript(DBCmdType type, DBObject dbo, DBSQLScript script)
     {
         // The Object's database must be attached to this driver
         if (dbo==null || dbo.getDatabase().getDriver()!=this)
-            return error(Errors.InvalidArg, dbo, "dbo");
+        	throw new EmpireException(Errors.InvalidArg, dbo, "dbo");
         // Check Type of object
         if (dbo instanceof DBDatabase)
         { // Database
             switch (type)
             {
                 case CREATE:
-                    return createDatabase((DBDatabase) dbo, script, true);
+                    createDatabase((DBDatabase) dbo, script, true);
+                    break;
                 case DROP:
-                    return dropObject(((DBDatabase) dbo).getSchema(), "DATABASE", script);
+                    dropObject(((DBDatabase) dbo).getSchema(), "DATABASE", script);
+                    break;
                 default:
-                    return error(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName()
+ "." + type);
+                	throw new EmpireException(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName()
+ "." + type);
             }
         } 
         else if (dbo instanceof DBTable)
@@ -400,11 +402,13 @@ public class DBDatabaseDriverMSSQL exten
             switch (type)
             {
                 case CREATE:
-                    return createTable((DBTable) dbo, script);
+                    createTable((DBTable) dbo, script);
+                    break;
                 case DROP:
-                    return dropObject(((DBTable) dbo).getName(), "TABLE", script);
+                    dropObject(((DBTable) dbo).getName(), "TABLE", script);
+                    break;
                 default:
-                    return error(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName()
+ "." + type);
+                	throw new EmpireException(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName()
+ "." + type);
             }
         } 
         else if (dbo instanceof DBView)
@@ -412,11 +416,13 @@ public class DBDatabaseDriverMSSQL exten
             switch (type)
             {
                 case CREATE:
-                    return createView((DBView) dbo, script);
+                    createView((DBView) dbo, script);
+                    break;
                 case DROP:
-                    return dropObject(((DBView) dbo).getName(), "VIEW", script);
+                    dropObject(((DBView) dbo).getName(), "VIEW", script);
+                    break;
                 default:
-                    return error(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName()
+ "." + type);
+                	throw new EmpireException(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName()
+ "." + type);
             }
         } 
         else if (dbo instanceof DBRelation)
@@ -424,20 +430,22 @@ public class DBDatabaseDriverMSSQL exten
             switch (type)
             {
                 case CREATE:
-                    return createRelation((DBRelation) dbo, script);
+                    createRelation((DBRelation) dbo, script);
+                    break;
                 case DROP:
-                    return dropObject(((DBRelation) dbo).getName(), "CONSTRAINT", script);
+                    dropObject(((DBRelation) dbo).getName(), "CONSTRAINT", script);
+                    break;
                 default:
-                    return error(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName()
+ "." + type);
+                	throw new EmpireException(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName()
+ "." + type);
             }
         } 
         else if (dbo instanceof DBTableColumn)
         { // Table Column
-            return alterTable((DBTableColumn) dbo, type, script);
+            alterTable((DBTableColumn) dbo, type, script);
         } 
         else
         { // an invalid argument has been supplied
-            return error(Errors.InvalidArg, dbo, "dbo");
+        	throw new EmpireException(Errors.InvalidArg, dbo, "dbo");
         }
     }
 
@@ -457,13 +465,13 @@ public class DBDatabaseDriverMSSQL exten
     /*
      * return the sql for creating a Database
      */
-    protected boolean createDatabase(DBDatabase db, DBSQLScript script, boolean createSchema)
+    protected void createDatabase(DBDatabase db, DBSQLScript script, boolean createSchema)
     {
         // User Master to create Database
         if (createSchema)
         {   // check database Name
             if (StringUtils.isEmpty(databaseName))
-                return error(Errors.InvalidProperty, "databaseName");
+            	throw new EmpireException(Errors.InvalidProperty, "databaseName");
             // Create Database
             script.addStmt("USE master");
             script.addStmt("CREATE DATABASE " + databaseName);
@@ -477,25 +485,20 @@ public class DBDatabaseDriverMSSQL exten
         Iterator<DBTable> tables = db.getTables().iterator();
         while (tables.hasNext())
         {
-            if (!createTable(tables.next(), script))
-                return false;
+            createTable(tables.next(), script);
         }
         // Create Relations
         Iterator<DBRelation> relations = db.getRelations().iterator();
         while (relations.hasNext())
         {
-            if (!createRelation(relations.next(), script))
-                return false;
+            createRelation(relations.next(), script);
         }
         // Create Views
         Iterator<DBView> views = db.getViews().iterator();
         while (views.hasNext())
         {
-            if (!createView(views.next(), script))
-                return false;
+            createView(views.next(), script);
         }
-        // Done
-        return true;
     }
     
     /**
@@ -503,7 +506,7 @@ public class DBDatabaseDriverMSSQL exten
      * 
      * @return true if the table has been created successfully
      */
-    protected boolean createTable(DBTable t, DBSQLScript script)
+    protected void createTable(DBTable t, DBSQLScript script)
     {
         StringBuilder sql = new StringBuilder();
         sql.append("-- creating table ");
@@ -542,8 +545,7 @@ public class DBDatabaseDriverMSSQL exten
         }
         sql.append(")");
         // Create the table
-        if (script.addStmt(sql) == false)
-            return false;
+        script.addStmt(sql);
         // Create other Indexes (except primary key)
         Iterator<DBIndex> indexes = t.getIndexes().iterator();
         while (indexes.hasNext())
@@ -572,11 +574,8 @@ public class DBDatabaseDriverMSSQL exten
             }
             sql.append(")");
             // Create Index
-            if (script.addStmt(sql) == false)
-                return false;
+            script.addStmt(sql);
         }
-        // done
-        return success();
     }
     
     /**
@@ -684,7 +683,7 @@ public class DBDatabaseDriverMSSQL exten
      * 
      * @return true if the relation has been created successfully
      */
-    protected boolean createRelation(DBRelation r, DBSQLScript script)
+    protected void createRelation(DBRelation r, DBSQLScript script)
     {
         DBTable sourceTable = (DBTable) r.getReferences()[0].getSourceColumn().getRowSet();
         DBTable targetTable = (DBTable) r.getReferences()[0].getTargetColumn().getRowSet();
@@ -721,10 +720,7 @@ public class DBDatabaseDriverMSSQL exten
         }
         // done
         sql.append(")");
-        if (script.addStmt(sql) == false)
-            return false;
-        // done
-        return success();
+        script.addStmt(sql);
     }
 
     /**
@@ -734,7 +730,7 @@ public class DBDatabaseDriverMSSQL exten
      * @param script to which to append the sql statement to
      * @return true if the statement was successfully appended to the buffer
      */
-    protected boolean alterTable(DBTableColumn col, DBCmdType type, DBSQLScript script)
+    protected void alterTable(DBTableColumn col, DBCmdType type, DBSQLScript script)
     {
         StringBuilder sql = new StringBuilder();
         sql.append("ALTER TABLE ");
@@ -755,7 +751,7 @@ public class DBDatabaseDriverMSSQL exten
                 break;
         }
         // done
-        return script.addStmt(sql);
+        script.addStmt(sql);
     }
 
     /**
@@ -763,17 +759,15 @@ public class DBDatabaseDriverMSSQL exten
      * 
      * @return true if the view has been created successfully
      */
-    protected boolean createView(DBView v, DBSQLScript script)
+    protected void createView(DBView v, DBSQLScript script)
     {
         // Create the Command
         DBCommandExpr cmd = v.createCommand();
         if (cmd==null)
         {   // Check whether Error information is available
             log.error("No command has been supplied for view " + v.getName());
-            if (v.hasError())
-                return error(v);
             // No error information available: Use Errors.NotImplemented
-            return error(Errors.NotImplemented, v.getName() + ".createCommand");
+            throw new EmpireException(Errors.NotImplemented, v.getName() + ".createCommand");
         }
         // Make sure there is no OrderBy
         cmd.clearOrderBy();
@@ -796,7 +790,7 @@ public class DBDatabaseDriverMSSQL exten
         sql.append(")\r\nAS\r\n");
         cmd.addSQL( sql, DBExpr.CTX_DEFAULT);
         // done
-        return script.addStmt(sql.toString());
+        script.addStmt(sql.toString());
     }
         
     /**
@@ -804,17 +798,17 @@ public class DBDatabaseDriverMSSQL exten
      * 
      * @return true if the object has been dropped successfully
      */
-    protected boolean dropObject(String name, String objType, DBSQLScript script)
+    protected void dropObject(String name, String objType, DBSQLScript script)
     {
         if (name == null || name.length() == 0)
-            return error(Errors.InvalidArg, name, "name");
+        	throw new EmpireException(Errors.InvalidArg, name, "name");
         // Create Drop Statement
         StringBuilder sql = new StringBuilder();
         sql.append("DROP ");
         sql.append(objType);
         sql.append(" ");
         appendElementName(sql, name);
-        return script.addStmt(sql);
+        script.addStmt(sql);
     }
 
 }

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/xml/XMLConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/xml/XMLConfiguration.java?rev=1088417&r1=1088416&r2=1088417&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/xml/XMLConfiguration.java
(original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/xml/XMLConfiguration.java
Sun Apr  3 21:12:14 2011
@@ -30,7 +30,7 @@ import javax.xml.parsers.DocumentBuilder
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.apache.commons.beanutils.BeanUtils;
-import org.apache.empire.commons.ErrorObject;
+import org.apache.empire.EmpireException;
 import org.apache.empire.commons.Errors;
 import org.apache.empire.commons.ObjectUtils;
 import org.apache.empire.commons.StringUtils;
@@ -51,7 +51,7 @@ import org.xml.sax.SAXException;
  * </PRE>
  *
  */
-public class XMLConfiguration extends ErrorObject
+public class XMLConfiguration
 {
     private static final Logger log = LoggerFactory.getLogger(XMLConfiguration.class);
 
@@ -62,16 +62,12 @@ public class XMLConfiguration extends Er
      * 
      * @param filename the file
      * @param fromResource will read from the classpath if true
-     * 
-     * @return true on success
      */
-    public boolean init(String filename, boolean fromResource)
+    public void init(String filename, boolean fromResource)
     {
         // Read the properties file
-        if (readConfiguration(filename, fromResource) == false)
-            return false;
-        // Done
-        return success();
+        readConfiguration(filename, fromResource);
+
     }
     
     /**
@@ -85,8 +81,11 @@ public class XMLConfiguration extends Er
 
     /**
      * Reads the configuration file and parses the XML Configuration.
+     * @param fileName
+     * @param fromResource
+     * 
      */
-    protected boolean readConfiguration(String fileName, boolean fromResource)
+    protected void readConfiguration(String fileName, boolean fromResource)
     {
         FileReader reader = null;
         InputStream inputStream = null;
@@ -98,6 +97,9 @@ public class XMLConfiguration extends Er
             {   // Open Resource
                 log.info("reading resource file: " + fileName);
                 inputStream = getClass().getClassLoader().getResourceAsStream(fileName);
+                if(inputStream == null){
+                	throw new FileNotFoundException("Could not read resource file: " + fileName);
+                }
                 // Parse File
                 doc = docBuilder.parse(inputStream);
             }
@@ -110,23 +112,22 @@ public class XMLConfiguration extends Er
             }
             // Get Root Element
             configRootNode = doc.getDocumentElement();
-            return success();
         } catch (FileNotFoundException e)
         {
             log.error("Configuration file {} not found!", fileName, e);
-            return error(Errors.FileNotFound, fileName);
+            throw new EmpireException(e, Errors.FileNotFound, fileName);
         } catch (IOException e)
         {
             log.error("Error reading configuration file {}", fileName, e);
-            return error(Errors.FileReadError, fileName);
+            throw new EmpireException(e, Errors.FileReadError, fileName);
         } catch (SAXException e)
         {
             log.error("Invalid XML in configuration file {}", fileName, e);
-            return error(e);
+            throw new EmpireException(e);
         } catch (ParserConfigurationException e)
         {
             log.error("ParserConfigurationException: {}", e.getMessage(), e);
-            return error(e);
+            throw new EmpireException(e);
         } finally
         { 
         	close(reader);
@@ -140,45 +141,44 @@ public class XMLConfiguration extends Er
      * @param propertiesNodeName the name of the properties node below the root element
      * @return true of successful or false otherwise
      */
-    public boolean readProperties(Object bean, String... propertiesNodeNames)
+    public void readProperties(Object bean, String... propertiesNodeNames)
     {
         // Check state
         if (configRootNode == null)
-            return error(Errors.ObjectNotValid, getClass().getName());
+        	throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
         // Check arguments
         if (bean == null)
-            return error(Errors.InvalidArg, null, "bean");
+        	throw new EmpireException(Errors.InvalidArg, null, "bean");
         
         Element propertiesNode = configRootNode;  
         for(String nodeName : propertiesNodeNames)
         {
             if (StringUtils.isEmpty(nodeName))
-                return error(Errors.InvalidArg, null, "propertiesNodeNames");
+            	throw new EmpireException(Errors.InvalidArg, null, "propertiesNodeNames");
             // Get configuration node
             propertiesNode = XMLUtil.findFirstChild(propertiesNode, nodeName);
             if (propertiesNode == null)
             { // Configuration
                 log.error("Property-Node {} has not been found.", nodeName);
-                return error(Errors.ItemNotFound, nodeName);
+                throw new EmpireException(Errors.ItemNotFound, nodeName);
             }
         }
         // read the properties
-        return readProperties(bean, propertiesNode);
+        readProperties(bean, propertiesNode);
     }
 
     /**
      * reads all properties from a given properties node and applies them to the given bean
      * @param bean the bean to which to apply the configuration
      * @param propertiesNode the properties node
-     * @return true of successful or false otherwise
      */
-    public boolean readProperties(Object bean, Element propertiesNode)
+    public void readProperties(Object bean, Element propertiesNode)
     {
         // Check arguments
         if (propertiesNode == null)
-            return error(Errors.InvalidArg, null, "propertiesNode");
+        	throw new EmpireException(Errors.InvalidArg, null, "propertiesNode");
         if (bean == null)
-            return error(Errors.InvalidArg, null, "bean");
+        	throw new EmpireException(Errors.InvalidArg, null, "bean");
         // apply configuration
         log.info("reading bean properties from node: {}", propertiesNode.getNodeName());
         NodeList nodeList = propertiesNode.getChildNodes();
@@ -190,8 +190,6 @@ public class XMLConfiguration extends Er
             // Get the Text and set the Property
             setPropertyValue(bean, item);
         }
-        // done
-        return success();
     }
     
     protected void setPropertyValue(Object bean, Node item)

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/xml/XMLWriter.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/xml/XMLWriter.java?rev=1088417&r1=1088416&r2=1088417&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/xml/XMLWriter.java
(original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/xml/XMLWriter.java
Sun Apr  3 21:12:14 2011
@@ -35,7 +35,6 @@ import javax.xml.transform.stream.Stream
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.empire.commons.ErrorObject;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.NamedNodeMap;
@@ -49,7 +48,7 @@ import org.w3c.dom.NodeList;
  * 
  *
  */
-public class XMLWriter extends ErrorObject
+public class XMLWriter
 {
     // Logger
     protected static final Logger    log                  = LoggerFactory.getLogger(XMLWriter.class);

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/db/DBCommandTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/db/DBCommandTest.java?rev=1088417&r1=1088416&r2=1088417&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/db/DBCommandTest.java
(original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/db/DBCommandTest.java
Sun Apr  3 21:12:14 2011
@@ -18,15 +18,15 @@
  */
 package org.apache.empire.db;
 
-import org.apache.empire.data.DataType;
-import org.junit.Test;
-import org.w3c.dom.Element;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 
 import java.util.ArrayList;
 import java.util.List;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import org.apache.empire.data.DataType;
+import org.junit.Test;
+import org.w3c.dom.Element;
 
 /**
  * @author francisdb
@@ -85,9 +85,9 @@ public class DBCommandTest
         }
 
         @Override
-        public boolean checkValue(Object value)
+        public void checkValue(Object value)
         {
-            return false;
+            //
         }
 
         @Override

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/db/IntegerTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/db/IntegerTest.java?rev=1088417&r1=1088416&r2=1088417&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/db/IntegerTest.java
(original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/db/IntegerTest.java
Sun Apr  3 21:12:14 2011
@@ -26,7 +26,6 @@ import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.empire.commons.ErrorObject;
 import org.apache.empire.data.DataMode;
 import org.apache.empire.data.DataType;
 import org.apache.empire.db.derby.DBDatabaseDriverDerby;
@@ -36,7 +35,6 @@ import org.apache.empire.db.mysql.DBData
 import org.apache.empire.db.oracle.DBDatabaseDriverOracle;
 import org.apache.empire.db.postgresql.DBDatabaseDriverPostgreSQL;
 import org.apache.empire.db.sqlserver.DBDatabaseDriverMSSQL;
-import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -49,11 +47,6 @@ import org.slf4j.LoggerFactory;
 public class IntegerTest {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(IntegerTest.class);
-
-    @Before
-    public void enableExceptions(){
-        ErrorObject.setExceptionsEnabled(true);
-    }
     
     @Test
     public void testHsqldb() {

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/db/PreparedStatementTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/db/PreparedStatementTest.java?rev=1088417&r1=1088416&r2=1088417&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/db/PreparedStatementTest.java
(original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/db/PreparedStatementTest.java
Sun Apr  3 21:12:14 2011
@@ -26,7 +26,6 @@ import java.sql.Connection;
 
 import org.apache.empire.DBResource;
 import org.apache.empire.DBResource.DB;
-import org.apache.empire.commons.ErrorObject;
 import org.apache.empire.db.DBCommand.DBCommandParam;
 import org.junit.Rule;
 import org.junit.Test;
@@ -40,7 +39,6 @@ public class PreparedStatementTest{
     @Test
     public void testPreparedStatement()
     {
-        ErrorObject.setExceptionsEnabled(true);
         
         Connection conn = dbResource.getConnection();
         

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java?rev=1088417&r1=1088416&r2=1088417&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java
(original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java
Sun Apr  3 21:12:14 2011
@@ -27,7 +27,6 @@ import java.util.Date;
 
 import org.apache.empire.DBResource;
 import org.apache.empire.DBResource.DB;
-import org.apache.empire.commons.ErrorObject;
 import org.apache.empire.db.CompanyDB;
 import org.apache.empire.db.DBCmdType;
 import org.apache.empire.db.DBDatabaseDriver;
@@ -45,7 +44,6 @@ public class DBDatabaseDriverHSqlTest{
     @Test
     public void test()
     {
-        ErrorObject.setExceptionsEnabled(true);
         
         Connection conn = dbResource.getConnection();
      

Added: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/xml/XMLConfigurationTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/xml/XMLConfigurationTest.java?rev=1088417&view=auto
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/xml/XMLConfigurationTest.java
(added)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/xml/XMLConfigurationTest.java
Sun Apr  3 21:12:14 2011
@@ -0,0 +1,54 @@
+package org.apache.empire.xml;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.empire.EmpireException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+public class XMLConfigurationTest {
+
+	@Rule
+	public ExpectedException expectedException = ExpectedException.none();
+	
+	@Test
+	public void testInitFail() {
+		XMLConfiguration configuration = new XMLConfiguration();
+		
+		expectedException.expect(EmpireException.class);
+		expectedException.expectMessage("The file missing.xml was not found.");
+		
+		configuration.init("missing.xml", false);
+	}
+
+	@Test
+	public void testGetRootNode() {
+		XMLConfiguration configuration = new XMLConfiguration();
+		configuration.init("src/test/resources/testconfig.xml", false);
+		assertNotNull(configuration.getRootNode());
+	}
+
+	@Test
+	public void testReadConfiguration() {
+		XMLConfiguration configuration = new XMLConfiguration();
+		configuration.readConfiguration("src/test/resources/testconfig.xml", false);
+		assertNotNull(configuration.getRootNode());
+	}
+
+//	@Test
+//	public void testReadPropertiesObjectStringArray() {
+//		fail("Not yet implemented");
+//	}
+//
+//	@Test
+//	public void testReadPropertiesObjectElement() {
+//		fail("Not yet implemented");
+//	}
+//
+//	@Test
+//	public void testSetPropertyValue() {
+//		fail("Not yet implemented");
+//	}
+
+}

Added: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/resources/testconfig.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/resources/testconfig.xml?rev=1088417&view=auto
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/resources/testconfig.xml (added)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/resources/testconfig.xml Sun
Apr  3 21:12:14 2011
@@ -0,0 +1 @@
+<config></config>
\ No newline at end of file



Mime
View raw message