summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2004-02-03 16:55:09 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2004-02-03 16:55:09 +0000
commit0352a26bfd4c43fa012b8122ebe9427808f4bbf1 (patch)
treeac001895830efdbc6ac60c93ca94dc009f9b50a7 /package
parent63e39be0965b44f71e760bbc09d964cbd7a6637e (diff)
INTEGRATION: CWS readstorage (1.2.12); FILE MERGED
2004/01/13 10:13:42 mav 1.2.12.2: #114521# cloning of encrypted storages 2004/01/09 09:04:46 mav 1.2.12.1: #114521# cloning of storage's subelements
Diffstat (limited to 'package')
-rw-r--r--package/qa/storages/TestHelper.java111
1 files changed, 92 insertions, 19 deletions
diff --git a/package/qa/storages/TestHelper.java b/package/qa/storages/TestHelper.java
index eb8e0f9e9004..2b86a16265a0 100644
--- a/package/qa/storages/TestHelper.java
+++ b/package/qa/storages/TestHelper.java
@@ -94,13 +94,8 @@ public class TestHelper {
}
// free the stream resources, garbage collector may remove the object too late
- XComponent xComponent = (XComponent) UnoRuntime.queryInterface( XComponent.class, xStream );
- if ( xComponent == null )
- {
- Error( "Can't get XComponent implementation from substream '" + sStreamName + "'!" );
+ if ( !disposeStream( xStream, sStreamName ) )
return false;
- }
- xComponent.dispose();
return true;
}
@@ -252,13 +247,8 @@ public class TestHelper {
}
// free the stream resources, garbage collector may remove the object too late
- XComponent xComponent = (XComponent) UnoRuntime.queryInterface( XComponent.class, xSubStream );
- if ( xComponent == null )
- {
- Error( "Can't get XComponent implementation from substream '" + sStreamName + "'!" );
+ if ( !disposeStream( xSubStream, sStreamName ) )
return 0;
- }
- xComponent.dispose();
return 1;
}
@@ -287,10 +277,11 @@ public class TestHelper {
bOk = false;
}
- if ( ( bIsRoot && ( nPropMode | ElementModes.ELEMENT_READ ) != ( nMode | ElementModes.ELEMENT_READ ) )
+ if ( ( bIsRoot
+ && ( nPropMode | ElementModes.ELEMENT_READ ) != ( nMode | ElementModes.ELEMENT_READ ) )
|| ( !bIsRoot && ( nPropMode & nMode ) != nMode ) )
{
- Error( "'OpenMode' property contains wrong value!" );
+ Error( "'OpenMode' property contains wrong value, expected " + nMode + ", in reality " + nPropMode + "!" );
bOk = false;
}
}
@@ -336,10 +327,11 @@ public class TestHelper {
bOk = false;
}
- if ( ( bIsRoot && ( nPropMode | ElementModes.ELEMENT_READ ) != ( nMode | ElementModes.ELEMENT_READ ) )
+ if ( ( bIsRoot
+ && ( nPropMode | ElementModes.ELEMENT_READ ) != ( nMode | ElementModes.ELEMENT_READ ) )
|| ( !bIsRoot && ( nPropMode & nMode ) != nMode ) )
{
- Error( "'OpenMode' property contains wrong value!" );
+ Error( "'OpenMode' property contains wrong value, expected " + nMode + ", in reality " + nPropMode + "!" );
bOk = false;
}
}
@@ -405,7 +397,6 @@ public class TestHelper {
}
}
-
// check properties
boolean bOk = false;
@@ -469,7 +460,13 @@ public class TestHelper {
return false;
}
- return InternalCheckStream( xSubStream, sName, sMediaType, pBytes );
+ boolean bResult = InternalCheckStream( xSubStream, sName, sMediaType, pBytes );
+
+ // free the stream resources, garbage collector may remove the object too late
+ if ( !disposeStream( xSubStream, sName ) )
+ return false;
+
+ return bResult;
}
public boolean checkEncrStream( XStorage xParentStorage,
@@ -534,7 +531,13 @@ public class TestHelper {
return false;
}
- return InternalCheckStream( xSubStream, sName, sMediaType, pBytes );
+ boolean bResult = InternalCheckStream( xSubStream, sName, sMediaType, pBytes );
+
+ // free the stream resources, garbage collector may remove the object too late
+ if ( !disposeStream( xSubStream, sName ) )
+ return false;
+
+ return bResult;
}
public boolean copyStorage( XStorage xSourceStorage, XStorage xDestStorage )
@@ -576,6 +579,28 @@ public class TestHelper {
return true;
}
+ public boolean disposeStream( XStream xStream, String sStreamName )
+ {
+ XComponent xComponent = (XComponent) UnoRuntime.queryInterface( XComponent.class, xStream );
+ if ( xComponent == null )
+ {
+ Error( "Can't get XComponent implementation from substream '" + sStreamName + "'!" );
+ return false;
+ }
+
+ try
+ {
+ xComponent.dispose();
+ }
+ catch( Exception e )
+ {
+ Error( "Substream '" + sStreamName + "' disposing throws exception: " + e );
+ return false;
+ }
+
+ return true;
+ }
+
public boolean disposeStorage( XStorage xStorage )
{
// dispose the storage
@@ -855,6 +880,54 @@ public class TestHelper {
return false;
}
+ public XStorage cloneSubStorage( XStorage xStorage, String sName )
+ {
+ // clone existing substorage
+ try
+ {
+ XStorage xSubStorage = xStorage.cloneStorageElement( sName );
+ return xSubStorage;
+ }
+ catch( Exception e )
+ {
+ Error( "Can't clone substorage '" + sName + "', exception: " + e );
+ }
+
+ return null;
+ }
+
+ public XStream cloneSubStream( XStorage xStorage, String sName )
+ {
+ // clone existing substream
+ try
+ {
+ XStream xStream = xStorage.cloneStreamElement( sName );
+ return xStream;
+ }
+ catch( Exception e )
+ {
+ Error( "Can't clone substream '" + sName + "', exception: " + e );
+ }
+
+ return null;
+ }
+
+ public XStream cloneEncrSubStream( XStorage xStorage, String sName, byte[] pPass )
+ {
+ // clone existing substream
+ try
+ {
+ XStream xStream = xStorage.cloneEncryptedStreamElement( sName, pPass );
+ return xStream;
+ }
+ catch( Exception e )
+ {
+ Error( "Can't clone encrypted substream '" + sName + "', exception: " + e );
+ }
+
+ return null;
+ }
+
public void Error( String sError )
{
m_aLogWriter.println( m_sTestPrefix + "Error: " + sError );