Author: leszek
Date: 2006-09-12 06:31:25 -0400 (Tue, 12 Sep 2006)
New Revision: 65292
Added:
trunk/mcs/class/System.Data.OracleClient/Test/System.Data.OracleClient/OracleLobTest.cs
Modified:
trunk/mcs/class/System.Data.OracleClient/ChangeLog
trunk/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleLob.cs
trunk/mcs/class/System.Data.OracleClient/System.Data.OracleClient/OracleLob.cs
trunk/mcs/class/System.Data.OracleClient/System.Data.OracleClient_test.dll.sources
trunk/mcs/class/System.Data.OracleClient/Test/System.Data.OracleClient/ChangeLog
Log:
Fixed bug 78898 in OracleLob (index was 1-based instead of 0) and added
regression test.
Modified: trunk/mcs/class/System.Data.OracleClient/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data.OracleClient/ChangeLog 2006-09-12 10:24:49 UTC
(rev 65291)
+++ trunk/mcs/class/System.Data.OracleClient/ChangeLog 2006-09-12 10:31:25 UTC
(rev 65292)
@@ -1,5 +1,9 @@
-2006-08-21 Leszek Ciesielski <[EMAIL PROTECTED]>
+2006-09-12 Leszek Ciesielski <[EMAIL PROTECTED]>
+ * OracleLob.cs : fix for bug 78898
+
+2006-09-11 Leszek Ciesielski <[EMAIL PROTECTED]>
+
* OracleCommand.cs : fix for bug 78765 and 79284
* OracleParameter.cs : fix for bug 78509 and 79284
* README.tests : New : information about running on-line tests from
Modified:
trunk/mcs/class/System.Data.OracleClient/System.Data.OracleClient/OracleLob.cs
===================================================================
---
trunk/mcs/class/System.Data.OracleClient/System.Data.OracleClient/OracleLob.cs
2006-09-12 10:24:49 UTC (rev 65291)
+++
trunk/mcs/class/System.Data.OracleClient/System.Data.OracleClient/OracleLob.cs
2006-09-12 10:31:25 UTC (rev 65292)
@@ -35,7 +35,7 @@
OracleType type;
long length = -1;
- long position = 1;
+ long position = 0;
#endregion // Fields
@@ -316,7 +316,7 @@
int bytesRead;
byte[] output = new byte[count];
- bytesRead = locator.Read (output, (uint) Position,
(uint) count, LobType == OracleType.Blob);
+ bytesRead = locator.Read (output, (uint) Position + 1,
(uint) count, LobType == OracleType.Blob);
output.CopyTo (buffer, offset);
position += bytesRead;
return bytesRead;
@@ -335,7 +335,7 @@
newPosition += offset;
break;
case SeekOrigin.End:
- newPosition = Length - offset;
+ newPosition = Length + offset;
break;
}
@@ -380,7 +380,7 @@
Array.Copy (buffer, offset, value, 0, count);
}
- position += locator.Write (value, (uint) Position,
(uint) value.Length, LobType);
+ position += locator.Write (value, (uint) Position + 1,
(uint) value.Length, LobType);
}
#endregion // Methods
Modified:
trunk/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleLob.cs
===================================================================
---
trunk/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleLob.cs
2006-09-12 10:24:49 UTC (rev 65291)
+++
trunk/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleLob.cs
2006-09-12 10:31:25 UTC (rev 65292)
@@ -17,7 +17,7 @@
OracleType type;
long length = -1;
- long position = 1;
+ long position = 0;
#endregion // Fields
@@ -275,7 +275,7 @@
newPosition += offset;
break;
case SeekOrigin.End:
- newPosition = Length - offset;
+ newPosition = Length + offset;
break;
}
Modified:
trunk/mcs/class/System.Data.OracleClient/System.Data.OracleClient_test.dll.sources
===================================================================
---
trunk/mcs/class/System.Data.OracleClient/System.Data.OracleClient_test.dll.sources
2006-09-12 10:24:49 UTC (rev 65291)
+++
trunk/mcs/class/System.Data.OracleClient/System.Data.OracleClient_test.dll.sources
2006-09-12 10:31:25 UTC (rev 65292)
@@ -1,3 +1,4 @@
System.Data.OracleClient/OraclePermissionAttributeTest.cs
System.Data.OracleClient/OracleCommandTest.cs
System.Data.OracleClient/OracleParameterTest.cs
+System.Data.OracleClient/OracleLobTest.cs
Modified:
trunk/mcs/class/System.Data.OracleClient/Test/System.Data.OracleClient/ChangeLog
===================================================================
---
trunk/mcs/class/System.Data.OracleClient/Test/System.Data.OracleClient/ChangeLog
2006-09-12 10:24:49 UTC (rev 65291)
+++
trunk/mcs/class/System.Data.OracleClient/Test/System.Data.OracleClient/ChangeLog
2006-09-12 10:31:25 UTC (rev 65292)
@@ -1,3 +1,8 @@
+2006-09-12 Leszek Ciesielski <[EMAIL PROTECTED]>
+
+ * OracleLobTest.cs: New. Regression tests for class
+ OracleLob.
+
2006-09-11 Leszek Ciesielski <[EMAIL PROTECTED]>
* OracleCommandTest.cs: New. Regression tests for class
Added:
trunk/mcs/class/System.Data.OracleClient/Test/System.Data.OracleClient/OracleLobTest.cs
===================================================================
---
trunk/mcs/class/System.Data.OracleClient/Test/System.Data.OracleClient/OracleLobTest.cs
2006-09-12 10:24:49 UTC (rev 65291)
+++
trunk/mcs/class/System.Data.OracleClient/Test/System.Data.OracleClient/OracleLobTest.cs
2006-09-12 10:31:25 UTC (rev 65292)
@@ -0,0 +1,152 @@
+//
+// OracleParameterTest.cs -
+// NUnit Test Cases for OracleLob
+//
+// Author:
+// Leszek Ciesielski <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2006 Forcom (http://www.forcom.com.pl/)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+using System.Configuration;
+using System.Globalization;
+using System.Threading;
+using System.Data.OracleClient;
+using System.Data;
+using System.IO;
+using System;
+
+namespace MonoTests.System.Data.OracleClient {
+
+ [TestFixture]
+ public class OracleLobTest {
+
+ String connection_string;
+ OracleConnection connection;
+ OracleCommand command;
+
+ [TestFixtureSetUp]
+ public void FixtureSetUp ()
+ {
+ connection_string =
ConfigurationSettings.AppSettings.Get ("OracleConnectionString");
+ if(connection_string == null)
+ Assert.Ignore ("Please consult README.tests.");
+ }
+
+ [SetUp]
+ public void SetUp ()
+ {
+ connection = new OracleConnection (connection_string);
+ connection.Open ();
+ command = connection.CreateCommand ();
+
+ // create the tables
+ command.CommandText =
+ "create table lob_test (id number(10),
lobo blob)";
+ command.ExecuteNonQuery ();
+ }
+
+ [TearDown]
+ public void TearDown ()
+ {
+ command = connection.CreateCommand ();
+ command.CommandText = "drop table lob_test";
+ command.ExecuteNonQuery ();
+
+ connection.Close ();
+ connection.Dispose ();
+ }
+
+ [Test] // regression for bug #78898
+ public void PositionIs0BasedTest ()
+ {
+ command = connection.CreateCommand (); // reusing
command from SetUp causes parameter names mismatch
+
+ // insert test values
+ command.CommandText =
+ "insert into lob_test (id, lobo)
values (11, '00000000000000000000000000000')";
+ command.ExecuteNonQuery ();
+
+ // select for writing test values
+ command.CommandText =
+ "select lobo from lob_test where id =
11 for update";
+
+ using (OracleDataReader reader = command.ExecuteReader
()) {
+ if (reader.Read ()) {
+ OracleLob lob = reader.GetOracleLob
(0);
+ Assert.AreEqual (0, lob.Position, "Lob
index is not 0 - based.");
+ lob.Seek (1, SeekOrigin.Current);
+ Assert.AreEqual (1, lob.Position, "Lob
seek placed position wrongly.");
+ lob.Seek (0, SeekOrigin.End);
+ Assert.AreEqual (lob.Length ,
lob.Position, "Lob end is too far away.");
+ TrySeek (lob, -lob.Length,
SeekOrigin.End, 0, 1);
+ TrySeek (lob, -lob.Length + 5,
SeekOrigin.End, 5, 2);
+ try {
+ lob.Seek (5, SeekOrigin.End);
+ Assert.Fail ("Illegal seek
succeeded.");
+ }
+ catch (ArgumentOutOfRangeException) {
// exception is required
+ }
+ lob.Seek (lob.Length - 5,
SeekOrigin.Begin);
+ Assert.AreEqual (lob.Length - 5 ,
lob.Position, "Lob position has unexpected value.");
+ lob.Seek (0, SeekOrigin.Begin);
+ TryRead (lob, 10, 1);
+ lob.Seek (5, SeekOrigin.Begin);
+ lob.Position = 0;
+ TryRead (lob, 10, 2);
+ lob.Position = lob.Length;
+ TryRead (lob, 0, 3);
+ lob.Seek (-1, SeekOrigin.Current);
+ TryRead (lob, 1, 4);
+ }
+ else {
+ Assert.Fail ("Expected records not
found.");
+ }
+ }
+ }
+
+ void TrySeek(OracleLob lob, long offset, SeekOrigin start,
long expected, int id)
+ {
+ try {
+ lob.Seek (offset, start);
+ Assert.AreEqual (expected, lob.Position, "Lob
position was unexpected [" + id + ']');
+ }
+ catch (ArgumentOutOfRangeException) {
+ Assert.Fail ("Unable to perform a legal seek
[" + id + ']');
+ }
+ }
+
+ void TryRead(OracleLob lob, long expectedCount, int id)
+ {
+ try {
+ long numberRead = lob.Read (new byte [10], 0,
10);
+ Assert.AreEqual (expectedCount, numberRead,
"Wrong number of bytes read [" + id + ']');
+ }
+ catch (OracleException e) {
+ if (e.Code == 24801)
+ Assert.Fail ("Unable to perform a
legal read [" + id + ']');
+ else throw;
+ }
+ }
+ }
+}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches