package org.jvyaml;

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

import junit.framework.TestCase;

import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.emitter.Emitter;
import org.yaml.snakeyaml.events.Event;
import org.yaml.snakeyaml.parser.Parser;
import org.yaml.snakeyaml.parser.ParserImpl;
import org.yaml.snakeyaml.scanner.ScannerImpl;

public class EmitterImplTest extends TestCase {

    public void testEmitterImpl() throws IOException {
        // TODO main(new String[0]);
    }

    public static void main(final String[] args) throws IOException {
        String filename;
        if (args.length == 1) {
            filename = args[0];
        } else {
            filename = "src/test/resources/specification/example2_28.yaml";
        }
        System.out.println("File contents:");
        final BufferedReader read = new BufferedReader(new FileReader(filename));
        String last = null;
        while ((last = read.readLine()) != null) {
            System.out.println(last);
        }
        read.close();
        System.out.println("--------------------------------");
        final Emitter emitter = new Emitter(new java.io.OutputStreamWriter(System.out),
                new DumperOptions());
        final Parser pars = new ParserImpl(new ScannerImpl(new org.yaml.snakeyaml.reader.Reader(
                new FileInputStream(filename))));
        while (pars.peekEvent() != null) {
            emitter.emit((Event) pars.getEvent());
        }
    }
}

@@ -258,24 +258,78 @@
 r.Emitter;%0D%0A
+import org.yaml.snakeyaml.events.DocumentStartEvent;%0D%0A
 import org.y
@@ -614,16 +614,8 @@
     
-// TODO 
 main
@@ -1596,44 +1596,407 @@
     
-emitter.emit((Event) pars.getEvent()
+Event event = (Event) pars.getEvent();%0D%0A            if (event instanceof DocumentStartEvent) %7B%0D%0A                DocumentStartEvent ev = (DocumentStartEvent) event;%0D%0A                Integer%5B%5D version = new Integer%5B%5D %7B new Integer(1), new Integer(1) %7D;%0D%0A                event = new DocumentStartEvent(null, null, ev.getExplicit(), version, ev.getTags());%0D%0A            %7D%0D%0A            emitter.emit(event
 );%0D%0A

fix test