Tag: cws_dev300_odbmacros3 User: fs Date: 2008-08-02 20:34:19+0000 Modified: dba/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java
Log: derive from the (new) TestCase class, move some of the CRM-independent methods therein File Changes: Directory: /dba/dbaccess/qa/complex/dbaccess/ ============================================= File [changed]: CRMBasedTestCase.java Url: http://dba.openoffice.org/source/browse/dba/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java?r1=1.1.6.5&r2=1.1.6.6 Delta lines: +2 -84 -------------------- --- CRMBasedTestCase.java 2008-07-30 20:51:27+0000 1.1.6.5 +++ CRMBasedTestCase.java 2008-08-02 20:34:17+0000 1.1.6.6 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: CRMBasedTestCase.java,v $ - * $Revision: 1.1.6.5 $ + * $Revision: 1.1.6.6 $ * * This file is part of OpenOffice.org. * @@ -29,59 +29,17 @@ ************************************************************************/ package complex.dbaccess; -import com.sun.star.beans.XPropertySet; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.sdb.XSingleSelectQueryComposer; import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XComponentContext; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.logging.Level; import java.util.logging.Logger; -public abstract class CRMBasedTestCase extends complexlib.ComplexTestCase +public abstract class CRMBasedTestCase extends TestCase { protected CRMDatabase m_database; // -------------------------------------------------------------------------------------------------------- - protected final XMultiServiceFactory getORB() - { - return (XMultiServiceFactory)param.getMSF(); - } - - // -------------------------------------------------------------------------------------------------------- - protected final XComponentContext getComponentContext() - { - XComponentContext context = null; - try - { - XPropertySet orbProps = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, getORB() ); - context = (XComponentContext)UnoRuntime.queryInterface( XComponentContext.class, - orbProps.getPropertyValue( "DefaultContext" ) ); - } - catch ( Exception ex ) - { - failed( "could not retrieve the ComponentContext" ); - } - return context; - } - - // -------------------------------------------------------------------------------------------------------- - /** returns the URL of a temporary file which can be used during the test. - * - * The file will be deleted when the process exits - * @return the URL of a temporary file - */ - protected final String createTempFileURL() throws IOException - { - File documentFile = java.io.File.createTempFile( getTestObjectName(), ".odb" ); - documentFile.deleteOnExit(); - return documentFile.getAbsoluteFile().toURL().toString(); - } - - // -------------------------------------------------------------------------------------------------------- protected void createTestCase() { try @@ -116,46 +74,6 @@ } // -------------------------------------------------------------------------------------------------------- - protected void verifyExpectedException( Object _object, Class _unoInterfaceClass, String _methodName, Object[] _methodArgs, - Class _expectedExceptionClass ) - { - verifyExpectedException( UnoRuntime.queryInterface( _unoInterfaceClass, _object ), _methodName, - _methodArgs, _expectedExceptionClass ); - } - - // -------------------------------------------------------------------------------------------------------- - protected void verifyExpectedException( Object _object, String _methodName, Object[] _methodArgs, - Class _expectedExceptionClass ) - { - Class objectClass = _object.getClass(); - Class[] methodArgsClasses = new Class[ _methodArgs.length ]; - for ( int i=0; i<_methodArgs.length; ++i ) - methodArgsClasses[i] = _methodArgs[i].getClass(); - - boolean noExceptionAllowed = _expectedExceptionClass == null; - - boolean caughtExpected = noExceptionAllowed ? true : false; - try - { - Method method = objectClass.getMethod( _methodName, methodArgsClasses ); - method.invoke(_object, _methodArgs ); - } - catch ( InvocationTargetException e ) - { - caughtExpected = noExceptionAllowed - ? false - : ( e.getTargetException().getClass().equals( _expectedExceptionClass ) ); - } - catch( Exception e ) - { - caughtExpected = false; - } - assure( "did not catch the expected exception (" + - ( noExceptionAllowed ? "none" : _expectedExceptionClass.getName() ) + - ") while calling " + _object.getClass().getName() + "." + _methodName, caughtExpected ); - } - - // -------------------------------------------------------------------------------------------------------- /** creates a SingleSelectQueryComposer for our connection */ protected final XSingleSelectQueryComposer createQueryComposer() throws com.sun.star.uno.Exception --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
