javaextensions/midprms_db/tsrc/javasrc/com/nokia/mj/test/rms/TestRecordEnumeration.java
branchRCL_3
changeset 83 26b2b12093af
parent 77 7cee158cb8cd
equal deleted inserted replaced
77:7cee158cb8cd 83:26b2b12093af
   134         aSuite.addTest(new TestRecordEnumeration("testReset", new TestMethod()
   134         aSuite.addTest(new TestRecordEnumeration("testReset", new TestMethod()
   135         {
   135         {
   136             public void run(TestCase tc)
   136             public void run(TestCase tc)
   137             {
   137             {
   138                 ((TestRecordEnumeration) tc).testReset();
   138                 ((TestRecordEnumeration) tc).testReset();
   139             }
       
   140         }));
       
   141 
       
   142         aSuite.addTest(new TestRecordEnumeration("testEnumerationOrder", new TestMethod()
       
   143         {
       
   144             public void run(TestCase tc)
       
   145             {
       
   146                 ((TestRecordEnumeration) tc).testEnumerationOrder();
       
   147             }
   139             }
   148         }));
   140         }));
   149 
   141 
   150         return aSuite;
   142         return aSuite;
   151     }
   143     }
  1153             }
  1145             }
  1154             catch (Exception e) {}
  1146             catch (Exception e) {}
  1155         }
  1147         }
  1156     }
  1148     }
  1157 
  1149 
  1158     public void testEnumerationOrder()
       
  1159     {
       
  1160         // This test checks that record enumeration returns records in FIFO order
       
  1161         // if null RecordComparator is provided
       
  1162         // MIDP spec says that order is undefined in this case but many acceptance tests
       
  1163         // assume this order
       
  1164         System.out.println("TestRecordEnumeration.testEnumerationOrder()");
       
  1165         RecordStore store = null;
       
  1166         String rec_store_name = "testEnumerationOrder";
       
  1167 
       
  1168         try
       
  1169         {
       
  1170             // 0: Init
       
  1171             System.out.println("0: Init");
       
  1172             try
       
  1173             {
       
  1174                 RecordStore.deleteRecordStore(rec_store_name);
       
  1175             }
       
  1176             catch (Exception e) {}
       
  1177             store = RecordStore.openRecordStore(rec_store_name, true);
       
  1178             populateRecordStore(store);
       
  1179 
       
  1180             // 1: check order
       
  1181             System.out.println("1: check order");
       
  1182             RecordEnumeration enumeration = store.enumerateRecords(null, null, false);
       
  1183             for(int i = 0; enumeration.hasNextElement(); i++)
       
  1184             {
       
  1185                 byte[] r = enumeration.nextRecord();
       
  1186                 assertEquals(r, iData[i].getBytes());
       
  1187             }
       
  1188         }
       
  1189         catch (Exception e)
       
  1190         {
       
  1191             e.printStackTrace();
       
  1192             fail("Unexpected exception " + e);
       
  1193         }
       
  1194         finally
       
  1195         {
       
  1196             try
       
  1197             {
       
  1198                 store.closeRecordStore();
       
  1199             }
       
  1200             catch (Exception e) {}
       
  1201             try
       
  1202             {
       
  1203                 RecordStore.deleteRecordStore(rec_store_name);
       
  1204             }
       
  1205             catch (Exception e) {}
       
  1206         }
       
  1207     }
       
  1208 
       
  1209 }
  1150 }
  1210 
  1151