19559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes/*
29559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes * Copyright (C) 2010 The Android Open Source Project
39559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes *
49559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes * Licensed under the Apache License, Version 2.0 (the "License");
59559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes * you may not use this file except in compliance with the License.
69559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes * You may obtain a copy of the License at
79559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes *
89559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes *      http://www.apache.org/licenses/LICENSE-2.0
99559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes *
109559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes * Unless required by applicable law or agreed to in writing, software
119559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes * distributed under the License is distributed on an "AS IS" BASIS,
129559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes * See the License for the specific language governing permissions and
149559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes * limitations under the License.
159559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes */
169559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes
179559e748729ef1deb6400f31d0407543cbff3566Elliott Hughespackage libcore.java.io;
189559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes
199559e748729ef1deb6400f31d0407543cbff3566Elliott Hughesimport java.io.ByteArrayOutputStream;
209559e748729ef1deb6400f31d0407543cbff3566Elliott Hughesimport java.io.ObjectOutputStream;
219559e748729ef1deb6400f31d0407543cbff3566Elliott Hughesimport junit.framework.TestCase;
229559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes
239559e748729ef1deb6400f31d0407543cbff3566Elliott Hughespublic final class ObjectOutputStreamTest extends TestCase {
249559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes    public void testLongString() throws Exception {
259559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes        // Most modified UTF-8 is limited to 64KiB, but serialized strings can have an 8-byte
269559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes        // length, so this should never throw java.io.UTFDataFormatException...
279559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes        StringBuilder sb = new StringBuilder();
289559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes        for (int i = 0; i < 64*1024 * 2; ++i) {
299559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes            sb.append('a');
309559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes        }
319559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes        String s = sb.toString();
329559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes        ObjectOutputStream os = new ObjectOutputStream(new ByteArrayOutputStream());
339559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes        os.writeObject(s);
349559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes    }
359559e748729ef1deb6400f31d0407543cbff3566Elliott Hughes}
36