db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r907668 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang: GeneratedColumnsHelper.java SampleSQLData.java UDTTest.java
Date Mon, 08 Feb 2010 14:28:57 GMT
Author: rhillegas
Date: Mon Feb  8 14:28:57 2010
New Revision: 907668

URL: http://svn.apache.org/viewvc?rev=907668&view=rev
Log:
DERBY-651: Add test to verify that Derby still does not support SQLData types.

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SampleSQLData.java
  (with props)
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsHelper.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UDTTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsHelper.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsHelper.java?rev=907668&r1=907667&r2=907668&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsHelper.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsHelper.java
Mon Feb  8 14:28:57 2010
@@ -96,6 +96,7 @@
     protected static  final   String  TABLE_DEPENDS_ON_TYPE = "X0Y29";
     protected static  final   String  VIEW_DEPENDS_ON_PRIVILEGE = "X0Y23";
     protected static  final   String  NON_EMPTY_SCHEMA = "X0Y54";
+    protected static  final   String  JAVA_EXCEPTION = "XJ001";
 
     ///////////////////////////////////////////////////////////////////////////////////
     //

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SampleSQLData.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SampleSQLData.java?rev=907668&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SampleSQLData.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SampleSQLData.java
Mon Feb  8 14:28:57 2010
@@ -0,0 +1,102 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.functionTests.tests.lang.SampleSQLData
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to you under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+/**
+ * A simple SQLData class.
+ */
+package org.apache.derbyTesting.functionTests.tests.lang;
+
+import java.sql.SQLData;
+import java.sql.SQLException;
+import java.sql.SQLInput;
+import java.sql.SQLOutput;
+
+public class SampleSQLData implements SQLData
+{
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTANTS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // STATE
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    private byte[] _data;
+    
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTRUCTOR
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    public SampleSQLData() {}
+
+    public SampleSQLData( byte[] data )
+    {
+        _data = data;
+    }
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // FUNCTIONS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    public static SampleSQLData makeSampleSQLData( int length )
+    {
+        return new SampleSQLData( new byte[ length ] );
+    }
+
+    public static String toString( SampleSQLData data ) { return data._data.toString(); }
+    
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // SQLData BEHAVIOR
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    public String getSQLTypeName() { return "SampleSQLData"; }
+    
+    public void writeSQL( SQLOutput out ) throws SQLException
+    {
+        out.writeBytes( _data );
+    }
+
+    public void readSQL( SQLInput in, String typeName ) throws SQLException
+    {
+        _data = in.readBytes();
+    }
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // OTHER Object OVERRIDES
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    public String toString()
+    {
+        return "SampleSQLData( " + _data.length + " )";
+    }
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SampleSQLData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UDTTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UDTTest.java?rev=907668&r1=907667&r2=907668&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UDTTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UDTTest.java
Mon Feb  8 14:28:57 2010
@@ -902,6 +902,25 @@
              );
     }
     
+    /**
+     * <p>
+     * Verify that implementing the SQLData interface does not make an object storeable.
+     * </p>
+     */
+    public void test_13_sqlData() throws Exception
+    {
+        Connection conn = getConnection();
+
+        goodStatement( conn, "create type SampleSQLData external name 'org.apache.derbyTesting.functionTests.tests.lang.SampleSQLData'
language java\n" );
+        goodStatement
+            ( conn,
+              "create function makeSampleSQLData( l int ) returns SampleSQLData\n" +
+              "language java parameter style java no sql external name 'org.apache.derbyTesting.functionTests.tests.lang.SampleSQLData.makeSampleSQLData'\n"
);
+        goodStatement( conn, "create table t_13_a( id int generated always as identity, data
SampleSQLData )\n" );
+
+        expectExecutionError( conn, JAVA_EXCEPTION, "insert into t_13_a( data ) values (
makeSampleSQLData( 3 ) )\n" );
+    }
+    
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // PROCEDURES AND FUNCTIONS



Mime
View raw message