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