1/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package libcore.java.io;
18
19import java.io.ByteArrayInputStream;
20import java.io.ByteArrayOutputStream;
21import java.io.IOException;
22import java.io.ObjectInputStream;
23import java.io.ObjectOutputStream;
24import java.io.Serializable;
25import junit.framework.TestCase;
26
27/**
28 * Tests serialization of user-level classes.
29 */
30public class OldAndroidSerializationTest extends TestCase {
31
32    static class MySerializable implements Serializable {}
33
34    public void testSerialization() throws IOException, ClassNotFoundException {
35        ByteArrayOutputStream bout = new ByteArrayOutputStream();
36        ObjectOutputStream oout = new ObjectOutputStream(bout);
37        oout.writeObject(new MySerializable());
38        oout.close();
39
40        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
41        Object o = new ObjectInputStream(bin).readObject();
42        assertTrue(o instanceof MySerializable);
43    }
44}
45