package pl.edu.icm.coansys.logsanalysis;

import java.io.File;
import java.util.List;
import org.apache.commons.io.FileUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.SequenceFile.Reader;
import static org.junit.Assert.*;
import org.junit.*;
import pl.edu.icm.coansys.importers.models.MostPopularProtos;
import pl.edu.icm.coansys.importers.models.MostPopularProtos.MostPopularStats;
import pl.edu.icm.coansys.importers.models.MostPopularProtos.ResourceStat;
import pl.edu.icm.oozierunner.OozieRunner;

public class TestIT {

    @BeforeClass
    public static void setUpClass() throws Exception {
        System.out.println("setUpClass");
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
        System.out.println("tearDownClass");
    }

    @Before
    public void setUp() throws Exception {
        System.out.println("setUp");
    }

    @After
    public void tearDown() {
        System.out.println("tearDown");
    }

    @Test
    public void testTest1() throws Exception {
        System.out.println("Test1");
        OozieRunner or = new OozieRunner();
        File workflowOutputData = or.run();

        assertTrue(workflowOutputData.exists());
        assertTrue(workflowOutputData.isDirectory());
        assertTrue(workflowOutputData.listFiles().length > 0);

        int foundRecords = 0;
        long counter = 0;

        for (File f : FileUtils.listFiles(workflowOutputData, null, true)) {
            if (f.isFile() && f.getName().startsWith("part-")) {
                Configuration conf = new Configuration();
                Path path = new Path("file://" + f.getAbsolutePath());
                Reader reader = new Reader(conf, Reader.file(path));
                NullWritable key  = NullWritable.get();
                BytesWritable value = new BytesWritable();
                while (reader.next(key, value)) {
                    MostPopularStats protoValue = MostPopularProtos.MostPopularStats.parseFrom(value.copyBytes());
                    for (ResourceStat stat : protoValue.getStatList()) {
                        foundRecords++;
                        counter += stat.getCounter();
                    }
                    System.out.println("output value: " + protoValue);
                }
            }
        }

        assertEquals(5, foundRecords);
        assertEquals(44, counter);
    }

    @Test
    public void testTest2() throws Exception {
        System.out.println("Test2");
    }
}
@@ -60,31 +60,8 @@
 le;%0A
-import java.util.List;%0A
 impo
@@ -96,16 +96,16 @@
 eUtils;%0A
+
 import o
@@ -327,21 +327,22 @@
 tic org.
-junit
+testng
 .Assert.
@@ -359,15 +359,31 @@
 org.
-junit.*
+testng.annotations.Test
 ;%0Aim
@@ -667,441 +667,8 @@
  %7B%0A%0A
-    @BeforeClass%0A    public static void setUpClass() throws Exception %7B%0A        System.out.println(%22setUpClass%22);%0A    %7D%0A%0A    @AfterClass%0A    public static void tearDownClass() throws Exception %7B%0A        System.out.println(%22tearDownClass%22);%0A    %7D%0A%0A    @Before%0A    public void setUp() throws Exception %7B%0A        System.out.println(%22setUp%22);%0A    %7D%0A%0A    @After%0A    public void tearDown() %7B%0A        System.out.println(%22tearDown%22);%0A    %7D%0A%0A
     
@@ -1883,79 +1883,8 @@
   %7D%0A
-                    System.out.println(%22output value: %22 + protoValue);%0A
     
@@ -1961,16 +1961,16 @@
 cords);%0A
+
         
@@ -2005,107 +2005,6 @@
    %7D
-%0A%0A    @Test%0A    public void testTest2() throws Exception %7B%0A        System.out.println(%22Test2%22);%0A    %7D
 %0A%7D

Change from junit to testng