diff options
author | Jörg Budischewski <jbu@openoffice.org> | 2001-01-08 12:27:40 +0000 |
---|---|---|
committer | Jörg Budischewski <jbu@openoffice.org> | 2001-01-08 12:27:40 +0000 |
commit | 19519616601a2a016eb966637742f4c3ca783e5b (patch) | |
tree | 47de6f14d3c206b0969158faa7677ecde3d08111 /io | |
parent | 9ad3304b4298c811f66791a5551a61ed543c20ce (diff) |
added tests for empty
Diffstat (limited to 'io')
-rw-r--r-- | io/test/makefile.mk | 16 | ||||
-rw-r--r-- | io/test/testconnection.cxx | 71 |
2 files changed, 72 insertions, 15 deletions
diff --git a/io/test/makefile.mk b/io/test/makefile.mk index 263475b1f948..c63283dff64a 100644 --- a/io/test/makefile.mk +++ b/io/test/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.3 $ +# $Revision: 1.4 $ # -# last change: $Author: jbu $ $Date: 2000-12-08 11:07:30 $ +# last change: $Author: jbu $ $Date: 2001-01-08 13:27:40 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -66,8 +66,8 @@ PRJNAME=extensions TARGET=workben LIBTARGET=NO -TESTAPP=testcomponent -#TESTAPP=testconnection +#TESTAPP=testcomponent +TESTAPP=testconnection TARGETTYPE=CUI ENABLE_EXCEPTIONS=TRUE @@ -89,7 +89,13 @@ UNOUCRRDB=$(SOLARBINDIR)$/udkapi.rdb UNOUCROUT=$(OUT)$/inc UNOTYPES = com.sun.star.connection.XConnector \ - com.sun.star.connection.XAcceptor + 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 + # # std testcomponent diff --git a/io/test/testconnection.cxx b/io/test/testconnection.cxx index 5e915e43e536..ff072ad78806 100644 --- a/io/test/testconnection.cxx +++ b/io/test/testconnection.cxx @@ -2,9 +2,9 @@ * * $RCSfile: testconnection.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jbu $ $Date: 2000-12-08 11:07:30 $ + * last change: $Author: jbu $ $Date: 2001-01-08 13:27:40 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -92,8 +92,8 @@ public: {} virtual void SAL_CALL run(); -private: Reference < XAcceptor > m_rAcceptor; +private: Reference < XConnection > m_rConnection; OUString m_sConnectionDescription; }; @@ -128,10 +128,10 @@ void MyThread::run() { m_rConnection = m_rAcceptor->accept( m_sConnectionDescription ); } - catch ( ... ) + catch ( Exception &e) { - printf( "Exception was thrown by acceptor thread\n" ); - throw; + OString tmp= OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ); + printf( "Exception was thrown by acceptor thread: %s\n", tmp.getStr() ); } if( m_rConnection.is() ) @@ -238,17 +238,13 @@ int __cdecl main( int argc, char * argv[] ) OUString aLibName = OUString::createFromAscii( REG_PREFIX ); aLibName += OUString::createFromAscii("connectr"); -#ifndef OS2 aLibName += OUString::createFromAscii(DLL_POSTFIX); -#endif xImplReg->registerImplementation( OUString::createFromAscii("com.sun.star.loader.SharedLibrary"), aLibName, Reference< XSimpleRegistry >() ); aLibName = OUString::createFromAscii( REG_PREFIX ); aLibName += OUString::createFromAscii("acceptor"); -#ifndef OS2 aLibName += OUString::createFromAscii(DLL_POSTFIX); -#endif xImplReg->registerImplementation( OUString::createFromAscii("com.sun.star.loader.SharedLibrary"), aLibName, Reference< XSimpleRegistry >() ); @@ -274,6 +270,61 @@ int __cdecl main( int argc, char * argv[] ) testConnection( OUString::createFromAscii("pipe,name=bla") , rAcceptorPipe , rConnector ); printf( " Done\n" ); + // check, if errornous strings make any problem + rAcceptor = Reference< XAcceptor > ( + xMgr->createInstance( OUString::createFromAscii( "com.sun.star.connection.Acceptor" ) ), + UNO_QUERY ); + + try + { + rAcceptor->accept( OUString() ); + OSL_ENSURE( 0 , "empty connection string" ); + } + catch( IllegalArgumentException & ) + { + // everything is fine + } + catch( ... ) + { + OSL_ENSURE( 0, "unexpected akexception with empty connection string" ); + } + + try + { + rConnector->connect( OUString() ); + OSL_ENSURE( 0 , "empty connection string" ); + } + catch( ConnectionSetupException & ) + { + // everything is fine + } + catch( ... ) + { + OSL_ENSURE( 0, "unexpected exception with empty connection string" ); + } + + + MyThread thread( rAcceptor , OUString::createFromAscii("socket,host=localhost,port=2001") ); + thread.create(); + + TimeValue value = {0,1}; + osl_waitThread( &value ); + try + { + rAcceptor->accept( OUString::createFromAscii("socket,host=localhost,port=2001") ); + OSL_ENSURE( 0 , "already existing exception expected" ); + } + catch( AlreadyAcceptingException & e) + { + // everything is fine + } + catch( ... ) + { + OSL_ENSURE( 0, "unknown exception, already existing existing expected" ); + } + + rAcceptor->stopAccepting(); + thread.join(); Reference < XComponent > rComp( xMgr , UNO_QUERY ); if( rComp.is() ) |