1*a740f2aaSAndrew Rist /************************************************************** 2*a740f2aaSAndrew Rist * 3*a740f2aaSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*a740f2aaSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*a740f2aaSAndrew Rist * distributed with this work for additional information 6*a740f2aaSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*a740f2aaSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*a740f2aaSAndrew Rist * "License"); you may not use this file except in compliance 9*a740f2aaSAndrew Rist * with the License. You may obtain a copy of the License at 10*a740f2aaSAndrew Rist * 11*a740f2aaSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*a740f2aaSAndrew Rist * 13*a740f2aaSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*a740f2aaSAndrew Rist * software distributed under the License is distributed on an 15*a740f2aaSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*a740f2aaSAndrew Rist * KIND, either express or implied. See the License for the 17*a740f2aaSAndrew Rist * specific language governing permissions and limitations 18*a740f2aaSAndrew Rist * under the License. 19*a740f2aaSAndrew Rist * 20*a740f2aaSAndrew Rist *************************************************************/ 21*a740f2aaSAndrew Rist 22cdf0e10cSrcweir package complex.storages; 23cdf0e10cSrcweir 24cdf0e10cSrcweir import com.sun.star.uno.XInterface; 25cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory; 26cdf0e10cSrcweir import com.sun.star.lang.XSingleServiceFactory; 27cdf0e10cSrcweir 28cdf0e10cSrcweir import com.sun.star.bridge.XUnoUrlResolver; 29cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 30cdf0e10cSrcweir import com.sun.star.uno.XInterface; 31cdf0e10cSrcweir import com.sun.star.io.XStream; 32cdf0e10cSrcweir import com.sun.star.io.XInputStream; 33cdf0e10cSrcweir 34cdf0e10cSrcweir import com.sun.star.embed.*; 35cdf0e10cSrcweir 36cdf0e10cSrcweir import share.LogWriter; 37cdf0e10cSrcweir import complex.storages.TestHelper; 38cdf0e10cSrcweir import complex.storages.StorageTest; 39cdf0e10cSrcweir 40cdf0e10cSrcweir public class RegressionTest_i30400 implements StorageTest { 41cdf0e10cSrcweir 42cdf0e10cSrcweir XMultiServiceFactory m_xMSF; 43cdf0e10cSrcweir XSingleServiceFactory m_xStorageFactory; 44cdf0e10cSrcweir TestHelper m_aTestHelper; 45cdf0e10cSrcweir RegressionTest_i30400( XMultiServiceFactory xMSF, XSingleServiceFactory xStorageFactory, LogWriter aLogWriter )46cdf0e10cSrcweir public RegressionTest_i30400( XMultiServiceFactory xMSF, XSingleServiceFactory xStorageFactory, LogWriter aLogWriter ) 47cdf0e10cSrcweir { 48cdf0e10cSrcweir m_xMSF = xMSF; 49cdf0e10cSrcweir m_xStorageFactory = xStorageFactory; 50cdf0e10cSrcweir m_aTestHelper = new TestHelper( aLogWriter, "RegressionTest_i30400: " ); 51cdf0e10cSrcweir } 52cdf0e10cSrcweir test()53cdf0e10cSrcweir public boolean test() 54cdf0e10cSrcweir { 55cdf0e10cSrcweir try 56cdf0e10cSrcweir { 57cdf0e10cSrcweir // ================================================ 58cdf0e10cSrcweir // create a temporary stream and a storage based on it 59cdf0e10cSrcweir // fill the storage with the data that will be used for testing 60cdf0e10cSrcweir // ================================================ 61cdf0e10cSrcweir 62cdf0e10cSrcweir XStream xTempFileStream = m_aTestHelper.CreateTempFileStream( m_xMSF ); 63cdf0e10cSrcweir if ( xTempFileStream == null ) 64cdf0e10cSrcweir return false; 65cdf0e10cSrcweir 66cdf0e10cSrcweir // create storage based on the temporary stream 67cdf0e10cSrcweir Object pArgs[] = new Object[2]; 68cdf0e10cSrcweir pArgs[0] = (Object) xTempFileStream; 69cdf0e10cSrcweir pArgs[1] = new Integer( ElementModes.WRITE ); 70cdf0e10cSrcweir byte pBytes1[] = { 1, 1, 1, 1, 1 }; 71cdf0e10cSrcweir String pPass1 = "1, 2, 3, 4, 5"; 72cdf0e10cSrcweir 73cdf0e10cSrcweir Object oTempStorage = m_xStorageFactory.createInstanceWithArguments( pArgs ); 74cdf0e10cSrcweir XStorage xTempStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage ); 75cdf0e10cSrcweir if ( xTempStorage == null ) 76cdf0e10cSrcweir { 77cdf0e10cSrcweir m_aTestHelper.Error( "Can't create temporary storage representation!" ); 78cdf0e10cSrcweir return false; 79cdf0e10cSrcweir } 80cdf0e10cSrcweir 81cdf0e10cSrcweir // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes 82cdf0e10cSrcweir if ( !m_aTestHelper.WriteBytesToSubstream( xTempStorage, "Stream1", "MediaType1", true, pBytes1 ) ) 83cdf0e10cSrcweir return false; 84cdf0e10cSrcweir 85cdf0e10cSrcweir // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes 86cdf0e10cSrcweir if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempStorage, "EncrStream1", "MediaType2", true, pBytes1, pPass1 ) ) 87cdf0e10cSrcweir return false; 88cdf0e10cSrcweir 89cdf0e10cSrcweir 90cdf0e10cSrcweir // open a new substorage 91cdf0e10cSrcweir XStorage xTempSubStorage = m_aTestHelper.openSubStorage( xTempStorage, 92cdf0e10cSrcweir "SubStorage1", 93cdf0e10cSrcweir ElementModes.WRITE ); 94cdf0e10cSrcweir if ( xTempSubStorage == null ) 95cdf0e10cSrcweir { 96cdf0e10cSrcweir m_aTestHelper.Error( "Can't create substorage!" ); 97cdf0e10cSrcweir return false; 98cdf0e10cSrcweir } 99cdf0e10cSrcweir 100cdf0e10cSrcweir // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes 101cdf0e10cSrcweir if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage, "SubStream1", "MediaType3", true, pBytes1 ) ) 102cdf0e10cSrcweir return false; 103cdf0e10cSrcweir 104cdf0e10cSrcweir // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes 105cdf0e10cSrcweir if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempSubStorage, "SubEncrStream1", "MediaType4", true, pBytes1, pPass1 ) ) 106cdf0e10cSrcweir return false; 107cdf0e10cSrcweir 108cdf0e10cSrcweir // open a new substorage in the existing substorage 109cdf0e10cSrcweir XStorage xTempSubSubStorage = m_aTestHelper.openSubStorage( xTempSubStorage, 110cdf0e10cSrcweir "SubSubStorage1", 111cdf0e10cSrcweir ElementModes.WRITE ); 112cdf0e10cSrcweir if ( xTempSubStorage == null ) 113cdf0e10cSrcweir { 114cdf0e10cSrcweir m_aTestHelper.Error( "Can't create substorage!" ); 115cdf0e10cSrcweir return false; 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes 119cdf0e10cSrcweir if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubSubStorage, "SubSubStream1", "MediaType5", true, pBytes1 ) ) 120cdf0e10cSrcweir return false; 121cdf0e10cSrcweir 122cdf0e10cSrcweir // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly 123cdf0e10cSrcweir if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempSubSubStorage, 124cdf0e10cSrcweir "MediaType6", 125cdf0e10cSrcweir false, 126cdf0e10cSrcweir ElementModes.WRITE ) ) 127cdf0e10cSrcweir return false; 128cdf0e10cSrcweir 129cdf0e10cSrcweir 130cdf0e10cSrcweir // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly 131cdf0e10cSrcweir if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempSubStorage, 132cdf0e10cSrcweir "MediaType7", 133cdf0e10cSrcweir false, 134cdf0e10cSrcweir ElementModes.WRITE ) ) 135cdf0e10cSrcweir return false; 136cdf0e10cSrcweir 137cdf0e10cSrcweir // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly 138cdf0e10cSrcweir if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempStorage, 139cdf0e10cSrcweir "MediaType8", 140cdf0e10cSrcweir true, 141cdf0e10cSrcweir ElementModes.WRITE ) ) 142cdf0e10cSrcweir return false; 143cdf0e10cSrcweir 144cdf0e10cSrcweir // ================================================ 145cdf0e10cSrcweir // check the copying with renaming 146cdf0e10cSrcweir // ================================================ 147cdf0e10cSrcweir 148cdf0e10cSrcweir if ( !TestCopyWithRenaming( xTempStorage, xTempSubStorage, xTempSubSubStorage ) ) 149cdf0e10cSrcweir return false; 150cdf0e10cSrcweir 151cdf0e10cSrcweir // ================================================ 152cdf0e10cSrcweir // commit the storages 153cdf0e10cSrcweir // ================================================ 154cdf0e10cSrcweir 155cdf0e10cSrcweir // commit lowlevel substorage 156cdf0e10cSrcweir if ( !m_aTestHelper.commitStorage( xTempSubSubStorage ) ) 157cdf0e10cSrcweir return false; 158cdf0e10cSrcweir 159cdf0e10cSrcweir // commit substorage 160cdf0e10cSrcweir if ( !m_aTestHelper.commitStorage( xTempSubStorage ) ) 161cdf0e10cSrcweir return false; 162cdf0e10cSrcweir 163cdf0e10cSrcweir // commit the root storage so the contents must be stored now 164cdf0e10cSrcweir if ( !m_aTestHelper.commitStorage( xTempStorage ) ) 165cdf0e10cSrcweir return false; 166cdf0e10cSrcweir 167cdf0e10cSrcweir // ================================================ 168cdf0e10cSrcweir // dispose the storages 169cdf0e10cSrcweir // ================================================ 170cdf0e10cSrcweir 171cdf0e10cSrcweir // dispose lowerest substorage 172cdf0e10cSrcweir if ( !m_aTestHelper.disposeStorage( xTempSubSubStorage ) ) 173cdf0e10cSrcweir return false; 174cdf0e10cSrcweir 175cdf0e10cSrcweir // dispose substorage 176cdf0e10cSrcweir if ( !m_aTestHelper.disposeStorage( xTempSubStorage ) ) 177cdf0e10cSrcweir return false; 178cdf0e10cSrcweir 179cdf0e10cSrcweir // dispose the temporary storage 180cdf0e10cSrcweir if ( !m_aTestHelper.disposeStorage( xTempStorage ) ) 181cdf0e10cSrcweir return false; 182cdf0e10cSrcweir 183cdf0e10cSrcweir // ================================================ 184cdf0e10cSrcweir // reopen the target storage readonly, and check the copying with renaming 185cdf0e10cSrcweir // ================================================ 186cdf0e10cSrcweir 187cdf0e10cSrcweir pArgs[1] = new Integer( ElementModes.READ ); 188cdf0e10cSrcweir oTempStorage = m_xStorageFactory.createInstanceWithArguments( pArgs ); 189cdf0e10cSrcweir xTempStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage ); 190cdf0e10cSrcweir if ( xTempStorage == null ) 191cdf0e10cSrcweir { 192cdf0e10cSrcweir m_aTestHelper.Error( "Can't create temporary storage representation!" ); 193cdf0e10cSrcweir return false; 194cdf0e10cSrcweir } 195cdf0e10cSrcweir 196cdf0e10cSrcweir // open the substorages 197cdf0e10cSrcweir 198cdf0e10cSrcweir xTempSubStorage = m_aTestHelper.openSubStorage( xTempStorage, 199cdf0e10cSrcweir "SubStorage1", 200cdf0e10cSrcweir ElementModes.READ ); 201cdf0e10cSrcweir if ( xTempSubStorage == null ) 202cdf0e10cSrcweir { 203cdf0e10cSrcweir m_aTestHelper.Error( "Can't create substorage!" ); 204cdf0e10cSrcweir return false; 205cdf0e10cSrcweir } 206cdf0e10cSrcweir 207cdf0e10cSrcweir // open the lowlevel substorages 208cdf0e10cSrcweir 209cdf0e10cSrcweir xTempSubSubStorage = m_aTestHelper.openSubStorage( xTempSubStorage, 210cdf0e10cSrcweir "SubSubStorage1", 211cdf0e10cSrcweir ElementModes.READ ); 212cdf0e10cSrcweir if ( xTempSubSubStorage == null ) 213cdf0e10cSrcweir { 214cdf0e10cSrcweir m_aTestHelper.Error( "Can't create substorage!" ); 215cdf0e10cSrcweir return false; 216cdf0e10cSrcweir } 217cdf0e10cSrcweir 218cdf0e10cSrcweir // test the copying with renaming 219cdf0e10cSrcweir if ( !TestCopyWithRenaming( xTempStorage, xTempSubStorage, xTempSubSubStorage ) ) 220cdf0e10cSrcweir return false; 221cdf0e10cSrcweir 222cdf0e10cSrcweir 223cdf0e10cSrcweir // the storage is based on the temporary stream so it can be left undisposed, since it does not lock 224cdf0e10cSrcweir // any resource, later the garbage collector will release the object and it must die by refcount 225cdf0e10cSrcweir 226cdf0e10cSrcweir return true; 227cdf0e10cSrcweir } 228cdf0e10cSrcweir catch( Exception e ) 229cdf0e10cSrcweir { 230cdf0e10cSrcweir m_aTestHelper.Error( "Exception: " + e ); 231cdf0e10cSrcweir return false; 232cdf0e10cSrcweir } 233cdf0e10cSrcweir } 234cdf0e10cSrcweir 235cdf0e10cSrcweir TestCopyWithRenaming( XStorage xTempStorage, XStorage xTempSubStorage, XStorage xTempSubSubStorage )236cdf0e10cSrcweir public boolean TestCopyWithRenaming( XStorage xTempStorage, XStorage xTempSubStorage, XStorage xTempSubSubStorage ) 237cdf0e10cSrcweir throws com.sun.star.uno.Exception 238cdf0e10cSrcweir { 239cdf0e10cSrcweir // ================================================ 240cdf0e10cSrcweir // create a second temporary stream and copy all the staff there 241cdf0e10cSrcweir // with renaming, check the success 242cdf0e10cSrcweir // ================================================ 243cdf0e10cSrcweir 244cdf0e10cSrcweir XStream xTempFileStream2 = m_aTestHelper.CreateTempFileStream( m_xMSF ); 245cdf0e10cSrcweir if ( xTempFileStream2 == null ) 246cdf0e10cSrcweir return false; 247cdf0e10cSrcweir 248cdf0e10cSrcweir Object pArgs[] = new Object[2]; 249cdf0e10cSrcweir pArgs[0] = (Object) xTempFileStream2; 250cdf0e10cSrcweir pArgs[1] = new Integer( ElementModes.WRITE ); 251cdf0e10cSrcweir byte pBytes1[] = { 1, 1, 1, 1, 1 }; 252cdf0e10cSrcweir String pPass1 = "1, 2, 3, 4, 5"; 253cdf0e10cSrcweir 254cdf0e10cSrcweir Object oTempStorage2 = m_xStorageFactory.createInstanceWithArguments( pArgs ); 255cdf0e10cSrcweir XStorage xTempStorage2 = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage2 ); 256cdf0e10cSrcweir if ( xTempStorage2 == null ) 257cdf0e10cSrcweir { 258cdf0e10cSrcweir m_aTestHelper.Error( "Can't create temporary storage representation!" ); 259cdf0e10cSrcweir return false; 260cdf0e10cSrcweir } 261cdf0e10cSrcweir 262cdf0e10cSrcweir // open a new substorage 263cdf0e10cSrcweir XStorage xTempSubStorage2 = m_aTestHelper.openSubStorage( xTempStorage2, 264cdf0e10cSrcweir "SubStorage1_target", 265cdf0e10cSrcweir ElementModes.WRITE ); 266cdf0e10cSrcweir if ( xTempSubStorage2 == null ) 267cdf0e10cSrcweir { 268cdf0e10cSrcweir m_aTestHelper.Error( "Can't create substorage!" ); 269cdf0e10cSrcweir return false; 270cdf0e10cSrcweir } 271cdf0e10cSrcweir 272cdf0e10cSrcweir // open a new substorage in the existing substorage 273cdf0e10cSrcweir XStorage xTempSubSubStorage2 = m_aTestHelper.openSubStorage( xTempSubStorage2, 274cdf0e10cSrcweir "SubSubStorage1_target", 275cdf0e10cSrcweir ElementModes.WRITE ); 276cdf0e10cSrcweir if ( xTempSubSubStorage2 == null ) 277cdf0e10cSrcweir { 278cdf0e10cSrcweir m_aTestHelper.Error( "Can't create substorage!" ); 279cdf0e10cSrcweir return false; 280cdf0e10cSrcweir } 281cdf0e10cSrcweir 282cdf0e10cSrcweir // make a copy with renaming on lowerest level 283cdf0e10cSrcweir if ( !m_aTestHelper.copyElementTo( xTempSubSubStorage, "SubSubStream1", xTempSubSubStorage2, "SubSubStream1_renamed" ) ) 284cdf0e10cSrcweir return false; 285cdf0e10cSrcweir 286cdf0e10cSrcweir // make a copy with renaming on the next level 287cdf0e10cSrcweir 288cdf0e10cSrcweir if ( !m_aTestHelper.copyElementTo( xTempSubStorage, "SubStream1", xTempSubStorage2, "SubStream1_renamed" ) ) 289cdf0e10cSrcweir return false; 290cdf0e10cSrcweir 291cdf0e10cSrcweir if ( !m_aTestHelper.copyElementTo( xTempSubStorage, "SubEncrStream1", xTempSubStorage2, "SubEncrStream1_renamed" ) ) 292cdf0e10cSrcweir return false; 293cdf0e10cSrcweir 294cdf0e10cSrcweir if ( !m_aTestHelper.copyElementTo( xTempSubStorage, "SubSubStorage1", xTempSubStorage2, "SubSubStorage1_renamed" ) ) 295cdf0e10cSrcweir return false; 296cdf0e10cSrcweir 297cdf0e10cSrcweir // make a copy with renaming of subelements of the root storage 298cdf0e10cSrcweir 299cdf0e10cSrcweir if ( !m_aTestHelper.copyElementTo( xTempStorage, "Stream1", xTempStorage2, "Stream1_renamed" ) ) 300cdf0e10cSrcweir return false; 301cdf0e10cSrcweir 302cdf0e10cSrcweir if ( !m_aTestHelper.copyElementTo( xTempStorage, "EncrStream1", xTempStorage2, "EncrStream1_renamed" ) ) 303cdf0e10cSrcweir return false; 304cdf0e10cSrcweir 305cdf0e10cSrcweir if ( !m_aTestHelper.copyElementTo( xTempStorage, "SubStorage1", xTempStorage2, "SubStorage1_renamed" ) ) 306cdf0e10cSrcweir return false; 307cdf0e10cSrcweir 308cdf0e10cSrcweir // ================================================ 309cdf0e10cSrcweir // commit the storages, and check the renaming in all stages 310cdf0e10cSrcweir // ================================================ 311cdf0e10cSrcweir 312cdf0e10cSrcweir // commit substorage to let the renaming take place 313cdf0e10cSrcweir if ( !m_aTestHelper.commitStorage( xTempSubSubStorage2 ) ) 314cdf0e10cSrcweir return false; 315cdf0e10cSrcweir 316cdf0e10cSrcweir // commit substorage to let the renaming take place 317cdf0e10cSrcweir if ( !m_aTestHelper.commitStorage( xTempSubStorage2 ) ) 318cdf0e10cSrcweir return false; 319cdf0e10cSrcweir 320cdf0e10cSrcweir // commit the root storage so the contents must be stored now 321cdf0e10cSrcweir if ( !m_aTestHelper.commitStorage( xTempStorage2 ) ) 322cdf0e10cSrcweir return false; 323cdf0e10cSrcweir 324cdf0e10cSrcweir // ================================================ 325cdf0e10cSrcweir // dispose the storages 326cdf0e10cSrcweir // ================================================ 327cdf0e10cSrcweir 328cdf0e10cSrcweir // dispose lowerest substorage 329cdf0e10cSrcweir if ( !m_aTestHelper.disposeStorage( xTempSubSubStorage2 ) ) 330cdf0e10cSrcweir return false; 331cdf0e10cSrcweir 332cdf0e10cSrcweir // dispose substorage 333cdf0e10cSrcweir if ( !m_aTestHelper.disposeStorage( xTempSubStorage2 ) ) 334cdf0e10cSrcweir return false; 335cdf0e10cSrcweir 336cdf0e10cSrcweir // dispose the temporary storage 337cdf0e10cSrcweir if ( !m_aTestHelper.disposeStorage( xTempStorage2 ) ) 338cdf0e10cSrcweir return false; 339cdf0e10cSrcweir 340cdf0e10cSrcweir // ================================================ 341cdf0e10cSrcweir // reopen the target storage readonly, and check the contents 342cdf0e10cSrcweir // ================================================ 343cdf0e10cSrcweir 344cdf0e10cSrcweir pArgs[1] = new Integer( ElementModes.READ ); 345cdf0e10cSrcweir oTempStorage2 = m_xStorageFactory.createInstanceWithArguments( pArgs ); 346cdf0e10cSrcweir xTempStorage2 = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage2 ); 347cdf0e10cSrcweir if ( xTempStorage2 == null ) 348cdf0e10cSrcweir { 349cdf0e10cSrcweir m_aTestHelper.Error( "Can't create temporary storage representation!" ); 350cdf0e10cSrcweir return false; 351cdf0e10cSrcweir } 352cdf0e10cSrcweir 353cdf0e10cSrcweir // open the substorages 354cdf0e10cSrcweir 355cdf0e10cSrcweir XStorage xTempSubStorage2_target = m_aTestHelper.openSubStorage( xTempStorage2, 356cdf0e10cSrcweir "SubStorage1_target", 357cdf0e10cSrcweir ElementModes.READ ); 358cdf0e10cSrcweir if ( xTempSubStorage2_target == null ) 359cdf0e10cSrcweir { 360cdf0e10cSrcweir m_aTestHelper.Error( "Can't create substorage!" ); 361cdf0e10cSrcweir return false; 362cdf0e10cSrcweir } 363cdf0e10cSrcweir 364cdf0e10cSrcweir XStorage xTempSubStorage2_renamed = m_aTestHelper.openSubStorage( xTempStorage2, 365cdf0e10cSrcweir "SubStorage1_renamed", 366cdf0e10cSrcweir ElementModes.READ ); 367cdf0e10cSrcweir if ( xTempSubStorage2_renamed == null ) 368cdf0e10cSrcweir { 369cdf0e10cSrcweir m_aTestHelper.Error( "Can't create substorage!" ); 370cdf0e10cSrcweir return false; 371cdf0e10cSrcweir } 372cdf0e10cSrcweir 373cdf0e10cSrcweir // open the lowlevel substorages 374cdf0e10cSrcweir 375cdf0e10cSrcweir XStorage xTempSubSubStorage2_inRenamed = m_aTestHelper.openSubStorage( xTempSubStorage2_renamed, 376cdf0e10cSrcweir "SubSubStorage1", 377cdf0e10cSrcweir ElementModes.READ ); 378cdf0e10cSrcweir if ( xTempSubSubStorage2_inRenamed == null ) 379cdf0e10cSrcweir { 380cdf0e10cSrcweir m_aTestHelper.Error( "Can't create substorage!" ); 381cdf0e10cSrcweir return false; 382cdf0e10cSrcweir } 383cdf0e10cSrcweir 384cdf0e10cSrcweir XStorage xTempSubSubStorage2_renamed = m_aTestHelper.openSubStorage( xTempSubStorage2_target, 385cdf0e10cSrcweir "SubSubStorage1_renamed", 386cdf0e10cSrcweir ElementModes.READ ); 387cdf0e10cSrcweir if ( xTempSubSubStorage2_renamed == null ) 388cdf0e10cSrcweir { 389cdf0e10cSrcweir m_aTestHelper.Error( "Can't create substorage!" ); 390cdf0e10cSrcweir return false; 391cdf0e10cSrcweir } 392cdf0e10cSrcweir 393cdf0e10cSrcweir XStorage xTempSubSubStorage2_target = m_aTestHelper.openSubStorage( xTempSubStorage2_target, 394cdf0e10cSrcweir "SubSubStorage1_target", 395cdf0e10cSrcweir ElementModes.READ ); 396cdf0e10cSrcweir if ( xTempSubSubStorage2_target == null ) 397cdf0e10cSrcweir { 398cdf0e10cSrcweir m_aTestHelper.Error( "Can't create substorage!" ); 399cdf0e10cSrcweir return false; 400cdf0e10cSrcweir } 401cdf0e10cSrcweir 402cdf0e10cSrcweir // check the storages 403cdf0e10cSrcweir 404cdf0e10cSrcweir if ( !m_aTestHelper.checkStorageProperties( xTempSubSubStorage2_inRenamed, "MediaType6", false, ElementModes.READ ) ) 405cdf0e10cSrcweir return false; 406cdf0e10cSrcweir 407cdf0e10cSrcweir if ( !m_aTestHelper.checkStorageProperties( xTempSubSubStorage2_renamed, "MediaType6", false, ElementModes.READ ) ) 408cdf0e10cSrcweir return false; 409cdf0e10cSrcweir 410cdf0e10cSrcweir if ( !m_aTestHelper.checkStorageProperties( xTempSubStorage2_renamed, "MediaType7", false, ElementModes.READ ) ) 411cdf0e10cSrcweir return false; 412cdf0e10cSrcweir 413cdf0e10cSrcweir 414cdf0e10cSrcweir // check the streams 415cdf0e10cSrcweir 416cdf0e10cSrcweir 417cdf0e10cSrcweir // sub sub level 418cdf0e10cSrcweir 419cdf0e10cSrcweir if ( !m_aTestHelper.checkStream( xTempSubSubStorage2_inRenamed, "SubSubStream1", "MediaType5", true, pBytes1 ) ) 420cdf0e10cSrcweir return false; 421cdf0e10cSrcweir 422cdf0e10cSrcweir if ( !m_aTestHelper.checkStream( xTempSubSubStorage2_renamed, "SubSubStream1", "MediaType5", true, pBytes1 ) ) 423cdf0e10cSrcweir return false; 424cdf0e10cSrcweir 425cdf0e10cSrcweir if ( !m_aTestHelper.checkStream( xTempSubSubStorage2_target, "SubSubStream1_renamed", "MediaType5", true, pBytes1 ) ) 426cdf0e10cSrcweir return false; 427cdf0e10cSrcweir 428cdf0e10cSrcweir // sub level 429cdf0e10cSrcweir 430cdf0e10cSrcweir if ( !m_aTestHelper.checkStream( xTempSubStorage2_renamed, "SubStream1", "MediaType3", true, pBytes1 ) ) 431cdf0e10cSrcweir return false; 432cdf0e10cSrcweir 433cdf0e10cSrcweir if ( !m_aTestHelper.checkEncrStream( xTempSubStorage2_renamed, "SubEncrStream1", "MediaType4", pBytes1, pPass1 ) ) 434cdf0e10cSrcweir return false; 435cdf0e10cSrcweir 436cdf0e10cSrcweir if ( !m_aTestHelper.checkStream( xTempSubStorage2_target, "SubStream1_renamed", "MediaType3", true, pBytes1 ) ) 437cdf0e10cSrcweir return false; 438cdf0e10cSrcweir 439cdf0e10cSrcweir if ( !m_aTestHelper.checkEncrStream( xTempSubStorage2_target, "SubEncrStream1_renamed", "MediaType4", pBytes1, pPass1 ) ) 440cdf0e10cSrcweir return false; 441cdf0e10cSrcweir 442cdf0e10cSrcweir // root storage level 443cdf0e10cSrcweir 444cdf0e10cSrcweir if ( !m_aTestHelper.checkStream( xTempStorage2, "Stream1_renamed", "MediaType1", true, pBytes1 ) ) 445cdf0e10cSrcweir return false; 446cdf0e10cSrcweir 447cdf0e10cSrcweir if ( !m_aTestHelper.checkEncrStream( xTempStorage2, "EncrStream1_renamed", "MediaType2", pBytes1, pPass1 ) ) 448cdf0e10cSrcweir return false; 449cdf0e10cSrcweir 450cdf0e10cSrcweir // the storage is based on the temporary stream so it can be left undisposed, since it does not lock 451cdf0e10cSrcweir // any resource, later the garbage collector will release the object and it must die by refcount 452cdf0e10cSrcweir 453cdf0e10cSrcweir return true; 454cdf0e10cSrcweir } 455cdf0e10cSrcweir } 456cdf0e10cSrcweir 457