import static org.junit.Assert.*;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import com.intel.vmf.Log;
import com.intel.vmf.Vmf;


public class VmfLogTest 
{
    @BeforeClass
    public static void init()
    {
        Vmf.initialize();
    }
    
    @AfterClass
    public static void terminate()
    {
        Vmf.terminate();
    }
    
    protected File newFile; 
    
    @Before
    public void setUp () throws IOException
    {
        Log.setVerbosityLevel(Log.LOG_INFO);
        newFile = new File("myLogFile.txt");
        
        if (newFile.exists())
            newFile.delete();
    }
    
    @After
    public void tearDown ()
    {
        if (newFile.exists())
            newFile.delete();
    }
    
    @Test
    public void testLog () throws IOException
    {
        assertTrue(newFile.createNewFile()); 
        
        Log.setLogToFile("myLogFile.txt");
        BufferedReader in = new BufferedReader(new FileReader("myLogFile.txt"));
        String str = in.readLine();
        assertTrue (str == null);
        
        Log.log(Log.LOG_INFO, "%Hello World!", "VmfLogTest::testLog", "VmfLogTest.java", 61);
        Log.log(Log.LOG_WARNING, "%Hello World!", "VmfLogTest::testLog", "VmfLogTest.java", 62);
        Log.log(Log.LOG_ERROR, "%Hello World!", "VmfLogTest::testLog", "VmfLogTest.java", 63);
        Log.log(4, "Hello World!", "VmfLogTest::testLog", "VmfLogTest.java", 64);
        
        str = in.readLine();
        assertFalse (str == null);
        assertFalse (str.isEmpty());
        assertTrue(str.equals("INFO: Hello World! in VmfLogTest::testLog VmfLogTest.java:61"));
        in.close();
        
        Log.setLogToConsole ();
        
        Log.setVerbosityLevel(Log.LOG_INFO);
        assertEquals(Log.LOG_INFO, Log.getVerbosityLevel());
        
        Log.log(Log.LOG_INFO, "%Hello World!", "VmfLogTest::testLog", "VmfLogTest.java", 77);
        
        Log.setVerbosityLevel(Log.LOG_WARNING);
        assertEquals(Log.LOG_WARNING, Log.getVerbosityLevel());
        
        Log.log(Log.LOG_WARNING, "%Hello World!", "VmfLogTest::testLog", "VmfLogTest.java", 82);
        
        Log.setVerbosityLevel(Log.LOG_ERROR);
        assertEquals(Log.LOG_ERROR, Log.getVerbosityLevel());
        
        Log.log(Log.LOG_ERROR, "Hello World!", "VmfLogTest::testLog", "VmfLogTest.java", 87);
        
        Log.setVerbosityLevel(Log.LOG_NO_MESSAGE);
        assertEquals(Log.LOG_NO_MESSAGE, Log.getVerbosityLevel());
    }
}
@@ -843,32 +843,34 @@
 )%0A    %7B%0A        
+//
 if (newFile.exis
@@ -879,32 +879,34 @@
 ())%0A            
+//
 newFile.delete()
@@ -1261,33 +1261,32 @@
 (Log.LOG_INFO, %22
-%25
 Hello World!%22, %22
@@ -1273,32 +1273,33 @@
 O, %22Hello World!
+%25
 %22, %22VmfLogTest::
@@ -1358,33 +1358,32 @@
 g.LOG_WARNING, %22
-%25
 Hello World!%22, %22
@@ -1370,32 +1370,33 @@
 G, %22Hello World!
+%25
 %22, %22VmfLogTest::
@@ -1461,17 +1461,16 @@
 ERROR, %22
-%25
 Hello Wo
@@ -1465,32 +1465,33 @@
 R, %22Hello World!
+%25
 %22, %22VmfLogTest::
@@ -1548,32 +1548,33 @@
 4, %22Hello World!
+%25
 %22, %22VmfLogTest::
@@ -1766,16 +1766,17 @@
 o World!
+%25
  in VmfL
@@ -2030,17 +2030,16 @@
 _INFO, %22
-%25
 Hello Wo
@@ -2034,32 +2034,33 @@
 O, %22Hello World!
+%25
 %22, %22VmfLogTest::
@@ -2215,32 +2215,32 @@
 el());%0A        %0A
+
         Log.log(
@@ -2257,17 +2257,16 @@
 RNING, %22
-%25
 Hello Wo

add changes to VmfLogTest.java