TrailFilePositionSetter { protected synchronized FilePositionResult getFilePosition(long scn, TransactionSCNFinderCallback callback) throws IOException { return getFilePosition(scn,callback,null); } TrailFilePositionSetter(String dir, String filePrefix);  TrailFilePositionSetter(String dir, String filePrefix, String phySourceName); synchronized FilePositionResult locateFilePosition(long scn, TransactionSCNFinderCallback callback); public Logger _log; static final long USE_LATEST_SCN; static final long USE_EARLIEST_SCN; static final String NEW_LINE_PATTERN_STR; static final String DOUBLE_CHAR_NEWLINE; static final int NO_NEWLINE_LEN; }
@Test public void testScnPositionSetter2() throws Exception { final Logger log = Logger.getLogger("TestTrailFilePositionSetter.testScnPositionSetter2"); log.info("starting"); String[] newLines = { "\r", "\n", "\r\n" }; for (String newLine : newLines) { for (int j = 10; j < 32; j++ ) { log.info("NumPerLine: " + j); File dir = createTempDir(); createTrailFiles(dir.getAbsolutePath(), TRAIL_FILENAME_PREFIX,100, 200,j,newLine,0, -1, "", false, ""); log.info("Directory is: " + dir); TrailFilePositionSetter posSetter = null; GGXMLTrailTransactionFinder finder = new GGXMLTrailTransactionFinder(); log.info("less than MinScn case started !!"); for (long i = 0 ; i < 100 ; i ++) { if ( true )break; posSetter = new TrailFilePositionSetter(dir.getAbsolutePath(), TRAIL_FILENAME_PREFIX); finder = new GGXMLTrailTransactionFinder(); FilePositionResult res = posSetter.getFilePosition(i,finder); Assert.assertEquals(res.getStatus(),FilePositionResult.Status.ERROR,"Result Status"); } log.info("less than MinScn case passed !!"); for (long i = 100 ; i < 300 ; i ++) { posSetter = new TrailFilePositionSetter(dir.getAbsolutePath(), TRAIL_FILENAME_PREFIX); finder = new GGXMLTrailTransactionFinder(); log.info("SCN: " + i); FilePositionResult res = posSetter.getFilePosition(i,finder); log.info("For scn (" + i + "): the result is: " + res); if (i%2 == 0) assertFilePositionResult(res,dir,i+1,FilePositionResult.Status.EXACT_SCN_NOT_FOUND); else assertFilePositionResult(res,dir,i,FilePositionResult.Status.FOUND); } FilePositionResult res = null; for (long i = 300 ; i < 320 ; i ++) { posSetter = new TrailFilePositionSetter(dir.getAbsolutePath(), TRAIL_FILENAME_PREFIX); finder = new GGXMLTrailTransactionFinder(); res = posSetter.getFilePosition(i,finder); assertFilePositionResult(res,dir,299,FilePositionResult.Status.EXACT_SCN_NOT_FOUND); } posSetter = new TrailFilePositionSetter(dir.getAbsolutePath(), TRAIL_FILENAME_PREFIX); finder = new GGXMLTrailTransactionFinder(); res = posSetter.getFilePosition(-1,finder); assertFilePositionResult(res,dir,299,FilePositionResult.Status.FOUND); } } log.info(DONE_STRING); }