harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r478608 - in /harmony/enhanced/classlib/trunk/modules/sql/src: main/java/javax/sql/rowset/serial/SerialJavaObject.java test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialJavaObjectTest.java
Date Thu, 23 Nov 2006 16:07:28 GMT
Author: tellison
Date: Thu Nov 23 08:07:27 2006
New Revision: 478608

URL: http://svn.apache.org/viewvc?view=rev&rev=478608
Log:
Apply patch HARMONY-2277 ([classlib][sql] javax.sql.rowset.serial.SerialJavaObject is not
implemented yet in Harmony)

Added:
    harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/serial/SerialJavaObject.java
  (with props)
    harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialJavaObjectTest.java
  (with props)

Added: harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/serial/SerialJavaObject.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/serial/SerialJavaObject.java?view=auto&rev=478608
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/serial/SerialJavaObject.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/serial/SerialJavaObject.java
Thu Nov 23 08:07:27 2006
@@ -0,0 +1,52 @@
+/*
+ *  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.rowset.serial;
+
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.util.Vector;
+
+public class SerialJavaObject implements Serializable, Cloneable {
+
+	private static final long serialVersionUID = -1465795139032831023L;
+
+	/**
+	 * obj and chain are defined in serialized form.
+	 */
+	private Object obj;
+
+	@SuppressWarnings({ "unchecked", "unused" }) // Required by serialized form
+    private Vector chain;
+
+	private transient Field[] fields;
+
+	public SerialJavaObject(Object obj) {
+		this.obj = obj;
+	}
+
+	public Field[] getFields() throws SerialException {
+		if (fields == null) {
+			fields = obj.getClass().getFields();
+		}
+		return fields;
+	}
+
+	public Object getObject() {
+		return obj;
+	}
+}

Propchange: harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/serial/SerialJavaObject.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialJavaObjectTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialJavaObjectTest.java?view=auto&rev=478608
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialJavaObjectTest.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialJavaObjectTest.java
Thu Nov 23 08:07:27 2006
@@ -0,0 +1,70 @@
+/*
+ *  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 org.apache.harmony.sql.tests.javax.sql.rowset.serial;
+
+import java.io.Serializable;
+import java.util.Arrays;
+
+import javax.sql.rowset.serial.SerialJavaObject;
+
+import junit.framework.TestCase;
+
+public class SerialJavaObjectTest extends TestCase {
+	public void test_Constructor() throws Exception {
+		TransientFieldClass tfc = new TransientFieldClass();
+		SerialJavaObject sjo = new SerialJavaObject(tfc);
+		assertSame(tfc, sjo.getObject());
+		Arrays.equals(sjo.getFields(), tfc.getClass().getFields());
+		
+		NonSerialiableClass nsc = new NonSerialiableClass();
+		sjo = new SerialJavaObject(nsc);
+		assertSame(nsc, sjo.getObject());
+		Arrays.equals(sjo.getFields(), nsc.getClass().getFields());
+		
+		StaticFieldClass sfc = new StaticFieldClass();
+		sjo = new SerialJavaObject(sfc);
+		assertSame(sfc, sjo.getObject());
+		Arrays.equals(sjo.getFields(), sfc.getClass().getFields());
+		
+		SerializableClass sc = new SerializableClass();
+		sjo = new SerialJavaObject(sc);
+		assertSame(sc, sjo.getObject());
+		Arrays.equals(sjo.getFields(), sc.getClass().getFields());
+	}
+	
+	static class TransientFieldClass {
+		transient int i;
+		String s;
+	}
+	
+	static class NonSerialiableClass {
+		int i;
+		String s;
+	}
+	
+	static class StaticFieldClass {
+		static int i;
+		String s;
+	}
+	
+	static class SerializableClass implements Serializable {
+		private static final long serialVersionUID = 0L;
+		int i;
+		String s;
+	}
+}

Propchange: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialJavaObjectTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message