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
;
54 using ::rtl::OUString
;
55 using ::rtl::OUStringToOString
;
60 void SAL_CALL
mergeKeys(
61 Reference
< registry::XRegistryKey
> const & xDest
,
62 Reference
< registry::XRegistryKey
> const & xSource
)
63 SAL_THROW( (registry::InvalidRegistryException
, registry::MergeConflictException
) );
65 static void mergeKeys(
66 Reference
< registry::XSimpleRegistry
> const & xDest
,
67 OUString
const & rBaseNode
,
68 OUString
const & rURL
)
69 SAL_THROW( (registry::InvalidRegistryException
, registry::MergeConflictException
) )
71 Reference
< registry::XRegistryKey
> xDestRoot( xDest
->getRootKey() );
72 Reference
< registry::XRegistryKey
> xDestKey
;
73 if (rBaseNode
.getLength())
75 xDestKey
= xDestRoot
->createKey( rBaseNode
);
76 xDestRoot
->closeKey();
82 Reference
< registry::XSimpleRegistry
> xSimReg( ::cppu::createSimpleRegistry() );
83 xSimReg
->open( rURL
, sal_True
, sal_False
);
84 OSL_ASSERT( xSimReg
->isValid() );
85 Reference
< registry::XRegistryKey
> xSourceKey( xSimReg
->getRootKey() );
86 ::stoc_impreg::mergeKeys( xDestKey
, xSourceKey
);
87 xSourceKey
->closeKey();
93 OString
userRegEnv("STAR_USER_REGISTRY=");
98 OSL_VERIFY( osl_getExecutableFile( &exe
.pData
) == osl_Process_E_None
);
99 #if defined(WIN32) || defined(WNT)
100 exe
= exe
.copy(0, exe
.getLength() - 16);
102 exe
= exe
.copy(0, exe
.getLength() - 12);
107 void setStarUserRegistry()
109 Registry
*myRegistry
= new Registry();
111 RegistryKey rootKey
, rKey
, rKey2
;
113 OUString userReg
= getExePath();
114 userReg
+= OUString("user.rdb");
115 if(myRegistry
->open(userReg
, REG_READWRITE
))
117 OSL_VERIFY(!myRegistry
->create(userReg
));
120 OSL_VERIFY(!myRegistry
->close());
123 userRegEnv
+= OUStringToOString(userReg
, RTL_TEXTENCODING_ASCII_US
);
124 putenv((char *)userRegEnv
.getStr());
127 void setLinkInDefaultRegistry(const OUString
& linkName
, const OUString
& linkTarget
)
129 Registry
*myRegistry
= new Registry();
133 OUString appReg
= getExePath();
134 appReg
+= OUString("stoctest.rdb");
136 OSL_VERIFY(!myRegistry
->open(appReg
, REG_READWRITE
));
137 OSL_VERIFY(!myRegistry
->openRootKey(rootKey
));
139 OSL_VERIFY(!rootKey
.createLink(linkName
, linkTarget
));
141 OSL_VERIFY(!rootKey
.closeKey());
142 OSL_VERIFY(!myRegistry
->close());
148 void test_SimpleRegistry(
149 OUString
const & testreg
,
150 OUString
const & testreg2
,
151 bool bMergeDifferently
= true )
153 Reference
<XInterface
> xIFace
;
157 "simplereg.uno" SAL_DLLEXTENSION
);
159 if (module
.load(dllName
))
161 // try to get provider from module
162 component_getFactoryFunc pCompFactoryFunc
= (component_getFactoryFunc
)
163 module
.getFunctionSymbol( OUString(COMPONENT_GETFACTORY
) );
165 if (pCompFactoryFunc
)
167 XSingleServiceFactory
* pRet
= (XSingleServiceFactory
*)
169 "com.sun.star.comp.stoc.SimpleRegistry", 0, 0 );
178 OSL_ENSURE( xIFace
.is(), "test_SimpleRegistry error1");
180 Reference
<XSingleServiceFactory
> xFactory( Reference
<XSingleServiceFactory
>::query(xIFace
) );
183 OSL_ENSURE( xFactory
.is(), "testloader error11");
185 Reference
<XInterface
> xIFace2
= xFactory
->createInstance();
188 OSL_ENSURE( xIFace2
.is(), "testloader error12");
190 Reference
<XServiceInfo
> xServInfo( Reference
<XServiceInfo
>::query(xIFace2
) );
192 OSL_ENSURE( xServInfo
.is(), "test_SimpleRegistry error2");
194 OSL_ENSURE( xServInfo
->getImplementationName() == "com.sun.star.comp.stoc.SimpleRegistry", "test_SimpleRegistry error3");
195 OSL_ENSURE( xServInfo
->supportsService(OUString( "com.sun.star.registry.SimpleRegistry")), "test_SimpleRegistry error4");
196 OSL_ENSURE( xServInfo
->getSupportedServiceNames().getLength() == 1, "test_SimpleRegistry error5");
199 Reference
<XSimpleRegistry
> xReg( Reference
<XSimpleRegistry
>::query(xIFace2
) );
202 OSL_ENSURE( xReg
.is(), "test_SimpleRegistry error6");
206 xReg
->open(testreg
, sal_False
, sal_True
);
208 OSL_ENSURE( xReg
->isValid() != sal_False
, "test_SimpleRegistry error 7" );
209 OSL_ENSURE( xReg
->isReadOnly() == sal_False
, "test_SimpleRegistry error 8" );
211 Reference
<XRegistryKey
> xRootKey(xReg
->getRootKey());
212 OSL_ENSURE( xRootKey
->isValid(), "test_SimpleRegistry error 9" );
214 Reference
<XRegistryKey
> xKey
= xRootKey
->createKey(OUString( "FirstKey" ));
216 Reference
<XRegistryKey
> xSubKey
= xKey
->createKey(OUString( "FirstSubKey" ));
217 xSubKey
->setLongValue(123456789);
219 xSubKey
= xKey
->createKey(OUString( "SecondSubKey" ));
220 xSubKey
->setAsciiValue(OUString( "ich bin ein acsii value" ));
222 xSubKey
= xKey
->createKey(OUString( "ThirdSubKey" ));
223 xSubKey
->setStringValue(OUString( "ich bin ein unicode value" ));
225 xSubKey
= xKey
->createKey(OUString( "FourthSubKey" ));
226 Sequence
<sal_Int8
> aSeq((sal_Int8
*)"ich bin ein binary value", 25);
227 xSubKey
->setBinaryValue(aSeq
);
229 Sequence
<OUString
> seqNames
= xKey
->getKeyNames();
230 Sequence
< Reference
<XRegistryKey
> > seqKeys
= xKey
->openKeys();
233 for (sal_Int32 i
=0; i
< seqNames
.getLength(); i
++)
235 name
= seqNames
.getArray()[i
];
236 xSubKey
= seqKeys
.getArray()[i
];
238 if (name
== OUString( "/FirstKey/FirstSubKey" ))
240 OSL_ENSURE( xSubKey
->getLongValue() == 123456789,
241 "test_SimpleRegistry error 10" );
243 if (name
== OUString( "/FirstKey/SecondSubKey" ))
245 OSL_ENSURE( xSubKey
->getAsciiValue() == OUString( "ich bin ein acsii value" ),
246 "test_SimpleRegistry error 11" );
248 if (name
== OUString( "/FirstKey/ThirdSubKey" ))
250 OSL_ENSURE( xSubKey
->getStringValue() == OUString( "ich bin ein unicode value" ),
251 "test_SimpleRegistry error 12" );
253 if (name
== OUString( "/FirstKey/FourthSubKey" ))
255 Sequence
<sal_Int8
> seqByte
= xSubKey
->getBinaryValue();
256 OSL_ENSURE(!strcmp(((const char*)seqByte
.getArray()), "ich bin ein binary value"),
257 "test_SimpleRegistry error 13" );
260 seqKeys
.getArray()[i
]->closeKey();
265 xRootKey
->deleteKey(OUString( "FirstKey" ));
266 xRootKey
->createKey(OUString( "SecondFirstKey" ));
268 xKey
= xRootKey
->createKey(OUString( "SecondKey" ));
269 sal_Int32 pLongs
[3] = {123, 456, 789};
270 Sequence
<sal_Int32
> seqLongs(pLongs
, 3);
271 xKey
->setLongListValue(seqLongs
);
273 Sequence
<sal_Int32
> seqLongs2
;
274 seqLongs2
= xKey
->getLongListValue();
275 OSL_ENSURE( seqLongs
.getLength() == 3, "test_SimpleRegistry error 14" );
276 OSL_ENSURE( seqLongs
.getArray()[0] == 123, "test_SimpleRegistry error 15" );
277 OSL_ENSURE( seqLongs
.getArray()[1] == 456, "test_SimpleRegistry error 16" );
278 OSL_ENSURE( seqLongs
.getArray()[2] == 789, "test_SimpleRegistry error 17" );
281 xKey
= xRootKey
->createKey(OUString( "ThirdKey" ));
283 pAscii
[0] = OUString( "Hallo" );
284 pAscii
[1] = OUString( "jetzt komm" );
285 pAscii
[2] = OUString( "ich" );
287 Sequence
<OUString
> seqAscii(pAscii
, 3);
288 xKey
->setAsciiListValue(seqAscii
);
290 Sequence
<OUString
> seqAscii2
;
291 seqAscii2
= xKey
->getAsciiListValue();
292 OSL_ENSURE( seqAscii2
.getLength() == 3, "test_SimpleRegistry error 18" );
293 OSL_ENSURE( seqAscii2
.getArray()[0] == OUString( "Hallo" ), "test_SimpleRegistry error 19");
294 OSL_ENSURE( seqAscii2
.getArray()[1] == OUString( "jetzt komm" ), "test_SimpleRegistry error 20");
295 OSL_ENSURE( seqAscii2
.getArray()[2] == OUString( "ich" ), "test_SimpleRegistry error 21");
297 xKey
= xRootKey
->createKey(OUString( "FourthKey" ));
298 OUString pUnicode
[3];
299 pUnicode
[0] = OUString( "Hallo" );
300 pUnicode
[1] = OUString( "jetzt komm" );
301 pUnicode
[2] = OUString( "ich als unicode" );
303 Sequence
<OUString
> seqUnicode(pUnicode
, 3);
304 xKey
->setStringListValue(seqUnicode
);
306 Sequence
<OUString
> seqUnicode2
;
307 seqUnicode2
= xKey
->getStringListValue();
308 OSL_ENSURE( seqUnicode2
.getLength() == 3, "test_SimpleRegistry error 22" );
309 OSL_ENSURE( seqUnicode2
.getArray()[0] == OUString( "Hallo" ), "test_SimpleRegistry error 23");
310 OSL_ENSURE( seqUnicode2
.getArray()[1] == OUString( "jetzt komm" ), "test_SimpleRegistry error 24");
311 OSL_ENSURE( seqUnicode2
.getArray()[2] == OUString( "ich als unicode" ), "test_SimpleRegistry error 25");
314 xReg
->open(testreg2
, sal_False
, sal_True
);
315 OSL_ENSURE( xReg
->isValid() != sal_False
, "test_SimpleRegistry error 25" );
316 xRootKey
= xReg
->getRootKey();
317 xKey
= xRootKey
->createKey(OUString( "ThirdKey/FirstSubKey/WithSubSubKey" ));
320 xRootKey
->createLink(
321 OUString( "LinkTest" ),
322 OUString( "/ThirdKey/FirstSubKey/WithSubSubKey" )) );
323 xRootKey
->closeKey();
326 xReg
->open(testreg
, sal_False
, sal_False
);
327 OSL_ENSURE( xReg
->isValid() != sal_False
, "test_SimpleRegistry error 26" );
329 if (bMergeDifferently
)
338 xReg
->mergeKey(OUString(), testreg2
);
341 xRootKey
= xReg
->getRootKey();
342 xKey
= xRootKey
->openKey( OUString( "LinkTest" ) );
343 OSL_ENSURE( xKey
.is() && xKey
->isValid() && xKey
->getKeyName() == "/ThirdKey/FirstSubKey/WithSubSubKey", "test_SimpleRegistry error 1213" );
346 xRootKey
->getKeyType( OUString( "LinkTest" ) ) ==
347 registry::RegistryKeyType_LINK
,
348 "test_SimpleRegistry error 1214" );
350 xKey
= xRootKey
->openKey(OUString( "FirstKey/SecondSubKey" ));
351 OSL_ENSURE( !xKey
.is(), "test_SimpleRegistry error 27" );
354 xKey
= xRootKey
->createKey(OUString( "FifthKey" ));
355 xKey
->createLink(OUString( "MyFirstLink" ),
356 OUString( "/ThirdKey/FirstSubKey" ));
358 xKey
= xRootKey
->openKey(OUString( "/FifthKey/MyFirstLink" ));
359 OSL_ENSURE( xKey
->isValid(), "test_SimpleRegistry error 27" );
360 OSL_ENSURE( xKey
->getKeyName() == OUString( "/ThirdKey/FirstSubKey" ), "test_SimpleRegistry error 28" );
362 xKey
->createLink(OUString( "/WithSubSubKey/MyFourthLink" ),
363 OUString( "/FourthKey/MySecondLink" ));
365 OSL_ENSURE( xKey
->getLinkTarget(OUString( "/WithSubSubKey/MyFourthLink" ))
366 == OUString( "/FourthKey/MySecondLink" ), "test_SimpleRegistry error 29" );
370 OSL_ENSURE( xKey
->getResolvedName(OUString( "/WithSubSubKey/MyFourthLink/BlaBlaBla" ))
371 == OUString( "/FourthKey/MySecondLink/BlaBlaBla" ), "test_SimpleRegistry error 30" );
373 catch(InvalidRegistryException
&)
377 xRootKey
->createLink(OUString( "/FourthKey/MySecondLink" ),
378 OUString( "/SixthKey/MyThirdLink" ));
379 xKey
= xRootKey
->createKey(OUString( "SixthKey" ));
380 xKey
->createLink(OUString( "MyThirdLink" ),
381 OUString( "/FourthKey/MySecondLink" ));
383 xKey
= xRootKey
->createKey(OUString( "/SixthKey/SixthSubKey" ));
387 xRootKey
->openKey(OUString( "/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink" ));
389 catch(InvalidRegistryException
&)
393 OSL_ENSURE( xRootKey
->getLinkTarget(OUString( "/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink" ))
394 == OUString( "/FourthKey/MySecondLink" ), "test_SimpleRegistry error 31" );
396 xRootKey
->deleteLink(OUString( "/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink" ));
398 xRootKey
->createLink(OUString( "/FourthKey/MySecondLink" ),
399 OUString( "/ThirdKey/FirstSubKey/WithSubSubKey" ));
401 xKey
= xRootKey
->openKey(OUString( "SixthKey" ));
402 seqNames
= xKey
->getKeyNames();
403 seqKeys
= xKey
->openKeys();
405 OSL_ENSURE( seqNames
.getArray()[0] == OUString( "/SixthKey/SixthSubKey" ),
406 "test_SimpleRegistry error 32" );
407 OSL_ENSURE( seqNames
.getArray()[1] == OUString( "/SixthKey/MyThirdLink" ),
408 "test_SimpleRegistry error 33" );
410 OSL_ENSURE( seqKeys
.getArray()[0]->getKeyName() == OUString( "/SixthKey/SixthSubKey" ),
411 "test_SimpleRegistry error 34" );
412 OSL_ENSURE( seqKeys
.getArray()[1]->getKeyName() == OUString( "/ThirdKey/FirstSubKey/WithSubSubKey" ),
413 "test_SimpleRegistry error 35" );
415 xRootKey
->deleteLink(OUString( "/FourthKey/MySecondLink" ));
416 xRootKey
->closeKey();
418 catch(InvalidRegistryException
&)
420 OSL_ENSURE(0, "exception InvalidRegistryExcption raised while doing test_SimpleRegistry");
422 catch(InvalidValueException
&)
424 OSL_ENSURE(0, "exception InvalidValueExcption raised while doing test_SimpleRegistry()");
429 printf("Test SimpleRegistry, OK!\n");
433 void test_DefaultRegistry(
434 OUString
const & testreg
,
435 OUString
const & testreg2
,
436 bool bMergeDifferently
= false )
438 // Test NestedRegistry
439 OUString
exePath( getExePath() );
440 OUString
userRdb(exePath
);
441 OUString
applicatRdb(exePath
);
443 userRdb
+= OUString("user.rdb");
444 applicatRdb
+= OUString("stoctest.rdb");
446 Reference
< XMultiServiceFactory
> rSMgr
= ::cppu::createRegistryServiceFactory( userRdb
, applicatRdb
, sal_False
, OUString());
447 //OUString("//./e:/src596/stoc/wntmsci3/bin") );
449 Reference
< XPropertySet
> xPropSet( rSMgr
, UNO_QUERY
);
450 OSL_ENSURE( xPropSet
.is(), "test_DefaultRegistry error0");
452 Any
aPropertyAny( xPropSet
->getPropertyValue( OUString("Registry") ) );
453 OSL_ENSURE( aPropertyAny
.hasValue(), "test_DefaultRegistry error1");
455 Reference
<XSimpleRegistry
> xReg
;
456 aPropertyAny
>>= xReg
;
457 OSL_ENSURE( xReg
.is(), "test_DefaultRegistry error1a");
459 Reference
<XServiceInfo
> xServInfo( Reference
<XServiceInfo
>::query(xReg
) );
461 OSL_ENSURE( xServInfo
.is(), "test_DefaultRegistry error2");
463 OSL_ENSURE( xServInfo
->getImplementationName() == OUString( "com.sun.star.comp.stoc.NestedRegistry" ), "test_DefualtRegistry error3");
464 OSL_ENSURE( xServInfo
->supportsService(OUString( "com.sun.star.registry.NestedRegistry" )), "test_DefaultRegistry error4");
465 OSL_ENSURE( xServInfo
->getSupportedServiceNames().getLength() == 1, "test_DefaultRegistry error5");
468 OSL_ENSURE( xReg
.is(), "test_DefaultRegistry error6");
472 Reference
<XRegistryKey
> xRootKey(xReg
->getRootKey());
474 Reference
<XRegistryKey
> xKey
= xRootKey
->openKey(OUString( "/UCR/com/sun/star/registry/XSimpleRegistry" ));
476 OSL_ENSURE( xKey
->getKeyName() == OUString( "/UCR/com/sun/star/registry/XSimpleRegistry" ),
477 "test_DefaultRegistry error 7" );
479 if (bMergeDifferently
)
488 xReg
->mergeKey(OUString( "Test" ), testreg
);
491 xKey
= xRootKey
->openKey(OUString( "Test/ThirdKey/FirstSubKey/WithSubSubKey" ));
493 xKey
->setLongValue(123456789);
495 xKey
= xRootKey
->openKey(OUString( "Test/ThirdKey/FirstSubKey" ));
498 xKey
->createKey(OUString( "SecondSubSubKey" ));
500 Sequence
<OUString
> seqNames
= xKey
->getKeyNames();
502 OSL_ENSURE( seqNames
.getLength() == 2, "test_DefaultRegistry error 8" );
505 xKey
= xRootKey
->openKey(OUString( "/Test/ThirdKey" ));
508 RegistryValueType valueType
= xKey
->getValueType();
509 OSL_ENSURE( valueType
== RegistryValueType_ASCIILIST
, "test_DefaultRegistry error 9" );
511 Sequence
<OUString
> seqValue
= xKey
->getAsciiListValue();
513 OSL_ENSURE( seqValue
.getLength() == 3, "test_DefaultRegistry error 10" );
514 OSL_ENSURE( seqValue
.getArray()[0] == OUString( "Hallo" ),
515 "test_DefaultRegistry error 11" );
516 OSL_ENSURE( seqValue
.getArray()[1] == OUString( "jetzt komm" ),
517 "test_DefaultRegistry error 12" );
518 OSL_ENSURE( seqValue
.getArray()[2] == OUString( "ich" ),
519 "test_DefaultRegistry error 13" );
521 Sequence
<sal_Int32
> seqLong(3);
522 seqLong
.getArray()[0] = 1234;
523 seqLong
.getArray()[1] = 4567;
524 seqLong
.getArray()[2] = 7890;
526 xKey
->setLongListValue(seqLong
);
528 Sequence
<sal_Int32
> seqLongValue
= xKey
->getLongListValue();
530 OSL_ENSURE( seqLongValue
.getLength() == 3, "test_DefaultRegistry error 14" );
531 OSL_ENSURE( seqLongValue
.getArray()[0] == 1234, "test_DefaultRegistry error 15" );
532 OSL_ENSURE( seqLongValue
.getArray()[1] == 4567, "test_DefaultRegistry error 16" );
533 OSL_ENSURE( seqLongValue
.getArray()[2] == 7890, "test_DefaultRegistry error 17" );
537 xKey
= xRootKey
->createKey(OUString( "/Test/FifthKey" ));
538 xKey
->createLink(OUString( "MyFirstLink" ),
539 OUString( "/Test/ThirdKey/FirstSubKey" ));
541 xKey
= xRootKey
->openKey(OUString( "/Test/FifthKey/MyFirstLink" ));
542 OSL_ENSURE( xKey
->isValid(), "test_DefaultRegistry error 18" );
543 OSL_ENSURE( xKey
->getKeyName() == OUString( "/Test/ThirdKey/FirstSubKey" ),
544 "test_DefaultRegistry error 19" );
546 xKey
->createLink(OUString( "/WithSubSubKey/MyFourthLink" ),
547 OUString( "/Test/FourthKey/MySecondLink" ));
549 OSL_ENSURE( xKey
->getLinkTarget(OUString( "/WithSubSubKey/MyFourthLink" ))
550 == OUString( "/Test/FourthKey/MySecondLink" ),
551 "test_DefaultRegistry error 20" );
555 OSL_ENSURE( xKey
->getResolvedName(OUString( "/WithSubSubKey/MyFourthLink/BlaBlaBla" ))
556 == OUString( "/Test/FourthKey/MySecondLink/BlaBlaBla" ),
557 "test_DefaultRegistry error 21" );
559 catch(InvalidRegistryException
&)
563 xRootKey
->createLink(OUString( "/Test/FourthKey/MySecondLink" ),
564 OUString( "/Test/SixthKey/MyThirdLink" ));
565 xKey
= xRootKey
->createKey(OUString( "/Test/SixthKey" ));
566 xKey
->createLink(OUString( "MyThirdLink" ),
567 OUString( "/Test/FourthKey/MySecondLink" ));
571 xRootKey
->openKey(OUString( "/Test/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink" ));
573 catch(InvalidRegistryException
&)
575 printf("test InvalidRegistryExcption OK!\n");
578 OSL_ENSURE( xRootKey
->getLinkTarget(OUString( "/Test/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink" ))
579 == OUString( "/Test/FourthKey/MySecondLink" ),
580 "test_DefaultRegistry error 22" );
582 xRootKey
->deleteLink(OUString( "/Test/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink" ));
584 xKey
= xRootKey
->openKey(OUString( "/Test/DefaultLink/SecondSubSubKey" ));
587 OSL_ENSURE( xKey
->getKeyName() == OUString( "/Test/ThirdKey/FirstSubKey/SecondSubSubKey" ), "test_DefaultRegistry error 23" );
589 xKey
= xRootKey
->createKey(OUString( "/Test/DefaultLink/ThirdSubSubKey" ));
592 OSL_ENSURE( xKey
->getKeyName() == OUString( "/Test/ThirdKey/FirstSubKey/ThirdSubSubKey" ),
593 "test_DefaultRegistry error 24" );
596 xKey
= xRootKey
->openKey(OUString( "Test" ));
597 OSL_ENSURE( xKey
->isValid(), "test_DefaultRegistry error 25" );
599 xRootKey
->deleteKey(OUString( "Test" ));
601 if (bMergeDifferently
)
605 OUString( "AllFromTestreg2" ),
610 xReg
->mergeKey(OUString( "AllFromTestreg2" ),
614 xKey
= xRootKey
->openKey(OUString( "/AllFromTestreg2/ThirdKey/FirstSubKey" ));
617 xRootKey
->deleteKey(OUString( "/AllFromTestreg2" ));
621 catch(InvalidRegistryException
&)
623 OSL_ENSURE(0, "exception InvalidRegistryExcption raised while doing test_DefaultRegistry");
625 catch(InvalidValueException
&)
627 OSL_ENSURE(0, "exception InvalidValueExcption raised while doing test_DefaultRegistry()");
633 catch(const InvalidRegistryException
& e
)
636 OSL_ENSURE(0, OUStringToOString(e
.Message
,RTL_TEXTENCODING_ASCII_US
).getStr());
643 Reference
< ::com::sun::star::lang::XComponent
> xComp( rSMgr
, UNO_QUERY
);
644 OSL_ENSURE( xComp
.is(), "### serivce manager has to implement XComponent!" );
647 printf("Test DefaultRegistry, OK!\n");
653 // setStarUserRegistry();
654 setLinkInDefaultRegistry(OUString("/Test/DefaultLink"),
655 OUString("/Test/FifthKey/MyFirstLink"));
657 OUString
reg1( "testreg1.rdb" );
658 OUString
reg2( "testreg2.rdb" );
659 OUString
areg1( "atestreg1.rdb" );
660 OUString
areg2( "atestreg2.rdb" );
662 test_SimpleRegistry( reg1
, reg2
);
663 test_DefaultRegistry( reg1
, reg2
);
664 test_SimpleRegistry( areg1
, areg2
, true ); // use different merge
665 test_DefaultRegistry( areg1
, areg2
, true );
667 Reference
< XSimpleRegistry
> xSimReg( ::cppu::createSimpleRegistry() );
668 xSimReg
->open( reg1
, sal_False
, sal_True
);
670 xSimReg
->open( reg2
, sal_False
, sal_True
);
672 xSimReg
->open( areg1
, sal_False
, sal_True
);
674 xSimReg
->open( areg2
, sal_False
, sal_True
);
680 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */