Search in sources :

Example 1 with Person

use of com.alibaba.dubbo.common.model.Person in project dubbo by alibaba.

the class AbstractSerializationPersionFailTest method test_StringPersonListMap.

@Test
public void test_StringPersonListMap() throws Exception {
    Map<String, List<Person>> args = new HashMap<String, List<Person>>();
    List<Person> sublist = new ArrayList<Person>();
    sublist.add(new Person());
    args.put("1", sublist);
    try {
        ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
        objectOutput.writeObject(args);
        fail();
    } catch (NotSerializableException expected) {
    } catch (IllegalStateException expected) {
        assertThat(expected.getMessage(), containsString("Serialized class com.alibaba.dubbo.common.model.Person must implement java.io.Serializable"));
    }
}
Also used : NotSerializableException(java.io.NotSerializableException) ObjectOutput(com.alibaba.dubbo.common.serialize.ObjectOutput) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) JUnitMatchers.containsString(org.junit.matchers.JUnitMatchers.containsString) Person(com.alibaba.dubbo.common.model.Person) Test(org.junit.Test)

Example 2 with Person

use of com.alibaba.dubbo.common.model.Person in project dubbo by alibaba.

the class AbstractSerializationPersionFailTest method test_IntPersonMap.

@Test
public void test_IntPersonMap() throws Exception {
    Map<Integer, Person> args = new HashMap<Integer, Person>();
    args.put(1, new Person());
    try {
        ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
        objectOutput.writeObject(args);
        fail();
    } catch (NotSerializableException expected) {
    } catch (IllegalStateException expected) {
        assertThat(expected.getMessage(), containsString("Serialized class com.alibaba.dubbo.common.model.Person must implement java.io.Serializable"));
    }
}
Also used : NotSerializableException(java.io.NotSerializableException) ObjectOutput(com.alibaba.dubbo.common.serialize.ObjectOutput) HashMap(java.util.HashMap) Person(com.alibaba.dubbo.common.model.Person) Test(org.junit.Test)

Example 3 with Person

use of com.alibaba.dubbo.common.model.Person in project dubbo by alibaba.

the class AbstractSerializationPersionFailTest method test_Person.

@Test
public void test_Person() throws Exception {
    try {
        ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
        objectOutput.writeObject(new Person());
        fail();
    } catch (NotSerializableException expected) {
    } catch (IllegalStateException expected) {
        assertThat(expected.getMessage(), containsString("Serialized class com.alibaba.dubbo.common.model.Person must implement java.io.Serializable"));
    }
}
Also used : NotSerializableException(java.io.NotSerializableException) ObjectOutput(com.alibaba.dubbo.common.serialize.ObjectOutput) Person(com.alibaba.dubbo.common.model.Person) Test(org.junit.Test)

Example 4 with Person

use of com.alibaba.dubbo.common.model.Person in project dubbo by alibaba.

the class AbstractSerializationPersionFailTest method test_PersonSet.

@Test
public void test_PersonSet() throws Exception {
    Set<Person> args = new HashSet<Person>();
    args.add(new Person());
    try {
        ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
        objectOutput.writeObject(args);
        fail();
    } catch (NotSerializableException expected) {
    } catch (IllegalStateException expected) {
        assertThat(expected.getMessage(), containsString("Serialized class com.alibaba.dubbo.common.model.Person must implement java.io.Serializable"));
    }
}
Also used : NotSerializableException(java.io.NotSerializableException) ObjectOutput(com.alibaba.dubbo.common.serialize.ObjectOutput) Person(com.alibaba.dubbo.common.model.Person) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 5 with Person

use of com.alibaba.dubbo.common.model.Person in project dubbo by alibaba.

the class AbstractSerializationPersionOkTest method test_PersonSet.

@Test
public void test_PersonSet() throws Exception {
    Set<Person> args = new HashSet<Person>();
    args.add(new Person());
    assertObject(args);
}
Also used : Person(com.alibaba.dubbo.common.model.Person) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Person (com.alibaba.dubbo.common.model.Person)18 Test (org.junit.Test)18 ArrayList (java.util.ArrayList)9 ObjectOutput (com.alibaba.dubbo.common.serialize.ObjectOutput)7 NotSerializableException (java.io.NotSerializableException)7 HashMap (java.util.HashMap)7 List (java.util.List)6 SerializablePerson (com.alibaba.dubbo.common.model.SerializablePerson)5 BigPerson (com.alibaba.dubbo.common.model.person.BigPerson)5 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 JUnitMatchers.containsString (org.junit.matchers.JUnitMatchers.containsString)2 Type (java.lang.reflect.Type)1 LinkedHashMap (java.util.LinkedHashMap)1