@Test
    public void testSetGetPrimitiveTypes() throws Exception {
        StructDataType type = new StructDataType("teststr");
        type.addField(new Field("int", DataType.INT));
        type.addField(new Field("flt", DataType.FLOAT));
        type.addField(new Field("str", DataType.STRING));
        type.addField(new Field("raw", DataType.RAW));
        type.addField(new Field("lng", DataType.LONG));
        type.addField(new Field("dbl", DataType.DOUBLE));
        type.addField(new Field("uri", DataType.URI));
        type.addField(new Field("byt", DataType.BYTE));

        Struct struct = new Struct(type);

        {
            IntegerFieldValue nt = new IntegerFieldValue(544);
            Object o = struct.setFieldValue("int", nt);
            assertNull(o);
            assertEquals(new IntegerFieldValue(544), struct.getFieldValue("int"));
            o = struct.setFieldValue("int", 500);
            assertEquals(nt, o);
            assertFalse(nt.equals(struct.getFieldValue("int")));
        }
        {
            FloatFieldValue flt = new FloatFieldValue(5.44f);
            Object o = struct.setFieldValue("flt", flt);
            assertNull(o);
            assertEquals(flt, struct.getFieldValue("flt"));
            o = struct.setFieldValue("flt", new FloatFieldValue(5.00f));
            assertEquals(flt, o);
            assertFalse(flt.equals(struct.getFieldValue("flt")));
        }
        {
            StringFieldValue string = new StringFieldValue("this is a string");
            Object o = struct.setFieldValue("str", string);
            assertNull(o);
            assertEquals(string, struct.getFieldValue("str"));
            o = struct.setFieldValue("str", "another string");
            assertEquals(string, o);
            assertSame(string, o);
            assertFalse(string.equals(struct.getFieldValue("str")));
        }
        {
            Raw buf = new Raw(ByteBuffer.wrap(new byte[100]));
            Object o = struct.setFieldValue("raw", buf);
            assertNull(o);
            assertEquals(buf, struct.getFieldValue("raw"));
            o = struct.setFieldValue("raw", new Raw(ByteBuffer.wrap(new byte[50])));
            assertEquals(buf, o);
            assertSame(buf, o);
            assertFalse(buf.equals(struct.getFieldValue("raw")));
        }
        {
            LongFieldValue lng = new LongFieldValue(59879879879079L);
            Object o = struct.setFieldValue("lng", lng);
            assertEquals(lng, struct.getFieldValue("lng"));
            o = struct.setFieldValue("lng", new LongFieldValue(23418798734243L));
            assertEquals(lng, o);
            assertFalse(lng.equals(struct.getFieldValue("lng")));
        }
        {
            DoubleFieldValue dbl = new DoubleFieldValue(5.44d);
            Object o = struct.setFieldValue("dbl", dbl);
            assertNull(o);
            assertEquals(dbl, struct.getFieldValue("dbl"));
            o = struct.setFieldValue("dbl", new DoubleFieldValue(5.00d));
            assertEquals(dbl, o);
            assertFalse(dbl.equals(struct.getFieldValue("dbl")));
        }
        {
            UriFieldValue uri = new UriFieldValue("this is a uri");
            Object o = struct.setFieldValue("uri", uri);
            assertNull(o);
            assertEquals(uri, struct.getFieldValue("uri"));
            o = struct.setFieldValue("uri", "another uri");
            assertEquals(uri, o);
            assertSame(uri, o);
            assertFalse(uri.equals(struct.getFieldValue("uri")));
        }
        {
            ByteFieldValue byt = new ByteFieldValue((byte)123);
            Object o = struct.setFieldValue("byt", byt);
            assertNull(o);
            assertEquals(byt, struct.getFieldValue("byt"));
            o = struct.setFieldValue("byt", (byte) 100);
            assertEquals(byt, o);
            assertFalse(byt.equals(struct.getFieldValue("byt")));
        }
    }
@author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
document/src/test/java/com/yahoo/document/datatypes/StructTestCase.java