Package java.io

Examples of java.io.ObjectStreamClass$InterfaceComparator


   * @tests java.io.ObjectStreamClass#lookup(java.lang.Class)
   */
  public void test_lookupLjava_lang_Class() {
    // Test for method java.io.ObjectStreamClass
    // java.io.ObjectStreamClass.lookup(java.lang.Class)
    ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
    assertTrue("lookup returned wrong class: " + osc.getName(), osc
        .getName().equals(
            "tests.api.java.io.ObjectStreamClassTest$DummyClass"));
  }
View Full Code Here


  /**
   * @tests java.io.ObjectStreamClass#toString()
   */
  public void test_toString() {
    // Test for method java.lang.String java.io.ObjectStreamClass.toString()
    ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
    String oscString = osc.toString();
    // The previous test was more specific than the spec so it was replaced
    // with the test below
    assertTrue("toString returned incorrect string: " + osc.toString(),
        oscString.indexOf("serialVersionUID") >= 0
            && oscString.indexOf("999999999999999L") >= 0);
    ;
  }
View Full Code Here

            && oscString.indexOf("999999999999999L") >= 0);
    ;
  }

    public void testSerialization() {
        ObjectStreamClass osc = ObjectStreamClass.lookup(ObjectStreamClass.class);
        assertEquals(0, osc.getFields().length);
    }
View Full Code Here

   
    public void test_specialTypes() {
        Class<?> proxyClass = Proxy.getProxyClass(this.getClass()
                .getClassLoader(), new Class[] { Runnable.class });

        ObjectStreamClass proxyStreamClass = ObjectStreamClass
                .lookup(proxyClass);

        assertEquals("Proxy classes should have zero serialVersionUID", 0,
                proxyStreamClass.getSerialVersionUID());
        ObjectStreamField[] proxyFields = proxyStreamClass.getFields();
        assertEquals("Proxy classes should have no serialized fields", 0,
                proxyFields.length);

        ObjectStreamClass enumStreamClass = ObjectStreamClass
                .lookup(Thread.State.class);

        assertEquals("Enum classes should have zero serialVersionUID", 0,
                enumStreamClass.getSerialVersionUID());
        ObjectStreamField[] enumFields = enumStreamClass.getFields();
        assertEquals("Enum classes should have no serialized fields", 0,
                enumFields.length);
    }
View Full Code Here

        byte[] bytes = baos.toByteArray();
        ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
        ObjectInputStream ois = new ObjectInputStream(bais);
        SerializableObject obj = (SerializableObject) ois.readObject();

        ObjectStreamClass oc = obj.getObjectStreamClass();
        ObjectStreamField field = oc.getField("i");
        assertEquals(Object.class, field.getType());
    }
View Full Code Here

        byte[] bytes = baos.toByteArray();
        ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
        MockObjectInputStream ois = new MockObjectInputStream(bais);
        ois.readObject();

        ObjectStreamClass oc = ois.getObjectStreamClass();
        ObjectStreamField field = oc.getField("i");
        assertEquals(Object.class, field.getType());
    }
View Full Code Here

        ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
        ObjectInputStream ois = new ObjectInputStream(bais);
        SerializableObject2 newObj = (SerializableObject2) ois.readObject();
       
        ObjectInputStream.GetField getField = newObj.getGetField();
        ObjectStreamClass objectStreamClass = getField.getObjectStreamClass();
       
        assertTrue(objectStreamClass.getField("i").isUnshared());
        assertFalse(objectStreamClass.getField("d").isUnshared());
        assertTrue(objectStreamClass.getField("s").isUnshared());
       
        assertEquals(1000, getField.get("i", null));
        assertEquals(SerializableObject2.today, getField.get("d", null));
        assertEquals("Richard", getField.get("s", null));
       
        assertTrue(objectStreamClass.getField("s").getTypeString() == "Ljava/lang/String;");
       
        assertEquals(0, objectStreamClass.getField("d").getOffset());
        assertEquals(1, objectStreamClass.getField("i").getOffset());
        assertEquals(2, objectStreamClass.getField("s").getOffset());
    }
View Full Code Here

        super(in);
    }

    public ObjectStreamClass readClassDescriptor() throws IOException,
            ClassNotFoundException {
        ObjectStreamClass osc = super.readClassDescriptor();
        //To get the ObjectStreamClass of SerializableObject
        if (osc.getSerialVersionUID() == -2953957835918368056L) {
            temp = osc;
        }
        return osc;
    }
View Full Code Here

      ClassNotFoundException {

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStreamWithWriteDesc1 oos = new ObjectOutputStreamWithWriteDesc1(
        baos);
    ObjectStreamClass desc = ObjectStreamClass
    .lookup(TestClassForSerialization.class);
    oos.writeClassDescriptor(desc);
    oos.close();

        byte[] bytes = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
    ObjectIutputStreamWithReadDesc1 ois = new ObjectIutputStreamWithReadDesc1(
        bais);
    Object obj = ois.readClassDescriptor();
    ois.close();
    assertEquals(desc.getClass(), obj.getClass());

        //eof
        bais = new ByteArrayInputStream(bytes);
        ExceptionalBufferedInputStream bis = new ExceptionalBufferedInputStream(
                bais);
View Full Code Here

        }

        @Override
        public ObjectStreamClass readClassDescriptor() throws IOException,
                ClassNotFoundException {
            ObjectStreamClass osc = super.readClassDescriptor();

            if (osc.getName().equals(returnClass.getName())) {
                return ObjectStreamClass.lookup(returnClass);
            }
            return osc;
        }
View Full Code Here

TOP

Related Classes of java.io.ObjectStreamClass$InterfaceComparator

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.