1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
26 #include <osl/module.hxx>
27 #include <osl/diagnose.h>
28 #include <osl/process.h>
29 #include <registry/registry.hxx>
32 #include <com/sun/star/registry/XSimpleRegistry.hpp>
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <cppuhelper/factory.hxx>
37 #include <cppuhelper/bootstrap.hxx>
38 #include <cppuhelper/servicefactory.hxx>
40 #include <com/sun/star/lang/XComponent.hpp>
44 #define _MAX_PATH PATH_MAX
47 using namespace com::sun::star
;
48 using namespace com::sun::star::uno
;
49 using namespace com::sun::star::registry
;
50 using namespace com::sun::star::lang
;
51 using namespace com::sun::star::beans
;
57 void SAL_CALL
mergeKeys(
58 Reference
< registry::XRegistryKey
> const & xDest
,
59 Reference
< registry::XRegistryKey
> const & xSource
)
60 SAL_THROW( (registry::InvalidRegistryException
, registry::MergeConflictException
) );
62 static void mergeKeys(
63 Reference
< registry::XSimpleRegistry
> const & xDest
,
64 OUString
const & rBaseNode
,
65 OUString
const & rURL
)
66 SAL_THROW( (registry::InvalidRegistryException
, registry::MergeConflictException
) )
68 Reference
< registry::XRegistryKey
> xDestRoot( xDest
->getRootKey() );
69 Reference
< registry::XRegistryKey
> xDestKey
;
70 if (rBaseNode
.getLength())
72 xDestKey
= xDestRoot
->createKey( rBaseNode
);
73 xDestRoot
->closeKey();
79 Reference
< registry::XSimpleRegistry
> xSimReg( ::cppu::createSimpleRegistry() );
80 xSimReg
->open( rURL
, sal_True
, sal_False
);
81 OSL_ASSERT( xSimReg
->isValid() );
82 Reference
< registry::XRegistryKey
> xSourceKey( xSimReg
->getRootKey() );
83 ::stoc_impreg::mergeKeys( xDestKey
, xSourceKey
);
84 xSourceKey
->closeKey();
90 OString
userRegEnv("STAR_USER_REGISTRY=");
95 OSL_VERIFY( osl_getExecutableFile( &exe
.pData
) == osl_Process_E_None
);
96 #if defined(WIN32) || defined(WNT)
97 exe
= exe
.copy(0, exe
.getLength() - 16);
99 exe
= exe
.copy(0, exe
.getLength() - 12);
104 void setStarUserRegistry()
106 Registry
*myRegistry
= new Registry();
108 RegistryKey rootKey
, rKey
, rKey2
;
110 OUString userReg
= getExePath();
111 userReg
+= "user.rdb";
112 if(myRegistry
->open(userReg
, REG_READWRITE
))
114 OSL_VERIFY(!myRegistry
->create(userReg
));
117 OSL_VERIFY(!myRegistry
->close());
120 userRegEnv
+= OUStringToOString(userReg
, RTL_TEXTENCODING_ASCII_US
);
121 putenv((char *)userRegEnv
.getStr());
124 void setLinkInDefaultRegistry(const OUString
& linkName
, const OUString
& linkTarget
)
126 Registry
*myRegistry
= new Registry();
130 OUString appReg
= getExePath();
131 appReg
+= "stoctest.rdb";
133 OSL_VERIFY(!myRegistry
->open(appReg
, REG_READWRITE
));
134 OSL_VERIFY(!myRegistry
->openRootKey(rootKey
));
136 OSL_VERIFY(!rootKey
.createLink(linkName
, linkTarget
));
138 OSL_VERIFY(!rootKey
.closeKey());
139 OSL_VERIFY(!myRegistry
->close());
145 void test_SimpleRegistry(
146 OUString
const & testreg
,
147 OUString
const & testreg2
,
148 bool bMergeDifferently
= true )
150 Reference
<XInterface
> xIFace
;
154 "simplereg.uno" SAL_DLLEXTENSION
);
156 if (module
.load(dllName
))
158 // try to get provider from module
159 component_getFactoryFunc pCompFactoryFunc
= (component_getFactoryFunc
)
160 module
.getFunctionSymbol( OUString(COMPONENT_GETFACTORY
) );
162 if (pCompFactoryFunc
)
164 XSingleServiceFactory
* pRet
= (XSingleServiceFactory
*)
166 "com.sun.star.comp.stoc.SimpleRegistry", 0, 0 );
175 OSL_ENSURE( xIFace
.is(), "test_SimpleRegistry error1");
177 Reference
<XSingleServiceFactory
> xFactory( Reference
<XSingleServiceFactory
>::query(xIFace
) );
180 OSL_ENSURE( xFactory
.is(), "testloader error11");
182 Reference
<XInterface
> xIFace2
= xFactory
->createInstance();
185 OSL_ENSURE( xIFace2
.is(), "testloader error12");
187 Reference
<XServiceInfo
> xServInfo( Reference
<XServiceInfo
>::query(xIFace2
) );
189 OSL_ENSURE( xServInfo
.is(), "test_SimpleRegistry error2");
191 OSL_ENSURE( xServInfo
->getImplementationName() == "com.sun.star.comp.stoc.SimpleRegistry", "test_SimpleRegistry error3");
192 OSL_ENSURE( xServInfo
->supportsService(OUString( "com.sun.star.registry.SimpleRegistry")), "test_SimpleRegistry error4");
193 OSL_ENSURE( xServInfo
->getSupportedServiceNames().getLength() == 1, "test_SimpleRegistry error5");
196 Reference
<XSimpleRegistry
> xReg( Reference
<XSimpleRegistry
>::query(xIFace2
) );
199 OSL_ENSURE( xReg
.is(), "test_SimpleRegistry error6");
203 xReg
->open(testreg
, sal_False
, sal_True
);
205 OSL_ENSURE( xReg
->isValid() != sal_False
, "test_SimpleRegistry error 7" );
206 OSL_ENSURE( xReg
->isReadOnly() == sal_False
, "test_SimpleRegistry error 8" );
208 Reference
<XRegistryKey
> xRootKey(xReg
->getRootKey());
209 OSL_ENSURE( xRootKey
->isValid(), "test_SimpleRegistry error 9" );
211 Reference
<XRegistryKey
> xKey
= xRootKey
->createKey(OUString( "FirstKey" ));
213 Reference
<XRegistryKey
> xSubKey
= xKey
->createKey(OUString( "FirstSubKey" ));
214 xSubKey
->setLongValue(123456789);
216 xSubKey
= xKey
->createKey(OUString( "SecondSubKey" ));
217 xSubKey
->setAsciiValue(OUString( "ich bin ein acsii value" ));
219 xSubKey
= xKey
->createKey(OUString( "ThirdSubKey" ));
220 xSubKey
->setStringValue(OUString( "ich bin ein unicode value" ));
222 xSubKey
= xKey
->createKey(OUString( "FourthSubKey" ));
223 Sequence
<sal_Int8
> aSeq((sal_Int8
*)"ich bin ein binary value", 25);
224 xSubKey
->setBinaryValue(aSeq
);
226 Sequence
<OUString
> seqNames
= xKey
->getKeyNames();
227 Sequence
< Reference
<XRegistryKey
> > seqKeys
= xKey
->openKeys();
230 for (sal_Int32 i
=0; i
< seqNames
.getLength(); i
++)
232 name
= seqNames
.getArray()[i
];
233 xSubKey
= seqKeys
.getArray()[i
];
235 if (name
== OUString( "/FirstKey/FirstSubKey" ))
237 OSL_ENSURE( xSubKey
->getLongValue() == 123456789,
238 "test_SimpleRegistry error 10" );
240 if (name
== OUString( "/FirstKey/SecondSubKey" ))
242 OSL_ENSURE( xSubKey
->getAsciiValue() == OUString( "ich bin ein acsii value" ),
243 "test_SimpleRegistry error 11" );
245 if (name
== OUString( "/FirstKey/ThirdSubKey" ))
247 OSL_ENSURE( xSubKey
->getStringValue() == OUString( "ich bin ein unicode value" ),
248 "test_SimpleRegistry error 12" );
250 if (name
== OUString( "/FirstKey/FourthSubKey" ))
252 Sequence
<sal_Int8
> seqByte
= xSubKey
->getBinaryValue();
253 OSL_ENSURE(!strcmp(((const char*)seqByte
.getArray()), "ich bin ein binary value"),
254 "test_SimpleRegistry error 13" );
257 seqKeys
.getArray()[i
]->closeKey();
262 xRootKey
->deleteKey(OUString( "FirstKey" ));
263 xRootKey
->createKey(OUString( "SecondFirstKey" ));
265 xKey
= xRootKey
->createKey(OUString( "SecondKey" ));
266 sal_Int32 pLongs
[3] = {123, 456, 789};
267 Sequence
<sal_Int32
> seqLongs(pLongs
, 3);
268 xKey
->setLongListValue(seqLongs
);
270 Sequence
<sal_Int32
> seqLongs2
;
271 seqLongs2
= xKey
->getLongListValue();
272 OSL_ENSURE( seqLongs
.getLength() == 3, "test_SimpleRegistry error 14" );
273 OSL_ENSURE( seqLongs
.getArray()[0] == 123, "test_SimpleRegistry error 15" );
274 OSL_ENSURE( seqLongs
.getArray()[1] == 456, "test_SimpleRegistry error 16" );
275 OSL_ENSURE( seqLongs
.getArray()[2] == 789, "test_SimpleRegistry error 17" );
278 xKey
= xRootKey
->createKey(OUString( "ThirdKey" ));
280 pAscii
[0] = OUString( "Hallo" );
281 pAscii
[1] = OUString( "jetzt komm" );
282 pAscii
[2] = OUString( "ich" );
284 Sequence
<OUString
> seqAscii(pAscii
, 3);
285 xKey
->setAsciiListValue(seqAscii
);
287 Sequence
<OUString
> seqAscii2
;
288 seqAscii2
= xKey
->getAsciiListValue();
289 OSL_ENSURE( seqAscii2
.getLength() == 3, "test_SimpleRegistry error 18" );
290 OSL_ENSURE( seqAscii2
.getArray()[0] == OUString( "Hallo" ), "test_SimpleRegistry error 19");
291 OSL_ENSURE( seqAscii2
.getArray()[1] == OUString( "jetzt komm" ), "test_SimpleRegistry error 20");
292 OSL_ENSURE( seqAscii2
.getArray()[2] == OUString( "ich" ), "test_SimpleRegistry error 21");
294 xKey
= xRootKey
->createKey(OUString( "FourthKey" ));
295 OUString pUnicode
[3];
296 pUnicode
[0] = OUString( "Hallo" );
297 pUnicode
[1] = OUString( "jetzt komm" );
298 pUnicode
[2] = OUString( "ich als unicode" );
300 Sequence
<OUString
> seqUnicode(pUnicode
, 3);
301 xKey
->setStringListValue(seqUnicode
);
303 Sequence
<OUString
> seqUnicode2
;
304 seqUnicode2
= xKey
->getStringListValue();
305 OSL_ENSURE( seqUnicode2
.getLength() == 3, "test_SimpleRegistry error 22" );
306 OSL_ENSURE( seqUnicode2
.getArray()[0] == OUString( "Hallo" ), "test_SimpleRegistry error 23");
307 OSL_ENSURE( seqUnicode2
.getArray()[1] == OUString( "jetzt komm" ), "test_SimpleRegistry error 24");
308 OSL_ENSURE( seqUnicode2
.getArray()[2] == OUString( "ich als unicode" ), "test_SimpleRegistry error 25");
311 xReg
->open(testreg2
, sal_False
, sal_True
);
312 OSL_ENSURE( xReg
->isValid() != sal_False
, "test_SimpleRegistry error 25" );
313 xRootKey
= xReg
->getRootKey();
314 xKey
= xRootKey
->createKey(OUString( "ThirdKey/FirstSubKey/WithSubSubKey" ));
317 xRootKey
->createLink(
318 OUString( "LinkTest" ),
319 OUString( "/ThirdKey/FirstSubKey/WithSubSubKey" )) );
320 xRootKey
->closeKey();
323 xReg
->open(testreg
, sal_False
, sal_False
);
324 OSL_ENSURE( xReg
->isValid() != sal_False
, "test_SimpleRegistry error 26" );
326 if (bMergeDifferently
)
335 xReg
->mergeKey(OUString(), testreg2
);
338 xRootKey
= xReg
->getRootKey();
339 xKey
= xRootKey
->openKey( OUString( "LinkTest" ) );
340 OSL_ENSURE( xKey
.is() && xKey
->isValid() && xKey
->getKeyName() == "/ThirdKey/FirstSubKey/WithSubSubKey", "test_SimpleRegistry error 1213" );
343 xRootKey
->getKeyType( OUString( "LinkTest" ) ) ==
344 registry::RegistryKeyType_LINK
,
345 "test_SimpleRegistry error 1214" );
347 xKey
= xRootKey
->openKey(OUString( "FirstKey/SecondSubKey" ));
348 OSL_ENSURE( !xKey
.is(), "test_SimpleRegistry error 27" );
351 xKey
= xRootKey
->createKey(OUString( "FifthKey" ));
352 xKey
->createLink(OUString( "MyFirstLink" ),
353 OUString( "/ThirdKey/FirstSubKey" ));
355 xKey
= xRootKey
->openKey(OUString( "/FifthKey/MyFirstLink" ));
356 OSL_ENSURE( xKey
->isValid(), "test_SimpleRegistry error 27" );
357 OSL_ENSURE( xKey
->getKeyName() == OUString( "/ThirdKey/FirstSubKey" ), "test_SimpleRegistry error 28" );
359 xKey
->createLink(OUString( "/WithSubSubKey/MyFourthLink" ),
360 OUString( "/FourthKey/MySecondLink" ));
362 OSL_ENSURE( xKey
->getLinkTarget(OUString( "/WithSubSubKey/MyFourthLink" ))
363 == OUString( "/FourthKey/MySecondLink" ), "test_SimpleRegistry error 29" );
367 OSL_ENSURE( xKey
->getResolvedName(OUString( "/WithSubSubKey/MyFourthLink/BlaBlaBla" ))
368 == OUString( "/FourthKey/MySecondLink/BlaBlaBla" ), "test_SimpleRegistry error 30" );
370 catch(InvalidRegistryException
&)
374 xRootKey
->createLink(OUString( "/FourthKey/MySecondLink" ),
375 OUString( "/SixthKey/MyThirdLink" ));
376 xKey
= xRootKey
->createKey(OUString( "SixthKey" ));
377 xKey
->createLink(OUString( "MyThirdLink" ),
378 OUString( "/FourthKey/MySecondLink" ));
380 xKey
= xRootKey
->createKey(OUString( "/SixthKey/SixthSubKey" ));
384 xRootKey
->openKey(OUString( "/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink" ));
386 catch(InvalidRegistryException
&)
390 OSL_ENSURE( xRootKey
->getLinkTarget(OUString( "/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink" ))
391 == OUString( "/FourthKey/MySecondLink" ), "test_SimpleRegistry error 31" );
393 xRootKey
->deleteLink(OUString( "/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink" ));
395 xRootKey
->createLink(OUString( "/FourthKey/MySecondLink" ),
396 OUString( "/ThirdKey/FirstSubKey/WithSubSubKey" ));
398 xKey
= xRootKey
->openKey(OUString( "SixthKey" ));
399 seqNames
= xKey
->getKeyNames();
400 seqKeys
= xKey
->openKeys();
402 OSL_ENSURE( seqNames
.getArray()[0] == OUString( "/SixthKey/SixthSubKey" ),
403 "test_SimpleRegistry error 32" );
404 OSL_ENSURE( seqNames
.getArray()[1] == OUString( "/SixthKey/MyThirdLink" ),
405 "test_SimpleRegistry error 33" );
407 OSL_ENSURE( seqKeys
.getArray()[0]->getKeyName() == OUString( "/SixthKey/SixthSubKey" ),
408 "test_SimpleRegistry error 34" );
409 OSL_ENSURE( seqKeys
.getArray()[1]->getKeyName() == OUString( "/ThirdKey/FirstSubKey/WithSubSubKey" ),
410 "test_SimpleRegistry error 35" );
412 xRootKey
->deleteLink(OUString( "/FourthKey/MySecondLink" ));
413 xRootKey
->closeKey();
415 catch(InvalidRegistryException
&)
417 OSL_ENSURE(0, "exception InvalidRegistryExcption raised while doing test_SimpleRegistry");
419 catch(InvalidValueException
&)
421 OSL_ENSURE(0, "exception InvalidValueExcption raised while doing test_SimpleRegistry()");
426 printf("Test SimpleRegistry, OK!\n");
430 void test_DefaultRegistry(
431 OUString
const & testreg
,
432 OUString
const & testreg2
,
433 bool bMergeDifferently
= false )
435 // Test NestedRegistry
436 OUString
exePath( getExePath() );
437 OUString
userRdb(exePath
);
438 OUString
applicatRdb(exePath
);
440 userRdb
+= "user.rdb";
441 applicatRdb
+= "stoctest.rdb";
443 Reference
< XMultiServiceFactory
> rSMgr
= ::cppu::createRegistryServiceFactory( userRdb
, applicatRdb
, sal_False
, OUString());
444 //OUString("//./e:/src596/stoc/wntmsci3/bin") );
446 Reference
< XPropertySet
> xPropSet( rSMgr
, UNO_QUERY
);
447 OSL_ENSURE( xPropSet
.is(), "test_DefaultRegistry error0");
449 Any
aPropertyAny( xPropSet
->getPropertyValue( OUString("Registry") ) );
450 OSL_ENSURE( aPropertyAny
.hasValue(), "test_DefaultRegistry error1");
452 Reference
<XSimpleRegistry
> xReg
;
453 aPropertyAny
>>= xReg
;
454 OSL_ENSURE( xReg
.is(), "test_DefaultRegistry error1a");
456 Reference
<XServiceInfo
> xServInfo( Reference
<XServiceInfo
>::query(xReg
) );
458 OSL_ENSURE( xServInfo
.is(), "test_DefaultRegistry error2");
460 OSL_ENSURE( xServInfo
->getImplementationName() == OUString( "com.sun.star.comp.stoc.NestedRegistry" ), "test_DefualtRegistry error3");
461 OSL_ENSURE( xServInfo
->supportsService(OUString( "com.sun.star.registry.NestedRegistry" )), "test_DefaultRegistry error4");
462 OSL_ENSURE( xServInfo
->getSupportedServiceNames().getLength() == 1, "test_DefaultRegistry error5");
465 OSL_ENSURE( xReg
.is(), "test_DefaultRegistry error6");
469 Reference
<XRegistryKey
> xRootKey(xReg
->getRootKey());
471 Reference
<XRegistryKey
> xKey
= xRootKey
->openKey(OUString( "/UCR/com/sun/star/registry/XSimpleRegistry" ));
473 OSL_ENSURE( xKey
->getKeyName() == OUString( "/UCR/com/sun/star/registry/XSimpleRegistry" ),
474 "test_DefaultRegistry error 7" );
476 if (bMergeDifferently
)
485 xReg
->mergeKey(OUString( "Test" ), testreg
);
488 xKey
= xRootKey
->openKey(OUString( "Test/ThirdKey/FirstSubKey/WithSubSubKey" ));
490 xKey
->setLongValue(123456789);
492 xKey
= xRootKey
->openKey(OUString( "Test/ThirdKey/FirstSubKey" ));
495 xKey
->createKey(OUString( "SecondSubSubKey" ));
497 Sequence
<OUString
> seqNames
= xKey
->getKeyNames();
499 OSL_ENSURE( seqNames
.getLength() == 2, "test_DefaultRegistry error 8" );
502 xKey
= xRootKey
->openKey(OUString( "/Test/ThirdKey" ));
505 RegistryValueType valueType
= xKey
->getValueType();
506 OSL_ENSURE( valueType
== RegistryValueType_ASCIILIST
, "test_DefaultRegistry error 9" );
508 Sequence
<OUString
> seqValue
= xKey
->getAsciiListValue();
510 OSL_ENSURE( seqValue
.getLength() == 3, "test_DefaultRegistry error 10" );
511 OSL_ENSURE( seqValue
.getArray()[0] == OUString( "Hallo" ),
512 "test_DefaultRegistry error 11" );
513 OSL_ENSURE( seqValue
.getArray()[1] == OUString( "jetzt komm" ),
514 "test_DefaultRegistry error 12" );
515 OSL_ENSURE( seqValue
.getArray()[2] == OUString( "ich" ),
516 "test_DefaultRegistry error 13" );
518 Sequence
<sal_Int32
> seqLong(3);
519 seqLong
.getArray()[0] = 1234;
520 seqLong
.getArray()[1] = 4567;
521 seqLong
.getArray()[2] = 7890;
523 xKey
->setLongListValue(seqLong
);
525 Sequence
<sal_Int32
> seqLongValue
= xKey
->getLongListValue();
527 OSL_ENSURE( seqLongValue
.getLength() == 3, "test_DefaultRegistry error 14" );
528 OSL_ENSURE( seqLongValue
.getArray()[0] == 1234, "test_DefaultRegistry error 15" );
529 OSL_ENSURE( seqLongValue
.getArray()[1] == 4567, "test_DefaultRegistry error 16" );
530 OSL_ENSURE( seqLongValue
.getArray()[2] == 7890, "test_DefaultRegistry error 17" );
534 xKey
= xRootKey
->createKey(OUString( "/Test/FifthKey" ));
535 xKey
->createLink(OUString( "MyFirstLink" ),
536 OUString( "/Test/ThirdKey/FirstSubKey" ));
538 xKey
= xRootKey
->openKey(OUString( "/Test/FifthKey/MyFirstLink" ));
539 OSL_ENSURE( xKey
->isValid(), "test_DefaultRegistry error 18" );
540 OSL_ENSURE( xKey
->getKeyName() == OUString( "/Test/ThirdKey/FirstSubKey" ),
541 "test_DefaultRegistry error 19" );
543 xKey
->createLink(OUString( "/WithSubSubKey/MyFourthLink" ),
544 OUString( "/Test/FourthKey/MySecondLink" ));
546 OSL_ENSURE( xKey
->getLinkTarget(OUString( "/WithSubSubKey/MyFourthLink" ))
547 == OUString( "/Test/FourthKey/MySecondLink" ),
548 "test_DefaultRegistry error 20" );
552 OSL_ENSURE( xKey
->getResolvedName(OUString( "/WithSubSubKey/MyFourthLink/BlaBlaBla" ))
553 == OUString( "/Test/FourthKey/MySecondLink/BlaBlaBla" ),
554 "test_DefaultRegistry error 21" );
556 catch(InvalidRegistryException
&)
560 xRootKey
->createLink(OUString( "/Test/FourthKey/MySecondLink" ),
561 OUString( "/Test/SixthKey/MyThirdLink" ));
562 xKey
= xRootKey
->createKey(OUString( "/Test/SixthKey" ));
563 xKey
->createLink(OUString( "MyThirdLink" ),
564 OUString( "/Test/FourthKey/MySecondLink" ));
568 xRootKey
->openKey(OUString( "/Test/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink" ));
570 catch(InvalidRegistryException
&)
572 printf("test InvalidRegistryExcption OK!\n");
575 OSL_ENSURE( xRootKey
->getLinkTarget(OUString( "/Test/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink" ))
576 == OUString( "/Test/FourthKey/MySecondLink" ),
577 "test_DefaultRegistry error 22" );
579 xRootKey
->deleteLink(OUString( "/Test/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink" ));
581 xKey
= xRootKey
->openKey(OUString( "/Test/DefaultLink/SecondSubSubKey" ));
584 OSL_ENSURE( xKey
->getKeyName() == OUString( "/Test/ThirdKey/FirstSubKey/SecondSubSubKey" ), "test_DefaultRegistry error 23" );
586 xKey
= xRootKey
->createKey(OUString( "/Test/DefaultLink/ThirdSubSubKey" ));
589 OSL_ENSURE( xKey
->getKeyName() == OUString( "/Test/ThirdKey/FirstSubKey/ThirdSubSubKey" ),
590 "test_DefaultRegistry error 24" );
593 xKey
= xRootKey
->openKey(OUString( "Test" ));
594 OSL_ENSURE( xKey
->isValid(), "test_DefaultRegistry error 25" );
596 xRootKey
->deleteKey(OUString( "Test" ));
598 if (bMergeDifferently
)
602 OUString( "AllFromTestreg2" ),
607 xReg
->mergeKey(OUString( "AllFromTestreg2" ),
611 xKey
= xRootKey
->openKey(OUString( "/AllFromTestreg2/ThirdKey/FirstSubKey" ));
614 xRootKey
->deleteKey(OUString( "/AllFromTestreg2" ));
618 catch(InvalidRegistryException
&)
620 OSL_ENSURE(0, "exception InvalidRegistryExcption raised while doing test_DefaultRegistry");
622 catch(InvalidValueException
&)
624 OSL_ENSURE(0, "exception InvalidValueExcption raised while doing test_DefaultRegistry()");
630 catch(const InvalidRegistryException
& e
)
633 OSL_ENSURE(0, OUStringToOString(e
.Message
,RTL_TEXTENCODING_ASCII_US
).getStr());
640 Reference
< ::com::sun::star::lang::XComponent
> xComp( rSMgr
, UNO_QUERY
);
641 OSL_ENSURE( xComp
.is(), "### serivce manager has to implement XComponent!" );
644 printf("Test DefaultRegistry, OK!\n");
650 // setStarUserRegistry();
651 setLinkInDefaultRegistry(OUString("/Test/DefaultLink"),
652 OUString("/Test/FifthKey/MyFirstLink"));
654 OUString
reg1( "testreg1.rdb" );
655 OUString
reg2( "testreg2.rdb" );
656 OUString
areg1( "atestreg1.rdb" );
657 OUString
areg2( "atestreg2.rdb" );
659 test_SimpleRegistry( reg1
, reg2
);
660 test_DefaultRegistry( reg1
, reg2
);
661 test_SimpleRegistry( areg1
, areg2
, true ); // use different merge
662 test_DefaultRegistry( areg1
, areg2
, true );
664 Reference
< XSimpleRegistry
> xSimReg( ::cppu::createSimpleRegistry() );
665 xSimReg
->open( reg1
, sal_False
, sal_True
);
667 xSimReg
->open( reg2
, sal_False
, sal_True
);
669 xSimReg
->open( areg1
, sal_False
, sal_True
);
671 xSimReg
->open( areg2
, sal_False
, sal_True
);
677 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */