Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 42590 invoked from network); 20 Sep 2006 08:10:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Sep 2006 08:10:32 -0000 Received: (qmail 95966 invoked by uid 500); 20 Sep 2006 08:10:29 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 95910 invoked by uid 500); 20 Sep 2006 08:10:29 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 95890 invoked by uid 99); 20 Sep 2006 08:10:29 -0000 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Sep 2006 01:10:28 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 9ED201A981A; Wed, 20 Sep 2006 01:10:08 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r448120 - in /incubator/cxf/trunk/rt/core/src: main/java/org/apache/cxf/transport/ test/java/org/apache/cxf/transport/ Date: Wed, 20 Sep 2006 08:10:08 -0000 To: cxf-commits@incubator.apache.org From: ningjiang@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20060920081008.9ED201A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: ningjiang Date: Wed Sep 20 01:10:07 2006 New Revision: 448120 URL: http://svn.apache.org/viewvc?view=rev&rev=448120 Log: [JIRA CXF-99] Fixed the sending data more than 8K broken issue Added: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/transport/ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/transport/CachedOutputStream.java incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/transport/CachedOutputStreamTest.java Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractCachedOutputStream.java Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractCachedOutputStream.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractCachedOutputStream.java?view=diff&rev=448120&r1=448119&r2=448120 ============================================================================== --- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractCachedOutputStream.java (original) +++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractCachedOutputStream.java Wed Sep 20 01:10:07 2006 @@ -91,10 +91,30 @@ * the real output stream * @throws IOException */ - public void resetOut(OutputStream out, boolean copyOldContent) throws IOException { - ByteArrayOutputStream bout = (ByteArrayOutputStream) currentStream; - if (copyOldContent && bout.size() > 0) { - bout.writeTo(out); + public void resetOut(OutputStream out, boolean copyOldContent) throws IOException { + if (inmem) { + ByteArrayOutputStream byteOut = (ByteArrayOutputStream) currentStream; + if (copyOldContent && byteOut.size() > 0) { + byteOut.writeTo(out); + } + } else { + //read the file + currentStream.close(); + FileInputStream fin = new FileInputStream(tempFile); + if (copyOldContent) { + byte[] buffer = new byte[4096]; + int len = 0; + int pos = 0; + while (true) { + len = fin.read(buffer, 0, 4096); + if (len != -1) { + out.write(buffer, 0, len); + pos += len; + } else { + break; + } + } + } } currentStream = out; } Added: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/transport/CachedOutputStream.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/transport/CachedOutputStream.java?view=auto&rev=448120 ============================================================================== --- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/transport/CachedOutputStream.java (added) +++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/transport/CachedOutputStream.java Wed Sep 20 01:10:07 2006 @@ -0,0 +1,46 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cxf.transport; + +import java.io.IOException; + +public class CachedOutputStream extends AbstractCachedOutputStream { + CachedOutputStream() { + super(); + } + + @Override + protected void doClose() throws IOException { + // TODO Auto-generated method stub + + } + + @Override + protected void doFlush() throws IOException { + // TODO Auto-generated method stub + + } + + @Override + protected void onWrite() throws IOException { + // TODO Auto-generated method stub + + } + +} Added: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/transport/CachedOutputStreamTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/transport/CachedOutputStreamTest.java?view=auto&rev=448120 ============================================================================== --- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/transport/CachedOutputStreamTest.java (added) +++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/transport/CachedOutputStreamTest.java Wed Sep 20 01:10:07 2006 @@ -0,0 +1,51 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cxf.transport; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; + + +import junit.framework.TestCase; + +public class CachedOutputStreamTest extends TestCase { + + public void testResetOut() throws IOException { + CachedOutputStream cos = new CachedOutputStream(); + String result = initTestData(16); + cos.write(result.getBytes()); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + cos.resetOut(out, true); + String test = out.toString(); + assertEquals("The test stream content isn't same ", test , result); + } + + String initTestData(int packetSize) { + String temp = "abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+?><[]/0123456789"; + String result = new String(); + for (int i = 0; i < 1024 * packetSize / temp.length(); i++) { + result = result + temp; + } + return result; + } + + +} + +