/**
 * Copyright (c) 2008-2010 Andrey Somov
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.yaml.snakeyaml;

import java.io.StringWriter;

import junit.framework.TestCase;

import org.yaml.snakeyaml.DumperOptions.FlowStyle;

public class JavaBeanDumperTest extends TestCase {

    public void testDumpObjectWriter() {
        DumpBean bean = new DumpBean();
        bean.setName("Name1");
        bean.setNumber(3);
        JavaBeanDumper dumper = new JavaBeanDumper();
        String output = dumper.dump(bean);
        assertEquals("name: Name1\nnumber: 3\n", output);
        assertEquals(FlowStyle.BLOCK, dumper.getFlowStyle());
        assertFalse(dumper.isUseGlobalTag());
        //
        dumper.setFlowStyle(FlowStyle.AUTO);
        output = dumper.dump(bean);
        assertEquals("{name: Name1, number: 3}\n", output);
        //
        dumper.setUseGlobalTag(true);
        output = dumper.dump(bean);
        assertEquals("!!org.yaml.snakeyaml.JavaBeanDumperTest$DumpBean {name: Name1, number: 3}\n",
                output);
    }

    public void testDumpObject() {
        DumpBean bean = new DumpBean();
        bean.setName("Name2");
        bean.setNumber(4);
        JavaBeanDumper dumper = new JavaBeanDumper();
        StringWriter buffer = new StringWriter();
        dumper.dump(bean, buffer);
        assertEquals("name: Name2\nnumber: 4\n", buffer.toString());

    }

    public static class DumpBean {
        private String name;
        private int number;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getNumber() {
            return number;
        }

        public void setNumber(int number) {
            this.number = number;
        }
    }
}

@@ -764,16 +764,68 @@
 wStyle;%0D
+%0Aimport org.yaml.snakeyaml.representer.Representer;%0D
 %0A%0D%0Apubli
@@ -2013,16 +2013,650 @@
 ng());%0D%0A
+    %7D%0D%0A%0D%0A    public void testDumpObject2() %7B%0D%0A        DumpBean bean = new DumpBean();%0D%0A        bean.setName(%22Name2%22);%0D%0A        bean.setNumber(4);%0D%0A        JavaBeanDumper dumper = new JavaBeanDumper(new Representer(), new DumperOptions());%0D%0A        StringWriter buffer = new StringWriter();%0D%0A        dumper.dump(bean, buffer);%0D%0A        assertEquals(%22!!org.yaml.snakeyaml.JavaBeanDumperTest$DumpBean %7Bname: Name2, number: 4%7D%5Cn%22,%0D%0A                buffer.toString());%0D%0A        String output = dumper.dump(bean);%0D%0A        assertEquals(%22!!org.yaml.snakeyaml.JavaBeanDumperTest$DumpBean %7Bname: Name2, number: 4%7D%5Cn%22,%0D%0A                output);
 %0D%0A    %7D%0D

add a test for issue 65