harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r548957 - in /harmony/enhanced/classlib/branches/java6/modules/sql/src: main/java/javax/sql/ test/java/org/apache/harmony/sql/tests/javax/sql/ test/resources/serialization/org/apache/harmony/sql/tests/javax/sql/
Date Wed, 20 Jun 2007 06:46:22 GMT
Author: tonywu
Date: Tue Jun 19 23:46:21 2007
New Revision: 548957

URL: http://svn.apache.org/viewvc?view=rev&rev=548957
Log:
Apply patch HARMONY-4239 ( [classlib][sql][java6] a new class javax.sql.StatementEvent)

Added:
    harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/StatementEvent.java
  (with props)
    harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/StatementEventTest.java
  (with props)
    harmony/enhanced/classlib/branches/java6/modules/sql/src/test/resources/serialization/org/apache/harmony/sql/tests/javax/sql/StatementEventTest.golden.ser
  (with props)

Added: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/StatementEvent.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/StatementEvent.java?view=auto&rev=548957
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/StatementEvent.java
(added)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/StatementEvent.java
Tue Jun 19 23:46:21 2007
@@ -0,0 +1,84 @@
+/* 
+ * 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.
+ */
+
+package javax.sql;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.EventObject;
+
+
+/**
+ * A statement event that a PreparedStatement is closed
+ * 
+ * @since 1.6
+ */
+public class StatementEvent extends EventObject {
+
+	private static final long serialVersionUID = -8089573731826608315L;
+
+	private SQLException exception;
+
+	private PreparedStatement statement;
+
+    /**
+     * the constructor
+     * 
+     * @param con
+     *            the statment related connection
+     * @param statement
+     *            the statement to be closed
+     * @param exception
+     *            the exception to throw
+     */
+    public StatementEvent(PooledConnection con, PreparedStatement statement,
+            SQLException exception) {
+        super(con);
+        this.statement = statement;
+        this.exception = exception;
+    }
+
+    /**
+     * the constructor with null exception
+     * 
+     * @param con
+     *            the statment related connection
+     * @param statement
+     *            the statement to be closed
+     */
+    public StatementEvent(PooledConnection con, PreparedStatement statement) {
+        this(con, statement, null);
+    }
+
+    /**
+     * Answer the statement of this event
+     * 
+     * @return the statment of this event
+     */
+    public PreparedStatement getStatement() {
+        return this.statement;
+    }
+
+    /**
+     * Answer the exception to be thrown
+     * 
+     * @return the exception of this event
+     */
+    public SQLException getSQLException() {
+        return this.exception;
+    }
+}

Propchange: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/StatementEvent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/StatementEventTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/StatementEventTest.java?view=auto&rev=548957
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/StatementEventTest.java
(added)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/StatementEventTest.java
Tue Jun 19 23:46:21 2007
@@ -0,0 +1,94 @@
+package org.apache.harmony.sql.tests.javax.sql;
+
+import java.io.Serializable;
+import java.sql.SQLException;
+
+import javax.sql.PooledConnection;
+import javax.sql.StatementEvent;
+
+import junit.framework.TestCase;
+
+import org.apache.harmony.testframework.serialization.SerializationTest;
+import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
+
+/**
+ * Test class for javax.sql.StatementEvent.
+ * 
+ * @since 1.6
+ */
+public class StatementEventTest extends TestCase {
+
+	private static PooledConnection pc = new Impl_PooledConnection();
+
+	private static StatementEvent st = new StatementEvent(pc, null);
+
+	/**
+	 * @tests {@link javax.sql.StatementEvent#StatementEvent(PooledConnection, java.sql.PreparedStatement)}
+	 */
+	public void testStatementEventPooledConnectionPreparedStatementSQLException() {
+		SQLException e = new SQLException();
+		StatementEvent st2 = new StatementEvent(pc, null, e);
+		assertNotNull(st2);
+
+		assertEquals(e, st2.getSQLException());
+	}
+
+	/**
+	 * @tests {@link javax.sql.StatementEvent#StatementEvent(PooledConnection, java.sql.PreparedStatement)}
+	 */
+	public void testStatementEventPooledConnectionPreparedStatement() {
+		assertNotNull(st);
+
+		try {
+			new StatementEvent(null, null);
+			fail("should throw IllegalArgumentException");
+		} catch (IllegalArgumentException e) {
+			// expected
+		}
+	}
+
+	/**
+	 * @tests {@link javax.sql.StatementEvent#getStatement()}
+	 */
+	public void testGetStatement() {
+		assertNull(st.getStatement());
+	}
+
+	/**
+	 * @tests {@link javax.sql.StatementEvent#getSQLException()}
+	 */
+	public void testGetSQLException() {
+		assertNull(st.getSQLException());
+	}
+
+	/**
+	 * @tests serialization/deserialization compatibility.
+	 */
+	public void testSerializationSelf() throws Exception {
+		SerializationTest.verifySelf(st, STATEMENTEVENT_COMPARATOR);
+	}
+
+	/**
+	 * @tests serialization/deserialization compatibility with RI.
+	 */
+	public void testSerializationCompatibility() throws Exception {
+		StatementEvent st3 = new StatementEvent(pc, null, new SQLException(
+				"test message"));
+		SerializationTest.verifyGolden(this, st3, STATEMENTEVENT_COMPARATOR);
+	}
+
+	private static final SerializableAssert STATEMENTEVENT_COMPARATOR = new SerializableAssert()
{
+
+		public void assertDeserialized(Serializable initial,
+				Serializable deserialized) {
+			StatementEvent iniSt = (StatementEvent) initial;
+			StatementEvent dserSt = (StatementEvent) deserialized;
+			if (null != iniSt.getSQLException()) {
+				assertEquals(iniSt.getSQLException().getMessage(), dserSt
+						.getSQLException().getMessage());
+			}
+			assertEquals(iniSt.getStatement(), dserSt.getStatement());
+		}
+
+	};
+}

Propchange: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/StatementEventTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/resources/serialization/org/apache/harmony/sql/tests/javax/sql/StatementEventTest.golden.ser
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/resources/serialization/org/apache/harmony/sql/tests/javax/sql/StatementEventTest.golden.ser?view=auto&rev=548957
==============================================================================
Binary file - no diff available.

Propchange: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/resources/serialization/org/apache/harmony/sql/tests/javax/sql/StatementEventTest.golden.ser
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message