private void diskQuadtreeTest(String fileName, Boundary boundaray) { // line of sample file is 100. And 2-Dimension,; QuadTreeFile quadTree = new QuadTreeFile(50, boundaray, "Q"); int count = 0; try { BufferedReader in = new BufferedReader(new FileReader(fileName)); String line; try { while ((line = in.readLine()) != null) { Point point = Point.stringToPoint(line); quadTree.insert(point); count++; assertEquals(count, quadTree.size()); } } catch (IOException e) { e.printStackTrace(); } } catch (FileNotFoundException e) { System.err.println(fileName + "is not existed in " + System.getProperty("user.dir")); e.printStackTrace(); } quadTree.save(); quadTree = QuadTreeFile.load("Q"); int pointSizes = 0; List<QuadTree> leaves = quadTree.leaves(); for (QuadTree leaf : leaves) { Iterator<Point> points = leaf.points(); while (points.hasNext()) { points.next(); pointSizes++; } } assertEquals(100, pointSizes); }
@After public void delete() { QuadTreeFile.delete("Q"); }