OracleDataAdapter_FillSchema_DsSt.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //
  2. // Copyright (c) 2006 Mainsoft Co.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining
  5. // a copy of this software and associated documentation files (the
  6. // "Software"), to deal in the Software without restriction, including
  7. // without limitation the rights to use, copy, modify, merge, publish,
  8. // distribute, sublicense, and/or sell copies of the Software, and to
  9. // permit persons to whom the Software is furnished to do so, subject to
  10. // the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be
  13. // included in all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  19. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  20. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. //
  23. using System;
  24. using System.Text;
  25. using System.Data;
  26. using System.Data.OracleClient;
  27. using MonoTests.System.Data.Utils;
  28. using NUnit.Framework;
  29. namespace MonoTests.System.Data.OracleClient
  30. {
  31. [TestFixture]
  32. public class OracleDataAdapter_FillSchema_DsSt : ADONetTesterClass
  33. {
  34. private Exception exp;
  35. private string connectionString = ConnectedDataProvider.ConnectionString;
  36. public static void Main()
  37. {
  38. OracleDataAdapter_FillSchema_DsSt tc = new OracleDataAdapter_FillSchema_DsSt();
  39. Exception l_exp = null;
  40. try
  41. {
  42. // Every Test must begin with BeginTest
  43. tc.BeginTest("OracleDataAdapter_FillSchema_DsSt");
  44. tc.run();
  45. }
  46. catch(Exception ex)
  47. {
  48. l_exp = ex;
  49. }
  50. finally
  51. {
  52. // Every Test must End with EndTest
  53. tc.EndTest(l_exp);
  54. }
  55. }
  56. public void run()
  57. {
  58. TestLongSqlExpression();
  59. }
  60. //Test case for bug #4708
  61. [Test(Description="Test case for bug #4708")]
  62. public void TestLongSqlExpression()
  63. {
  64. BeginCase("Long SQL string cause java.lang.StackOverflowError (Test case for bug #4708)");
  65. StringBuilder querySb = new StringBuilder();
  66. querySb.Append("SELECT ");
  67. querySb.Append("c.CustomerID as ci1, c.CustomerID as ci2, c.CustomerID as ci3, c.CustomerID as ci4, ");
  68. querySb.Append("c.CompanyName as cn1, c.CompanyName as cn2, c.CompanyName as cn3, c.CompanyName as cn4, ");
  69. querySb.Append("c.ContactName as cntn1, c.ContactName as cntn2, c.ContactName as cntn3, c.ContactName as cntn4, ");
  70. querySb.Append("c.ContactTitle as ct1, c.ContactTitle as ct2, c.ContactTitle as ct3, c.ContactTitle as ct4, ");
  71. querySb.Append("c.Address as ad1, c.Address as ad2, c.Address as ad3, c.Address as ad4, ");
  72. querySb.Append("c.City as ct1, c.City as ct2, c.City as ct3, c.City as ct4, ");
  73. querySb.Append("c.Region as rg1, c.Region as rg2, c.Region as rg3, c.Region as rg4, ");
  74. querySb.Append("c.PostalCode as pc1, c.PostalCode as pc2, c.PostalCode as pc3, c.PostalCode as pc4, ");
  75. querySb.Append("c.Country as co1, c.Country as co2, c.Country as co3, c.Country as co4, ");
  76. querySb.Append("c.Phone as ph1, c.Phone as ph2, c.Phone as ph3, c.Phone as ph4, ");
  77. querySb.Append("c.Fax as fx1, c.Fax as fx2, c.Fax as fx3, c.Fax as fx4 ");
  78. querySb.Append("FROM Customers c");
  79. OracleDataAdapter adapter = null;
  80. DataSet schemaDs = new DataSet();
  81. try
  82. {
  83. using(adapter = new OracleDataAdapter(querySb.ToString(), this.connectionString))
  84. {
  85. adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
  86. adapter.FillSchema(schemaDs, SchemaType.Source);
  87. Compare(schemaDs.Tables.Count, 1);
  88. }
  89. }
  90. catch(Exception ex)
  91. {
  92. exp = ex;
  93. }
  94. finally
  95. {
  96. EndCase(exp);
  97. exp = null;
  98. }
  99. }
  100. }
  101. }