persistentstorage/sql/TEST/t_sqlapi2.cpp
branchRCL_3
changeset 15 fcc16690f446
parent 12 6b6fd149daa2
equal deleted inserted replaced
14:04ec7606545c 15:fcc16690f446
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
   975 	TRAP(err, strm5.OpenL(TheDb, KNullDesC, KNullDesC, 1, KNullDesC));
   975 	TRAP(err, strm5.OpenL(TheDb, KNullDesC, KNullDesC, 1, KNullDesC));
   976 	TEST(err != KErrNone);
   976 	TEST(err != KErrNone);
   977 	//Attempt to open a read blob stream with a set of KNullDesC database/table/column names.
   977 	//Attempt to open a read blob stream with a set of KNullDesC database/table/column names.
   978 	RSqlBlobReadStream strm6;
   978 	RSqlBlobReadStream strm6;
   979 	TRAP(err, strm6.OpenL(TheDb, KNullDesC, KNullDesC, 1, KNullDesC));
   979 	TRAP(err, strm6.OpenL(TheDb, KNullDesC, KNullDesC, 1, KNullDesC));
       
   980 	TEST(err != KErrNone);
       
   981 	//Attempt to open a read blob stream, where the blob column name is invalid and contains non-convertible characters.
       
   982     TBuf<3> invName;
       
   983     invName.SetLength(3);
       
   984     invName[0] = TChar(0xD800); 
       
   985     invName[1] = TChar(0xFC00); 
       
   986     invName[2] = TChar(0x0000);
       
   987 	RSqlBlobReadStream strm7;
       
   988 	TRAP(err, strm7.OpenL(TheDb,  _L("A"), invName, 1, KNullDesC));
       
   989 	TEST(err != KErrNone);
       
   990 	//Attempt to open a read blob stream, where the table name is invalid and contains non-convertible characters.
       
   991 	RSqlBlobReadStream strm8;
       
   992 	TRAP(err, strm8.OpenL(TheDb, invName, _L("Data"), 1, KNullDesC));
       
   993 	TEST(err != KErrNone);
       
   994 	//Attempt to open a read blob stream, where the attached db name is invalid and contains non-convertible characters.
       
   995 	RSqlBlobReadStream strm9;
       
   996 	TRAP(err, strm9.OpenL(TheDb, _L("A"), _L("Data"), 1, invName));
   980 	TEST(err != KErrNone);
   997 	TEST(err != KErrNone);
   981 	//
   998 	//
   982 	err = TheDb.Detach(KAttachDb);
   999 	err = TheDb.Detach(KAttachDb);
   983 	TEST2(err, KErrNone);
  1000 	TEST2(err, KErrNone);
   984 	TheDb.Close();
  1001 	TheDb.Close();
  1702 @SYMTestCaseDesc		Expired SQL statements test.
  1719 @SYMTestCaseDesc		Expired SQL statements test.
  1703 						The test creates a database and opens 2 connections to that database.
  1720 						The test creates a database and opens 2 connections to that database.
  1704 						Connection 2 prepares couple of SELECT and INSERT statements (8-bit and 16-bit).
  1721 						Connection 2 prepares couple of SELECT and INSERT statements (8-bit and 16-bit).
  1705 						Then connection 1 renames the table used in the already prepared statements.
  1722 						Then connection 1 renames the table used in the already prepared statements.
  1706 						Connection 2 attempts to execute the prepared statements. The execution should fail
  1723 						Connection 2 attempts to execute the prepared statements. The execution should fail
  1707 						because the statements are expired, the database schema has changed after they 
  1724 						because the database schema has changed after they were prepared.
  1708 						were prepared.
       
  1709 @SYMTestActions			Expired SQL statements test.
  1725 @SYMTestActions			Expired SQL statements test.
  1710 @SYMTestExpectedResults Test must not fail
  1726 @SYMTestExpectedResults Test must not fail
  1711 @SYMTestPriority		High
  1727 @SYMTestPriority		High
  1712 @SYMDEF					DEF145236
  1728 @SYMDEF					DEF145236
  1713 */
  1729 */
  1745 	
  1761 	
  1746 	//Try to execute the already prepared statements.
  1762 	//Try to execute the already prepared statements.
  1747 	err = stmt1.Next();
  1763 	err = stmt1.Next();
  1748 	TEST2(err, KSqlErrSchema);
  1764 	TEST2(err, KSqlErrSchema);
  1749 	err = stmt1.Next();
  1765 	err = stmt1.Next();
  1750 	TEST2(err, KSqlErrStmtExpired);
  1766 	TEST(err != KSqlAtRow);
  1751 	err = stmt2.Next();
  1767 	err = stmt2.Next();
  1752 	TEST2(err, KSqlErrStmtExpired);
  1768 	TEST(err != KSqlAtRow);
  1753 	err = stmt3.Exec();
  1769 	err = stmt3.Exec();
  1754 	TEST2(err, KSqlErrStmtExpired);
  1770 	TEST(err < 0);
  1755 	err = stmt4.Exec();
  1771 	err = stmt4.Exec();
  1756 	TEST2(err, KSqlErrStmtExpired);
  1772 	TEST(err < 0);
  1757 	//
  1773 	//
  1758 	stmt4.Close();
  1774 	stmt4.Close();
  1759 	stmt3.Close();
  1775 	stmt3.Close();
  1760 	stmt2.Close();
  1776 	stmt2.Close();
  1761 	stmt1.Close();
  1777 	stmt1.Close();