diff options
author | Kurt Zenker <kz@openoffice.org> | 2009-06-03 11:26:39 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2009-06-03 11:26:39 +0000 |
commit | 65d3b7eea08aeb5bb6b510d683a1de602fc856cc (patch) | |
tree | 20d65f8e4aa9d14aa9e589f5b9ef9947ebb9f568 /package/qa | |
parent | CWS-TOOLING: integrate CWS tl66 (diff) | |
download | core-65d3b7eea08aeb5bb6b510d683a1de602fc856cc.tar.gz core-65d3b7eea08aeb5bb6b510d683a1de602fc856cc.zip |
CWS-TOOLING: integrate CWS os128
2009-04-22 12:58:26 +0200 b_michaelsen r271093 : #i101084# using the frames enumeration for other SwXFrames-queries; also added a complex test to ensure the behavior to be the same
2009-04-20 14:53:03 +0200 mav r270987 : #i101219# adjust the testcases to test memory cache and temporary file cache
2009-04-20 14:52:09 +0200 mav r270986 : #i101219#,#i99077# use memory to cache data; no precopying on commit
2009-04-20 14:39:21 +0200 mav r270984 : #i101219# use memory to cache data
2009-04-20 14:39:08 +0200 mav r270983 : #i101219# use memory to cache data
2009-04-20 14:38:45 +0200 mav r270982 : #i101219# use memory to cache data
2009-04-17 07:37:52 +0200 os r270912 : CWS-TOOLING: rebase CWS os128 to trunk@270723 (milestone: DEV300:m46)
2009-04-15 14:54:18 +0200 b_michaelsen r270845 : #i101084# using frame enumerations for paragraph export for better performance
2009-04-15 14:52:54 +0200 b_michaelsen r270843 : #i101084# implemented XEnumerationAccess interface on framesets
2009-04-03 17:08:10 +0200 mav r270504 : #i100722# do not compress streams of known compressed types per default
2009-04-03 13:49:50 +0200 os r270484 : resync error fixed
2009-04-03 12:55:32 +0200 mav r270470 : #i100722# do not compress streams of known compressed types per default
2009-04-03 10:00:58 +0200 os r270463 : resync error fixed
2009-04-03 09:52:53 +0200 os r270462 : resync error fixed
2009-04-03 09:10:14 +0200 os r270449 : #i99568# string compare operator of hash_map changed
2009-04-03 09:03:49 +0200 os r270446 : #i100683# normalize file URLs
2009-04-02 11:09:27 +0200 os r270381 : #i100683# making URLs relative without file access
2009-04-02 09:04:42 +0200 os r270366 : CWS-TOOLING: rebase CWS os128 to trunk@270033 (milestone: DEV300:m45)
2009-03-31 08:08:37 +0200 os r270258 : #i100683# reducing calls to URIHelper::simpleNormalizeMakeRelative()
2009-03-19 17:06:22 +0100 os r269756 : #i99568# XTolerantMultiPropertySet activated
2009-03-16 11:46:14 +0100 os r269517 : wrong commit to #i97471# removed
2009-03-16 11:36:50 +0100 os r269514 : #i97471# SwDrawTextShell::Init(): mouse double click and key input in group objects at the same time: prevent crash
2009-03-13 11:08:54 +0100 os r269464 : #i99568# static SfxItemPropertySet
2009-03-13 11:03:22 +0100 os r269463 : #i99568# static SfxItemPropertySet
2009-03-11 12:59:27 +0100 os r269320 : #i99568# WhichId of properties handled from ScDocOptionsObj added
2009-03-06 09:09:58 +0100 os r268972 : #i99568# SfxItemPropertySet improvements
2009-03-05 20:54:43 +0100 os r268942 : #i99568# Sfx/SvxItemPropertySet improvements
2009-03-05 20:19:52 +0100 os r268941 : #i99568# SfxItemPropertySet improvements
2009-03-05 20:05:03 +0100 os r268940 : #i99568# SfxItemPropertySet improvements
2009-03-05 18:54:47 +0100 os r268936 : #i99568# Sfx/SvxItemPropertySet improvements
2009-03-05 17:51:38 +0100 os r268931 : #i99568# Sfx/SvxItemPropertySet improvements
2009-03-05 17:33:03 +0100 os r268930 : #i99568# Sfx/SvxItemPropertySet improvements
2009-03-05 15:53:00 +0100 os r268920 : #i99568# Sfx/SvxItemPropertySet improvements
2009-03-05 15:52:50 +0100 os r268919 : #i99568# Sfx/SvxItemPropertySet improvements
2009-03-05 15:50:41 +0100 os r268918 : #i99568# Sfx/SvxItemPropertySet improvements
2009-03-05 15:41:04 +0100 os r268916 : #i99568# Sfx/SvxItemPropertySet improvements
2009-03-05 15:40:40 +0100 os r268915 : #i99568# Sfx/SvxItemPropertySet improvements
2009-03-05 10:16:20 +0100 os r268881 : #i99568# Sfx/SvxItemPropertySet improvements
2009-03-05 10:15:55 +0100 os r268880 : #i99568# Sfx/SvxItemPropertySet improvements
2009-03-03 08:40:09 +0100 os r268704 : ScTableSheetObj::GetItemPropertyMap fixed
2009-03-03 07:50:00 +0100 os r268703 : SfxItemProperty set as pointer
2009-03-03 07:49:46 +0100 os r268702 : SfxItemProperty set as pointer
2009-03-02 08:15:37 +0100 os r268631 : minor fix
2009-03-02 07:58:38 +0100 os r268630 : minor fix
2009-02-27 13:03:25 +0100 os r268584 : exports
2009-02-27 11:17:04 +0100 os r268567 : debug code removed
2009-02-27 11:04:07 +0100 os r268565 : duplicate return removed
2009-02-27 10:17:37 +0100 os r268558 : syntax fixed
2009-02-27 09:56:14 +0100 os r268554 : #i99568# type mix fixed
2009-02-27 09:40:56 +0100 os r268553 : #i99568# exports changes reverted
2009-02-25 12:50:54 +0100 os r268433 : #i99568# SfxItemPropertySet rework
2009-02-25 12:13:39 +0100 os r268432 : #i99568# SfxItemPropertySet rework
2009-02-25 12:12:47 +0100 os r268431 : #i99568# SfxItemPropertySet rework
2009-02-25 12:10:27 +0100 os r268430 : #i99568# SfxItemPropertySet rework
2009-02-25 12:09:36 +0100 os r268429 : #i99568# SfxItemPropertySet rework
2009-02-25 12:07:39 +0100 os r268428 : #i99568# SfxItemPropertySet rework
2009-02-25 11:59:35 +0100 os r268427 : #i99568# SfxItemPropertySet rework
2009-02-25 11:52:52 +0100 os r268425 : #i99568# SfxItemPropertySet rework
2009-02-25 11:49:17 +0100 os r268424 : #i99568# SfxItemPropertySet rework
2009-02-25 11:45:17 +0100 os r268423 : #i99568# SfxItemPropertySet rework
2009-02-11 11:39:04 +0100 os r267587 : #i57008# use registration of index marks at SwUnoCallback
Diffstat (limited to 'package/qa')
-rw-r--r-- | package/qa/storages/StorageUnitTest.java | 9 | ||||
-rw-r--r-- | package/qa/storages/Test01.java | 18 | ||||
-rw-r--r-- | package/qa/storages/Test02.java | 11 | ||||
-rw-r--r-- | package/qa/storages/Test03.java | 33 | ||||
-rw-r--r-- | package/qa/storages/Test04.java | 33 | ||||
-rw-r--r-- | package/qa/storages/Test05.java | 42 | ||||
-rw-r--r-- | package/qa/storages/Test07.java | 24 | ||||
-rw-r--r-- | package/qa/storages/Test08.java | 16 | ||||
-rw-r--r-- | package/qa/storages/Test09.java | 14 | ||||
-rw-r--r-- | package/qa/storages/Test10.java | 25 | ||||
-rw-r--r-- | package/qa/storages/Test11.java | 28 | ||||
-rw-r--r-- | package/qa/storages/Test12.java | 25 | ||||
-rw-r--r-- | package/qa/storages/Test13.java | 31 | ||||
-rw-r--r-- | package/qa/storages/Test18.java | 172 | ||||
-rw-r--r-- | package/qa/storages/TestHelper.java | 93 | ||||
-rw-r--r-- | package/qa/storages/makefile.mk | 1 |
16 files changed, 557 insertions, 18 deletions
diff --git a/package/qa/storages/StorageUnitTest.java b/package/qa/storages/StorageUnitTest.java index 7e8caa314e96..2ebfb2967e1d 100644 --- a/package/qa/storages/StorageUnitTest.java +++ b/package/qa/storages/StorageUnitTest.java @@ -84,6 +84,7 @@ public class StorageUnitTest extends ComplexTestCase "ExecuteTest15", "ExecuteTest16", "ExecuteTest17", + "ExecuteTest18", "ExecuteRegressionTest_114358", "ExecuteRegressionTest_i29169", "ExecuteRegressionTest_i30400", @@ -97,7 +98,8 @@ public class StorageUnitTest extends ComplexTestCase "ExecuteRegressionTest_i59886", "ExecuteRegressionTest_i61909", "ExecuteRegressionTest_i84234", - "ExecuteRegressionTest_125919"}; + "ExecuteRegressionTest_125919" + }; } public String getTestObjectName() @@ -234,6 +236,11 @@ public class StorageUnitTest extends ComplexTestCase assure( "Test17 failed!", aTest.test() ); } + public void ExecuteTest18() + { + StorageTest aTest = new Test18( m_xMSF, m_xStorageFactory, log ); + assure( "Test18 failed!", aTest.test() ); + } public void ExecuteRegressionTest_114358() { diff --git a/package/qa/storages/Test01.java b/package/qa/storages/Test01.java index e1a78fd85763..a793a2fd5809 100644 --- a/package/qa/storages/Test01.java +++ b/package/qa/storages/Test01.java @@ -58,6 +58,18 @@ public class Test01 implements StorageTest { return false; } + byte pBigBytes[] = new byte[33000]; + for ( int nInd = 0; nInd < 33000; nInd++ ) + pBigBytes[nInd] = (byte)( nInd % 128 ); + + // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes + if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage, "BigSubStream1", "MediaType1", true, pBigBytes ) ) + return false; + + // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes + if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage, "BigSubStream2", "MediaType2", false, pBigBytes ) ) + return false; + byte pBytes1[] = { 1, 1, 1, 1, 1 }; // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes @@ -136,6 +148,12 @@ public class Test01 implements StorageTest { if ( !m_aTestHelper.checkStorageProperties( xResultSubStorage, "MediaType4", false, ElementModes.READ ) ) return false; + if ( !m_aTestHelper.checkStream( xResultSubStorage, "BigSubStream1", "MediaType1", true, pBigBytes ) ) + return false; + + if ( !m_aTestHelper.checkStream( xResultSubStorage, "BigSubStream2", "MediaType2", false, pBigBytes ) ) + return false; + if ( !m_aTestHelper.checkStream( xResultSubStorage, "SubStream1", "MediaType1", true, pBytes1 ) ) return false; diff --git a/package/qa/storages/Test02.java b/package/qa/storages/Test02.java index 729cdd27fa11..668efbe6a509 100644 --- a/package/qa/storages/Test02.java +++ b/package/qa/storages/Test02.java @@ -60,6 +60,14 @@ public class Test02 implements StorageTest { return false; } + byte pBigBytes[] = new byte[33000]; + for ( int nInd = 0; nInd < 33000; nInd++ ) + pBigBytes[nInd] = (byte)( nInd % 128 ); + + // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes + if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage, "BigSubStream1", "MediaType1", true, pBigBytes ) ) + return false; + byte pBytes1[] = { 1, 1, 1, 1, 1 }; // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes @@ -136,6 +144,9 @@ public class Test02 implements StorageTest { if ( !m_aTestHelper.checkStorageProperties( xResultSubStorage, "MediaType3", false, ElementModes.READ ) ) return false; + if ( !m_aTestHelper.checkStream( xResultSubStorage, "BigSubStream1", "MediaType1", true, pBigBytes ) ) + return false; + if ( !m_aTestHelper.checkStream( xResultSubStorage, "SubStream1", "MediaType1", true, pBytes1 ) ) return false; diff --git a/package/qa/storages/Test03.java b/package/qa/storages/Test03.java index 80259500778b..353cd4df8d14 100644 --- a/package/qa/storages/Test03.java +++ b/package/qa/storages/Test03.java @@ -52,6 +52,18 @@ public class Test03 implements StorageTest { return false; } + byte pBigBytes[] = new byte[33000]; + for ( int nInd = 0; nInd < 33000; nInd++ ) + pBigBytes[nInd] = (byte)( nInd % 128 ); + + // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes + if ( !m_aTestHelper.WriteBytesToSubstream( xTempStorage, "BigSubStream1", "MediaType1", true, pBigBytes ) ) + return false; + + // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes + if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage, "BigSubStream2", "MediaType2", false, pBigBytes ) ) + return false; + byte pBytes1[] = { 1, 1, 1, 1, 1 }; // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes @@ -140,15 +152,24 @@ public class Test03 implements StorageTest { // check that root storage contents are represented correctly String sRootCont[] = xRootNameAccess.getElementNames(); - if ( sRootCont.length != 2 ) + if ( sRootCont.length != 3 ) { m_aTestHelper.Error( "Root storage contains wrong amount of children!" ); return false; } - if ( !( sRootCont[0].equals( "SubStorage1" ) && sRootCont[1].equals( "SubStream1" ) - || sRootCont[0].equals( "SubStream1" ) && sRootCont[1].equals( "SubStorage1" ) ) - || !( xRootNameAccess.hasByName( "SubStream1" ) && xRootNameAccess.hasByName( "SubStorage1" ) ) ) + int nFlag = 0; + for ( int nInd = 0; nInd < sRootCont.length; nInd++ ) + { + if ( sRootCont[nInd].equals( "SubStorage1" ) ) + nFlag |= 1; + else if ( sRootCont[nInd].equals( "SubStream1" ) ) + nFlag |= 2; + else if ( sRootCont[nInd].equals( "BigSubStream1" ) ) + nFlag |= 4; + } + + if ( nFlag != 7 || !( xRootNameAccess.hasByName( "BigSubStream1" ) && xRootNameAccess.hasByName( "SubStream1" ) && xRootNameAccess.hasByName( "SubStorage1" ) ) ) { m_aTestHelper.Error( "Root storage contains wrong list of children!" ); return false; @@ -169,9 +190,9 @@ public class Test03 implements StorageTest { return false; } - if ( !xChildAccess.hasByName( "SubStream2" ) + if ( !( xChildAccess.hasByName( "SubStream2" ) && xChildAccess.hasByName( "BigSubStream2" ) ) || !xResultSubStorage.isStreamElement( "SubStream2" ) - || xResultSubStorage.isStorageElement( "SubStream2" ) ) + || !xResultSubStorage.isStreamElement( "BigSubStream2" ) ) { m_aTestHelper.Error( "'SubStream2' can not be detected as child stream element of 'SubStorage1'!" ); return false; diff --git a/package/qa/storages/Test04.java b/package/qa/storages/Test04.java index 6c6dedee1817..81f770f8ff9a 100644 --- a/package/qa/storages/Test04.java +++ b/package/qa/storages/Test04.java @@ -63,6 +63,14 @@ public class Test04 implements StorageTest { return false; } + byte pBigBytes[] = new byte[33000]; + for ( int nInd = 0; nInd < 33000; nInd++ ) + pBigBytes[nInd] = (byte)( nInd % 128 ); + + // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes + if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage1, "BigSubStream1", "MediaType1", true, pBigBytes ) ) + return false; + byte pBytes1[] = { 1, 1, 1, 1, 1 }; // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes @@ -79,6 +87,10 @@ public class Test04 implements StorageTest { return false; } + // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes + if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage2, "BigSubStream2", "MediaType2", false, pBigBytes ) ) + return false; + byte pBytes2[] = { 2, 2, 2, 2, 2 }; // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes @@ -158,6 +170,15 @@ public class Test04 implements StorageTest { if ( !m_aTestHelper.moveElementTo( xTempSubStorage1, "SubStream1", xTempFileStorage ) ) return false; + if ( !m_aTestHelper.copyElementTo( xTempSubStorage1, "BigSubStream1", xTempFileStorage ) ) + return false; + + if ( !m_aTestHelper.renameElement( xTempFileStorage, "BigSubStream1", "BigSubStream1_copy" ) ) + return false; + + if ( !m_aTestHelper.moveElementTo( xTempSubStorage1, "BigSubStream1", xTempFileStorage ) ) + return false; + if ( !m_aTestHelper.commitStorage( xTempFileStorage ) ) return false; @@ -212,15 +233,27 @@ public class Test04 implements StorageTest { if ( !m_aTestHelper.checkStream( xResStorage, "SubStream1", "MediaType1", true, pBytes1 ) ) return false; + if ( !m_aTestHelper.checkStream( xResStorage, "BigSubStream1", "MediaType1", true, pBigBytes ) ) + return false; + if ( !m_aTestHelper.checkStream( xResStorage, "SubStream1_copy", "MediaType1", true, pBytes1 ) ) return false; + if ( !m_aTestHelper.checkStream( xResStorage, "BigSubStream1_copy", "MediaType1", true, pBigBytes ) ) + return false; + if ( !m_aTestHelper.checkStream( xResSubStorage1, "SubStream1", "MediaType1", true, pBytes1 ) ) return false; + if ( !m_aTestHelper.checkStream( xResSubStorage1, "BigSubStream1", "MediaType1", true, pBigBytes ) ) + return false; + if ( !m_aTestHelper.checkStream( xResSubStorage2, "SubStream2", "MediaType2", false, pBytes2 ) ) return false; + if ( !m_aTestHelper.checkStream( xResSubStorage2, "BigSubStream2", "MediaType2", false, pBigBytes ) ) + return false; + // the storage must be disposed before removing if ( !m_aTestHelper.disposeStorage( xResSubStorage2 ) ) return false; diff --git a/package/qa/storages/Test05.java b/package/qa/storages/Test05.java index bea3d3cccbd0..adf943c6ef12 100644 --- a/package/qa/storages/Test05.java +++ b/package/qa/storages/Test05.java @@ -72,6 +72,17 @@ public class Test05 implements StorageTest { return false; } + byte pBigBytes[] = new byte[33000]; + for ( int nInd = 0; nInd < 33000; nInd++ ) + pBigBytes[nInd] = (byte)( nInd % 128 ); + + // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes + if ( !m_aTestHelper.WriteBytesToSubstream( xSubSubStorage, "BigSubStream1", "MediaType1", true, pBigBytes ) ) + return false; + + // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes + if ( !m_aTestHelper.WriteBytesToSubstream( xSubSubStorage, "BigSubStream2", "MediaType2", false, pBigBytes ) ) + return false; byte pBytes1[] = { 1, 1, 1, 1, 1 }; @@ -126,27 +137,40 @@ public class Test05 implements StorageTest { XStream xSubStream1 = m_aTestHelper.OpenStream( xSubSubStorage, "SubStream1", ElementModes.WRITE | ElementModes.NOCREATE ); + XStream xBigSubStream1 = m_aTestHelper.OpenStream( xSubSubStorage, + "BigSubStream1", + ElementModes.WRITE | ElementModes.NOCREATE ); XStream xSubStream2 = m_aTestHelper.OpenStream( xSubSubStorage, "SubStream2", ElementModes.READ | ElementModes.NOCREATE ); - if ( xSubStream1 == null || xSubStream2 == null ) + XStream xBigSubStream2 = m_aTestHelper.OpenStream( xSubSubStorage, + "BigSubStream2", + ElementModes.READ | ElementModes.NOCREATE ); + + if ( xSubStream1 == null || xBigSubStream1 == null || xSubStream2 == null || xBigSubStream2 == null ) return false; // it should be possible to have more then one copy of stream for reading XStream xSubStream2clone = m_aTestHelper.OpenStream( xSubSubStorage, "SubStream2", ElementModes.READ | ElementModes.NOCREATE ); - if ( xSubStream2 == null ) + XStream xBigSubStream2clone = m_aTestHelper.OpenStream( xSubSubStorage, + "BigSubStream2", + ElementModes.READ | ElementModes.NOCREATE ); + if ( xSubStream2clone == null || xBigSubStream2clone == null ) return false; - // so now the first stream can not be open neither for reading nor for writing + // so now the first streams can not be open neither for reading nor for writing if ( !m_aTestHelper.cantOpenStream( xSubSubStorage, "SubStream1", ElementModes.WRITE ) - || !m_aTestHelper.cantOpenStream( xSubSubStorage, "SubStream1", ElementModes.READ ) ) + || !m_aTestHelper.cantOpenStream( xSubSubStorage, "SubStream1", ElementModes.READ ) + || !m_aTestHelper.cantOpenStream( xSubSubStorage, "BigSubStream1", ElementModes.WRITE ) + || !m_aTestHelper.cantOpenStream( xSubSubStorage, "BigSubStream1", ElementModes.READ ) ) return false; - // the second stream can not be open for writing - if ( !m_aTestHelper.cantOpenStream( xSubSubStorage, "SubStream2", ElementModes.WRITE ) ) + // the second streams can not be open for writing + if ( !m_aTestHelper.cantOpenStream( xSubSubStorage, "SubStream2", ElementModes.WRITE ) + || !m_aTestHelper.cantOpenStream( xSubSubStorage, "BigSubStream2", ElementModes.WRITE ) ) return false; @@ -249,9 +273,15 @@ public class Test05 implements StorageTest { if ( !m_aTestHelper.checkStream( xResSubSubStorage, "SubStream1", "MediaType1", true, pBytes1 ) ) return false; + if ( !m_aTestHelper.checkStream( xResSubSubStorage, "BigSubStream1", "MediaType1", true, pBigBytes ) ) + return false; + if ( !m_aTestHelper.checkStream( xResSubSubStorage, "SubStream2", "MediaType2", false, pBytes2 ) ) return false; + if ( !m_aTestHelper.checkStream( xResSubSubStorage, "BigSubStream2", "MediaType2", false, pBigBytes ) ) + return false; + // dispose used storages to free resources if ( !m_aTestHelper.disposeStorage( xResultStorage ) ) return false; diff --git a/package/qa/storages/Test07.java b/package/qa/storages/Test07.java index 31907a92bb01..970c6f13ec09 100644 --- a/package/qa/storages/Test07.java +++ b/package/qa/storages/Test07.java @@ -48,10 +48,18 @@ public class Test07 implements StorageTest { return false; } + byte pBigBytes[] = new byte[33000]; + for ( int nInd = 0; nInd < 33000; nInd++ ) + pBigBytes[nInd] = (byte)( nInd % 128 ); + byte pBytes1[] = { 1, 1, 1, 1, 1 }; String sPass1 = "12345"; // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes + if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempStorage, "BigSubStream1", "MediaType1", true, pBigBytes, sPass1 ) ) + return false; + + // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempStorage, "SubStream1", "MediaType1", true, pBytes1, sPass1 ) ) return false; @@ -59,6 +67,10 @@ public class Test07 implements StorageTest { String sPass2 = "54321"; // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes + if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempStorage, "BigSubStream2", "MediaType2", false, pBigBytes, sPass2 ) ) + return false; + + // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempStorage, "SubStream2", "MediaType2", false, pBytes2, sPass2 ) ) return false; @@ -112,15 +124,27 @@ public class Test07 implements StorageTest { if ( !m_aTestHelper.checkEncrStream( xResultStorage, "SubStream1", "MediaType1", pBytes1, sPass1 ) ) return false; + if ( !m_aTestHelper.checkEncrStream( xResultStorage, "BigSubStream1", "MediaType1", pBigBytes, sPass1 ) ) + return false; + if ( !m_aTestHelper.checkEncrStream( xResultStorage, "SubStream2", "MediaType2", pBytes2, sPass2 ) ) return false; + if ( !m_aTestHelper.checkEncrStream( xResultStorage, "BigSubStream2", "MediaType2", pBigBytes, sPass2 ) ) + return false; + if ( !m_aTestHelper.checkEncrStream( x2CopyStorage, "SubStream1", "MediaType1", pBytes1, sPass1 ) ) return false; + if ( !m_aTestHelper.checkEncrStream( x2CopyStorage, "BigSubStream1", "MediaType1", pBigBytes, sPass1 ) ) + return false; + if ( !m_aTestHelper.checkEncrStream( x2CopyStorage, "SubStream2", "MediaType2", pBytes2, sPass2 ) ) return false; + if ( !m_aTestHelper.checkEncrStream( x2CopyStorage, "BigSubStream2", "MediaType2", pBigBytes, sPass2 ) ) + return false; + // dispose used storages to free resources if ( !m_aTestHelper.disposeStorage( xResultStorage ) ) return false; diff --git a/package/qa/storages/Test08.java b/package/qa/storages/Test08.java index e476397c8cd5..5e024db588c8 100644 --- a/package/qa/storages/Test08.java +++ b/package/qa/storages/Test08.java @@ -74,17 +74,25 @@ public class Test08 implements StorageTest { return false; } + byte pBigBytes[] = new byte[33000]; + for ( int nInd = 0; nInd < 33000; nInd++ ) + pBigBytes[nInd] = (byte)( nInd % 128 ); + // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes // the stream will be encrypted with common password byte pBytes1[] = { 1, 1, 1, 1, 1 }; if ( !m_aTestHelper.WBToSubstrOfEncr( xTempSubStorage, "SubStream1", "MediaType1", true, pBytes1, true ) ) return false; + if ( !m_aTestHelper.WBToSubstrOfEncr( xTempSubStorage, "BigSubStream1", "MediaType1", true, pBigBytes, true ) ) + return false; // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes // the stream will not be encrypted byte pBytes2[] = { 2, 2, 2, 2, 2 }; if ( !m_aTestHelper.WBToSubstrOfEncr( xTempSubStorage, "SubStream2", "MediaType2", false, pBytes2, false ) ) return false; + if ( !m_aTestHelper.WBToSubstrOfEncr( xTempSubStorage, "BigSubStream2", "MediaType2", false, pBigBytes, false ) ) + return false; // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes // the stream will be compressed with own password @@ -94,6 +102,8 @@ public class Test08 implements StorageTest { // the stream will not be encrypted if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempSubStorage, "SubStream3", "MediaType3", false, pBytes3, sPass2 ) ) return false; + if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempSubStorage, "BigSubStream3", "MediaType3", false, pBigBytes, sPass2 ) ) + return false; // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempStorage, @@ -190,13 +200,19 @@ public class Test08 implements StorageTest { if ( !m_aTestHelper.checkEncrStream( xResultSubStorage, "SubStream1", "MediaType1", pBytes1, sPass1 ) ) return false; + if ( !m_aTestHelper.checkEncrStream( xResultSubStorage, "BigSubStream1", "MediaType1", pBigBytes, sPass1 ) ) + return false; if ( !m_aTestHelper.checkStream( xResultSubStorage, "SubStream2", "MediaType2", false, pBytes2 ) ) return false; + if ( !m_aTestHelper.checkStream( xResultSubStorage, "BigSubStream2", "MediaType2", false, pBigBytes ) ) + return false; // the common root storage password should allow to open this stream if ( !m_aTestHelper.checkStream( xResultSubStorage, "SubStream3", "MediaType3", true, pBytes3 ) ) return false; + if ( !m_aTestHelper.checkStream( xResultSubStorage, "BigSubStream3", "MediaType3", true, pBigBytes ) ) + return false; // dispose used storages to free resources if ( !m_aTestHelper.disposeStorage( xResultStorage ) ) diff --git a/package/qa/storages/Test09.java b/package/qa/storages/Test09.java index a8140369e564..2ce2dfb1e484 100644 --- a/package/qa/storages/Test09.java +++ b/package/qa/storages/Test09.java @@ -45,11 +45,16 @@ public class Test09 implements StorageTest { String sPass1 = "123"; String sPass2 = "321"; byte pBytes[] = { 1, 1, 1, 1, 1 }; + byte pBigBytes[] = new byte[33000]; + for ( int nInd = 0; nInd < 33000; nInd++ ) + pBigBytes[nInd] = (byte)( nInd % 128 ); // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes // the stream will not be encrypted if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempStorage, "SubStream1", "MediaType1", false, pBytes, sPass1 ) ) return false; + if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempStorage, "BigSubStream1", "MediaType1", false, pBigBytes, sPass1 ) ) + return false; // create temporary file String sTempFileURL = m_aTestHelper.CreateTempFile( m_xMSF ); @@ -84,6 +89,13 @@ public class Test09 implements StorageTest { else if ( nResult == -1 ) return true; // tested optional feature is not supported + // change password of the substream of new storage based on file + nResult = m_aTestHelper.ChangeStreamPass( xTempFileStorage, "BigSubStream1", sPass1, sPass2 ); + if ( nResult == 0 ) + return false; // test failed + else if ( nResult == -1 ) + return true; // tested optional feature is not supported + if ( !m_aTestHelper.commitStorage( xTempFileStorage ) ) return false; @@ -107,6 +119,8 @@ public class Test09 implements StorageTest { if ( !m_aTestHelper.checkEncrStream( xResultStorage, "SubStream1", "MediaType1", pBytes, sPass2 ) ) return false; + if ( !m_aTestHelper.checkEncrStream( xResultStorage, "BigSubStream1", "MediaType1", pBigBytes, sPass2 ) ) + return false; // dispose used storages to free resources if ( !m_aTestHelper.disposeStorage( xResultStorage ) ) diff --git a/package/qa/storages/Test10.java b/package/qa/storages/Test10.java index a1114b45c6b8..162daa5abe29 100644 --- a/package/qa/storages/Test10.java +++ b/package/qa/storages/Test10.java @@ -43,12 +43,20 @@ public class Test10 implements StorageTest { return false; } + byte pBigBytes[] = new byte[33000]; + for ( int nInd = 0; nInd < 33000; nInd++ ) + pBigBytes[nInd] = (byte)( nInd % 128 ); + byte pBytes1[] = { 1, 1, 1, 1, 1 }; // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes if ( !m_aTestHelper.WriteBytesToSubstream( xTempStorage, "SubStream1", "MediaType1", true, pBytes1 ) ) return false; + // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes + if ( !m_aTestHelper.WriteBytesToSubstream( xTempStorage, "BigSubStream1", "MediaType1", true, pBigBytes ) ) + return false; + // open a new substorage XStorage xTempSubStorage = m_aTestHelper.openSubStorage( xTempStorage, @@ -66,6 +74,10 @@ public class Test10 implements StorageTest { if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage, "SubStream2", "MediaType2", true, pBytes2 ) ) return false; + // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes + if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage, "BigSubStream2", "MediaType2", true, pBigBytes ) ) + return false; + // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempStorage, "MediaType3", @@ -120,9 +132,16 @@ public class Test10 implements StorageTest { if ( !m_aTestHelper.InternalCheckStream( xClonedSubStream, "SubStream1", "MediaType1", true, pBytes1, true ) ) return false; + XStream xClonedBigSubStream = m_aTestHelper.cloneSubStream( xTempStorage, "BigSubStream1" ); + if ( !m_aTestHelper.InternalCheckStream( xClonedBigSubStream, "BigSubStream1", "MediaType1", true, pBigBytes, true ) ) + return false; + if ( !m_aTestHelper.disposeStream( xClonedSubStream, "SubStream1" ) ) return false; + if ( !m_aTestHelper.disposeStream( xClonedBigSubStream, "BigSubStream1" ) ) + return false; + // ============================== // commit substorage and check cloning // ============================== @@ -143,6 +162,9 @@ public class Test10 implements StorageTest { if ( !m_aTestHelper.checkStream( xClonedSubStorage, "SubStream2", "MediaType2", true, pBytes2 ) ) return false; + if ( !m_aTestHelper.checkStream( xClonedSubStorage, "BigSubStream2", "MediaType2", true, pBigBytes ) ) + return false; + XStorage xCloneOfRoot = m_aTestHelper.cloneStorage( m_xStorageFactory, xTempStorage ); if ( xCloneOfRoot == null ) { @@ -195,6 +217,9 @@ public class Test10 implements StorageTest { if ( !m_aTestHelper.checkStream( xSubStorageOfClone, "SubStream2", "MediaType2", true, pBytes2 ) ) return false; + if ( !m_aTestHelper.checkStream( xSubStorageOfClone, "BigSubStream2", "MediaType2", true, pBigBytes ) ) + return false; + return true; } catch( Exception e ) diff --git a/package/qa/storages/Test11.java b/package/qa/storages/Test11.java index a7949f79e7cc..198fa41fe588 100644 --- a/package/qa/storages/Test11.java +++ b/package/qa/storages/Test11.java @@ -44,6 +44,10 @@ public class Test11 implements StorageTest { return false; } + byte pBigBytes[] = new byte[33000]; + for ( int nInd = 0; nInd < 33000; nInd++ ) + pBigBytes[nInd] = (byte)( nInd % 128 ); + String sPass1 = "111111111"; byte pBytes1[] = { 1, 1, 1, 1, 1 }; @@ -51,6 +55,10 @@ public class Test11 implements StorageTest { if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempStorage, "SubStream1", "MediaType1", true, pBytes1, sPass1 ) ) return false; + // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes + if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempStorage, "BigSubStream1", "MediaType1", true, pBigBytes, sPass1 ) ) + return false; + // open a new substorage XStorage xTempSubStorage = m_aTestHelper.openSubStorage( xTempStorage, "SubStorage1", @@ -68,6 +76,10 @@ public class Test11 implements StorageTest { if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempSubStorage, "SubStream2", "MediaType2", true, pBytes2, sPass2 ) ) return false; + // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes + if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempSubStorage, "BigSubStream2", "MediaType2", true, pBigBytes, sPass2 ) ) + return false; + // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempStorage, "MediaType3", @@ -122,9 +134,16 @@ public class Test11 implements StorageTest { if ( !m_aTestHelper.InternalCheckStream( xClonedSubStream, "SubStream1", "MediaType1", true, pBytes1, true ) ) return false; + XStream xClonedBigSubStream = m_aTestHelper.cloneEncrSubStream( xTempStorage, "BigSubStream1", sPass1 ); + if ( !m_aTestHelper.InternalCheckStream( xClonedBigSubStream, "BigSubStream1", "MediaType1", true, pBigBytes, true ) ) + return false; + if ( !m_aTestHelper.disposeStream( xClonedSubStream, "SubStream1" ) ) return false; + if ( !m_aTestHelper.disposeStream( xClonedBigSubStream, "BigSubStream1" ) ) + return false; + // ============================== // commit substorage and check cloning // ============================== @@ -145,6 +164,9 @@ public class Test11 implements StorageTest { if ( !m_aTestHelper.checkEncrStream( xClonedSubStorage, "SubStream2", "MediaType2", pBytes2, sPass2 ) ) return false; + if ( !m_aTestHelper.checkEncrStream( xClonedSubStorage, "BigSubStream2", "MediaType2", pBigBytes, sPass2 ) ) + return false; + // ============================== // commit the root storage and check cloning // ============================== @@ -165,6 +187,9 @@ public class Test11 implements StorageTest { if ( !m_aTestHelper.checkEncrStream( xCloneOfRoot, "SubStream1", "MediaType1", pBytes1, sPass1 ) ) return false; + if ( !m_aTestHelper.checkEncrStream( xCloneOfRoot, "BigSubStream1", "MediaType1", pBigBytes, sPass1 ) ) + return false; + XStorage xSubStorageOfClone = xCloneOfRoot.openStorageElement( "SubStorage1", ElementModes.READ ); if ( xSubStorageOfClone == null ) { @@ -178,6 +203,9 @@ public class Test11 implements StorageTest { if ( !m_aTestHelper.checkEncrStream( xSubStorageOfClone, "SubStream2", "MediaType2", pBytes2, sPass2 ) ) return false; + if ( !m_aTestHelper.checkEncrStream( xSubStorageOfClone, "BigSubStream2", "MediaType2", pBigBytes, sPass2 ) ) + return false; + return true; } catch( Exception e ) diff --git a/package/qa/storages/Test12.java b/package/qa/storages/Test12.java index 89d88819b79e..05928cf76b0d 100644 --- a/package/qa/storages/Test12.java +++ b/package/qa/storages/Test12.java @@ -60,12 +60,20 @@ public class Test12 implements StorageTest { return false; } + byte pBigBytes[] = new byte[33000]; + for ( int nInd = 0; nInd < 33000; nInd++ ) + pBigBytes[nInd] = (byte)( nInd % 128 ); + byte pBytes1[] = { 1, 1, 1, 1, 1 }; // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage, "SubStream1", "MediaType1", true, pBytes1 ) ) return false; + // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes + if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage, "BigSubStream1", "MediaType1", true, pBigBytes ) ) + return false; + // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempStorage, "MediaType2", @@ -96,7 +104,7 @@ public class Test12 implements StorageTest { // check substorage // ================================================ - if ( !checkSubStorages( xTempStorage, pBytes1 ) ) + if ( !checkSubStorages( xTempStorage, pBytes1, pBigBytes ) ) return false; // dispose used storage to free resources @@ -118,7 +126,7 @@ public class Test12 implements StorageTest { if ( !m_aTestHelper.checkStorageProperties( xResWriteStorage, "MediaType2", true, ElementModes.WRITE ) ) return false; - if( !checkSubStorages( xResWriteStorage, pBytes1 ) ) + if( !checkSubStorages( xResWriteStorage, pBytes1, pBigBytes ) ) return false; // try to open for writing after opening for reading @@ -137,6 +145,9 @@ public class Test12 implements StorageTest { if ( !m_aTestHelper.checkStream( xResWSubStorage, "SubStream1", "MediaType1", true, pBytes1 ) ) return false; + if ( !m_aTestHelper.checkStream( xResWSubStorage, "BigSubStream1", "MediaType1", true, pBigBytes ) ) + return false; + // dispose used storage to free resources if ( !m_aTestHelper.disposeStorage( xResWriteStorage ) ) return false; @@ -171,7 +182,7 @@ public class Test12 implements StorageTest { if ( !m_aTestHelper.checkStorageProperties( xResultStorage, "MediaType2", true, ElementModes.READ ) ) return false; - if( !checkSubStorages( xResultStorage, pBytes1 ) ) + if( !checkSubStorages( xResultStorage, pBytes1, pBigBytes ) ) return false; return true; @@ -183,7 +194,7 @@ public class Test12 implements StorageTest { } } - private boolean checkSubStorages( XStorage xStorage, byte[] pBytes1 ) + private boolean checkSubStorages( XStorage xStorage, byte[] pBytes1, byte[] pBigBytes ) { XStorage xReadSubStorage1 = m_aTestHelper.openSubStorage( xStorage, "SubStorage1", @@ -208,9 +219,15 @@ public class Test12 implements StorageTest { if ( !m_aTestHelper.checkStream( xReadSubStorage1, "SubStream1", "MediaType1", true, pBytes1 ) ) return false; + if ( !m_aTestHelper.checkStream( xReadSubStorage1, "BigSubStream1", "MediaType1", true, pBigBytes ) ) + return false; + if ( !m_aTestHelper.checkStream( xReadSubStorage2, "SubStream1", "MediaType1", true, pBytes1 ) ) return false; + if ( !m_aTestHelper.checkStream( xReadSubStorage2, "BigSubStream1", "MediaType1", true, pBigBytes ) ) + return false; + if ( !m_aTestHelper.disposeStorage( xReadSubStorage1 ) ) return false; diff --git a/package/qa/storages/Test13.java b/package/qa/storages/Test13.java index bec101914259..e8b05264f44d 100644 --- a/package/qa/storages/Test13.java +++ b/package/qa/storages/Test13.java @@ -44,6 +44,9 @@ public class Test13 implements StorageTest { String aSubStream1Path = aStreamPrefix + "SubStream1"; String aSubStream2Path = aStreamPrefix + "SubStream2"; String aSubStream3Path = aStreamPrefix + "SubStream3"; + String aBigSubStream1Path = aStreamPrefix + "BigSubStream1"; + String aBigSubStream2Path = aStreamPrefix + "BigSubStream2"; + String aBigSubStream3Path = aStreamPrefix + "BigSubStream3"; String sTempFileURL = m_aTestHelper.CreateTempFile( m_xMSF ); if ( sTempFileURL == null || sTempFileURL == "" ) @@ -65,12 +68,18 @@ public class Test13 implements StorageTest { return false; } + byte pBigBytes[] = new byte[33000]; + for ( int nInd = 0; nInd < 33000; nInd++ ) + pBigBytes[nInd] = (byte)( nInd % 128 ); + byte pBytes1[] = { 1, 1, 1, 1, 1 }; // open a new substream hierarchically, set "MediaType" and "Compressed" properties to it, write some bytes // and commit if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aSubStream1Path, "MediaType1", true, pBytes1, true ) ) return false; + if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aBigSubStream1Path, "MediaType1", true, pBigBytes, true ) ) + return false; byte pBytes2[] = { 2, 2, 2, 2, 2 }; @@ -78,11 +87,15 @@ public class Test13 implements StorageTest { // and commit if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aSubStream2Path, "MediaType2", false, pBytes2, true ) ) return false; + if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aBigSubStream2Path, "MediaType2", false, pBigBytes, true ) ) + return false; // open a new substream hierarchically, set "MediaType" and "Compressed" properties to it, write some bytes // and don't commit if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aSubStream3Path, "MediaType2", false, pBytes2, false ) ) return false; + if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aBigSubStream3Path, "MediaType2", false, pBigBytes, false ) ) + return false; // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempFileStorage, @@ -120,21 +133,35 @@ public class Test13 implements StorageTest { if ( !m_aTestHelper.checkStreamH( xTempFileStorage, aSubStream1Path, "MediaType1", true, pBytes1 ) ) return false; + if ( !m_aTestHelper.checkStreamH( xTempFileStorage, aBigSubStream1Path, "MediaType1", true, pBigBytes ) ) + return false; + if ( !m_aTestHelper.checkStreamH( xTempFileStorage, aSubStream2Path, "MediaType2", false, pBytes2 ) ) return false; + if ( !m_aTestHelper.checkStreamH( xTempFileStorage, aBigSubStream2Path, "MediaType2", false, pBigBytes ) ) + return false; + if ( !m_aTestHelper.cantOpenStreamH( xTempFileStorage, aSubStream3Path, ElementModes.READ ) ) return false; + if ( !m_aTestHelper.cantOpenStreamH( xTempFileStorage, aBigSubStream3Path, ElementModes.READ ) ) + return false; + // open existing substream hierarchically, set "MediaType" and "Compressed" properties to it, write some bytes // and commit if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aSubStream1Path, "MediaType3", true, pBytes2, true ) ) return false; + if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aBigSubStream1Path, "MediaType3", true, pBigBytes, true ) ) + return false; + // open existing substream hierarchically, set "MediaType" and "Compressed" properties to it, write some bytes // and don't commit if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aSubStream2Path, "MediaType3", true, pBytes1, false ) ) return false; + if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aBigSubStream2Path, "MediaType3", true, pBigBytes, false ) ) + return false; // commit the root storage so the contents must be stored now if ( !m_aTestHelper.commitStorage( xTempFileStorage ) ) @@ -164,9 +191,11 @@ public class Test13 implements StorageTest { if ( !m_aTestHelper.checkStreamH( xResultStorage, aSubStream1Path, "MediaType3", true, pBytes2 ) ) return false; + if ( !m_aTestHelper.checkStreamH( xResultStorage, aBigSubStream1Path, "MediaType3", true, pBigBytes ) ) + return false; // the following stream was not commited last time, so the last change must be lost - if ( !m_aTestHelper.checkStreamH( xResultStorage, aSubStream2Path, "MediaType2", false, pBytes2 ) ) + if ( !m_aTestHelper.checkStreamH( xResultStorage, aBigSubStream2Path, "MediaType2", false, pBigBytes ) ) return false; // dispose used storages to free resources diff --git a/package/qa/storages/Test18.java b/package/qa/storages/Test18.java new file mode 100644 index 000000000000..335a230027ce --- /dev/null +++ b/package/qa/storages/Test18.java @@ -0,0 +1,172 @@ +package complex.storages; + +import com.sun.star.uno.XInterface; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XSingleServiceFactory; + +import com.sun.star.bridge.XUnoUrlResolver; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import com.sun.star.embed.*; + +import share.LogWriter; +import complex.storages.TestHelper; +import complex.storages.StorageTest; + +public class Test18 implements StorageTest { + + XMultiServiceFactory m_xMSF; + XSingleServiceFactory m_xStorageFactory; + TestHelper m_aTestHelper; + + public Test18( XMultiServiceFactory xMSF, XSingleServiceFactory xStorageFactory, LogWriter aLogWriter ) + { + m_xMSF = xMSF; + m_xStorageFactory = xStorageFactory; + m_aTestHelper = new TestHelper( aLogWriter, "Test18: " ); + } + + public boolean test() + { + try + { + // test the default value of Compressed property + String sTempFileURL = m_aTestHelper.CreateTempFile( m_xMSF ); + if ( sTempFileURL == null || sTempFileURL == "" ) + { + m_aTestHelper.Error( "No valid temporary file was created!" ); + return false; + } + + // create temporary storage based on arbitrary medium + // after such a storage is closed it is lost + Object oTempStorage = m_xStorageFactory.createInstance(); + XStorage xTempStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage ); + if ( xTempStorage == null ) + { + m_aTestHelper.Error( "Can't create temporary storage representation!" ); + return false; + } + + // open a new substorage + XStorage xTempSubStorage = m_aTestHelper.openSubStorage( xTempStorage, + "SubStorage1", + ElementModes.WRITE ); + if ( xTempSubStorage == null ) + { + m_aTestHelper.Error( "Can't create substorage!" ); + return false; + } + + byte pBytes1[] = { 1, 1, 1, 1, 1 }; + + // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes + if ( !m_aTestHelper.WriteBytesToSubstreamDefaultCompressed( xTempSubStorage, "SubStream1", "image/jpeg", pBytes1 ) ) + return false; + + // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes + if ( !m_aTestHelper.WriteBytesToSubstreamDefaultCompressed( xTempSubStorage, "SubStream2", "image/png", pBytes1 ) ) + return false; + + // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes + if ( !m_aTestHelper.WriteBytesToSubstreamDefaultCompressed( xTempSubStorage, "SubStream3", "image/gif", pBytes1 ) ) + return false; + + // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes + if ( !m_aTestHelper.WriteBytesToSubstreamDefaultCompressed( xTempSubStorage, "SubStream4", "MediaType1", pBytes1 ) ) + return false; + + // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly + if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempStorage, + "MediaType3", + true, + ElementModes.WRITE ) ) + return false; + + // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly + if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempSubStorage, + "MediaType4", + false, + ElementModes.WRITE ) ) + return false; + + // create temporary storage based on a previously created temporary file + Object pArgs[] = new Object[2]; + pArgs[0] = (Object) sTempFileURL; + pArgs[1] = new Integer( ElementModes.WRITE ); + + Object oTempFileStorage = m_xStorageFactory.createInstanceWithArguments( pArgs ); + XStorage xTempFileStorage = (XStorage)UnoRuntime.queryInterface( XStorage.class, oTempFileStorage ); + if ( xTempFileStorage == null ) + { + m_aTestHelper.Error( "Can't create storage based on temporary file!" ); + return false; + } + + // copy xTempStorage to xTempFileStorage + // xTempFileStorage will be automatically commited + if ( !m_aTestHelper.copyStorage( xTempStorage, xTempFileStorage ) ) + return false; + + // dispose used storages to free resources + if ( !m_aTestHelper.disposeStorage( xTempStorage ) || !m_aTestHelper.disposeStorage( xTempFileStorage ) ) + return false; + + // ================================================ + // now check all the written and copied information + // ================================================ + + // the temporary file must not be locked any more after storage disposing + pArgs[1] = new Integer( ElementModes.WRITE ); + Object oResultStorage = m_xStorageFactory.createInstanceWithArguments( pArgs ); + XStorage xResultStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oResultStorage ); + if ( xResultStorage == null ) + { + m_aTestHelper.Error( "Can't reopen storage based on temporary file!" ); + return false; + } + + if ( !m_aTestHelper.checkStorageProperties( xResultStorage, "MediaType3", true, ElementModes.WRITE ) ) + return false; + + // open existing substorage + XStorage xResultSubStorage = m_aTestHelper.openSubStorage( xResultStorage, + "SubStorage1", + ElementModes.READ ); + if ( xResultSubStorage == null ) + { + m_aTestHelper.Error( "Can't open existing substorage!" ); + return false; + } + + if ( !m_aTestHelper.checkStorageProperties( xResultSubStorage, "MediaType4", false, ElementModes.READ ) ) + return false; + + if ( !m_aTestHelper.checkStream( xResultSubStorage, "SubStream1", "image/jpeg", false, pBytes1 ) ) + return false; + + if ( !m_aTestHelper.checkStream( xResultSubStorage, "SubStream2", "image/png", false, pBytes1 ) ) + return false; + + if ( !m_aTestHelper.checkStream( xResultSubStorage, "SubStream3", "image/gif", false, pBytes1 ) ) + return false; + + if ( !m_aTestHelper.checkStream( xResultSubStorage, "SubStream4", "MediaType1", true, pBytes1 ) ) + return false; + + // dispose used storages to free resources + if ( !m_aTestHelper.disposeStorage( xResultStorage ) ) + return false; + + return true; + } + catch( Exception e ) + { + m_aTestHelper.Error( "Exception: " + e ); + return false; + } + } + +} + diff --git a/package/qa/storages/TestHelper.java b/package/qa/storages/TestHelper.java index a6a05603ac1b..dc28786513b1 100644 --- a/package/qa/storages/TestHelper.java +++ b/package/qa/storages/TestHelper.java @@ -96,6 +96,99 @@ public class TestHelper { return true; } + public boolean WriteBytesToSubstreamDefaultCompressed( XStorage xStorage, + String sStreamName, + String sMediaType, + byte[] pBytes ) + { + // open substream element + XStream xSubStream = null; + try + { + Object oSubStream = xStorage.openStreamElement( sStreamName, ElementModes.WRITE ); + xSubStream = (XStream) UnoRuntime.queryInterface( XStream.class, oSubStream ); + if ( xSubStream == null ) + { + Error( "Can't create substream '" + sStreamName + "'!" ); + return false; + } + } + catch( Exception e ) + { + Error( "Can't create substream '" + sStreamName + "', exception : " + e + "!" ); + return false; + } + + // get output stream of substream + XOutputStream xOutput = xSubStream.getOutputStream(); + if ( xOutput == null ) + { + Error( "Can't get XOutputStream implementation from substream '" + sStreamName + "'!" ); + return false; + } + + // get XTrucate implementation from output stream + XTruncate xTruncate = (XTruncate) UnoRuntime.queryInterface( XTruncate.class, xOutput ); + if ( xTruncate == null ) + { + Error( "Can't get XTruncate implementation from substream '" + sStreamName + "'!" ); + return false; + } + + // write requested byte sequence + try + { + xTruncate.truncate(); + xOutput.writeBytes( pBytes ); + } + catch( Exception e ) + { + Error( "Can't write to stream '" + sStreamName + "', exception: " + e ); + return false; + } + + // get access to the XPropertySet interface + XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, xSubStream ); + if ( xPropSet == null ) + { + Error( "Can't get XPropertySet implementation from substream '" + sStreamName + "'!" ); + return false; + } + + // set properties to the stream + // do not set the compressed property + try + { + xPropSet.setPropertyValue( "MediaType", sMediaType ); + } + catch( Exception e ) + { + Error( "Can't set properties to substream '" + sStreamName + "', exception: " + e ); + return false; + } + + // check size property of the stream + try + { + int nSize = AnyConverter.toInt( xPropSet.getPropertyValue( "Size" ) ); + if ( nSize != pBytes.length ) + { + Error( "The 'Size' property of substream '" + sStreamName + "' contains wrong value!" ); + return false; + } + } + catch( Exception e ) + { + Error( "Can't get 'Size' property from substream '" + sStreamName + "', exception: " + e ); + return false; + } + + // free the stream resources, garbage collector may remove the object too late + if ( !disposeStream( xSubStream, sStreamName ) ) + return false; + + return true; + } public boolean WriteBytesToSubstream( XStorage xStorage, String sStreamName, diff --git a/package/qa/storages/makefile.mk b/package/qa/storages/makefile.mk index a8a5bbf8219e..81cacb939510 100644 --- a/package/qa/storages/makefile.mk +++ b/package/qa/storages/makefile.mk @@ -64,6 +64,7 @@ JAVAFILES =\ Test15.java\ Test16.java\ Test17.java\ + Test18.java\ RegressionTest_114358.java\ RegressionTest_i29169.java\ RegressionTest_i30400.java\ |