import com.intel.vmf.Metadata;
import com.intel.vmf.MetadataDesc;
import com.intel.vmf.FieldDesc;
import com.intel.vmf.Variant;
import com.intel.vmf.Vmf;
import com.intel.vmf.MetadataSchema;
import com.intel.vmf.ReferenceDesc;

import static org.junit.Assert.*;

import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

public class VmfMetadataSchemaTest 
{
    @BeforeClass
    public static void init()
    {
        Vmf.initialize();
    }
    
    @AfterClass
    public static void terminate()
    {
        Vmf.terminate();
    }
    
    protected MetadataSchema schema;
    
    protected FieldDesc fields1[] = new FieldDesc [3];
    
    protected ReferenceDesc refs[] = new ReferenceDesc [3];
    
    protected FieldDesc fields2[] = new FieldDesc [4];
    
    protected MetadataDesc mdDesc1; 
    protected MetadataDesc mdDesc2;
    
    protected Metadata md1;
    protected Metadata md2;
    
    @Before
    public void setUp ()
    {
        fields1[0] = new FieldDesc ("name", Variant.type_string, false);
        fields1[1] = new FieldDesc ("last name", Variant.type_string, false);
        fields1[2] = new FieldDesc ("age", Variant.type_integer, false);
        
        fields2[0] = new FieldDesc ("manufacturer", Variant.type_string, false);
        fields2[1] = new FieldDesc ("model", Variant.type_string, false);
        fields2[2] = new FieldDesc ("number", Variant.type_string, false);
        fields2[3] = new FieldDesc ("age", Variant.type_integer, false);
        
        refs[0] = new ReferenceDesc ("friend");
        refs[1] = new ReferenceDesc ("colleague", false, true);
        refs[2] = new ReferenceDesc ("spouse", true, false);
        
        mdDesc1 = new MetadataDesc ("person", fields1, refs);
        mdDesc2 = new MetadataDesc ("car", fields2);
        
        schema = new MetadataSchema ("test_schema", "Anna");
    }
    
    @Test
    public void testMetadataSchema ()
    {
        String str1 = schema.getName();
        assertEquals(str1, "test_schema");
        
        String str2 = schema.getAuthor ();
        assertEquals(str2, "Anna");
        
        schema.add(mdDesc1);
        schema.add(mdDesc2);
        
        assertEquals(2, schema.size());
        
        MetadataDesc mdDesc3 = schema.findMetadataDesc("person");
        assertEquals("person", mdDesc3.getMetadataName());
        
        FieldDesc fds[] = mdDesc3.getFields();
        assertEquals(3, fds.length);
        
        ReferenceDesc rds[] = mdDesc3.getAllReferenceDescs();
        assertEquals(4, rds.length);
        
        MetadataDesc mdDescs[] = schema.getAll();
        assertEquals(2, mdDescs.length);
        
        String stdName = "vmf://ns.intel.com/vmf/std-dst-schema-1.0";
        
        MetadataSchema std = MetadataSchema.getStdSchema();
        
        assertEquals(stdName, std.getName());
        
        assertEquals(stdName, MetadataSchema.getStdSchemaName ());
    }
    
    @Test
    public void testDeleteByGC()
    {
        schema = null;
        
        fields1 = null;
        fields2 = null;
        
        refs = null;
        
        mdDesc1 = null;
        mdDesc2 = null;
        
        md1 = null;
        md2 = null;
        
        System.gc();
    }
}

@@ -357,20 +357,85 @@
 g.junit.
-Test
+Rule;%0Aimport org.junit.Test;%0Aimport org.junit.rules.ExpectedException
 ;%0A%0Apubli
@@ -3040,32 +3040,669 @@
 ());%0A    %7D%0A    %0A
+    @Rule%0A    public ExpectedException thrown = ExpectedException.none();%0A    %0A    @Test%0A    public void testAddTrown()%0A    %7B%0A        schema.add(mdDesc1);%0A        thrown.expect(com.intel.vmf.VmfException.class);%0A        thrown.expectMessage(%22vmf::Exception: Metadata with same name already exists!%22);%0A        schema.add(mdDesc1);%0A    %7D%0A    %0A    @Test%0A    public void testCreateSchemaTrown()%0A    %7B%0A        thrown.expect(com.intel.vmf.VmfException.class);%0A        thrown.expectMessage(%22vmf::Exception: Schema name can't be empty.%22);%0A        @SuppressWarnings(%22unused%22)%0A        MetadataSchema newSchema = new MetadataSchema(%22%22);%0A    %7D%0A    %0A
     @Test%0A    pu

add tests to VmfMetadataSchemaTest