1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_io.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <com/sun/star/test/XSimpleTest.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/io/XConnectable.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include <cppuhelper/factory.hxx> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> // OWeakObject 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #include <osl/conditn.hxx> 44*cdf0e10cSrcweir #include <osl/mutex.hxx> 45*cdf0e10cSrcweir #include <osl/thread.hxx> 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir #include <string.h> 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir using namespace ::rtl; 50*cdf0e10cSrcweir using namespace ::osl; 51*cdf0e10cSrcweir using namespace ::cppu; 52*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 53*cdf0e10cSrcweir using namespace ::com::sun::star::io; 54*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 55*cdf0e10cSrcweir using namespace ::com::sun::star::test; 56*cdf0e10cSrcweir // streams 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir #include "testfactreg.hxx" 59*cdf0e10cSrcweir #define IMPLEMENTATION_NAME "test.com.sun.star.comp.extensions.stm.Pipe" 60*cdf0e10cSrcweir #define SERVICE_NAME "test.com.sun.star.io.Pipe" 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir class WriteToStreamThread : 64*cdf0e10cSrcweir public Thread 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir public: 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir WriteToStreamThread( Reference< XOutputStream > xOutput , int iMax ) 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir m_output = xOutput; 72*cdf0e10cSrcweir m_iMax = iMax; 73*cdf0e10cSrcweir } 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir virtual ~WriteToStreamThread() {} 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir protected: 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir /// Working method which should be overridden. 81*cdf0e10cSrcweir virtual void SAL_CALL run() { 82*cdf0e10cSrcweir for( int i = 0 ; i < m_iMax ; i ++ ) { 83*cdf0e10cSrcweir m_output->writeBytes( createIntSeq(i) ); 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir m_output->closeOutput(); 86*cdf0e10cSrcweir } 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir /** Called when run() is done. 89*cdf0e10cSrcweir * You might want to override it to do some cleanup. 90*cdf0e10cSrcweir */ 91*cdf0e10cSrcweir virtual void SAL_CALL onTerminated() 92*cdf0e10cSrcweir { 93*cdf0e10cSrcweir delete this; 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir private: 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir Reference < XOutputStream > m_output; 100*cdf0e10cSrcweir int m_iMax; 101*cdf0e10cSrcweir }; 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir class OPipeTest : public WeakImplHelper1 < XSimpleTest > 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir public: 108*cdf0e10cSrcweir OPipeTest( const Reference< XMultiServiceFactory > & rFactory ); 109*cdf0e10cSrcweir ~OPipeTest(); 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir public: // implementation names 112*cdf0e10cSrcweir static Sequence< OUString > getSupportedServiceNames_Static(void) throw(); 113*cdf0e10cSrcweir static OUString getImplementationName_Static() throw(); 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir public: 116*cdf0e10cSrcweir virtual void SAL_CALL testInvariant(const OUString& TestName, const Reference < XInterface >& TestObject) 117*cdf0e10cSrcweir throw ( IllegalArgumentException, RuntimeException) ; 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL test( const OUString& TestName, 120*cdf0e10cSrcweir const Reference < XInterface >& TestObject, 121*cdf0e10cSrcweir sal_Int32 hTestHandle) 122*cdf0e10cSrcweir throw ( IllegalArgumentException, 123*cdf0e10cSrcweir RuntimeException); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir virtual sal_Bool SAL_CALL testPassed(void) throw ( RuntimeException) ; 126*cdf0e10cSrcweir virtual Sequence< OUString > SAL_CALL getErrors(void) throw (RuntimeException) ; 127*cdf0e10cSrcweir virtual Sequence< Any > SAL_CALL getErrorExceptions(void) throw (RuntimeException); 128*cdf0e10cSrcweir virtual Sequence< OUString > SAL_CALL getWarnings(void) throw (RuntimeException); 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir private: 131*cdf0e10cSrcweir void testSimple( const Reference < XInterface > & ); 132*cdf0e10cSrcweir void testBufferResizing( const Reference < XInterface > & ); 133*cdf0e10cSrcweir void testMultithreading( const Reference < XInterface > & ); 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir private: 136*cdf0e10cSrcweir Sequence<Any> m_seqExceptions; 137*cdf0e10cSrcweir Sequence<OUString> m_seqErrors; 138*cdf0e10cSrcweir Sequence<OUString> m_seqWarnings; 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir }; 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir OPipeTest::OPipeTest( const Reference< XMultiServiceFactory > &rFactory ) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir OPipeTest::~OPipeTest() 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir void OPipeTest::testInvariant( const OUString& TestName, const Reference < XInterface >& TestObject ) 157*cdf0e10cSrcweir throw ( IllegalArgumentException, 158*cdf0e10cSrcweir RuntimeException) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir Reference< XServiceInfo > info( TestObject, UNO_QUERY ); 161*cdf0e10cSrcweir ERROR_ASSERT( info.is() , "XServiceInfo not supported !" ); 162*cdf0e10cSrcweir if( info.is() ) 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir ERROR_ASSERT( info->supportsService( TestName ), "XServiceInfo test failed" ); 165*cdf0e10cSrcweir ERROR_ASSERT( ! info->supportsService( 166*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("bla bluzb") ) ), "XServiceInfo test failed" ); 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir sal_Int32 OPipeTest::test( 173*cdf0e10cSrcweir const OUString& TestName, 174*cdf0e10cSrcweir const Reference < XInterface >& TestObject, 175*cdf0e10cSrcweir sal_Int32 hTestHandle) 176*cdf0e10cSrcweir throw ( IllegalArgumentException, RuntimeException) 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir if( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.Pipe") ) == TestName ) { 179*cdf0e10cSrcweir try 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir if( 0 == hTestHandle ) { 182*cdf0e10cSrcweir testInvariant( TestName , TestObject ); 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir else if( 1 == hTestHandle ) { 185*cdf0e10cSrcweir testSimple( TestObject ); 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir else if( 2 == hTestHandle ) { 188*cdf0e10cSrcweir testBufferResizing( TestObject ); 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir else if( 3 == hTestHandle ) { 191*cdf0e10cSrcweir testMultithreading( TestObject ); 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir catch( Exception & e ) 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir OString s = OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ); 197*cdf0e10cSrcweir BUILD_ERROR( 0 , s.getStr() ); 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir catch( ... ) 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir BUILD_ERROR( 0 , "unknown exception (Exception is not base class)" ); 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir hTestHandle ++; 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir if( 4 == hTestHandle ) 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir // all tests finished. 209*cdf0e10cSrcweir hTestHandle = -1; 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir else { 213*cdf0e10cSrcweir throw IllegalArgumentException(); 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir return hTestHandle; 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir sal_Bool OPipeTest::testPassed(void) throw (RuntimeException) 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir return m_seqErrors.getLength() == 0; 223*cdf0e10cSrcweir } 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir Sequence< OUString > OPipeTest::getErrors(void) throw (RuntimeException) 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir return m_seqErrors; 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir Sequence< Any > OPipeTest::getErrorExceptions(void) throw (RuntimeException) 233*cdf0e10cSrcweir { 234*cdf0e10cSrcweir return m_seqExceptions; 235*cdf0e10cSrcweir } 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir Sequence< OUString > OPipeTest::getWarnings(void) throw (RuntimeException) 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir return m_seqWarnings; 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir /*** 245*cdf0e10cSrcweir * the test methods 246*cdf0e10cSrcweir * 247*cdf0e10cSrcweir ****/ 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir void OPipeTest::testSimple( const Reference < XInterface > &r ) 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir Reference< XInputStream > input( r , UNO_QUERY ); 254*cdf0e10cSrcweir Reference < XOutputStream > output( r , UNO_QUERY ); 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir ERROR_ASSERT( input.is() , "queryInterface on XInputStream failed" ); 257*cdf0e10cSrcweir ERROR_ASSERT( output.is() , "queryInterface onXOutputStream failed" ); 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir // basic read/write 260*cdf0e10cSrcweir Sequence<sal_Int8> seqWrite = createSeq( "Hallo, du Ei !" ); 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir Sequence<sal_Int8> seqRead; 263*cdf0e10cSrcweir for( int i = 0 ; i < 5000 ; i ++ ) { 264*cdf0e10cSrcweir output->writeBytes( seqWrite ); 265*cdf0e10cSrcweir input->readBytes( seqRead , input->available() ); 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir ERROR_ASSERT( ! strcmp( (char *) seqWrite.getArray() , (char * )seqRead.getArray() ) , 268*cdf0e10cSrcweir "error during read/write/skip" ); 269*cdf0e10cSrcweir ERROR_ASSERT( 0 == input->available() , 270*cdf0e10cSrcweir "error during read/write/skip" ); 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir // available shouldn't return a negative value 273*cdf0e10cSrcweir input->skipBytes( seqWrite.getLength() - 5 ); 274*cdf0e10cSrcweir ERROR_ASSERT( 0 == input->available() , "wrong available after skip" ); 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir // 5 bytes should be available 277*cdf0e10cSrcweir output->writeBytes( seqWrite ); 278*cdf0e10cSrcweir ERROR_ASSERT( 5 == input->available() , "wrong available after skip/write " ); 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir input->readBytes( seqRead , 5 ); 281*cdf0e10cSrcweir ERROR_ASSERT( ! strcmp( (char*) seqRead.getArray() , 282*cdf0e10cSrcweir (char*) &( seqWrite.getArray()[seqWrite.getLength()-5] ) ), 283*cdf0e10cSrcweir "write/read mismatich" ); 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir } 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir output->writeBytes( seqWrite ); 288*cdf0e10cSrcweir ERROR_ASSERT( seqWrite.getLength() == input->available(), "wrong available() after write" ); 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir ERROR_ASSERT( 10 == input->readSomeBytes( seqRead , 10 ) , "maximal number of bytes ignored" ); 291*cdf0e10cSrcweir ERROR_ASSERT( seqWrite.getLength() -10 == input->readSomeBytes( seqRead , 100 ) , 292*cdf0e10cSrcweir "something wrong with readSomeBytes" ); 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir output->closeOutput(); 296*cdf0e10cSrcweir try{ 297*cdf0e10cSrcweir output->writeBytes( Sequence<sal_Int8> (100) ); 298*cdf0e10cSrcweir ERROR_ASSERT( 0 , "writing on a closed stream does not cause an exception" ); 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir catch (IOException & ) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir } 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir ERROR_ASSERT(! input->readBytes( seqRead , 1 ), "eof not found !" ); 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir input->closeInput(); 307*cdf0e10cSrcweir try 308*cdf0e10cSrcweir { 309*cdf0e10cSrcweir input->readBytes( seqRead , 1 ); 310*cdf0e10cSrcweir ERROR_ASSERT( 0 , "reading from a closed stream does not cause an exception" ); 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir catch( IOException & ) { 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir try 316*cdf0e10cSrcweir { 317*cdf0e10cSrcweir input->available( ); 318*cdf0e10cSrcweir ERROR_ASSERT( 0 , "calling available from a closed stream should thrown an io exception" ); 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir catch( IOException & ) 321*cdf0e10cSrcweir { 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir try 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir input->skipBytes(42 ); 327*cdf0e10cSrcweir ERROR_ASSERT( 0 , "calling available from a closed stream should thrown an io exception" ); 328*cdf0e10cSrcweir } 329*cdf0e10cSrcweir catch( IOException & ) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir } 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir void OPipeTest::testBufferResizing( const Reference < XInterface > &r ) 336*cdf0e10cSrcweir { 337*cdf0e10cSrcweir int i; 338*cdf0e10cSrcweir int iMax = 20000; 339*cdf0e10cSrcweir Reference< XInputStream > input( r , UNO_QUERY ); 340*cdf0e10cSrcweir Reference < XOutputStream > output( r , UNO_QUERY ); 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir ERROR_ASSERT( input.is() , "queryInterface on XInputStream failed" ); 343*cdf0e10cSrcweir ERROR_ASSERT( output.is() , "queryInterface on XOutputStream failed" ); 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir Sequence<sal_Int8> seqRead; 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir // this is just to better check the 348*cdf0e10cSrcweir // internal buffers 349*cdf0e10cSrcweir output->writeBytes( Sequence<sal_Int8>(100) ); 350*cdf0e10cSrcweir Sequence< sal_Int8 > dummy; 351*cdf0e10cSrcweir input->readBytes( dummy , 100); 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir for( i = 0 ; i < iMax ; i ++ ) { 354*cdf0e10cSrcweir output->writeBytes( createIntSeq( i ) ); 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir for( i = 0 ; i < iMax ; i ++ ) { 358*cdf0e10cSrcweir input->readBytes( seqRead, createIntSeq(i).getLength() ); 359*cdf0e10cSrcweir ERROR_ASSERT( ! strcmp( (char*) seqRead.getArray() , 360*cdf0e10cSrcweir (char*) createIntSeq(i).getArray() ) , 361*cdf0e10cSrcweir "written/read mismatch\n" ); 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir output->closeOutput(); 365*cdf0e10cSrcweir ERROR_ASSERT( ! input->readBytes( seqRead , 1 ) , "eof not reached !" ); 366*cdf0e10cSrcweir input->closeInput(); 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir void OPipeTest::testMultithreading( const Reference < XInterface > &r ) 372*cdf0e10cSrcweir { 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir int i; 375*cdf0e10cSrcweir int iMax = 30000; 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir Reference< XInputStream > input( r , UNO_QUERY ); 378*cdf0e10cSrcweir Reference < XOutputStream > output( r , UNO_QUERY ); 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir ERROR_ASSERT( input.is() , "queryInterface on XInputStream failed" ); 381*cdf0e10cSrcweir ERROR_ASSERT( output.is() , "queryInterface on XOutputStream failed" ); 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir Sequence<sal_Int8> seqRead; 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir // deletes itself 386*cdf0e10cSrcweir Thread *p = new WriteToStreamThread( output, iMax ); 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir ERROR_ASSERT( p , "couldn't create thread for testing !\n" ); 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir p->create(); 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir for( i = 0 ; sal_True ; i ++ ) { 393*cdf0e10cSrcweir if( 0 == input->readBytes( seqRead, createIntSeq(i).getLength() ) ) { 394*cdf0e10cSrcweir // eof reached ! 395*cdf0e10cSrcweir break; 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir ERROR_ASSERT( ! strcmp( (char*) seqRead.getArray() , 399*cdf0e10cSrcweir (char*) createIntSeq(i).getArray() ) , 400*cdf0e10cSrcweir "written/read mismatch\n" ); 401*cdf0e10cSrcweir } 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir ERROR_ASSERT( i == iMax , "less elements read than written !"); 404*cdf0e10cSrcweir input->closeInput(); 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir /** 410*cdf0e10cSrcweir * for external binding 411*cdf0e10cSrcweir * 412*cdf0e10cSrcweir * 413*cdf0e10cSrcweir **/ 414*cdf0e10cSrcweir Reference < XInterface > SAL_CALL OPipeTest_CreateInstance( const Reference< XMultiServiceFactory> & rSMgr ) throw (Exception) 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir OPipeTest *p = new OPipeTest( rSMgr ); 417*cdf0e10cSrcweir Reference< XInterface > x ( SAL_STATIC_CAST( OWeakObject * , p ) ); 418*cdf0e10cSrcweir return x; 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir Sequence<OUString> OPipeTest_getSupportedServiceNames(void) throw() 424*cdf0e10cSrcweir { 425*cdf0e10cSrcweir Sequence<OUString> aRet(1); 426*cdf0e10cSrcweir aRet.getArray()[0] = OPipeTest_getServiceName(); 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir return aRet; 429*cdf0e10cSrcweir } 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir OUString OPipeTest_getServiceName() throw() 432*cdf0e10cSrcweir { 433*cdf0e10cSrcweir return OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME ) ); 434*cdf0e10cSrcweir } 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir OUString OPipeTest_getImplementationName() throw() 437*cdf0e10cSrcweir { 438*cdf0e10cSrcweir return OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) ); 439*cdf0e10cSrcweir } 440