package org.ethereum.solidity;

import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertTrue;

import org.ethereum.solidity.Abi.Entry;
import org.ethereum.solidity.Abi.Entry.Type;
import org.junit.Test;

import java.io.IOException;

public class AbiTest {

    @Test
    public void simpleTest() throws IOException {
        String contractAbi = "[{"
                + "\"name\":\"simpleFunction\","
                + "\"constant\":true,"
                + "\"payable\":true,"
                + "\"type\":\"function\","
                + "\"inputs\": [{\"name\":\"_in\", \"type\":\"bytes32\"}],"
                + "\"outputs\":[{\"name\":\"_out\",\"type\":\"bytes32\"}]}]";

        Abi abi = Abi.fromJson(contractAbi);
        assertEquals(abi.size(), 1);

        Entry onlyFunc = abi.get(0);
        assertEquals(onlyFunc.type, Type.function);
        assertEquals(onlyFunc.inputs.size(), 1);
        assertEquals(onlyFunc.outputs.size(), 1);
        assertTrue(onlyFunc.payable);
        assertTrue(onlyFunc.constant);
    }

    public static void main(String[] args) throws Exception {
        new AbiTest().simpleTest();
    }
}

@@ -1065,99 +1065,697 @@
     
-public static void main(String%5B%5D args) throws Exception %7B%0A        new AbiTest().simpleTest(
+@Test%0A    public void simpleLegacyTest() throws IOException %7B%0A        String contractAbi = %22%5B%7B%22%0A                + %22%5C%22name%5C%22:%5C%22simpleFunction%5C%22,%22%0A                + %22%5C%22constant%5C%22:true,%22%0A                + %22%5C%22type%5C%22:%5C%22function%5C%22,%22%0A                + %22%5C%22inputs%5C%22: %5B%7B%5C%22name%5C%22:%5C%22_in%5C%22, %5C%22type%5C%22:%5C%22bytes32%5C%22%7D%5D,%22%0A                + %22%5C%22outputs%5C%22:%5B%7B%5C%22name%5C%22:%5C%22_out%5C%22,%5C%22type%5C%22:%5C%22bytes32%5C%22%7D%5D%7D%5D%22;%0A%0A        Abi abi = Abi.fromJson(contractAbi);%0A        assertEquals(abi.size(), 1);%0A%0A        Entry onlyFunc = abi.get(0);%0A        assertEquals(onlyFunc.type, Type.function);%0A        assertEquals(onlyFunc.inputs.size(), 1);%0A        assertEquals(onlyFunc.outputs.size(), 1);%0A        assertTrue(onlyFunc.constant
 );%0A 

Add test for solc backward compatibility