Author: arminw
Date: Tue May 15 08:23:38 2007
New Revision: 538209

URL: http://svn.apache.org/viewvc?view=rev&rev=538209
Log:
update tests, modify test classes

Modified:
    db/ojb/trunk/src/java/org/apache/ojb/broker/platforms/BlobWrapper.java
    db/ojb/trunk/src/java/org/apache/ojb/broker/platforms/ClobWrapper.java

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/platforms/BlobWrapper.java
URL: 
http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/platforms/BlobWrapper.java?view=diff&rev=538209&r1=538208&r2=538209
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/platforms/BlobWrapper.java 
(original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/platforms/BlobWrapper.java Tue 
May 15 08:23:38 2007
@@ -28,14 +28,12 @@
 /**
  * Wraps the Oracle BLOB type and makes it accessible via reflection
  * without having to import the Oracle Classes.
- * @author <a href="mailto:[EMAIL PROTECTED]">Matthew Baird</a>
- * @author <a href="mailto:[EMAIL PROTECTED]">Erik Forkalsrud</a>
- * @author <a href="[EMAIL PROTECTED]">Martin Kal&eacute;n</a>
+ *
  * @version CVS $Id$
  */
 public class BlobWrapper
 {
-       protected Object m_blob;
+    protected Object m_blob;
 
     // Fields - values must be looked up via reflection not be compile-time 
Oracle-version dependent
     protected static Field durationSession;
@@ -43,16 +41,16 @@
     protected static Field modeReadOnly;
     protected static Field modeReadWrite;
 
-       // Methods
-       protected static Method createTemporary;
+    // Methods
+    protected static Method createTemporary;
     protected static Method freeTemporary;
-       protected static Method open;
-       protected static Method isOpen;
-       protected static Method getBinaryStream;
-       protected static Method getBinaryOutputStream;
-       protected static Method getBufferSize;
-       protected static Method close;
-       protected static Method trim;
+    protected static Method open;
+    protected static Method isOpen;
+    protected static Method getBinaryStream;
+    protected static Method getBinaryOutputStream;
+    protected static Method getBufferSize;
+    protected static Method close;
+    protected static Method trim;
 
     /**
      * Initialize all methods and fields via reflection.
@@ -77,7 +75,7 @@
             modeReadOnly = ClassHelper.getField(blobClass, "MODE_READONLY");
             modeReadWrite = ClassHelper.getField(blobClass, "MODE_READWRITE");
         }
-        catch (Exception ignore)
+        catch(Exception ignore)
         {
             // ignore it
         }
@@ -93,29 +91,37 @@
         m_blob = blob;
     }
 
-    protected static int staticIntFieldValue(Field field) {
-        int value = 0;
-        try {
+    protected static int staticIntFieldValue(Field field)
+    {
+        int value;
+        try
+        {
             value = field.getInt(null);
-        } catch (Exception ignore) {
+        }
+        catch(Exception ignore)
+        {
             value = -1;
         }
         return value;
     }
 
-    public static int getDurationSessionValue() {
+    public static int getDurationSessionValue()
+    {
         return staticIntFieldValue(durationSession);
     }
 
-    public static int getDurationCallValue() {
+    public static int getDurationCallValue()
+    {
         return staticIntFieldValue(durationCall);
     }
 
-    public static int getModeReadOnlyValue() {
+    public static int getModeReadOnlyValue()
+    {
         return staticIntFieldValue(modeReadOnly);
     }
 
-    public static int getModeReadWriteValue() {
+    public static int getModeReadWriteValue()
+    {
         return staticIntFieldValue(modeReadWrite);
     }
 
@@ -129,14 +135,15 @@
 
     public void open(int i) throws SQLException
     {
-        if (m_blob == null) {
+        if(m_blob == null)
+        {
             return;
         }
         try
         {
             open.invoke(m_blob, new Object[]{new Integer(i)});
         }
-        catch (Throwable e)
+        catch(Throwable e)
         {
             throw new SQLException(e.getMessage());
         }
@@ -144,36 +151,39 @@
 
     public boolean isOpen() throws SQLException
     {
-        if (m_blob == null) {
+        if(m_blob == null)
+        {
             return false;
         }
-        
-               boolean blobOpen = false;
-               try
-               {
-                       Boolean retval = (Boolean) isOpen.invoke(m_blob, null);
-            if (retval != null) {
+
+        boolean blobOpen = false;
+        try
+        {
+            Boolean retval = (Boolean) isOpen.invoke(m_blob, null);
+            if(retval != null)
+            {
                 blobOpen = retval.booleanValue();
             }
-               }
-               catch (Throwable e)
-               {
-                       throw new SQLException(e.getMessage());
-               }
-               return blobOpen;
+        }
+        catch(Throwable e)
+        {
+            throw new SQLException(e.getMessage());
+        }
+        return blobOpen;
     }
 
     public InputStream getBinaryStream() throws SQLException
     {
-        if (m_blob == null) {
+        if(m_blob == null)
+        {
             return null;
         }
-        InputStream retval = null;
+        InputStream retval;
         try
         {
             retval = (InputStream) getBinaryStream.invoke(m_blob, null);
         }
-        catch (Throwable e)
+        catch(Throwable e)
         {
             throw new SQLException(e.getMessage());
         }
@@ -182,15 +192,16 @@
 
     public OutputStream getBinaryOutputStream() throws SQLException
     {
-        if (m_blob == null) {
+        if(m_blob == null)
+        {
             return null;
         }
-        OutputStream retval = null;
+        OutputStream retval;
         try
         {
             retval = (OutputStream) getBinaryOutputStream.invoke(m_blob, null);
         }
-        catch (Throwable e)
+        catch(Throwable e)
         {
             throw new SQLException(e.getMessage());
         }
@@ -199,15 +210,16 @@
 
     public int getBufferSize() throws SQLException
     {
-        if (m_blob == null) {
+        if(m_blob == null)
+        {
             return 0;
         }
-        Integer retval = null;
+        Integer retval;
         try
         {
             retval = (Integer) getBufferSize.invoke(m_blob, null);
         }
-        catch (Throwable e)
+        catch(Throwable e)
         {
             throw new SQLException(e.getMessage());
         }
@@ -216,14 +228,15 @@
 
     public void close() throws SQLException
     {
-        if (m_blob == null) {
+        if(m_blob == null)
+        {
             return;
         }
         try
         {
             close.invoke(m_blob, null);
         }
-        catch (Throwable e)
+        catch(Throwable e)
         {
             throw new SQLException(e.getMessage());
         }
@@ -232,14 +245,15 @@
 
     public void trim(long l) throws SQLException
     {
-        if (m_blob == null) {
+        if(m_blob == null)
+        {
             return;
         }
         try
         {
             trim.invoke(m_blob, new Object[]{new Long(l)});
         }
-        catch (Throwable e)
+        catch(Throwable e)
         {
             throw new SQLException(e.getMessage());
         }
@@ -248,14 +262,15 @@
 
     public void freeTemporary() throws SQLException
     {
-        if (m_blob == null) {
+        if(m_blob == null)
+        {
             return;
         }
         try
         {
             freeTemporary.invoke(m_blob, null);
         }
-        catch (Throwable e)
+        catch(Throwable e)
         {
             throw new SQLException(e.getMessage());
         }

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/platforms/ClobWrapper.java
URL: 
http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/platforms/ClobWrapper.java?view=diff&rev=538209&r1=538208&r2=538209
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/platforms/ClobWrapper.java 
(original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/platforms/ClobWrapper.java Tue 
May 15 08:23:38 2007
@@ -28,13 +28,12 @@
 /**
  * Wraps the Oracle CLOB type and makes it accessible via reflection
  * without having to import the Oracle Classes.
- * @author <a href="mailto:[EMAIL PROTECTED]">Matthew Baird</a>
- * @author <a href="[EMAIL PROTECTED]">Martin Kal&eacute;n</a>
+ *
  * @version CVS $Id$
  */
 public class ClobWrapper
 {
-       protected Object m_clob;
+    protected Object m_clob;
 
     // Fields - values must be looked up via reflection not be compile-time 
Oracle-version dependent
     protected static Field durationSession;
@@ -42,220 +41,237 @@
     protected static Field modeReadOnly;
     protected static Field modeReadWrite;
 
-       // Methods
-       protected static Method createTemporary;
+    // Methods
+    protected static Method createTemporary;
     protected static Method freeTemporary;
-       protected static Method open;
-       protected static Method isOpen;
-       protected static Method getCharacterStream;
-       protected static Method getCharacterOutputStream;
-       protected static Method getBufferSize;
-       protected static Method close;
-       protected static Method trim;
-
-       /**
-        * Initialize all methods and fields via reflection.
-        */
-       static
-       {
-               try
-               {
-                       Class clobClass = 
ClassHelper.getClass("oracle.sql.CLOB", false);
-                       createTemporary = 
clobClass.getMethod("createTemporary", new Class[]{Connection.class, 
Boolean.TYPE, Integer.TYPE});
+    protected static Method open;
+    protected static Method isOpen;
+    protected static Method getCharacterStream;
+    protected static Method getCharacterOutputStream;
+    protected static Method getBufferSize;
+    protected static Method close;
+    protected static Method trim;
+
+    /**
+     * Initialize all methods and fields via reflection.
+     */
+    static
+    {
+        try
+        {
+            Class clobClass = ClassHelper.getClass("oracle.sql.CLOB", false);
+            createTemporary = clobClass.getMethod("createTemporary", new 
Class[]{Connection.class, Boolean.TYPE, Integer.TYPE});
             freeTemporary = clobClass.getMethod("freeTemporary", null);
-                       open = clobClass.getMethod("open", new 
Class[]{Integer.TYPE});
-                       isOpen = clobClass.getMethod("isOpen", null);
-                       getCharacterStream = 
clobClass.getMethod("getCharacterStream", null);
-                       getCharacterOutputStream = 
clobClass.getMethod("getCharacterOutputStream", null);
-                       getBufferSize = clobClass.getMethod("getBufferSize", 
null);
-                       close = clobClass.getMethod("close", null);
-                       trim = clobClass.getMethod("trim", new 
Class[]{Long.TYPE});
+            open = clobClass.getMethod("open", new Class[]{Integer.TYPE});
+            isOpen = clobClass.getMethod("isOpen", null);
+            getCharacterStream = clobClass.getMethod("getCharacterStream", 
null);
+            getCharacterOutputStream = 
clobClass.getMethod("getCharacterOutputStream", null);
+            getBufferSize = clobClass.getMethod("getBufferSize", null);
+            close = clobClass.getMethod("close", null);
+            trim = clobClass.getMethod("trim", new Class[]{Long.TYPE});
 
             durationSession = ClassHelper.getField(clobClass, 
"DURATION_SESSION");
             durationCall = ClassHelper.getField(clobClass, "DURATION_CALL");
             modeReadOnly = ClassHelper.getField(clobClass, "MODE_READONLY");
             modeReadWrite = ClassHelper.getField(clobClass, "MODE_READWRITE");
-               }
-               catch (Exception ignore)
-               {
+        }
+        catch(Exception ignore)
+        {
             // ignore it
-               }
-       }
+        }
+    }
+
+    public Object getClob()
+    {
+        return m_clob;
+    }
 
-       public Object getClob()
-       {
-               return m_clob;
-       }
-
-       public void setClob(Object clob)
-       {
-               m_clob = clob;
-       }
-
-    protected static int staticIntFieldValue(Field field) {
-        int value = 0;
-        try {
+    public void setClob(Object clob)
+    {
+        m_clob = clob;
+    }
+
+    protected static int staticIntFieldValue(Field field)
+    {
+        int value;
+        try
+        {
             value = field.getInt(null);
-        } catch (Exception ignore) {
+        }
+        catch(Exception ignore)
+        {
             value = -1;
         }
         return value;
     }
 
-    public static int getDurationSessionValue() {
+    public static int getDurationSessionValue()
+    {
         return staticIntFieldValue(durationSession);
     }
 
-    public static int getDurationCallValue() {
+    public static int getDurationCallValue()
+    {
         return staticIntFieldValue(durationCall);
     }
 
-    public static int getModeReadOnlyValue() {
+    public static int getModeReadOnlyValue()
+    {
         return staticIntFieldValue(modeReadOnly);
     }
 
-    public static int getModeReadWriteValue() {
+    public static int getModeReadWriteValue()
+    {
         return staticIntFieldValue(modeReadWrite);
     }
 
-       public static ClobWrapper createTemporary(Connection conn, boolean b, 
int i) throws Exception
-       {
-               ClobWrapper retval = new ClobWrapper();
+    public static ClobWrapper createTemporary(Connection conn, boolean b, int 
i) throws Exception
+    {
+        ClobWrapper retval = new ClobWrapper();
         // Passing null to invoke static method
         retval.setClob(createTemporary.invoke(null, new Object[]{conn, 
BooleanUtils.toBooleanObject(b), new Integer(i)}));
-               return retval;
-       }
+        return retval;
+    }
 
-       public void open(int i) throws SQLException
-       {
-        if (m_clob == null) {
+    public void open(int i) throws SQLException
+    {
+        if(m_clob == null)
+        {
             return;
         }
-               try
-               {
-                       open.invoke(m_clob, new Object[]{new Integer(i)});
-               }
-               catch (Throwable e)
-               {
-                       throw new SQLException(e.getMessage());
-               }
-       }
-
-       public boolean isOpen() throws SQLException
-       {
-        if (m_clob == null) {
+        try
+        {
+            open.invoke(m_clob, new Object[]{new Integer(i)});
+        }
+        catch(Throwable e)
+        {
+            throw new SQLException(e.getMessage());
+        }
+    }
+
+    public boolean isOpen() throws SQLException
+    {
+        if(m_clob == null)
+        {
             return false;
         }
-               boolean clobOpen = false;
-               try
-               {
-                       Boolean retval = (Boolean) isOpen.invoke(m_clob, null);
-            if (retval != null) {
+        boolean clobOpen = false;
+        try
+        {
+            Boolean retval = (Boolean) isOpen.invoke(m_clob, null);
+            if(retval != null)
+            {
                 clobOpen = retval.booleanValue();
             }
-               }
-               catch (Throwable e)
-               {
-                       throw new SQLException(e.getMessage());
-               }
-               return clobOpen;
-       }
-
-       public Reader getCharacterStream() throws SQLException
-       {
-        if (m_clob == null) {
+        }
+        catch(Throwable e)
+        {
+            throw new SQLException(e.getMessage());
+        }
+        return clobOpen;
+    }
+
+    public Reader getCharacterStream() throws SQLException
+    {
+        if(m_clob == null)
+        {
             return null;
         }
-               Reader retval = null;
-               try
-               {
-                       retval = (Reader) getCharacterStream.invoke(m_clob, 
null);
-               }
-               catch (Throwable e)
-               {
-                       throw new SQLException(e.getMessage());
-               }
-               return retval;
-       }
-
-       public Writer getCharacterOutputStream() throws SQLException
-       {
-        if (m_clob == null) {
+        Reader retval;
+        try
+        {
+            retval = (Reader) getCharacterStream.invoke(m_clob, null);
+        }
+        catch(Throwable e)
+        {
+            throw new SQLException(e.getMessage());
+        }
+        return retval;
+    }
+
+    public Writer getCharacterOutputStream() throws SQLException
+    {
+        if(m_clob == null)
+        {
             return null;
         }
-               Writer retval = null;
-               try
-               {
-                       retval = (Writer) 
getCharacterOutputStream.invoke(m_clob, null);
-               }
-               catch (Throwable e)
-               {
-                       throw new SQLException(e.getMessage());
-               }
-               return retval;
-       }
-
-       public int getBufferSize() throws SQLException
-       {
-        if (m_clob == null) {
+        Writer retval;
+        try
+        {
+            retval = (Writer) getCharacterOutputStream.invoke(m_clob, null);
+        }
+        catch(Throwable e)
+        {
+            throw new SQLException(e.getMessage());
+        }
+        return retval;
+    }
+
+    public int getBufferSize() throws SQLException
+    {
+        if(m_clob == null)
+        {
             return 0;
         }
-               Integer retval = null;
-               try
-               {
-                       retval = (Integer) getBufferSize.invoke(m_clob, null);
-               }
-               catch (Throwable e)
-               {
-                       throw new SQLException(e.getMessage());
-               }
-               return retval.intValue();
-       }
-
-       public void close() throws SQLException
-       {
-        if (m_clob == null) {
+        Integer retval;
+        try
+        {
+            retval = (Integer) getBufferSize.invoke(m_clob, null);
+        }
+        catch(Throwable e)
+        {
+            throw new SQLException(e.getMessage());
+        }
+        return retval.intValue();
+    }
+
+    public void close() throws SQLException
+    {
+        if(m_clob == null)
+        {
             return;
         }
-               try
-               {
-                       close.invoke(m_clob, null);
-               }
-               catch (Throwable e)
-               {
-                       throw new SQLException(e.getMessage());
-               }
-
-       }
-
-       public void trim(long l) throws SQLException
-       {
-        if (m_clob == null) {
+        try
+        {
+            close.invoke(m_clob, null);
+        }
+        catch(Throwable e)
+        {
+            throw new SQLException(e.getMessage());
+        }
+
+    }
+
+    public void trim(long l) throws SQLException
+    {
+        if(m_clob == null)
+        {
             return;
         }
-               try
-               {
-                       trim.invoke(m_clob, new Object[]{new Long(l)});
-               }
-               catch (Throwable e)
-               {
-                       throw new SQLException(e.getMessage());
-               }
-
-       }
-
-       public void freeTemporary() throws SQLException
-       {
-        if (m_clob == null) {
+        try
+        {
+            trim.invoke(m_clob, new Object[]{new Long(l)});
+        }
+        catch(Throwable e)
+        {
+            throw new SQLException(e.getMessage());
+        }
+
+    }
+
+    public void freeTemporary() throws SQLException
+    {
+        if(m_clob == null)
+        {
             return;
         }
-               try
-               {
-                       freeTemporary.invoke(m_clob, null);
-               }
-               catch (Throwable e)
-               {
-                       throw new SQLException(e.getMessage());
-               }
-       }
+        try
+        {
+            freeTemporary.invoke(m_clob, null);
+        }
+        catch(Throwable e)
+        {
+            throw new SQLException(e.getMessage());
+        }
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to