//package Cases;


// CSC 468. Project Stage 1. 
// Test File for the StructureIndex structure.
// Alex Dekhtyar

// Note: the organization of your project may require somewhat different import statements.
//       Please, edit this test file accordingly.
//

import java.io.*;
import java.io.File;

import neustore.base.DBIndex;
import neustore.base.LRUBuffer;
import neustore.base.DiskAddress;  // change as necessary

public class AttributeIndexTest {

public static void main(String[] args)throws IOException {


                int pageSize = 4096;  // Size of a single buffer/disk page. Insert your size HERE!

		//all the pages will be stored under this file name
		String filename1="TESTFILE2";
		File file= new File(filename1);
		if(file.delete())
		{
			 System.out.println("File already exists: deleted");
			 
		}
		else
		{
			System.out.println("File not found");
		}
		
		//create a buffer with 5 slots. 
		LRUBuffer buf= new LRUBuffer (5, pageSize);

	
	AttributeIndex atts = new AttributeIndex(bufb,filename1,1);
	
	atts.insertEntry(1,"foo", "1");
	atts.insertEntry(1, "bar", "2");
	atts.insertEntry(2, "foo", "3");
	
	String res = atts.getValue(1,"foo");
	System.out.println("1: foo ="+res);
	
	res = atts.getValue(2,"foo");
	System.out.println("2: foo ="+res);
	
	res = atts.getValue(1,"bar");
	System.out.println("1: bar ="+res);
	
        int flag = atts.deleteEntry(1,"foo");
        System.out.print("DeleteEntry(1,foo) status:");
        System.out.println(flag);     

        res = atts.getValue(1,"foo");
        System.out.println("1: foo ="+res);

}

}