Package com.thoughtworks.acceptance.objects

Examples of com.thoughtworks.acceptance.objects.Software


        xstream.alias("software", Software.class);

        ObjectOutputStream oos = xstream.createObjectOutputStream(writer);
        oos.writeInt(123);
        oos.writeObject("hello");
        oos.writeObject(new Software("tw", "xs"));
        oos.close();

        String expectedXml = ""
            + "<object-stream>\n"
            + "  <int>123</int>\n"
            + "  <string>hello</string>\n"
            + "  <software>\n"
            + "    <vendor>tw</vendor>\n"
            + "    <name>xs</name>\n"
            + "  </software>\n"
            + "</object-stream>";

        assertEquals(expectedXml, writer.toString());

        ObjectInputStream ois = xstream.createObjectInputStream(new StringReader(writer
            .toString()));
        assertEquals(123, ois.readInt());
        assertEquals("hello", ois.readObject());
        assertEquals(new Software("tw", "xs"), ois.readObject());

        try {
            ois.readObject(); // As far as I can see this is the only clue the
                                // ObjectInputStream gives that it's done.
            fail("Expected EOFException");
View Full Code Here


        xstream.alias("software", Software.class);

        ObjectOutputStream oos = xstream.createObjectOutputStream(writer);
        oos.writeInt(123);
        oos.writeObject("hello");
        oos.writeObject(new Software("tw", "xs"));
        oos.flush();
        oos.close();

        byte[] data = baos.toByteArray();
        assertTrue("Too less data: " + data.length, data.length > 2);

        ObjectInputStream ois = xstream.createObjectInputStream(new InputStreamReader(
            new InflaterInputStream(new ByteArrayInputStream(data), new Inflater()), "UTF-8"));
        assertEquals(123, ois.readInt());
        assertEquals("hello", ois.readObject());
        assertEquals(new Software("tw", "xs"), ois.readObject());

        try {
            ois.readObject(); // As far as I can see this is the only clue the
                                // ObjectInputStream gives that it's done.
            fail("Expected EOFException");
View Full Code Here

        xstream.registerLocalConverter(SampleLists.class, "good", new PersistenceArrayListConverter());
       
        SampleLists lists = new SampleLists();
        lists.good.add("Guilherme");
        lists.good.add(new Integer(1970));
        lists.good.add(new Software("Codehaus", "XStream"));

        String expected = "" +
                "<lists>\n" +
                "  <good>" + dir.getPath() + "</good>\n" +
                "  <bad class=\"list\"/>\n" +
View Full Code Here

    private void assertBothWays() {

        xstream.alias("software", Software.class);

        final Software sw = new Software("jw", "xstr");
        final String xml = "<software>\n"
                + "  <vendor>jw</vendor>\n"
                + "  <name>xstr</name>\n"
                + "</software>";

        String resultXml = xstream.toXML(sw);
        assertEquals(xml, resultXml);
        Object resultRoot = xstream.fromXML(resultXml);
        if (!sw.equals(resultRoot)) {
            assertEquals("Object deserialization failed", "DESERIALIZED OBJECT\n"
                    + xstream.toXML(sw), "DESERIALIZED OBJECT\n" + xstream.toXML(resultRoot));
        }
    }
View Full Code Here

        assertBothWaysNormalized(map, expected, "map", "entry", "string[1]");
    }

    public void testMapCanContainCustomObjects() {
        Map map = new HashMap();
        map.put(new Software("microsoft", "windows"), new Hardware("x86", "p4"));

        xstream.alias("software", Software.class);
        xstream.alias("hardware", Hardware.class);

        String expected = "" +
View Full Code Here

            "    <arch>x86</arch>\n" +
            "    <name>p4</name>\n" +
            "  </v>\n" +
            "</java.util.Collections_-SingletonMap>";

        assertBothWays(Collections.singletonMap(new Software("microsoft", "windows"), new Hardware("x86", "p4")), expected);
    }
View Full Code Here

        }

    }

    public void testWritesCustomFieldsToStream() {
        ObjectWithCustomSerialization obj = new ObjectWithCustomSerialization(1, 2, "hello", new Software("tw", "xs"));
        xstream.alias("custom", ObjectWithCustomSerialization.class);
        xstream.alias("software", Software.class);

        String expectedXml = ""
                + "<custom serialization=\"custom\">\n"
View Full Code Here

    public void testAllowsNamedFields() {
        ObjectWithNamedFields obj = new ObjectWithNamedFields();
        obj.name = "Joe";
        obj.number = 99;
        obj.someSoftware = new Software("tw", "xs");
        obj.polymorphic = new Hardware("small", "ipod");
        obj.nothing = null;

        xstream.alias("with-named-fields", ObjectWithNamedFields.class);
        xstream.alias("software", Software.class);
View Full Code Here

                + "</with-named-fields>";

        ObjectWithNamedFields result = (ObjectWithNamedFields) xstream.fromXML(inputXml);
        assertEquals(-1, result.number);
        assertEquals("unknown", result.name);
        assertEquals(new Software("tw", "xs"), result.someSoftware);
    }
View Full Code Here

    }

    public void testCustomStreamWithNestedCustomStream() {
        ObjectWithNamedFields outer = new ObjectWithNamedFields();
        outer.name = "Joe";
        outer.someSoftware = new Software("tw", "xs");
        outer.nothing = null;

        ObjectWithNamedFields inner = new ObjectWithNamedFields();
        inner.name = "Thing";
View Full Code Here

TOP

Related Classes of com.thoughtworks.acceptance.objects.Software

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.