package net.openhft.chronicle.wire.method;

import junit.framework.TestCase;
import net.openhft.chronicle.bytes.Bytes;
import org.junit.Ignore;

import java.lang.reflect.Proxy;

import static net.openhft.chronicle.wire.WireType.BINARY;

public class GenerateMethodWriterInheritanceTest extends TestCase {

    public void test() {
        AnInterface writer = BINARY.apply(Bytes.elasticByteBuffer())
                .methodWriter(AnInterface.class, ADescendant.class);

        writer.sayHello("hello world");

        // Proxy method writer is constructed in case compilation of generated code failed.
        assertFalse(Proxy.isProxyClass(writer.getClass()));
    }

    @Ignore("https://github.com/OpenHFT/Chronicle-Wire/issues/215")
    public void testSameNamedMethod() {
        AnInterface writer = BINARY.apply(Bytes.elasticByteBuffer())
                .methodWriter(AnInterface.class, AnInterfaceSameName.class);

        writer.sayHello("hello world");

        // Proxy method writer is constructed in case compilation of generated code failed.
        assertFalse(Proxy.isProxyClass(writer.getClass()));
    }

    interface AnInterface {
        void sayHello(String name);
    }

    interface AnInterfaceSameName {
        void sayHello(String name);
    }

    interface ADescendant extends AnInterface {
    }
}


@@ -136,16 +136,39 @@
 .Ignore;
+%0Aimport org.junit.Test;
 %0A%0Aimport
@@ -251,16 +251,60 @@
 .BINARY;
+%0Aimport static org.junit.Assert.assertFalse;
 %0A%0Apublic
@@ -350,27 +350,20 @@
 est 
-extends TestCase %7B%0A
+%7B%0A%0A    @Test
 %0A   
@@ -719,24 +719,34 @@
 )));%0A    %7D%0A%0A
+    @Test%0A
     @Ignore(

fix @Ignore