diff options
author | Michael Stahl <mstahl@redhat.com> | 2012-01-28 20:57:40 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-01-28 20:57:40 +0100 |
commit | 2716f7dce26f16a2b677c178aa7d01cea096ae47 (patch) | |
tree | 9e9f67205cd5b72f1031721273e1534a3a1e5b0f /io/test | |
parent | 10ac9e750447fd57e3cef7993b0ad6c6538d6269 (diff) |
replace obsolete "master" branch with README that points at new repoHEADmaster-deletedmaster
Diffstat (limited to 'io/test')
-rw-r--r-- | io/test/makefile.mk | 92 | ||||
-rw-r--r-- | io/test/stm/datatest.cxx | 1113 | ||||
-rw-r--r-- | io/test/stm/exports.dxp | 2 | ||||
-rw-r--r-- | io/test/stm/makefile.mk | 99 | ||||
-rw-r--r-- | io/test/stm/marktest.cxx | 680 | ||||
-rw-r--r-- | io/test/stm/pipetest.cxx | 442 | ||||
-rw-r--r-- | io/test/stm/pumptest.cxx | 452 | ||||
-rw-r--r-- | io/test/stm/testfactreg.cxx | 211 | ||||
-rw-r--r-- | io/test/stm/testfactreg.hxx | 122 | ||||
-rw-r--r-- | io/test/testcomponent.cxx | 220 | ||||
-rw-r--r-- | io/test/testconnection.cxx | 285 |
11 files changed, 0 insertions, 3718 deletions
diff --git a/io/test/makefile.mk b/io/test/makefile.mk deleted file mode 100644 index e35f33622..000000000 --- a/io/test/makefile.mk +++ /dev/null @@ -1,92 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=.. - -PRJNAME=extensions -TARGET=workben -LIBTARGET=NO - -TARGETTYPE=CUI -ENABLE_EXCEPTIONS=TRUE - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk -.IF "$(L10N_framework)"=="" -# --- Files -------------------------------------------------------- - -OBJFILES= $(OBJ)$/testcomponent.obj \ - $(OBJ)$/testconnection.obj - -UNOUCRDEP=$(SOLARBINDIR)$/udkapi.rdb -UNOUCRRDB=$(SOLARBINDIR)$/udkapi.rdb - -# output directory (one dir for each project) -UNOUCROUT=$(OUT)$/inc - -UNOTYPES = com.sun.star.connection.XConnector \ - com.sun.star.connection.XAcceptor \ - com.sun.star.registry.XImplementationRegistration \ - com.sun.star.lang.XComponent \ - com.sun.star.lang.XSingleServiceFactory \ - com.sun.star.lang.XMultiServiceFactory \ - com.sun.star.test.XSimpleTest \ - com.sun.star.lang.XSingleComponentFactory \ - com.sun.star.lang.XMultiComponentFactory - - -# -# std testcomponent -# - -APP1TARGET = testcomponent -APP1OBJS = $(OBJ)$/testcomponent.obj -APP1STDLIBS = $(SALLIB) \ - $(CPPULIB)\ - $(CPPUHELPERLIB) - -APP2TARGET = testconnection -APP2OBJS = $(OBJ)$/testconnection.obj -APP2STDLIBS = $(SALLIB) \ - $(CPPULIB) \ - $(CPPUHELPERLIB) - - - -# --- Targets ------------------------------------------------------ - -ALL : $(BIN)$/applicat.rdb \ - ALLTAR - -$(BIN)$/applicat.rdb: $(SOLARBINDIR)$/udkapi.rdb - rm -f $@ - regmerge $@ / $? - -.ENDIF # L10N_framework - -.INCLUDE : target.mk diff --git a/io/test/stm/datatest.cxx b/io/test/stm/datatest.cxx deleted file mode 100644 index f9fc2f6c8..000000000 --- a/io/test/stm/datatest.cxx +++ /dev/null @@ -1,1113 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_io.hxx" - -#include <stdio.h> - -#include <com/sun/star/test/XSimpleTest.hpp> -#include <com/sun/star/io/XActiveDataSink.hpp> -#include <com/sun/star/io/XActiveDataSource.hpp> -#include <com/sun/star/io/XObjectInputStream.hpp> -#include <com/sun/star/io/XObjectOutputStream.hpp> -#include <com/sun/star/io/XMarkableStream.hpp> -#include <com/sun/star/io/XConnectable.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/lang/WrappedTargetException.hpp> - -#include <com/sun/star/lang/IllegalArgumentException.hpp> - -#include <com/sun/star/lang/XServiceInfo.hpp> - -#include <cppuhelper/factory.hxx> - -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implbase2.hxx> - -#include <osl/conditn.hxx> -#include <osl/mutex.hxx> - -#include <string.h> - -using namespace ::rtl; -using namespace ::osl; -using namespace ::cppu; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::io; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::test; -using namespace ::com::sun::star::beans; -// streams - -#include "testfactreg.hxx" - -#define DATASTREAM_TEST_MAX_HANDLE 1 - -/**** -* The following test class tests XDataInputStream and XDataOutputStream at equal terms, -* so when errors occur, it may be in either one implementation. -* The class also uses stardiv.uno.io.pipe. If problems occur, make sure to run also the -* pipe test routines ( test.com.sun.star.io.pipe ). -* -* -*****/ - -class ODataStreamTest : - public WeakImplHelper1< XSimpleTest > -{ -public: - ODataStreamTest( const Reference < XMultiServiceFactory > & rFactory ) : - m_rFactory( rFactory ) - {} - -public: - virtual void SAL_CALL testInvariant(const OUString& TestName, const Reference < XInterface >& TestObject) - throw ( IllegalArgumentException, - RuntimeException); - - virtual sal_Int32 SAL_CALL test( const OUString& TestName, - const Reference < XInterface >& TestObject, - sal_Int32 hTestHandle) - throw ( IllegalArgumentException, - RuntimeException); - - virtual sal_Bool SAL_CALL testPassed(void) throw ( RuntimeException); - virtual Sequence< OUString > SAL_CALL getErrors(void) throw (RuntimeException); - virtual Sequence< Any > SAL_CALL getErrorExceptions(void) throw (RuntimeException); - virtual Sequence< OUString > SAL_CALL getWarnings(void) throw (RuntimeException); - -private: - void testSimple( const Reference < XDataInputStream > & , const Reference < XDataOutputStream > &); - -protected: - Sequence<Any> m_seqExceptions; - Sequence<OUString> m_seqErrors; - Sequence<OUString> m_seqWarnings; - - Reference < XMultiServiceFactory > m_rFactory; -}; - - - - -void ODataStreamTest::testInvariant( - const OUString& TestName, - const Reference < XInterface >& TestObject ) - throw ( IllegalArgumentException, - RuntimeException) -{ - if( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.DataInputStream")) == TestName ) { - Reference < XConnectable > connect( TestObject , UNO_QUERY ); - Reference < XActiveDataSink > active( TestObject , UNO_QUERY ); - Reference < XInputStream > input( TestObject , UNO_QUERY ); - Reference < XDataInputStream > dataInput( TestObject , UNO_QUERY ); - - WARNING_ASSERT( connect.is(), "XConnectable cannot be queried" ); - WARNING_ASSERT( active.is() , "XActiveDataSink cannot be queried" ); - ERROR_ASSERT( input.is() , "XInputStream cannot be queried" ); - ERROR_ASSERT( dataInput.is() , "XDataInputStream cannot be queried" ); - - - } - else if( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.DataInputStream")) == TestName ) { - Reference < XConnectable > connect( TestObject , UNO_QUERY ); - Reference < XActiveDataSource > active( TestObject , UNO_QUERY ); - Reference < XOutputStream > output( TestObject , UNO_QUERY ); - Reference < XDataOutputStream > dataOutput( TestObject , UNO_QUERY ); - - WARNING_ASSERT( connect.is(), "XConnectable cannot be queried" ); - WARNING_ASSERT( active.is() , "XActiveDataSink cannot be queried" ); - ERROR_ASSERT( output.is() , "XInputStream cannot be queried" ); - ERROR_ASSERT( dataOutput.is(), "XDataInputStream cannot be queried" ); - - } - - Reference < XServiceInfo > info( TestObject, UNO_QUERY ); - ERROR_ASSERT( info.is() , "XServiceInfo not supported !" ); - if( info.is() ) - { - ERROR_ASSERT( info->supportsService( TestName ), "XServiceInfo test failed" ); - ERROR_ASSERT( ! info->supportsService( OUString(RTL_CONSTASCII_USTRINGPARAM("bla bluzb")) ) , "XServiceInfo test failed" ); - } - -} - - -sal_Int32 ODataStreamTest::test( - const OUString& TestName, - const Reference < XInterface >& TestObject, - sal_Int32 hTestHandle) - throw ( IllegalArgumentException, - RuntimeException) -{ - if( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.DataInputStream")) == TestName || - OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.DataOutputStream")) == TestName ) { - - try - { - if( 0 == hTestHandle ) { - testInvariant( TestName , TestObject ); - } - else { - Reference <XActiveDataSink > rSink( TestObject, UNO_QUERY ); - Reference <XActiveDataSource > rSource( TestObject , UNO_QUERY ); - - Reference < XDataInputStream > rInput( TestObject , UNO_QUERY ); - Reference < XDataOutputStream > rOutput( TestObject , UNO_QUERY ); - - - Reference < XInterface > x = m_rFactory->createInstance( - OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.Pipe" ))); - - Reference < XInputStream > rPipeInput( x , UNO_QUERY ); - Reference < XOutputStream > rPipeOutput( x , UNO_QUERY ); - - if( ! rSink.is() ) { - x = m_rFactory->createInstance( - OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.DataInputStream")) ); - rInput = Reference < XDataInputStream > ( x , UNO_QUERY); - rSink = Reference< XActiveDataSink > ( x , UNO_QUERY ); - } - else if ( !rSource.is() ) - { - x = m_rFactory->createInstance( - OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.DataOutputStream") ) ); - rOutput = Reference< XDataOutputStream > ( x , UNO_QUERY ); - rSource = Reference< XActiveDataSource > ( x, UNO_QUERY ); - } - - OSL_ASSERT( rPipeInput.is() ); - OSL_ASSERT( rPipeOutput.is() ); - rSink->setInputStream( rPipeInput ); - rSource->setOutputStream( rPipeOutput ); - - OSL_ASSERT( rSink->getInputStream().is() ); - OSL_ASSERT( rSource->getOutputStream().is() ); - - if( 1 == hTestHandle ) { - testSimple( rInput , rOutput ); - } - } - } - catch( Exception & e ) - { - OString o = OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ); - BUILD_ERROR( 0 , o.getStr() ); - } - catch( ... ) - { - BUILD_ERROR( 0 , "unknown exception (Exception is not base class)" ); - } - - hTestHandle ++; - - if( hTestHandle >= 2) { - // all tests finished. - hTestHandle = -1; - } - } - else { - BUILD_ERROR( 0 , "service not supported by test." ); - } - return hTestHandle; -} - - - -sal_Bool ODataStreamTest::testPassed(void) throw (RuntimeException) -{ - return m_seqErrors.getLength() == 0; -} - - -Sequence< OUString > ODataStreamTest::getErrors(void) throw (RuntimeException) -{ - return m_seqErrors; -} - - -Sequence< Any > ODataStreamTest::getErrorExceptions(void) throw (RuntimeException) -{ - return m_seqExceptions; -} - - -Sequence< OUString > ODataStreamTest::getWarnings(void) throw (RuntimeException) -{ - return m_seqWarnings; -} - -void ODataStreamTest::testSimple( const Reference < XDataInputStream > &rInput, - const Reference < XDataOutputStream > &rOutput ) -{ - rOutput->writeLong( 0x34ff3c ); - rOutput->writeLong( 0x34ff3d ); - rOutput->writeLong( -1027 ); - - ERROR_ASSERT( 0x34ff3c == rInput->readLong() , "long read/write mismatch" ); - ERROR_ASSERT( 0x34ff3d == rInput->readLong() , "long read/write mismatch" ); - ERROR_ASSERT( -1027 == rInput->readLong() , "long read/write mismatch" ); - - rOutput->writeByte( 0x77 ); - ERROR_ASSERT( 0x77 == rInput->readByte() , "byte read/write mismatch" ); - - rOutput->writeBoolean( 25 ); - ERROR_ASSERT( rInput->readBoolean() , "boolean read/write mismatch" ); - - rOutput->writeBoolean( sal_False ); - ERROR_ASSERT( ! rInput->readBoolean() , "boolean read/write mismatch" ); - - rOutput->writeFloat( (float) 42.42 ); - ERROR_ASSERT( rInput->readFloat() == ((float)42.42) , "float read/write mismatch" ); - - rOutput->writeDouble( (double) 42.42 ); - ERROR_ASSERT( rInput->readDouble() == 42.42 , "double read/write mismatch" ); - - rOutput->writeHyper( 0x123456789abcdefLL ); - ERROR_ASSERT( rInput->readHyper() == 0x123456789abcdefLL , "int64 read/write mismatch" ); - - rOutput->writeUTF( OUString(RTL_CONSTASCII_USTRINGPARAM("Live long and prosper !")) ); - ERROR_ASSERT( rInput->readUTF() == OUString(RTL_CONSTASCII_USTRINGPARAM("Live long and prosper !")) , - "UTF read/write mismatch" ); - - Sequence<sal_Unicode> wc(0x10001); - for( int i = 0 ; i < 0x10000 ; i ++ ) { - wc.getArray()[i] = L'c'; - } - wc.getArray()[0x10000] = 0; - OUString str( wc.getArray() , 0x10000 ); - rOutput->writeUTF( str ); - ERROR_ASSERT( rInput->readUTF() == str , "error reading 64k block" ); - - rOutput->closeOutput(); - try - { - rInput->readLong(); - ERROR_ASSERT( 0 , "eof-exception does not occur !" ); - } - catch ( IOException & ) - { - //ok - } - catch( ... ) - { - ERROR_ASSERT( 0 , "wrong exception after reading beyond eof" ); - } - - Sequence<sal_Int8> dummy (1); - ERROR_ASSERT( ! rInput->readBytes( dummy , 1 ), - "stream must be on eof !" ); - - rInput->closeInput(); - - try - { - rOutput->writeByte( 1 ); - ERROR_ASSERT( 0 , "writing still possible though chain must be interrupted" ); - } - catch( IOException & ) - { - // ok - } - catch( ... ) { - ERROR_ASSERT( 0 , "IOException expected, but another exception was thrown" ); - } - -} - - - -/** -* for external binding -* -* -**/ -Reference < XInterface > SAL_CALL ODataStreamTest_CreateInstance( const Reference < XMultiServiceFactory > & rSMgr ) throw(Exception) -{ - ODataStreamTest *p = new ODataStreamTest( rSMgr ); - return Reference < XInterface > ( SAL_STATIC_CAST( OWeakObject * , p ) ); -} - -Sequence<OUString> ODataStreamTest_getSupportedServiceNames( int i) throw () -{ - Sequence<OUString> aRet(1); - - aRet.getArray()[0] = ODataStreamTest_getImplementationName( i); - - - return aRet; -} - -OUString ODataStreamTest_getServiceName( int i) throw () -{ - if( 1 == i ) { - return OUString( RTL_CONSTASCII_USTRINGPARAM("test.com.sun.star.io.DataInputStream" )); - } - else { - return OUString( RTL_CONSTASCII_USTRINGPARAM("test.com.sun.star.io.DataOutputStream" )); - } -} - -OUString ODataStreamTest_getImplementationName( int i) throw () -{ - if( 1 == i ) { - return OUString( - RTL_CONSTASCII_USTRINGPARAM("test.com.sun.star.comp.extensions.stm.DataInputStream") ); - } - else { - return OUString( RTL_CONSTASCII_USTRINGPARAM( - "test.com.sun.star.comp.extensions.stm.DataOutputStream" ) ); - } -} - -class MyPersistObject : public WeakImplHelper2< XPersistObject , XPropertySet > -{ -public: - MyPersistObject( ) : m_sServiceName( OMyPersistObject_getServiceName() ) , - m_l( -392 ), - m_f( 7883.2 ), - m_d( -123923.5 ), - m_b( sal_True ), - m_byte( 42 ), - m_c( 429 ), - m_s( OUString( RTL_CONSTASCII_USTRINGPARAM( "foo" ) ) ) - {} - MyPersistObject( const OUString & sServiceName ) : m_sServiceName( sServiceName ) - {} - - -public: - virtual OUString SAL_CALL getServiceName(void) throw (RuntimeException); - virtual void SAL_CALL write( const Reference< XObjectOutputStream >& OutStream ) - throw (IOException, RuntimeException); - virtual void SAL_CALL read(const Reference< XObjectInputStream >& InStream) - throw (IOException, RuntimeException); - -public: - - virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo(void) - throw (RuntimeException); - - virtual void SAL_CALL setPropertyValue(const OUString& aPropertyName, const Any& aValue) - throw ( UnknownPropertyException, - PropertyVetoException, - IllegalArgumentException, - WrappedTargetException, - RuntimeException); - virtual Any SAL_CALL getPropertyValue(const OUString& PropertyName) - throw ( UnknownPropertyException, - WrappedTargetException, - RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( - const OUString& aPropertyName, - const Reference < XPropertyChangeListener > & xListener) - throw ( UnknownPropertyException, - WrappedTargetException, - RuntimeException); - - virtual void SAL_CALL removePropertyChangeListener( - const OUString& aPropertyName, - const Reference< XPropertyChangeListener > & aListener) - throw ( UnknownPropertyException, - WrappedTargetException, - RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( - const OUString& PropertyName, - const Reference< XVetoableChangeListener > & aListener) - throw ( UnknownPropertyException, - WrappedTargetException, - RuntimeException); - - virtual void SAL_CALL removeVetoableChangeListener( - const OUString& PropertyName, - const Reference< XVetoableChangeListener >& aListener) - throw ( UnknownPropertyException, - WrappedTargetException, - RuntimeException); - -public: - sal_Int32 m_l; - float m_f; - double m_d; - sal_Bool m_b; - sal_Int8 m_byte; - sal_Unicode m_c; - OUString m_s; - Reference< XPersistObject > m_ref; - OUString m_sServiceName; -}; - - - -Reference <XPropertySetInfo > MyPersistObject::getPropertySetInfo(void) - throw (RuntimeException) -{ - return Reference< XPropertySetInfo >(); -} - -void MyPersistObject::setPropertyValue( - const OUString& aPropertyName, - const Any& aValue) - throw ( UnknownPropertyException, - PropertyVetoException, - IllegalArgumentException, - WrappedTargetException, - RuntimeException) -{ - if( 0 == aPropertyName.compareToAscii("long") ) { - aValue >>= m_l; - } - else if ( 0 == aPropertyName.compareToAscii("float") ) { - aValue >>= m_f; - } - else if( 0 == aPropertyName.compareToAscii("double") ) { - aValue >>= m_d; - } - else if( 0 == aPropertyName.compareToAscii("bool") ) { - aValue >>= m_b; - } - else if( 0 == aPropertyName.compareToAscii("byte" ) ) { - aValue >>= m_byte; - } - else if( 0 == aPropertyName.compareToAscii("char") ) { - aValue >>= m_c; - } - else if( 0 == aPropertyName.compareToAscii("string") ) { - aValue >>= m_s; - } - else if( 0 == aPropertyName.compareToAscii("object") ) { - if( aValue.getValueType() == getCppuType( (Reference< XPersistObject> *)0 ) ) - { - aValue >>= m_ref; - } - else - { - m_ref = 0; - } - } -} - - -Any MyPersistObject::getPropertyValue(const OUString& aPropertyName) - throw ( UnknownPropertyException, - WrappedTargetException, - RuntimeException) -{ - Any aValue; - if( 0 == aPropertyName.compareToAscii("long" ) ) { - aValue <<= m_l; - } - else if ( 0 == aPropertyName.compareToAscii("float") ) { - aValue <<= m_f; - } - else if( 0 == aPropertyName.compareToAscii("double") ) { - aValue <<= m_d; - } - else if( 0 == aPropertyName.compareToAscii("bool") ) { - aValue <<= m_b; - } - else if( 0 == aPropertyName.compareToAscii("byte") ) { - aValue <<= m_byte; - } - else if( 0 == aPropertyName.compareToAscii("char" ) ) { - aValue <<= m_c; - } - else if( 0 == aPropertyName.compareToAscii("string") ) { - aValue <<= m_s; - } - else if( 0 == aPropertyName.compareToAscii("object" ) ) - { - aValue <<= m_ref; - } - return aValue; -} - - -void MyPersistObject::addPropertyChangeListener( - const OUString& aPropertyName, - const Reference< XPropertyChangeListener > & xListener) - throw ( UnknownPropertyException, - WrappedTargetException, - RuntimeException) -{ - -} - -void MyPersistObject::removePropertyChangeListener( - const OUString& aPropertyName, - const Reference < XPropertyChangeListener > & aListener) - throw ( UnknownPropertyException, - WrappedTargetException, - RuntimeException) -{ -} - - -void MyPersistObject::addVetoableChangeListener( - const OUString& PropertyName, - const Reference <XVetoableChangeListener >& aListener) - throw ( UnknownPropertyException, - WrappedTargetException, - RuntimeException) -{ - -} - -void MyPersistObject::removeVetoableChangeListener( - const OUString& PropertyName, - const Reference < XVetoableChangeListener > & aListener) - throw ( UnknownPropertyException, - WrappedTargetException, - RuntimeException) -{ - -} - - - - -OUString MyPersistObject::getServiceName() throw (RuntimeException) -{ - return m_sServiceName; -} - -void MyPersistObject::write( const Reference< XObjectOutputStream > & rOut ) - throw (IOException,RuntimeException) -{ - rOut->writeLong( m_l); - rOut->writeFloat( m_f ); - rOut->writeDouble( m_d ); - rOut->writeBoolean( m_b ); - rOut->writeByte( m_byte ); - rOut->writeChar( m_c ); - rOut->writeUTF( m_s ); - rOut->writeObject( m_ref ); -} - - -void MyPersistObject::read( const Reference< XObjectInputStream > & rIn ) - throw (IOException, RuntimeException) -{ - m_l = rIn->readLong(); - m_f = rIn->readFloat(); - m_d = rIn->readDouble(); - m_b = rIn->readBoolean(); - m_byte = rIn->readByte(); - m_c = rIn->readChar(); - m_s = rIn->readUTF(); - m_ref = rIn->readObject(); -} - -Reference < XInterface > SAL_CALL OMyPersistObject_CreateInstance( - const Reference < XMultiServiceFactory > & rSMgr ) - throw(Exception) -{ - MyPersistObject *p = new MyPersistObject( ); - return Reference < XInterface > ( SAL_STATIC_CAST( OWeakObject * , p ) ); -} - -Sequence<OUString> OMyPersistObject_getSupportedServiceNames( ) throw () -{ - Sequence<OUString> aRet(1); - aRet.getArray()[0] = OMyPersistObject_getImplementationName(); - return aRet; -} - -OUString OMyPersistObject_getServiceName( ) throw () -{ - return OUString( RTL_CONSTASCII_USTRINGPARAM("test.com.sun.star.io.PersistTest" )); -} - -OUString OMyPersistObject_getImplementationName( ) throw () -{ - return OUString( RTL_CONSTASCII_USTRINGPARAM( "test.com.sun.star.io.PersistTest" ) ); -} - -class OObjectStreamTest : - public ODataStreamTest -{ -public: - OObjectStreamTest( const Reference < XMultiServiceFactory > &r) : ODataStreamTest(r) {} - -public: - virtual void SAL_CALL testInvariant(const OUString& TestName, - const Reference < XInterface >& TestObject) - throw ( IllegalArgumentException, - RuntimeException); - - virtual sal_Int32 SAL_CALL test( - const OUString& TestName, - const Reference < XInterface >& TestObject, - sal_Int32 hTestHandle) - throw ( IllegalArgumentException, - RuntimeException); - - -private: - void OObjectStreamTest::testObject( const Reference <XObjectOutputStream > &rOut, - const Reference <XObjectInputStream> &rIn ); - -private: -}; - - -void OObjectStreamTest::testInvariant( const OUString& TestName, - const Reference < XInterface >& TestObject ) - throw ( IllegalArgumentException, RuntimeException) -{ - - if( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.io.ObjectInputStream" ) ) - == TestName ) - { - ODataStreamTest::testInvariant( TestName , TestObject ); - Reference< XObjectInputStream > dataInput( TestObject , UNO_QUERY ); - Reference< XMarkableStream > markable( TestObject , UNO_QUERY ); - ERROR_ASSERT( dataInput.is() , "XObjectInputStream cannot be queried" ); - ERROR_ASSERT( markable.is() , "XMarkableStream cannot be queried" ); - } - else if( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.ObjectOutputStream") ) - == TestName ) - { - ODataStreamTest::testInvariant( TestName , TestObject ); - Reference < XMarkableStream > markable( TestObject , UNO_QUERY ); - Reference < XObjectOutputStream > dataOutput( TestObject , UNO_QUERY ); - ERROR_ASSERT( dataOutput.is(), "XObjectOutputStream cannot be queried" ); - ERROR_ASSERT( markable.is() , "XMarkableStream cannot be queried" ); - } - - Reference < XServiceInfo > info( TestObject, UNO_QUERY ); - ERROR_ASSERT( info.is() , "XServiceInfo not supported !" ); - if( info.is() ) - { - ERROR_ASSERT( info->supportsService( TestName ), "XServiceInfo test failed" ); - ERROR_ASSERT( ! info->supportsService( OUString(RTL_CONSTASCII_USTRINGPARAM("bla bluzb")) ) , "XServiceInfo test failed" ); - } - -} - -sal_Int32 OObjectStreamTest::test( const OUString& TestName, - const Reference < XInterface >& TestObject, - sal_Int32 hTestHandle) - throw ( IllegalArgumentException, - RuntimeException) -{ - if( 0 == TestName.compareToAscii("com.sun.star.io.ObjectInputStream") || - 0 == TestName.compareToAscii("com.sun.star.io.ObjectOutputStream" ) ) { - - try - { - if( 0 == hTestHandle ) { - testInvariant( TestName , TestObject ); - } - else if( DATASTREAM_TEST_MAX_HANDLE >= hTestHandle ) { - sal_Int32 hOldHandle = hTestHandle; - hTestHandle = ODataStreamTest::test( - OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.DataInputStream" )), - TestObject , hTestHandle ); - if( hTestHandle == -1 ){ - hTestHandle = hOldHandle; - } - } - else { - - Reference<XActiveDataSink > rSink( TestObject, UNO_QUERY ); - Reference<XActiveDataSource > rSource( TestObject , UNO_QUERY ); - - Reference< XObjectInputStream > rInput( TestObject , UNO_QUERY ); - Reference< XObjectOutputStream > rOutput( TestObject , UNO_QUERY ); - - - Reference < XInterface > x = m_rFactory->createInstance( - OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.Pipe" )) ); - - Reference <XInputStream > rPipeInput( x , UNO_QUERY ); - Reference <XOutputStream > rPipeOutput( x , UNO_QUERY ); - - x = m_rFactory->createInstance( - OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.MarkableInputStream") ) ); - - Reference <XInputStream > markableInput( x , UNO_QUERY ); - Reference <XActiveDataSink> markableSink( x , UNO_QUERY ); - - x = m_rFactory->createInstance( OUString( - RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.MarkableOutputStream" ) ) ); - Reference <XOutputStream > markableOutput( x , UNO_QUERY ); - Reference <XActiveDataSource > markableSource( x , UNO_QUERY ); - - OSL_ASSERT( markableInput.is() ); - OSL_ASSERT( markableOutput.is() ); - OSL_ASSERT( markableSink.is() ); - OSL_ASSERT( markableSource.is() ); - - markableSink->setInputStream( rPipeInput ); - markableSource->setOutputStream( rPipeOutput ); - - if( ! rSink.is() ) { - x = m_rFactory->createInstance( - OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.ObjectInputStream") )); - rInput = Reference < XObjectInputStream > ( x , UNO_QUERY ); - rSink = Reference < XActiveDataSink > ( x , UNO_QUERY ); - } - else if ( !rSource.is() ) { - x = m_rFactory->createInstance( - OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.ObjectOutputStream" ))); - rOutput = Reference <XObjectOutputStream > ( x , UNO_QUERY ); - rSource = Reference <XActiveDataSource>( x, UNO_QUERY ); - } - - OSL_ASSERT( rPipeInput.is() ); - OSL_ASSERT( rPipeOutput.is() ); - - rSink->setInputStream( markableInput ); - rSource->setOutputStream( markableOutput ); - - OSL_ASSERT( rSink->getInputStream().is() ); - OSL_ASSERT( rSource->getOutputStream().is() ); - - if( 1 + DATASTREAM_TEST_MAX_HANDLE == hTestHandle ) { - testObject( rOutput , rInput); - } - rInput->closeInput(); - rOutput->closeOutput(); - - } - } - catch( Exception &e ) { - OString o = OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ); - BUILD_ERROR( 0 , o.getStr() ); - } - catch( ... ) { - BUILD_ERROR( 0 , "unknown exception (Exception is not base class)" ); - } - - hTestHandle ++; - - if( hTestHandle > 1 +DATASTREAM_TEST_MAX_HANDLE ) { - // all tests finished. - hTestHandle = -1; - } - } - else { - BUILD_ERROR( 0 , "service not supported by test." ); - } - return hTestHandle; -} - - -sal_Bool compareMyPropertySet( Reference< XPropertySet > &r1 , Reference < XPropertySet > &r2 ) -{ - sal_Bool b = sal_True; - - if( r1->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("long")) ).getValueType() == getCppuVoidType() || - r2->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("long")) ).getValueType() == getCppuVoidType() ) { - - // one of the objects is not the correct propertyset ! - fprintf( stderr, "compareMyPropertySet: 1\n" ); - return sal_False; - } - - b = b && ( r1->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("long")) ) == - r2->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("long")) ) ); - if( ! b ) fprintf( stderr, "compareMyPropertySet: 2\n" ); - - b = b && ( r1->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("float")) ) == - r2->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("float")) ) ); - if( ! b ){ - float f1(0.0); - float f2(0.0); - r1->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("float")) ) >>= f1; - r2->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("float")) ) >>= f2; - fprintf( stderr, "compareMyPropertySet: %f %f 3\n",f1,f2 ); - } - - b = b && ( r1->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("double")) ) == - r2->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("double" ))) ); - if( ! b ) fprintf( stderr, "compareMyPropertySet: 4\n" ); - - sal_Bool b1(sal_False), b2(sal_False); - Any a =r1->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("bool")) ); - a >>= b1; - a = r2->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("bool")) ); - a >>= b2; - b = b && ( (b1 && b2) || b1 == b2 ); - if( ! b ) fprintf( stderr, "compareMyPropertySet: 5\n" ); - -// b = b && r1->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("bool")) ) == -// r2->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("bool")) ) ); - - b = b && ( r1->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("byte")) ) == - r2->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("byte")) ) ); - if( ! b ) fprintf( stderr, "compareMyPropertySet: 6\n" ); - - b = b && ( r1->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("char")) ) == - r2->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("char")) ) ); - if( ! b ) fprintf( stderr, "compareMyPropertySet: 7\n" ); - - b = b && ( r1->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("string")) ) == - r2->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("string")) )); - if( ! b ) fprintf( stderr, "compareMyPropertySet: 8\n" ); - - Any o1 = r1->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("object")) ); - Any o2 = r2->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("object")) ); - - if( o1.getValueType() == getCppuType( (Reference<XPersistObject>*)0 ) ) { - - if( o2.getValueType() == getCppuType( (Reference<XPersistObject>*)0 ) ) { - Reference < XPersistObject > rPersist1; - Reference < XPersistObject > rPersist2; - o1 >>= rPersist1; - o2 >>= rPersist2; - Reference <XPropertySet > rProp1( rPersist1 , UNO_QUERY ); - Reference < XPropertySet > rProp2( rPersist2 , UNO_QUERY ); - - if( rProp1.is() && rProp2.is() && ! ( rProp1 == rProp2 ) - &&( rProp1 != r1 )) { - b = b && compareMyPropertySet( rProp1 , rProp2 ); - } - } - else { - b = sal_False; - } - if( ! b ) fprintf( stderr, "compareMyPropertySet: 9\n" ); - } - else { - if( o2.getValueType() == getCppuType( (Reference<XPersistObject>*)0 ) ) { - b = sal_False; - } - if( ! b ) fprintf( stderr, "compareMyPropertySet: 10\n" ); - } - - return b; -} - -void OObjectStreamTest::testObject( const Reference< XObjectOutputStream > &rOut, - const Reference < XObjectInputStream > &rIn ) -{ - ERROR_ASSERT( rOut.is() , "no objectOutputStream" ); - ERROR_ASSERT( rIn.is() , "no objectInputStream" ); - - - - // tests, if saving an object with an unknown service name allows - // reading the data behind the object ! - { - Reference < XInterface > x = * new MyPersistObject( - OUString( RTL_CONSTASCII_USTRINGPARAM("bla blubs")) ); - - Reference< XPersistObject > persistRef( x , UNO_QUERY ); - ERROR_ASSERT( persistRef.is() , "couldn't instantiate PersistTest object" ); - - rOut->writeObject( persistRef ); - rOut->writeLong( (sal_Int32) 0xdeadbeef ); - - ERROR_ASSERT( 0 != rIn->available() , "no data arrived at input" ); - - try - { - Reference <XPersistObject > xReadPersistRef = rIn->readObject(); - ERROR_ASSERT( 0 , "expected exception not thrown" ); - } - catch( IOException & ) - { - // all is ok - } - - ERROR_ASSERT( (sal_Int32) 0xdeadbeef == rIn->readLong() , - "wrong data after object with unknown service name." ); - } - - { - Reference < XInterface > x = m_rFactory->createInstance( - OUString( RTL_CONSTASCII_USTRINGPARAM("test.com.sun.star.io.PersistTest"))); - Reference< XPersistObject > persistRef( x , UNO_QUERY ); - - ERROR_ASSERT( persistRef.is() , "couldn't instantiate PersistTest object" ); - - Reference < XPropertySet > rProp( persistRef , UNO_QUERY ); - ERROR_ASSERT( rProp.is() , "test object is no property set " ); - - Any any; - sal_Int32 i = 0x83482; - any <<= i; - rProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("long")) , any ); - - float f = (float)42.23; - any <<= f; - rProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("float")) , any ); - - double d = 233.321412; - any <<= d; - rProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("double")) , any ); - - sal_Bool b = sal_True; - any.setValue( &b , getCppuBooleanType() ); - rProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("bool")) , any ); - - sal_Int8 by = 120; - any <<= by; - rProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("byte")) , any ); - - sal_Unicode c = 'h'; - any.setValue( &c , getCppuCharType() ); - rProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("char")) , any ); - - OUString str( RTL_CONSTASCII_USTRINGPARAM( "hi du !" ) ); - any <<= str; - rProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("string")) , any ); - - any <<= persistRef; - rProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("object")) , any ); - - // do read and write - rOut->writeObject( persistRef ); - ERROR_ASSERT( 0 != rIn->available() , "no data arrived at input" ); - Reference< XPersistObject > xReadPersist = rIn->readObject( ); - - Reference< XPropertySet > rPropRead( xReadPersist , UNO_QUERY ); - ERROR_ASSERT( compareMyPropertySet( rProp , rPropRead ) , "objects has not been read properly !" ); - - // destroy selfreferences - rProp->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("object")), Any() ); - rPropRead->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("object")), Any() ); - } - - { - Reference< XMarkableStream > markableOut( rOut , UNO_QUERY ); - ERROR_ASSERT( markableOut.is() , "markable stream cannot be queried" ); - - // do the same thing multiple times to check if - // buffering and marks work correctly - for( int i = 0 ; i < 2000 ; i ++ ) { - - Reference < XInterface > x = m_rFactory->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("test.com.sun.star.io.PersistTest"))); - Reference< XPersistObject > persistRef( x , UNO_QUERY ); - - Reference < XPropertySet > rProp( persistRef , UNO_QUERY ); - ERROR_ASSERT( rProp.is() , "test object is no property set " ); - - Any any; - sal_Int32 i = 0x83482; - any <<= i; - rProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("long")) , any ); - - float f = 42.23; - any <<= f; - rProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("float")) , any ); - - double d = 233.321412; - any <<= d; - rProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("double")) , any ); - - sal_Bool b = sal_True; - any.setValue( &b , getCppuBooleanType() ); - rProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("bool")) , any ); - - sal_Int8 by = 120; - any <<= by; - rProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("byte")) , any ); - - sal_Unicode c = 'h'; - any.setValue( &c , getCppuCharType() ); - rProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("char")) , any ); - - OUString str( RTL_CONSTASCII_USTRINGPARAM( "hi du !" ) ); - any <<= str; - rProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("string")) , any ); - - x = m_rFactory->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("test.com.sun.star.io.PersistTest"))); - Reference <XPersistObject > persist2ndRef( x , UNO_QUERY ); - - // Note : persist2ndRef contains coincident values, but also coincident values must be - // saved properly ! - any <<= persist2ndRef; - rProp->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("object")) , any ); - - // simply test, if markable operations and object operations do not interfere - sal_Int32 nMark = markableOut->createMark(); - - // do read and write - rOut->writeObject( persistRef ); - - // further markable tests ! - sal_Int32 nOffset = markableOut->offsetToMark( nMark ); - markableOut->jumpToMark( nMark ); - markableOut->deleteMark( nMark ); - markableOut->jumpToFurthest(); - - - - - - ERROR_ASSERT( 0 != rIn->available() , "no data arrived at input" ); - Reference < XPersistObject > xReadPersistRef = rIn->readObject( ); - - Reference< XPropertySet > rProp1( persistRef , UNO_QUERY ); - Reference< XPropertySet > rProp2( xReadPersistRef , UNO_QUERY ); - ERROR_ASSERT( compareMyPropertySet( rProp1, rProp2) , - "objects has not been read properly !" ); - } - } -} - - -Reference < XInterface > SAL_CALL OObjectStreamTest_CreateInstance( const Reference < XMultiServiceFactory > & rSMgr ) throw(Exception) -{ - OObjectStreamTest *p = new OObjectStreamTest( rSMgr ); - return Reference < XInterface > ( SAL_STATIC_CAST( OWeakObject * , p ) ); -} - -Sequence<OUString> OObjectStreamTest_getSupportedServiceNames( int i) throw () -{ - Sequence<OUString> aRet(1); - aRet.getArray()[0] = OObjectStreamTest_getImplementationName( i); - return aRet; -} - -OUString OObjectStreamTest_getServiceName( int i) throw () -{ - if( 1 == i ) { - return OUString( RTL_CONSTASCII_USTRINGPARAM("test.com.sun.star.io.ObjectInputStream" )); - } - else { - return OUString( RTL_CONSTASCII_USTRINGPARAM("test.com.sun.star.io.ObjectOutputStream")); - } -} - -OUString OObjectStreamTest_getImplementationName( int i) throw () -{ - if( 1 == i ) { - return OUString( RTL_CONSTASCII_USTRINGPARAM("test.com.sun.star.comp.extensions.stm.ObjectInputStream" )); - } - else { - return OUString( RTL_CONSTASCII_USTRINGPARAM("test.com.sun.star.comp.extensions.stm.ObjectOutputStream")); - } -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/io/test/stm/exports.dxp b/io/test/stm/exports.dxp deleted file mode 100644 index 86214860d..000000000 --- a/io/test/stm/exports.dxp +++ /dev/null @@ -1,2 +0,0 @@ -component_getFactory -component_writeInfo diff --git a/io/test/stm/makefile.mk b/io/test/stm/makefile.mk deleted file mode 100644 index f09cdb6ba..000000000 --- a/io/test/stm/makefile.mk +++ /dev/null @@ -1,99 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* -PRJ=..$/.. - -PRJNAME=io -TARGET=teststm -NO_BSYMBOLIC=TRUE -ENABLE_EXCEPTIONS=TRUE - -# --- Settings ----------------------------------------------------- -.INCLUDE : settings.mk -.IF "$(L10N_framework)"=="" -# --- Files -------------------------------------------------------- -UNOUCRDEP=$(SOLARBINDIR)$/udkapi.rdb -UNOUCRRDB=$(SOLARBINDIR)$/udkapi.rdb - -# output directory (one dir for each project) -UNOUCROUT=$(OUT)$/inc - -UNOTYPES = com.sun.star.test.XSimpleTest \ - com.sun.star.beans.XPropertySet \ - com.sun.star.io.UnexpectedEOFException \ - com.sun.star.io.WrongFormatException \ - com.sun.star.io.XActiveDataControl \ - com.sun.star.io.XActiveDataSink \ - com.sun.star.io.XActiveDataSource \ - com.sun.star.io.XConnectable \ - com.sun.star.io.XMarkableStream \ - com.sun.star.io.XObjectInputStream \ - com.sun.star.io.XObjectOutputStream \ - com.sun.star.lang.IllegalArgumentException \ - com.sun.star.lang.XComponent \ - com.sun.star.lang.XMultiServiceFactory \ - com.sun.star.lang.XServiceInfo \ - com.sun.star.lang.XSingleServiceFactory \ - com.sun.star.lang.XSingleComponentFactory \ - com.sun.star.lang.XMultiComponentFactory \ - com.sun.star.uno.XComponentContext \ - com.sun.star.lang.XTypeProvider \ - com.sun.star.registry.XImplementationRegistration \ - com.sun.star.registry.XRegistryKey \ - com.sun.star.test.XSimpleTest \ - com.sun.star.uno.TypeClass \ - com.sun.star.uno.XAggregation \ - com.sun.star.uno.XWeak - -SLOFILES= \ - $(SLO)$/testfactreg.obj \ - $(SLO)$/pipetest.obj \ - $(SLO)$/datatest.obj \ - $(SLO)$/marktest.obj \ - $(SLO)$/pumptest.obj - -SHL1TARGET= $(TARGET) - -SHL1STDLIBS= \ - $(SALLIB) \ - $(CPPULIB) \ - $(CPPUHELPERLIB) - -SHL1LIBS= $(SLB)$/$(TARGET).lib - -SHL1IMPLIB= i$(TARGET) - -SHL1DEPN= makefile.mk $(SHL1LIBS) -SHL1DEF= $(MISC)$/$(SHL1TARGET).def - -DEF1NAME= $(SHL1TARGET) -DEF1EXPORTFILE= exports.dxp - - -# --- Targets ------------------------------------------------------ -.ENDIF # L10N_framework - -.INCLUDE : target.mk diff --git a/io/test/stm/marktest.cxx b/io/test/stm/marktest.cxx deleted file mode 100644 index d863f9c84..000000000 --- a/io/test/stm/marktest.cxx +++ /dev/null @@ -1,680 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_io.hxx" -#include <com/sun/star/test/XSimpleTest.hpp> -#include <com/sun/star/io/XActiveDataSink.hpp> -#include <com/sun/star/io/XActiveDataSource.hpp> -#include <com/sun/star/io/XMarkableStream.hpp> -#include <com/sun/star/io/XConnectable.hpp> - -#include <com/sun/star/lang/XServiceInfo.hpp> - -#include <cppuhelper/factory.hxx> - -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implbase2.hxx> - -#include <osl/conditn.hxx> -#include <osl/mutex.hxx> - -using namespace ::rtl; -using namespace ::osl; -using namespace ::cppu; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::io; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::test; -// streams - -#include "testfactreg.hxx" - - -class OMarkableOutputStreamTest : public WeakImplHelper1< XSimpleTest > -{ -public: - OMarkableOutputStreamTest( const Reference< XMultiServiceFactory > & rFactory ); - ~OMarkableOutputStreamTest(); - -public: // implementation names - static Sequence< OUString > getSupportedServiceNames_Static(void) throw (); - static OUString getImplementationName_Static() throw (); - -public: - virtual void SAL_CALL testInvariant( - const OUString& TestName, - const Reference < XInterface >& TestObject) - throw ( IllegalArgumentException, - RuntimeException) ; - - virtual sal_Int32 SAL_CALL test( const OUString& TestName, - const Reference < XInterface >& TestObject, - sal_Int32 hTestHandle) - throw ( IllegalArgumentException, RuntimeException); - virtual sal_Bool SAL_CALL testPassed(void) - throw ( RuntimeException); - virtual Sequence< OUString > SAL_CALL getErrors(void) - throw (RuntimeException); - virtual Sequence< Any > SAL_CALL getErrorExceptions(void) - throw (RuntimeException); - virtual Sequence< OUString > SAL_CALL getWarnings(void) - throw (RuntimeException); - -private: - void testSimple( const Reference< XOutputStream > &r, const Reference < XInputStream > &rInput ); - -private: - Sequence<Any> m_seqExceptions; - Sequence<OUString> m_seqErrors; - Sequence<OUString> m_seqWarnings; - Reference< XMultiServiceFactory > m_rFactory; - -}; - -OMarkableOutputStreamTest::OMarkableOutputStreamTest( const Reference< XMultiServiceFactory > &rFactory ) - : m_rFactory( rFactory ) -{ - -} - -OMarkableOutputStreamTest::~OMarkableOutputStreamTest() -{ - -} - - - - -void OMarkableOutputStreamTest::testInvariant( const OUString& TestName, - const Reference < XInterface >& TestObject ) - throw ( IllegalArgumentException, RuntimeException) -{ - Reference< XServiceInfo > info( TestObject, UNO_QUERY ); - ERROR_ASSERT( info.is() , "XServiceInfo not supported !" ); - if( info.is() ) - { - ERROR_ASSERT( info->supportsService( TestName ), "XServiceInfo test failed" ); - ERROR_ASSERT( ! info->supportsService( - OUString( RTL_CONSTASCII_USTRINGPARAM("bla bluzb")) ) , "XServiceInfo test failed" ); - } -} - - -sal_Int32 OMarkableOutputStreamTest::test( - const OUString& TestName, - const Reference < XInterface >& TestObject, - sal_Int32 hTestHandle) - throw ( IllegalArgumentException, RuntimeException) -{ - if( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.MarkableOutputStream") ) - == TestName ) { - try - { - if( 0 == hTestHandle ) - { - testInvariant( TestName , TestObject ); - } - else - { - Reference < XInterface > x = m_rFactory->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.Pipe"))); - Reference< XOutputStream > rPipeOutput( x , UNO_QUERY ); - Reference < XInputStream > rPipeInput( x , UNO_QUERY ); - - Reference< XActiveDataSource > source( TestObject , UNO_QUERY ); - source->setOutputStream( rPipeOutput ); - - Reference< XOutputStream > rOutput( TestObject , UNO_QUERY ); - - OSL_ASSERT( rPipeInput.is() ); - OSL_ASSERT( rOutput.is() ); - if( 1 == hTestHandle ) { - // checks usual streaming - testSimple( rOutput , rPipeInput ); - } - } - - } - catch( Exception &e ) - { - OString o = OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ); - BUILD_ERROR( 0 , o.getStr() ); - } - catch( ... ) - { - BUILD_ERROR( 0 , "unknown exception (Exception is not base class)" ); - } - - hTestHandle ++; - - if( 2 == hTestHandle ) - { - // all tests finished. - hTestHandle = -1; - } - } - else { - throw IllegalArgumentException(); - } - return hTestHandle; -} - - - -sal_Bool OMarkableOutputStreamTest::testPassed(void) throw (RuntimeException) -{ - return m_seqErrors.getLength() == 0; -} - - -Sequence< OUString > OMarkableOutputStreamTest::getErrors(void) throw (RuntimeException) -{ - return m_seqErrors; -} - - -Sequence< Any > OMarkableOutputStreamTest::getErrorExceptions(void) throw (RuntimeException) -{ - return m_seqExceptions; -} - - -Sequence< OUString > OMarkableOutputStreamTest::getWarnings(void) throw (RuntimeException) -{ - return m_seqWarnings; -} - - -void OMarkableOutputStreamTest::testSimple( const Reference< XOutputStream > &rOutput , - const Reference< XInputStream > &rInput ) -{ - Reference < XMarkableStream > rMarkable( rOutput , UNO_QUERY ); - - ERROR_ASSERT( rMarkable.is() , "no MarkableStream implemented" ); - - // first check normal input/output facility - char pcStr[] = "Live long and prosper !"; - - Sequence<sal_Int8> seqWrite( strlen( pcStr )+1 ); - memcpy( seqWrite.getArray() , pcStr , seqWrite.getLength() ); - - Sequence<sal_Int8> seqRead( seqWrite.getLength() ); - - int nMax = 10,i; - - for( i = 0 ; i < nMax ; i ++ ) { - rOutput->writeBytes( seqWrite ); - rInput->readBytes( seqRead , rInput->available() ); - ERROR_ASSERT( ! strcmp( (char *) seqWrite.getArray() , (char * )seqRead.getArray() ) , - "error during read/write/skip" ); - } - - // Check buffer resizing - nMax = 3000; - for( i = 0 ; i < nMax ; i ++ ) { - rOutput->writeBytes( seqWrite ); - } - - for( i = 0 ; i < nMax ; i ++ ) { - rInput->readBytes( seqRead , seqWrite.getLength() ); - ERROR_ASSERT( ! strcmp( (char *) seqWrite.getArray() , (char * )seqRead.getArray() ) , - "error during read/write" ); - } - - // Check creating marks ! - sal_Int32 nMark = rMarkable->createMark(); - - for( i = 0 ; i < nMax ; i ++ ) { - rOutput->writeBytes( seqWrite ); - } - - ERROR_ASSERT( 0 == rInput->available() , "bytes available though mark is holded" ); - - ERROR_ASSERT( nMax*seqWrite.getLength() == rMarkable->offsetToMark( nMark ) , - "offsetToMark failure" ); - - rMarkable->deleteMark( nMark ); - ERROR_ASSERT( nMax*seqWrite.getLength() == rInput->available(),"bytes are not available though mark has been deleted" ); - - rInput->skipBytes( nMax*seqWrite.getLength() ); - ERROR_ASSERT( 0 == rInput->available(), "skip bytes failure" ); - - try - { - rMarkable->jumpToMark( nMark ); - ERROR_ASSERT( 0 , "jump to non existing mark possible !" ); - } - catch ( IllegalArgumentException & ) - { - // ok, exception was thrown - } - - // test putting marks not at the end of the stream! - ERROR_ASSERT( 0 == rInput->available(), "stream isn't clean" ); - { - Sequence< sal_Int8 > aByte(256); - - for( i = 0 ; i < 256 ; i ++ ) - { - aByte.getArray()[i] = i; - } - sal_Int32 nMark1 = rMarkable->createMark(); - - rOutput->writeBytes( aByte ); - rMarkable->jumpToMark( nMark1 ); - aByte.realloc( 10 ); - rOutput->writeBytes( aByte ); - - sal_Int32 nMark2 = rMarkable->createMark( ); - - for( i = 0 ; i < 10 ; i ++ ) - { - aByte.getArray()[i] = i+10; - } - - rOutput->writeBytes( aByte ); - - // allow the bytes to be written ! - rMarkable->jumpToFurthest(); - rMarkable->deleteMark( nMark1 ); - rMarkable->deleteMark( nMark2 ); - - ERROR_ASSERT( 256 == rInput->available(), "in between mark failure" ); - rInput->readBytes( aByte ,256); - for( i = 0 ; i < 256 ; i ++ ) - { - ERROR_ASSERT( i == ((sal_uInt8*)(aByte.getArray()))[i] , "in between mark failure" ); - } - } - - { - // now a more extensive mark test ! - Sequence<sal_Int8> as[4]; - sal_Int32 an[4]; - - for( i = 0 ; i < 4 ; i ++ ) { - as[i].realloc(1); - as[i].getArray()[0] = i; - an[i] = rMarkable->createMark(); - rOutput->writeBytes( as[i] ); - } - - // check offset to mark - for( i = 0 ; i < 4 ; i ++ ) { - ERROR_ASSERT( rMarkable->offsetToMark( an[i] ) == 4-i , "offsetToMark failure" ); - } - - rMarkable->jumpToMark( an[1] ); - ERROR_ASSERT( rMarkable->offsetToMark( an[3] ) == -2 , "offsetToMark failure" ); - - rMarkable->jumpToFurthest( ); - ERROR_ASSERT( rMarkable->offsetToMark( an[0] ) == 4 , "offsetToMark failure" ); - - // now do a rewrite ! - for( i = 0 ; i < 4 ; i ++ ) { - rMarkable->jumpToMark( an[3-i] ); - rOutput->writeBytes( as[i] ); - } - // NOTE : CursorPos 1 - - // now delete the marks ! - for( i = 0 ; i < 4 ; i ++ ) { - rMarkable->deleteMark( an[i] ); - } - ERROR_ASSERT( rInput->available() == 1 , "wrong number of bytes flushed" ); - - rMarkable->jumpToFurthest(); - - ERROR_ASSERT( rInput->available() == 4 , "wrong number of bytes flushed" ); - - rInput->readBytes( seqRead , 4 ); - - ERROR_ASSERT( 3 == seqRead.getArray()[0] , "rewrite didn't work" ); - ERROR_ASSERT( 2 == seqRead.getArray()[1] , "rewrite didn't work" ); - ERROR_ASSERT( 1 == seqRead.getArray()[2] , "rewrite didn't work" ); - ERROR_ASSERT( 0 == seqRead.getArray()[3] , "rewrite didn't work" ); - - rOutput->closeOutput(); - rInput->closeInput(); - } - -} - -/*** -* the test methods -* -****/ - - - - - -/** -* for external binding -* -* -**/ -Reference < XInterface > SAL_CALL OMarkableOutputStreamTest_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr ) throw(Exception) -{ - OMarkableOutputStreamTest *p = new OMarkableOutputStreamTest( rSMgr ); - return Reference < XInterface > ( SAL_STATIC_CAST( OWeakObject * , p ) ); -} - - - -Sequence<OUString> OMarkableOutputStreamTest_getSupportedServiceNames(void) throw () -{ - Sequence<OUString> aRet(1); - aRet.getArray()[0] = OMarkableOutputStreamTest_getImplementationName(); - - return aRet; -} - -OUString OMarkableOutputStreamTest_getServiceName() throw () -{ - return OUString( RTL_CONSTASCII_USTRINGPARAM("test.com.sun.star.io.MarkableOutputStream")); -} - -OUString OMarkableOutputStreamTest_getImplementationName() throw () -{ - return OUString( RTL_CONSTASCII_USTRINGPARAM("test.com.sun.starextensions.stm.MarkableOutputStream")); -} - - - - - - - -//----------------------------------------------------- -// Input stream - - -class OMarkableInputStreamTest : public WeakImplHelper1< XSimpleTest > -{ -public: - OMarkableInputStreamTest( const Reference< XMultiServiceFactory > & rFactory ); - ~OMarkableInputStreamTest(); - -public: // implementation names - static Sequence< OUString > getSupportedServiceNames_Static(void) throw () ; - static OUString getImplementationName_Static() throw () ; - -public: - virtual void SAL_CALL testInvariant( - const OUString& TestName, - const Reference < XInterface >& TestObject) - throw ( IllegalArgumentException, RuntimeException) ; - - virtual sal_Int32 SAL_CALL test( - const OUString& TestName, - const Reference < XInterface >& TestObject, - sal_Int32 hTestHandle) - throw ( IllegalArgumentException, - RuntimeException) ; - - virtual sal_Bool SAL_CALL testPassed(void) - throw ( RuntimeException); - virtual Sequence< OUString > SAL_CALL getErrors(void) - throw (RuntimeException); - virtual Sequence< Any > SAL_CALL getErrorExceptions(void) - throw (RuntimeException); - virtual Sequence< OUString > SAL_CALL getWarnings(void) - throw (RuntimeException); - -private: - void testSimple( const Reference< XOutputStream > &r, - const Reference < XInputStream > &rInput ); - -private: - Sequence<Any> m_seqExceptions; - Sequence<OUString> m_seqErrors; - Sequence<OUString> m_seqWarnings; - Reference< XMultiServiceFactory > m_rFactory; - -}; - -OMarkableInputStreamTest::OMarkableInputStreamTest( const Reference< XMultiServiceFactory > &rFactory ) - : m_rFactory( rFactory ) -{ - -} - -OMarkableInputStreamTest::~OMarkableInputStreamTest() -{ - -} - - - -void OMarkableInputStreamTest::testInvariant( - const OUString& TestName, const Reference < XInterface >& TestObject ) - throw ( IllegalArgumentException, RuntimeException) -{ - if( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.MarkableInputStream")) - == TestName ) { - Reference <XServiceInfo > info( TestObject, UNO_QUERY ); - ERROR_ASSERT( info.is() , "XServiceInfo not supported !" ); - if( info.is() ) - { - ERROR_ASSERT( info->supportsService( TestName ), "XServiceInfo test failed" ); - ERROR_ASSERT( - ! info->supportsService( - OUString(RTL_CONSTASCII_USTRINGPARAM("bla bluzb")) ) , - "XServiceInfo test failed" ); - } - } - else - { - throw IllegalArgumentException(); - } -} - - -sal_Int32 OMarkableInputStreamTest::test( - const OUString& TestName, - const Reference < XInterface >& TestObject, - sal_Int32 hTestHandle) throw ( IllegalArgumentException, RuntimeException) -{ - if( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.MarkableInputStream")) == TestName ) - { - try - { - if( 0 == hTestHandle ) { - testInvariant( TestName , TestObject ); - } - else { - Reference < XInterface > x = m_rFactory->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.Pipe"))); - Reference< XOutputStream > rPipeOutput( x , UNO_QUERY ); - Reference < XInputStream > rPipeInput( x , UNO_QUERY ); - - Reference < XActiveDataSink > sink( TestObject , UNO_QUERY ); - sink->setInputStream( rPipeInput ); - - Reference < XInputStream > rInput( TestObject , UNO_QUERY ); - - OSL_ASSERT( rPipeOutput.is() ); - OSL_ASSERT( rInput.is() ); - if( 1 == hTestHandle ) { - // checks usual streaming - testSimple( rPipeOutput , rInput ); - } - } - - } - catch( Exception & e ) - { - OString o = OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ); - BUILD_ERROR( 0 , o.getStr() ); - } - catch( ... ) - { - BUILD_ERROR( 0 , "unknown exception (Exception is not base class)" ); - } - - hTestHandle ++; - - if( 2 == hTestHandle ) { - // all tests finished. - hTestHandle = -1; - } - } - else - { - throw IllegalArgumentException(); - } - return hTestHandle; -} - - - -sal_Bool OMarkableInputStreamTest::testPassed(void) throw (RuntimeException) -{ - return m_seqErrors.getLength() == 0; -} - - -Sequence< OUString > OMarkableInputStreamTest::getErrors(void) throw (RuntimeException) -{ - return m_seqErrors; -} - - -Sequence< Any > OMarkableInputStreamTest::getErrorExceptions(void) throw (RuntimeException) -{ - return m_seqExceptions; -} - - -Sequence< OUString > OMarkableInputStreamTest::getWarnings(void) throw (RuntimeException) -{ - return m_seqWarnings; -} - - -void OMarkableInputStreamTest::testSimple( const Reference< XOutputStream > &rOutput , - const Reference < XInputStream > &rInput ) -{ - Reference < XMarkableStream > rMarkable( rInput , UNO_QUERY ); - - Sequence<sal_Int8> seqWrite( 256 ); - Sequence<sal_Int8> seqRead(10); - - for( int i = 0 ; i < 256 ; i ++ ) - { - seqWrite.getArray()[i] = i; - } - - rOutput->writeBytes( seqWrite ); - ERROR_ASSERT( 256 == rInput->available() , "basic read/write failure" ); - - rInput->readBytes( seqRead , 10 ); - ERROR_ASSERT( 9 == seqRead.getArray()[9] , "basic read/write failure" ); - - sal_Int32 nMark = rMarkable->createMark(); - - rInput->skipBytes( 50 ); - ERROR_ASSERT( 256-10-50 == rInput->available() , "marking error" ); - ERROR_ASSERT( 50 == rMarkable->offsetToMark( nMark ) , "marking error" ); - - rMarkable->jumpToMark( nMark ); - ERROR_ASSERT( 256-10 == rInput->available() , "marking error" ); - - rInput->readBytes( seqRead , 10 ); - ERROR_ASSERT( 10 == seqRead.getArray()[0] , "marking error" ); - - // pos 20 - { - sal_Int32 nInBetweenMark = rMarkable->createMark( ); - rMarkable->jumpToMark( nMark ); - rMarkable->jumpToMark( nInBetweenMark ); - - rInput->readBytes( seqRead , 10 ); - ERROR_ASSERT( 20 == seqRead.getArray()[0] , "Inbetween mark failed!\n" ); - - rMarkable->deleteMark( nMark ); - - // Check if releasing the first bytes works correct. - rMarkable->jumpToMark( nInBetweenMark); - rInput->readBytes( seqRead , 10 ); - ERROR_ASSERT( 20 == seqRead.getArray()[0] , "Inbetween mark failed!\n" ); - - rMarkable->deleteMark( nInBetweenMark ); - } - - rMarkable->jumpToFurthest(); - ERROR_ASSERT( 256-10-50 == rInput->available() , "marking error" ); - - - ERROR_ASSERT( 100 == rInput->readSomeBytes( seqRead , 100 ) , "wrong results using readSomeBytes" ); - ERROR_ASSERT( 96 == rInput->readSomeBytes( seqRead , 1000) , "wrong results using readSomeBytes" ); - rOutput->closeOutput(); - rInput->closeInput(); -} - -/*** -* the test methods -* -****/ - - - - - -/** -* for external binding -* -* -**/ -Reference < XInterface > SAL_CALL OMarkableInputStreamTest_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr ) throw(Exception) -{ - OMarkableInputStreamTest *p = new OMarkableInputStreamTest( rSMgr ); - return Reference < XInterface > ( SAL_STATIC_CAST( OWeakObject * , p ) ); -} - - - -Sequence<OUString> OMarkableInputStreamTest_getSupportedServiceNames(void) throw () -{ - Sequence<OUString> aRet(1); - aRet.getArray()[0] = OMarkableInputStreamTest_getImplementationName(); - - return aRet; -} - -OUString OMarkableInputStreamTest_getServiceName() throw () -{ - return OUString( RTL_CONSTASCII_USTRINGPARAM("test.com.sun.star.io.MarkableInputStream")); -} - -OUString OMarkableInputStreamTest_getImplementationName() throw () -{ - return OUString( RTL_CONSTASCII_USTRINGPARAM("test.com.sun.star.extensions.stm.MarkableInputStream" )); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/io/test/stm/pipetest.cxx b/io/test/stm/pipetest.cxx deleted file mode 100644 index 2e7acaa78..000000000 --- a/io/test/stm/pipetest.cxx +++ /dev/null @@ -1,442 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_io.hxx" - -#include <com/sun/star/test/XSimpleTest.hpp> -#include <com/sun/star/io/XInputStream.hpp> -#include <com/sun/star/io/XOutputStream.hpp> -#include <com/sun/star/io/XConnectable.hpp> -#include <com/sun/star/lang/IllegalArgumentException.hpp> - -#include <com/sun/star/lang/XServiceInfo.hpp> - -#include <cppuhelper/factory.hxx> - -#include <cppuhelper/implbase1.hxx> // OWeakObject - -#include <osl/conditn.hxx> -#include <osl/mutex.hxx> -#include <osl/thread.hxx> - -#include <string.h> - -using namespace ::rtl; -using namespace ::osl; -using namespace ::cppu; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::io; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::test; -// streams - -#include "testfactreg.hxx" -#define IMPLEMENTATION_NAME "test.com.sun.star.comp.extensions.stm.Pipe" -#define SERVICE_NAME "test.com.sun.star.io.Pipe" - - -class WriteToStreamThread : - public Thread -{ - -public: - - WriteToStreamThread( Reference< XOutputStream > xOutput , int iMax ) - { - m_output = xOutput; - m_iMax = iMax; - } - - virtual ~WriteToStreamThread() {} - - -protected: - - /// Working method which should be overridden. - virtual void SAL_CALL run() { - for( int i = 0 ; i < m_iMax ; i ++ ) { - m_output->writeBytes( createIntSeq(i) ); - } - m_output->closeOutput(); - } - - /** Called when run() is done. - * You might want to override it to do some cleanup. - */ - virtual void SAL_CALL onTerminated() - { - delete this; - } - - -private: - - Reference < XOutputStream > m_output; - int m_iMax; -}; - - - -class OPipeTest : public WeakImplHelper1 < XSimpleTest > -{ -public: - OPipeTest( const Reference< XMultiServiceFactory > & rFactory ); - ~OPipeTest(); - -public: // implementation names - static Sequence< OUString > getSupportedServiceNames_Static(void) throw(); - static OUString getImplementationName_Static() throw(); - -public: - virtual void SAL_CALL testInvariant(const OUString& TestName, const Reference < XInterface >& TestObject) - throw ( IllegalArgumentException, RuntimeException) ; - - virtual sal_Int32 SAL_CALL test( const OUString& TestName, - const Reference < XInterface >& TestObject, - sal_Int32 hTestHandle) - throw ( IllegalArgumentException, - RuntimeException); - - virtual sal_Bool SAL_CALL testPassed(void) throw ( RuntimeException) ; - virtual Sequence< OUString > SAL_CALL getErrors(void) throw (RuntimeException) ; - virtual Sequence< Any > SAL_CALL getErrorExceptions(void) throw (RuntimeException); - virtual Sequence< OUString > SAL_CALL getWarnings(void) throw (RuntimeException); - -private: - void testSimple( const Reference < XInterface > & ); - void testBufferResizing( const Reference < XInterface > & ); - void testMultithreading( const Reference < XInterface > & ); - -private: - Sequence<Any> m_seqExceptions; - Sequence<OUString> m_seqErrors; - Sequence<OUString> m_seqWarnings; - -}; - - - -OPipeTest::OPipeTest( const Reference< XMultiServiceFactory > &rFactory ) -{ - -} - -OPipeTest::~OPipeTest() -{ - -} - - - -void OPipeTest::testInvariant( const OUString& TestName, const Reference < XInterface >& TestObject ) - throw ( IllegalArgumentException, - RuntimeException) -{ - Reference< XServiceInfo > info( TestObject, UNO_QUERY ); - ERROR_ASSERT( info.is() , "XServiceInfo not supported !" ); - if( info.is() ) - { - ERROR_ASSERT( info->supportsService( TestName ), "XServiceInfo test failed" ); - ERROR_ASSERT( ! info->supportsService( - OUString( RTL_CONSTASCII_USTRINGPARAM("bla bluzb") ) ), "XServiceInfo test failed" ); - } - -} - - -sal_Int32 OPipeTest::test( - const OUString& TestName, - const Reference < XInterface >& TestObject, - sal_Int32 hTestHandle) - throw ( IllegalArgumentException, RuntimeException) -{ - if( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.Pipe") ) == TestName ) { - try - { - if( 0 == hTestHandle ) { - testInvariant( TestName , TestObject ); - } - else if( 1 == hTestHandle ) { - testSimple( TestObject ); - } - else if( 2 == hTestHandle ) { - testBufferResizing( TestObject ); - } - else if( 3 == hTestHandle ) { - testMultithreading( TestObject ); - } - } - catch( Exception & e ) - { - OString s = OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ); - BUILD_ERROR( 0 , s.getStr() ); - } - catch( ... ) - { - BUILD_ERROR( 0 , "unknown exception (Exception is not base class)" ); - } - - hTestHandle ++; - - if( 4 == hTestHandle ) - { - // all tests finished. - hTestHandle = -1; - } - } - else { - throw IllegalArgumentException(); - } - return hTestHandle; -} - - - -sal_Bool OPipeTest::testPassed(void) throw (RuntimeException) -{ - return m_seqErrors.getLength() == 0; -} - - -Sequence< OUString > OPipeTest::getErrors(void) throw (RuntimeException) -{ - return m_seqErrors; -} - - -Sequence< Any > OPipeTest::getErrorExceptions(void) throw (RuntimeException) -{ - return m_seqExceptions; -} - - -Sequence< OUString > OPipeTest::getWarnings(void) throw (RuntimeException) -{ - return m_seqWarnings; -} - - -/*** -* the test methods -* -****/ - - -void OPipeTest::testSimple( const Reference < XInterface > &r ) -{ - - Reference< XInputStream > input( r , UNO_QUERY ); - Reference < XOutputStream > output( r , UNO_QUERY ); - - ERROR_ASSERT( input.is() , "queryInterface on XInputStream failed" ); - ERROR_ASSERT( output.is() , "queryInterface onXOutputStream failed" ); - - // basic read/write - Sequence<sal_Int8> seqWrite = createSeq( "Hallo, du Ei !" ); - - Sequence<sal_Int8> seqRead; - for( int i = 0 ; i < 5000 ; i ++ ) { - output->writeBytes( seqWrite ); - input->readBytes( seqRead , input->available() ); - - ERROR_ASSERT( ! strcmp( (char *) seqWrite.getArray() , (char * )seqRead.getArray() ) , - "error during read/write/skip" ); - ERROR_ASSERT( 0 == input->available() , - "error during read/write/skip" ); - - // available shouldn't return a negative value - input->skipBytes( seqWrite.getLength() - 5 ); - ERROR_ASSERT( 0 == input->available() , "wrong available after skip" ); - - // 5 bytes should be available - output->writeBytes( seqWrite ); - ERROR_ASSERT( 5 == input->available() , "wrong available after skip/write " ); - - input->readBytes( seqRead , 5 ); - ERROR_ASSERT( ! strcmp( (char*) seqRead.getArray() , - (char*) &( seqWrite.getArray()[seqWrite.getLength()-5] ) ), - "write/read mismatich" ); - - } - - output->writeBytes( seqWrite ); - ERROR_ASSERT( seqWrite.getLength() == input->available(), "wrong available() after write" ); - - ERROR_ASSERT( 10 == input->readSomeBytes( seqRead , 10 ) , "maximal number of bytes ignored" ); - ERROR_ASSERT( seqWrite.getLength() -10 == input->readSomeBytes( seqRead , 100 ) , - "something wrong with readSomeBytes" ); - - - output->closeOutput(); - try{ - output->writeBytes( Sequence<sal_Int8> (100) ); - ERROR_ASSERT( 0 , "writing on a closed stream does not cause an exception" ); - } - catch (IOException & ) - { - } - - ERROR_ASSERT(! input->readBytes( seqRead , 1 ), "eof not found !" ); - - input->closeInput(); - try - { - input->readBytes( seqRead , 1 ); - ERROR_ASSERT( 0 , "reading from a closed stream does not cause an exception" ); - } - catch( IOException & ) { - } - - try - { - input->available( ); - ERROR_ASSERT( 0 , "calling available from a closed stream should thrown an io exception" ); - } - catch( IOException & ) - { - - } - try - { - input->skipBytes(42 ); - ERROR_ASSERT( 0 , "calling available from a closed stream should thrown an io exception" ); - } - catch( IOException & ) - { - - } -} - -void OPipeTest::testBufferResizing( const Reference < XInterface > &r ) -{ - int i; - int iMax = 20000; - Reference< XInputStream > input( r , UNO_QUERY ); - Reference < XOutputStream > output( r , UNO_QUERY ); - - ERROR_ASSERT( input.is() , "queryInterface on XInputStream failed" ); - ERROR_ASSERT( output.is() , "queryInterface on XOutputStream failed" ); - - Sequence<sal_Int8> seqRead; - - // this is just to better check the - // internal buffers - output->writeBytes( Sequence<sal_Int8>(100) ); - Sequence< sal_Int8 > dummy; - input->readBytes( dummy , 100); - - for( i = 0 ; i < iMax ; i ++ ) { - output->writeBytes( createIntSeq( i ) ); - } - - for( i = 0 ; i < iMax ; i ++ ) { - input->readBytes( seqRead, createIntSeq(i).getLength() ); - ERROR_ASSERT( ! strcmp( (char*) seqRead.getArray() , - (char*) createIntSeq(i).getArray() ) , - "written/read mismatch\n" ); - } - - output->closeOutput(); - ERROR_ASSERT( ! input->readBytes( seqRead , 1 ) , "eof not reached !" ); - input->closeInput(); -} - - - -void OPipeTest::testMultithreading( const Reference < XInterface > &r ) -{ - - int i; - int iMax = 30000; - - Reference< XInputStream > input( r , UNO_QUERY ); - Reference < XOutputStream > output( r , UNO_QUERY ); - - ERROR_ASSERT( input.is() , "queryInterface on XInputStream failed" ); - ERROR_ASSERT( output.is() , "queryInterface on XOutputStream failed" ); - - Sequence<sal_Int8> seqRead; - - // deletes itself - Thread *p = new WriteToStreamThread( output, iMax ); - - ERROR_ASSERT( p , "couldn't create thread for testing !\n" ); - - p->create(); - - for( i = 0 ; sal_True ; i ++ ) { - if( 0 == input->readBytes( seqRead, createIntSeq(i).getLength() ) ) { - // eof reached ! - break; - } - - ERROR_ASSERT( ! strcmp( (char*) seqRead.getArray() , - (char*) createIntSeq(i).getArray() ) , - "written/read mismatch\n" ); - } - - ERROR_ASSERT( i == iMax , "less elements read than written !"); - input->closeInput(); -} - - - -/** -* for external binding -* -* -**/ -Reference < XInterface > SAL_CALL OPipeTest_CreateInstance( const Reference< XMultiServiceFactory> & rSMgr ) throw (Exception) -{ - OPipeTest *p = new OPipeTest( rSMgr ); - Reference< XInterface > x ( SAL_STATIC_CAST( OWeakObject * , p ) ); - return x; -} - - - -Sequence<OUString> OPipeTest_getSupportedServiceNames(void) throw() -{ - Sequence<OUString> aRet(1); - aRet.getArray()[0] = OPipeTest_getServiceName(); - - return aRet; -} - -OUString OPipeTest_getServiceName() throw() -{ - return OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME ) ); -} - -OUString OPipeTest_getImplementationName() throw() -{ - return OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/io/test/stm/pumptest.cxx b/io/test/stm/pumptest.cxx deleted file mode 100644 index 122e3323a..000000000 --- a/io/test/stm/pumptest.cxx +++ /dev/null @@ -1,452 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_io.hxx" -#include <stdio.h> -#include <osl/time.h> - -#include <osl/diagnose.h> -#include <com/sun/star/test/XSimpleTest.hpp> - -#include <com/sun/star/io/XActiveDataSource.hpp> -#include <com/sun/star/io/XActiveDataSink.hpp> -#include <com/sun/star/io/XActiveDataControl.hpp> -#include <com/sun/star/io/XConnectable.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/registry/XRegistryKey.hpp> - -#include <uno/dispatcher.h> -#include <uno/mapping.hxx> -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/factory.hxx> -#include <osl/mutex.hxx> -#include <osl/thread.h> -#include <list> - - - - -using namespace ::rtl; -using namespace ::osl; -using namespace ::cppu; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::io; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::test; - -#include "testfactreg.hxx" - -static void mywait() -{ - TimeValue a = { 0, 10000 }; - osl_waitThread( &a ); - osl_yieldThread(); - osl_yieldThread(); -} - -class OPumpTest : public WeakImplHelper1 < XSimpleTest > -{ -public: - OPumpTest( const Reference< XMultiServiceFactory > & rFactory ); - ~OPumpTest(); - -public: // implementation names - static Sequence< OUString > getSupportedServiceNames_Static(void) throw(); - static OUString getImplementationName_Static() throw(); - -public: - virtual void SAL_CALL testInvariant(const OUString& TestName, const Reference < XInterface >& TestObject) - throw ( IllegalArgumentException, RuntimeException) ; - - virtual sal_Int32 SAL_CALL test( const OUString& TestName, - const Reference < XInterface >& TestObject, - sal_Int32 hTestHandle) - throw ( IllegalArgumentException, - RuntimeException); - - virtual sal_Bool SAL_CALL testPassed(void) throw ( RuntimeException) ; - virtual Sequence< OUString > SAL_CALL getErrors(void) throw (RuntimeException) ; - virtual Sequence< Any > SAL_CALL getErrorExceptions(void) throw (RuntimeException); - virtual Sequence< OUString > SAL_CALL getWarnings(void) throw (RuntimeException); - -private: - void testSimple( const Reference < XInterface > & ); - void testWrongUsage( const Reference < XInterface > & ); - void testClose( const Reference< XInterface >& ); - void testTerminate( const Reference< XInterface >& ); - void testFunction( const Reference< XInterface >& ); -private: - Sequence<Any> m_seqExceptions; - Sequence<OUString> m_seqErrors; - Sequence<OUString> m_seqWarnings; - Reference< XMultiServiceFactory > m_rSmgr; - -}; - -OPumpTest::OPumpTest( const Reference< XMultiServiceFactory > &rFactory ) : - m_rSmgr( rFactory ) -{ - -} - -OPumpTest::~OPumpTest() -{ - -} - - - -void OPumpTest::testInvariant( const OUString& TestName, const Reference < XInterface >& TestObject ) - throw ( IllegalArgumentException, - RuntimeException) -{ - Reference< XServiceInfo > info( TestObject, UNO_QUERY ); - ERROR_ASSERT( info.is() , "XServiceInfo not supported !" ); - if( info.is() ) - { - ERROR_ASSERT( info->supportsService( TestName ), "XServiceInfo test failed" ); - ERROR_ASSERT( ! info->supportsService( - OUString( RTL_CONSTASCII_USTRINGPARAM("bla bluzb") ) ), "XServiceInfo test failed" ); - } - - Reference < XActiveDataSource > xActiveDataSource( TestObject, UNO_QUERY ); - Reference < XActiveDataSink > xActiveDataSink( TestObject, UNO_QUERY ); - Reference < XActiveDataControl > xActiveDataControl( TestObject , UNO_QUERY ); - Reference < XConnectable > xConnectable( TestObject , UNO_QUERY ); - - ERROR_ASSERT( xActiveDataSource.is() && xActiveDataSink.is() && xActiveDataControl.is () && - xConnectable.is(), "specified interface not supported" ); -} - - -sal_Int32 OPumpTest::test( - const OUString& TestName, - const Reference < XInterface >& TestObject, - sal_Int32 hTestHandle) - throw ( IllegalArgumentException, RuntimeException) -{ - if( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.Pump") ) == TestName ) { - try - { - if( 0 == hTestHandle ) { - testInvariant( TestName , TestObject ); - } - else if ( 1 == hTestHandle ) - { - testWrongUsage( TestObject); - } - else if ( 2 == hTestHandle ) - { - testClose( TestObject); - } - else if ( 3 == hTestHandle ) - { - testTerminate( TestObject ); - } - else if ( 4 == hTestHandle ) - { - testFunction( TestObject ); - } - } - catch( Exception & e ) - { - OString s = OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ); - BUILD_ERROR( 0 , s.getStr() ); - } - catch( ... ) - { - BUILD_ERROR( 0 , "unknown exception (Exception is not base class)" ); - } - - hTestHandle ++; - - if( 5 == hTestHandle ) - { - // all tests finished. - hTestHandle = -1; - } - } - else { - throw IllegalArgumentException(); - } - return hTestHandle; -} - - - -sal_Bool OPumpTest::testPassed(void) throw (RuntimeException) -{ - return m_seqErrors.getLength() == 0; -} - - -Sequence< OUString > OPumpTest::getErrors(void) throw (RuntimeException) -{ - return m_seqErrors; -} - - -Sequence< Any > OPumpTest::getErrorExceptions(void) throw (RuntimeException) -{ - return m_seqExceptions; -} - - -Sequence< OUString > OPumpTest::getWarnings(void) throw (RuntimeException) -{ - return m_seqWarnings; -} - - -/*** -* the test methods -* -****/ - - -void OPumpTest::testSimple( const Reference < XInterface > &r ) -{ - // jbu todo: add sensible test - -} - -class TestListener: public WeakImplHelper1< XStreamListener > -{ -public: - sal_Bool m_bStarted; - sal_Bool m_bClosed; - sal_Bool m_bTerminated; - sal_Bool m_bError; - sal_Bool m_bDisposed; - TestListener() : m_bStarted (sal_False), - m_bClosed (sal_False), - m_bTerminated ( sal_False ), - m_bError( sal_False ), - m_bDisposed( sal_False ) - {} - - virtual void SAL_CALL disposing( const EventObject &obj ) throw (::com::sun::star::uno::RuntimeException) - { - m_bDisposed = sal_True; -// printf( "disposing called\n"); - } - - virtual void SAL_CALL started( ) throw (::com::sun::star::uno::RuntimeException) - { - m_bStarted = sal_True; -// printf( "started called\n"); - } - virtual void SAL_CALL closed( ) throw (::com::sun::star::uno::RuntimeException) - { - m_bClosed = sal_True; -// printf( "closed called\n"); - } - virtual void SAL_CALL terminated( ) throw (::com::sun::star::uno::RuntimeException) - { - m_bTerminated = sal_True; -// printf( "terminated called\n"); - } - virtual void SAL_CALL error( const ::com::sun::star::uno::Any& aException ) - throw (::com::sun::star::uno::RuntimeException) - { - m_bError = sal_True; - Exception e; - aException >>= e; -// printf( "error called %s\n", OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US).getStr() ); - } -}; - -class TestCase -{ -public: - TestCase( const Reference< XMultiServiceFactory > & rSMgr, - const Reference< XInterface > &r ) : m_rSmgr( rSMgr ), m_pTestListener( 0 ) - { - m_rControl = Reference<XActiveDataControl>( r, UNO_QUERY ); - - Reference< XActiveDataSource > rSource ( r, UNO_QUERY ); - Reference< XActiveDataSink > rSink( r , UNO_QUERY ); - - m_rOutSource = Reference< XOutputStream > ( createPipe() ); - rSink->setInputStream(Reference< XInputStream> (m_rOutSource,UNO_QUERY)); - - Reference< XOutputStream > rOutSink( createPipe() ); - m_rInSink = Reference< XInputStream > ( rOutSink, UNO_QUERY ); - rSource->setOutputStream( rOutSink ); - - m_pTestListener = new TestListener(); - m_pTestListener->acquire(); - m_rControl->addListener( m_pTestListener ); - } - - ~TestCase() - { - if( m_pTestListener ) - m_pTestListener->release(); - } - - TestListener *m_pTestListener; - Reference< XActiveDataControl > m_rControl; - Reference< XOutputStream > m_rOutSource; - Reference< XInputStream > m_rInSink; - Reference< XMultiServiceFactory > m_rSmgr; - -private: - Reference< XOutputStream > createPipe() - { - Reference< XOutputStream > rOut( m_rSmgr->createInstance( - OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.Pipe"))),UNO_QUERY); - return rOut; - } -}; - - - -void OPumpTest::testClose( const Reference< XInterface > &r ) -{ - TestCase t( m_rSmgr, r ); - - ERROR_ASSERT( ! t.m_pTestListener->m_bStarted , "started too early" ); - ERROR_ASSERT( ! t.m_pTestListener->m_bTerminated , "terminiation unexpected" ); - ERROR_ASSERT( ! t.m_pTestListener->m_bError, "unexpected error" ); - ERROR_ASSERT( ! t.m_pTestListener->m_bClosed, "unexpected clase" ); - - t.m_rControl->start(); - mywait(); - - ERROR_ASSERT( t.m_pTestListener->m_bStarted , "should have been started already" ); - ERROR_ASSERT( ! t.m_pTestListener->m_bTerminated , "terminiation unexpected" ); - ERROR_ASSERT( ! t.m_pTestListener->m_bError, "unexpected error" ); - ERROR_ASSERT( ! t.m_pTestListener->m_bClosed, "unexpected clase" ); - - Reference< XStreamListener > rListener( new TestListener() ); - t.m_rControl->addListener( rListener ); - t.m_rControl->removeListener( rListener ); - - t.m_rOutSource->closeOutput(); - mywait(); - ERROR_ASSERT( t.m_pTestListener->m_bStarted , "should have been started already" ); - ERROR_ASSERT( ! t.m_pTestListener->m_bTerminated , "should be terminiated already" ); - ERROR_ASSERT( ! t.m_pTestListener->m_bError, "unexpected error" ); - ERROR_ASSERT( t.m_pTestListener->m_bClosed, "should be closed already" ); -} - -void OPumpTest::testTerminate( const Reference< XInterface > &r ) -{ - TestCase t( m_rSmgr, r ); - - ERROR_ASSERT( ! t.m_pTestListener->m_bStarted , "started too early" ); - ERROR_ASSERT( ! t.m_pTestListener->m_bTerminated , "terminiation unexpected" ); - ERROR_ASSERT( ! t.m_pTestListener->m_bError, "unexpected error" ); - ERROR_ASSERT( ! t.m_pTestListener->m_bClosed, "unexpected clase" ); - - t.m_rControl->start(); - mywait(); - - ERROR_ASSERT( t.m_pTestListener->m_bStarted , "should have been started already" ); - ERROR_ASSERT( ! t.m_pTestListener->m_bTerminated , "terminiation unexpected" ); - ERROR_ASSERT( ! t.m_pTestListener->m_bError, "unexpected error" ); - ERROR_ASSERT( ! t.m_pTestListener->m_bClosed, "unexpected clase" ); - - t.m_rControl->terminate(); - - mywait(); - ERROR_ASSERT( t.m_pTestListener->m_bStarted , "should have been started already" ); - ERROR_ASSERT( t.m_pTestListener->m_bTerminated , "should be terminiated already" ); - // terminte leads to an error, that is no surprise, in fact - // one can't tell wether the error occurs because of the terminate - // call or for some other reason ! -// ERROR_ASSERT( ! t.m_pTestListener->m_bError, "unexpected error" ); - ERROR_ASSERT( t.m_pTestListener->m_bClosed, "should be closed already" ); -} - -void OPumpTest::testFunction( const Reference< XInterface > &r ) -{ - TestCase t( m_rSmgr, r ); - - t.m_rControl->start(); - - t.m_rOutSource->writeBytes( Sequence< sal_Int8 > ( 5 ) ); - - Sequence< sal_Int8 > dummy; - ERROR_ASSERT( 5 == t.m_rInSink->readBytes( dummy , 5 ), "couldn't read the expected number of bytes" ); - - t.m_rOutSource->closeOutput(); - mywait(); - - ERROR_ASSERT( t.m_pTestListener->m_bStarted , "should have been started already" ); - ERROR_ASSERT( ! t.m_pTestListener->m_bTerminated , "should be terminiated already" ); - ERROR_ASSERT( ! t.m_pTestListener->m_bError, "unexpected error" ); - ERROR_ASSERT( t.m_pTestListener->m_bClosed, "should be closed already" ); -} - -void OPumpTest::testWrongUsage( const Reference< XInterface > &r ) -{ - Reference< XActiveDataSource > rSource ( r, UNO_QUERY ); - Reference< XActiveDataSink > rSink( r , UNO_QUERY ); - Reference< XActiveDataControl > rControl( r, UNO_QUERY ); - - Reference< XInputStream > rIn( m_rSmgr->createInstance( - OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.DataInputStream"))),UNO_QUERY); - Reference< XOutputStream > rOut( m_rSmgr->createInstance( - OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.DataOutputStream"))),UNO_QUERY); - - rSink->setInputStream( rIn ); - rSource->setOutputStream( rOut ); - - rControl->start(); - - mywait(); -} - -Reference< XInterface > SAL_CALL OPumpTest_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr ) throw( Exception ) -{ - return *new OPumpTest( rSMgr ); -} - -Sequence<OUString> OPumpTest_getSupportedServiceNames(void) throw() -{ - OUString s = OPumpTest_getServiceName(); - Sequence< OUString > seq( &s , 1 ); - return seq; - -} -OUString OPumpTest_getServiceName() throw() -{ - return OUString( RTL_CONSTASCII_USTRINGPARAM( "test.com.sun.star.io.Pump" ) ); -} - -OUString OPumpTest_getImplementationName() throw() -{ - return OUString( RTL_CONSTASCII_USTRINGPARAM( "test.com.sun.star.comp.io.Pump") ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/io/test/stm/testfactreg.cxx b/io/test/stm/testfactreg.cxx deleted file mode 100644 index 804b5630f..000000000 --- a/io/test/stm/testfactreg.cxx +++ /dev/null @@ -1,211 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_io.hxx" -#include <stdio.h> -#include <string.h> - -#include <osl/diagnose.h> - -#include <cppuhelper/factory.hxx> // for EXTERN_SERVICE_CALLTYPE - -using namespace ::rtl; -using namespace ::cppu; -using namespace ::com::sun::star::registry; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; - -#include "testfactreg.hxx" - - -extern "C" -{ - -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - if (pRegistryKey) - { - try - { - Reference< XRegistryKey > xKey( - reinterpret_cast< XRegistryKey * >( pRegistryKey ) ); - - OUString str = OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + - OPipeTest_getImplementationName() + - OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ); - Reference< XRegistryKey > xNewKey = xKey->createKey( str ); - xNewKey->createKey( OPipeTest_getServiceName() ); - - str = OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + - OPumpTest_getImplementationName() + - OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ); - xNewKey = xKey->createKey( str ); - xNewKey->createKey( OPumpTest_getServiceName() ); - - str = OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + - ODataStreamTest_getImplementationName(1) + - OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ); - xNewKey = xKey->createKey( str ); - xNewKey->createKey( ODataStreamTest_getServiceName(1) ); - - str = OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + - ODataStreamTest_getImplementationName(2) + - OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ); - xNewKey = xKey->createKey( str ); - xNewKey->createKey( ODataStreamTest_getServiceName(2) ); - - str = OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + - OObjectStreamTest_getImplementationName(1) + - OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ); - xNewKey = xKey->createKey( str ); - xNewKey->createKey( OObjectStreamTest_getServiceName(1) ); - - str = OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + - OObjectStreamTest_getImplementationName(2) + - OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ); - xNewKey = xKey->createKey( str ); - xNewKey->createKey( OObjectStreamTest_getServiceName(2) ); - - str = OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + - OMarkableOutputStreamTest_getImplementationName() + - OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ); - xNewKey = xKey->createKey( str ); - xNewKey->createKey( OMarkableOutputStreamTest_getServiceName() ); - - str = OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + - OMarkableInputStreamTest_getImplementationName() + - OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ); - xNewKey = xKey->createKey( str ); - xNewKey->createKey( OMarkableInputStreamTest_getServiceName() ); - - str = OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + - OMyPersistObject_getImplementationName() + - OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ); - xNewKey = xKey->createKey( str ); - xNewKey->createKey( OMyPersistObject_getServiceName() ); - - return sal_True; - } - catch (InvalidRegistryException &) - { - OSL_FAIL( "### InvalidRegistryException!" ); - } - } - return sal_False; -} - -SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( - const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) -{ - void * pRet = 0; - - if (pServiceManager ) - { - Reference< XSingleServiceFactory > xRet; - Reference< XMultiServiceFactory > xSMgr = - reinterpret_cast< XMultiServiceFactory * > ( pServiceManager ); - - OUString aImplementationName = OUString::createFromAscii( pImplName ); - - if (aImplementationName == OPipeTest_getImplementationName() ) - { - xRet = createSingleFactory( xSMgr, aImplementationName, - OPipeTest_CreateInstance, - OPipeTest_getSupportedServiceNames() ); - } - else if (aImplementationName == OPumpTest_getImplementationName() ) - { - xRet = createSingleFactory( xSMgr, aImplementationName, - OPumpTest_CreateInstance, - OPumpTest_getSupportedServiceNames() ); - } - - else if( aImplementationName == ODataStreamTest_getImplementationName(1) ) { - xRet = createSingleFactory( xSMgr , aImplementationName, - ODataStreamTest_CreateInstance, - ODataStreamTest_getSupportedServiceNames(1) ); - } - else if( aImplementationName == ODataStreamTest_getImplementationName(2) ) { - xRet = createSingleFactory( xSMgr , aImplementationName, - ODataStreamTest_CreateInstance, - ODataStreamTest_getSupportedServiceNames(2) ); - } - else if( aImplementationName == OObjectStreamTest_getImplementationName(1) ) { - xRet = createSingleFactory( xSMgr , aImplementationName, - OObjectStreamTest_CreateInstance, - OObjectStreamTest_getSupportedServiceNames(1) ); - } - else if( aImplementationName == OObjectStreamTest_getImplementationName(2) ) { - xRet = createSingleFactory( xSMgr , aImplementationName, - OObjectStreamTest_CreateInstance, - OObjectStreamTest_getSupportedServiceNames(2) ); - } - else if( aImplementationName == OMarkableOutputStreamTest_getImplementationName() ) { - xRet = createSingleFactory( xSMgr , aImplementationName, - OMarkableOutputStreamTest_CreateInstance, - OMarkableOutputStreamTest_getSupportedServiceNames() ); - } - else if( aImplementationName == OMarkableInputStreamTest_getImplementationName() ) { - xRet = createSingleFactory( xSMgr , aImplementationName, - OMarkableInputStreamTest_CreateInstance, - OMarkableInputStreamTest_getSupportedServiceNames() ); - } - else if( aImplementationName == OMyPersistObject_getImplementationName() ) { - xRet = createSingleFactory( xSMgr , aImplementationName, - OMyPersistObject_CreateInstance, - OMyPersistObject_getSupportedServiceNames() ); - } - if (xRet.is()) - { - xRet->acquire(); - pRet = xRet.get(); - } - } - - return pRet; -} - -} - -Sequence<sal_Int8 > createSeq( char * p ) -{ - Sequence<sal_Int8> seq( strlen( p )+1 ); - strcpy( (char * ) seq.getArray() , p ); - return seq; -} - -Sequence<sal_Int8> createIntSeq( sal_Int32 i ) -{ - char pcCount[20]; - sprintf( pcCount , "%d" , i ); - return createSeq( pcCount ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/io/test/stm/testfactreg.hxx b/io/test/stm/testfactreg.hxx deleted file mode 100644 index 5aefcad6a..000000000 --- a/io/test/stm/testfactreg.hxx +++ /dev/null @@ -1,122 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <rtl/strbuf.hxx> - -Reference< XInterface > SAL_CALL OPipeTest_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr ) throw( Exception ); -Sequence<OUString> OPipeTest_getSupportedServiceNames(void) throw(); -OUString OPipeTest_getServiceName() throw(); -OUString OPipeTest_getImplementationName() throw(); - -Reference< XInterface > SAL_CALL OPumpTest_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr ) throw( Exception ); -Sequence<OUString> OPumpTest_getSupportedServiceNames(void) throw(); -OUString OPumpTest_getServiceName() throw(); -OUString OPumpTest_getImplementationName() throw(); - -Reference< XInterface > SAL_CALL ODataStreamTest_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr ) throw(Exception); -Sequence<OUString> ODataStreamTest_getSupportedServiceNames( int i) throw(); -OUString ODataStreamTest_getServiceName( int i) throw(); -OUString ODataStreamTest_getImplementationName( int i) throw(); - -Reference< XInterface > SAL_CALL OMarkableOutputStreamTest_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr ) throw(Exception); -Sequence<OUString> OMarkableOutputStreamTest_getSupportedServiceNames(void) throw(); -OUString OMarkableOutputStreamTest_getServiceName() throw(); -OUString OMarkableOutputStreamTest_getImplementationName() throw(); - -Reference< XInterface > SAL_CALL OMarkableInputStreamTest_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr ) throw(Exception); -Sequence<OUString> OMarkableInputStreamTest_getSupportedServiceNames(void) throw(); -OUString OMarkableInputStreamTest_getServiceName() throw(); -OUString OMarkableInputStreamTest_getImplementationName() throw(); - -Reference< XInterface > SAL_CALL OObjectStreamTest_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr ) throw(Exception); -Sequence<OUString> OObjectStreamTest_getSupportedServiceNames( int i) throw(); -OUString OObjectStreamTest_getServiceName( int i) throw(); -OUString OObjectStreamTest_getImplementationName( int i) throw(); - -Reference< XInterface > SAL_CALL OMyPersistObject_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr ) throw(Exception); -Sequence<OUString> OMyPersistObject_getSupportedServiceNames( ) throw(); -OUString OMyPersistObject_getServiceName( ) throw(); -OUString OMyPersistObject_getImplementationName( ) throw(); - -Sequence<sal_Int8> createSeq( char * p ); -Sequence<sal_Int8> createIntSeq( sal_Int32 i ); - -#define BUILD_ERROR(expr, Message)\ - {\ - m_seqErrors.realloc( m_seqErrors.getLength() + 1 ); \ - m_seqExceptions.realloc( m_seqExceptions.getLength() + 1 ); \ - OStringBuffer str(128); \ - str.append( __FILE__ );\ - str.append( " " ); \ - str.append( "(" ); \ - str.append( OString::valueOf( (sal_Int32)__LINE__) );\ - str.append(")\n" );\ - str.append( "[ " ); \ - str.append( #expr ); \ - str.append( " ] : " ); \ - str.append( Message ); \ - m_seqErrors.getArray()[ m_seqErrors.getLength()-1] =\ - OStringToOUString( str.makeStringAndClear() , RTL_TEXTENCODING_ASCII_US ); \ - }\ - ((void)0) - - -#define WARNING_ASSERT(expr, Message) \ - if( ! (expr) ) { \ - m_seqWarnings.realloc( m_seqErrors.getLength() +1 ); \ - OStringBuffer str(128);\ - str.append( __FILE__);\ - str.append( " "); \ - str.append( "(" ); \ - str.append(OString::valueOf( (sal_Int32)__LINE__)) ;\ - str.append( ")\n");\ - str.append( "[ " ); \ - str.append( #expr ); \ - str.append( " ] : ") ; \ - str.append( Message); \ - m_seqWarnings.getArray()[ m_seqWarnings.getLength()-1] =\ - OStringToOUString( str.makeStringAndClear() , RTL_TEXTENCODING_ASCII_US ); \ - return; \ - }\ - ((void)0) - -#define ERROR_ASSERT(expr, Message) \ - if( ! (expr) ) { \ - BUILD_ERROR(expr, Message );\ - return; \ - }\ - ((void)0) - -#define ERROR_EXCEPTION_ASSERT(expr, Message, Exception) \ - if( !(expr)) { \ - BUILD_ERROR(expr,Message);\ - m_seqExceptions.getArray()[ m_seqExceptions.getLength()-1] = Any( Exception );\ - return; \ - } \ - ((void)0) - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/io/test/testcomponent.cxx b/io/test/testcomponent.cxx deleted file mode 100644 index 9d715327c..000000000 --- a/io/test/testcomponent.cxx +++ /dev/null @@ -1,220 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_io.hxx" - -//------------------------------------------------------ -// testcomponent - Loads a service and its testcomponent from dlls performs a test. -// Expands the dll-names depending on the actual environment. -// Example : testcomponent stardiv.uno.io.Pipe stm -// -// Therefor the testcode must exist in teststm and the testservice must be named test.stardiv.uno.io.Pipe -// - -#include <stdio.h> -#include <com/sun/star/registry/XImplementationRegistration.hpp> -#include <com/sun/star/lang/XComponent.hpp> - -#include <com/sun/star/test/XSimpleTest.hpp> - -#include <cppuhelper/servicefactory.hxx> - -using namespace ::rtl; -using namespace ::cppu; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::test; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::registry; - -// Needed to switch on solaris threads - -int main (int argc, char **argv) -{ - - if( argc < 3) { - printf( "usage : testcomponent service dll [additional dlls]\n" ); - exit( 0 ); - } - - // create service manager - Reference< XMultiServiceFactory > xSMgr = createRegistryServiceFactory( - OUString( RTL_CONSTASCII_USTRINGPARAM( "applicat.rdb" ) ) ); - - Reference < XImplementationRegistration > xReg; - Reference < XSimpleRegistry > xSimpleReg; - - try - { - // Create registration service - Reference < XInterface > x = xSMgr->createInstance( - OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.ImplementationRegistration")) ); - xReg = Reference< XImplementationRegistration > ( x , UNO_QUERY ); - } - catch( Exception & ) { - printf( "Couldn't create ImplementationRegistration service\n" ); - exit(1); - } - - sal_Char szBuf[1024]; - OString sTestName; - - try - { - // Load dll for the tested component - for( int n = 2 ; n <argc ; n ++ ) { - OUString aDllName = OStringToOUString( argv[n] , RTL_TEXTENCODING_ASCII_US ); - xReg->registerImplementation( - OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.SharedLibrary")), - aDllName, - xSimpleReg ); - } - } - catch( Exception &e ) { - printf( "%s\n" , OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ).getStr() ); - - exit(1); - } - - - try - { - // Load dll for the test component - sTestName = "test"; - sTestName += argv[2]; - -#if defined(SAL_W32) - OUString aDllName = OStringToOUString( sTestName , RTL_TEXTENCODING_ASCII_US ); -#else - OUString aDllName(RTL_CONSTASCII_USTRINGPARAM("lib")); - aDllName += OStringToOUString( sTestName , RTL_TEXTENCODING_ASCII_US ); - aDllName += OUString(RTL_CONSTASCII_USTRINGPARAM(".so")); -#endif - - xReg->registerImplementation( - OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.SharedLibrary")) , - aDllName, - xSimpleReg ); - } - catch( Exception & e ) - { - printf( "Couldn't reach dll %s\n" , szBuf ); - exit(1); - } - - - // Instantiate test service - sTestName = "test."; - sTestName += argv[1]; - - Reference < XInterface > xIntTest = - xSMgr->createInstance( OStringToOUString( sTestName , RTL_TEXTENCODING_ASCII_US ) ); - Reference< XSimpleTest > xTest( xIntTest , UNO_QUERY ); - - if( ! xTest.is() ) { - printf( "Couldn't instantiate test service \n" ); - exit( 1 ); - } - - - sal_Int32 nHandle = 0; - sal_Int32 nNewHandle; - sal_Int32 nErrorCount = 0; - sal_Int32 nWarningCount = 0; - - // loop until all test are performed - while( nHandle != -1 ) - { - // Instantiate serivce - Reference< XInterface > x = - xSMgr->createInstance( OStringToOUString( argv[1] , RTL_TEXTENCODING_ASCII_US ) ); - if( ! x.is() ) - { - printf( "Couldn't instantiate service !\n" ); - exit( 1 ); - } - - // do the test - try - { - nNewHandle = xTest->test( - OStringToOUString( argv[1] , RTL_TEXTENCODING_ASCII_US ) , x , nHandle ); - } - catch( Exception & e ) { - OString o = OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ); - printf( "testcomponent : uncaught exception %s\n" , o.getStr() ); - exit(1); - } - catch( ... ) - { - printf( "testcomponent : uncaught unknown exception\n" ); - exit(1); - } - - - // print errors and warning - Sequence<OUString> seqErrors = xTest->getErrors(); - Sequence<OUString> seqWarnings = xTest->getWarnings(); - if( seqWarnings.getLength() > nWarningCount ) - { - printf( "Warnings during test %d!\n" , nHandle ); - for( ; nWarningCount < seqWarnings.getLength() ; nWarningCount ++ ) - { - OString o = OUStringToOString( - seqWarnings.getArray()[nWarningCount], RTL_TEXTENCODING_ASCII_US ); - printf( "Warning\n%s\n---------\n" , o.getStr() ); - } - } - - - if( seqErrors.getLength() > nErrorCount ) { - printf( "Errors during test %d!\n" , nHandle ); - for( ; nErrorCount < seqErrors.getLength() ; nErrorCount ++ ) - { - OString o = OUStringToOString( - seqErrors.getArray()[nErrorCount], RTL_TEXTENCODING_ASCII_US ); - printf( "%s\n" , o.getStr() ); - } - } - - nHandle = nNewHandle; - } - - if( xTest->testPassed() ) { - printf( "Test passed !\n" ); - } - else { - printf( "Test failed !\n" ); - } - - Reference <XComponent > rComp( xSMgr , UNO_QUERY ); - rComp->dispose(); - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/io/test/testconnection.cxx b/io/test/testconnection.cxx deleted file mode 100644 index d44a4b23e..000000000 --- a/io/test/testconnection.cxx +++ /dev/null @@ -1,285 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_io.hxx" -#include <stdio.h> -#include <osl/time.h> - -#include <osl/diagnose.h> -#include <osl/thread.hxx> - -#include <cppuhelper/servicefactory.hxx> - -#include <com/sun/star/lang/XComponent.hpp> - -#include <com/sun/star/registry/XImplementationRegistration.hpp> - -#include <com/sun/star/connection/XConnector.hpp> -#include <com/sun/star/connection/XAcceptor.hpp> - -using namespace ::osl; -using namespace ::rtl; -using namespace ::cppu; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::io; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::registry; -using namespace ::com::sun::star::connection; - - -class MyThread : - public Thread -{ -public: - MyThread( const Reference< XAcceptor > &r , const OUString & sConnectionDescription) : - m_rAcceptor( r ), - m_sConnectionDescription( sConnectionDescription ) - {} - virtual void SAL_CALL run(); - - Reference < XAcceptor > m_rAcceptor; -private: - Reference < XConnection > m_rConnection; - OUString m_sConnectionDescription; -}; - -void doWrite( const Reference < XConnection > &r ) -{ - Sequence < sal_Int8 > seq(10); - for( sal_Int32 i = 0 ; i < 10 ; i ++ ) - { - seq.getArray()[i] = i; - } - - r->write( seq ); -} - -void doRead( const Reference < XConnection > &r ) -{ - Sequence < sal_Int8 > seq(10); - - OSL_ASSERT( 10 == r->read( seq , 10 ) ); - - for( sal_Int32 i = 0 ; i < 10 ; i ++ ) - { - OSL_ASSERT( seq.getConstArray()[i] == i ); - } -} - - -void MyThread::run() -{ - try - { - m_rConnection = m_rAcceptor->accept( m_sConnectionDescription ); - } - catch ( Exception &e) - { - OString tmp= OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ); - printf( "Exception was thrown by acceptor thread: %s\n", tmp.getStr() ); - } - - if( m_rConnection.is() ) - { - Sequence < sal_Int8 > seq(12); - try - { - doWrite( m_rConnection ); - doRead( m_rConnection ); - } - catch (... ) - { - printf( "unknown exception was thrown\n" ); - throw; - } - } - -} - - - - - -void testConnection( const OUString &sConnectionDescription , - const Reference < XAcceptor > &rAcceptor, - const Reference < XConnector > &rConnector ) -{ - { - MyThread thread( rAcceptor , sConnectionDescription ); - thread.create(); - - sal_Bool bGotit = sal_False; - Reference < XConnection > r; - - while( ! bGotit ) - { - try - { - // Why is this wait necessary ???? - TimeValue value = {1,0}; - osl_waitThread( &value ); - r = rConnector->connect( sConnectionDescription ); - OSL_ASSERT( r.is() ); - doWrite( r ); - doRead( r ); - bGotit = sal_True; - } - catch( ... ) - { - printf( "Couldn't connect, retrying ...\n" ); - - } - } - - r->close(); - - try - { - Sequence < sal_Int8 > seq(10); - r->write( seq ); - OSL_FAIL( "expected exception not thrown" ); - } - catch ( IOException & ) - { - // everything is ok - } - catch ( ... ) - { - OSL_FAIL( "wrong exception was thrown" ); - } - - thread.join(); - } -} - - -int SAL_CALL main( int argc, char * argv[] ) -{ - Reference< XMultiServiceFactory > xMgr( - createRegistryServiceFactory( OUString( RTL_CONSTASCII_USTRINGPARAM("applicat.rdb")) ) ); - - Reference< XImplementationRegistration > xImplReg( - xMgr->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.ImplementationRegistration")) ), UNO_QUERY ); - OSL_ENSURE( xImplReg.is(), "### no impl reg!" ); - - OUString aLibName = - OUString(RTL_CONSTASCII_USTRINGPARAM( "connector.uno" SAL_DLLEXTENSION )); - xImplReg->registerImplementation( - OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.SharedLibrary")), aLibName, Reference< XSimpleRegistry >() ); - - aLibName = OUString(RTL_CONSTASCII_USTRINGPARAM( "acceptor.uno" SAL_DLLEXTENSION )); - xImplReg->registerImplementation( - OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.SharedLibrary")), aLibName, Reference< XSimpleRegistry >() ); - - Reference < XAcceptor > rAcceptor( - xMgr->createInstance( - OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.connection.Acceptor")) ) , UNO_QUERY ); - - Reference < XAcceptor > rAcceptorPipe( - xMgr->createInstance( - OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.connection.Acceptor")) ) , UNO_QUERY ); - - Reference < XConnector > rConnector( - xMgr->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.connection.Connector")) ) , UNO_QUERY ); - - - printf( "Testing sockets" ); - fflush( stdout ); - testConnection( OUString(RTL_CONSTASCII_USTRINGPARAM("socket,host=localhost,port=2001")), rAcceptor , rConnector ); - printf( " Done\n" ); - - printf( "Testing pipe" ); - fflush( stdout ); - testConnection( OUString(RTL_CONSTASCII_USTRINGPARAM("pipe,name=bla")) , rAcceptorPipe , rConnector ); - printf( " Done\n" ); - - // check, if errornous strings make any problem - rAcceptor = Reference< XAcceptor > ( - xMgr->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.connection.Acceptor")) ), - UNO_QUERY ); - - try - { - rAcceptor->accept( OUString() ); - OSL_FAIL( "empty connection string" ); - } - catch( IllegalArgumentException & ) - { - // everything is fine - } - catch( ... ) - { - OSL_FAIL( "unexpected akexception with empty connection string" ); - } - - try - { - rConnector->connect( OUString() ); - OSL_FAIL( "empty connection string" ); - } - catch( ConnectionSetupException & ) - { - // everything is fine - } - catch( ... ) - { - OSL_FAIL( "unexpected exception with empty connection string" ); - } - - - MyThread thread( rAcceptor , OUString(RTL_CONSTASCII_USTRINGPARAM("socket,host=localhost,port=2001")) ); - thread.create(); - - TimeValue value = {0,1}; - osl_waitThread( &value ); - try - { - rAcceptor->accept( OUString(RTL_CONSTASCII_USTRINGPARAM("socket,host=localhost,port=2001")) ); - OSL_FAIL( "already existing exception expected" ); - } - catch( AlreadyAcceptingException & e) - { - // everything is fine - } - catch( ... ) - { - OSL_FAIL( "unknown exception, already existing existing expected" ); - } - - rAcceptor->stopAccepting(); - thread.join(); - - Reference < XComponent > rComp( xMgr , UNO_QUERY ); - if( rComp.is() ) - { - rComp->dispose(); - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |