1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cppuhelper.hxx"
30 
31 #include "sal/config.h"
32 
33 #include "test/cppuhelper/propertysetmixin/CppSupplier.hpp"
34 #include "test/cppuhelper/propertysetmixin/JavaSupplier.hpp"
35 #include "test/cppuhelper/propertysetmixin/XSupplier.hpp"
36 #include "test/cppuhelper/propertysetmixin/XTest3.hpp"
37 
38 #include "com/sun/star/beans/Ambiguous.hpp"
39 #include "com/sun/star/beans/Defaulted.hpp"
40 #include "com/sun/star/beans/Optional.hpp"
41 #include "com/sun/star/beans/Property.hpp"
42 #include "com/sun/star/beans/PropertyAttribute.hpp"
43 #include "com/sun/star/beans/PropertyChangeEvent.hpp"
44 #include "com/sun/star/beans/PropertyState.hpp"
45 #include "com/sun/star/beans/PropertyValue.hpp"
46 #include "com/sun/star/beans/PropertyVetoException.hpp"
47 #include "com/sun/star/beans/UnknownPropertyException.hpp"
48 #include "com/sun/star/beans/XFastPropertySet.hpp"
49 #include "com/sun/star/beans/XPropertyAccess.hpp"
50 #include "com/sun/star/beans/XPropertyChangeListener.hpp"
51 #include "com/sun/star/beans/XPropertySet.hpp"
52 #include "com/sun/star/beans/XPropertySetInfo.hpp"
53 #include "com/sun/star/beans/XVetoableChangeListener.hpp"
54 #include "com/sun/star/lang/XComponent.hpp"
55 #include "com/sun/star/uno/Any.hxx"
56 #include "com/sun/star/uno/Reference.hxx"
57 #include "com/sun/star/uno/RuntimeException.hpp"
58 #include "com/sun/star/uno/Sequence.hxx"
59 #include "com/sun/star/uno/Type.hxx"
60 #include "com/sun/star/uno/XComponentContext.hpp"
61 #include "cppuhelper/bootstrap.hxx"
62 #include "cppuhelper/implbase1.hxx"
63 #include "cppunit/TestAssert.h"
64 #include "cppunit/TestFixture.h"
65 #include "cppunit/extensions/HelperMacros.h"
66 #include "cppunit/plugin/TestPlugIn.h"
67 #include "osl/mutex.hxx"
68 #include "rtl/ref.hxx"
69 #include "rtl/string.h"
70 #include "rtl/textenc.h"
71 #include "rtl/ustring.h"
72 #include "rtl/ustring.hxx"
73 #include "sal/types.h"
74 
75 #include <limits>
76 #include <ostream>
77 
78 namespace com { namespace sun { namespace star {
79     struct EventObject;
80 } } }
81 
82 namespace css = com::sun::star;
83 
84 namespace {
85 
86 std::ostream & operator <<(std::ostream & out, rtl::OUString const & value) {
87     return out << rtl::OUStringToOString(value, RTL_TEXTENCODING_UTF8).getStr();
88 }
89 
90 std::ostream & operator <<(std::ostream & out, css::uno::Type const & value) {
91     return out << "com::sun::star::uno::Type[" << value.getTypeName() << ']';
92 }
93 
94 std::ostream & operator <<(std::ostream & out, css::uno::Any const & value) {
95     return
96         out << "com::sun::star::uno::Any[" << value.getValueType() << ", ...]";
97 }
98 
99 class BoundListener:
100     public cppu::WeakImplHelper1< css::beans::XPropertyChangeListener >
101 {
102 public:
103     BoundListener(): m_count(0) {}
104 
105     int count() const {
106         osl::MutexGuard g(m_mutex);
107         return m_count;
108     }
109 
110     virtual void SAL_CALL disposing(css::lang::EventObject const &)
111         throw (css::uno::RuntimeException)
112     {
113         osl::MutexGuard g(m_mutex);
114         CPPUNIT_ASSERT(m_count < std::numeric_limits< int >::max());
115         ++m_count;
116     }
117 
118     virtual void SAL_CALL propertyChange(
119         css::beans::PropertyChangeEvent const &)
120         throw (css::uno::RuntimeException)
121     { CPPUNIT_FAIL("BoundListener::propertyChange called"); }
122 
123 private:
124     BoundListener(BoundListener &); // not defined
125     void operator =(BoundListener &); // not defined
126 
127     virtual ~BoundListener() {}
128 
129     mutable osl::Mutex m_mutex;
130     int m_count;
131 };
132 
133 class VetoListener:
134     public cppu::WeakImplHelper1< css::beans::XVetoableChangeListener >
135 {
136 public:
137     VetoListener(): m_count(0) {}
138 
139     int count() const {
140         osl::MutexGuard g(m_mutex);
141         return m_count;
142     }
143 
144     virtual void SAL_CALL disposing(css::lang::EventObject const &)
145         throw (css::uno::RuntimeException)
146     {
147         osl::MutexGuard g(m_mutex);
148         CPPUNIT_ASSERT(m_count < std::numeric_limits< int >::max());
149         ++m_count;
150     }
151 
152     virtual void SAL_CALL vetoableChange(
153         css::beans::PropertyChangeEvent const &)
154         throw (css::beans::PropertyVetoException, css::uno::RuntimeException)
155     { CPPUNIT_FAIL("VetoListener::vetoableChange called"); }
156 
157 private:
158     VetoListener(VetoListener &); // not defined
159     void operator =(VetoListener &); // not defined
160 
161     virtual ~VetoListener() {}
162 
163     mutable osl::Mutex m_mutex;
164     int m_count;
165 };
166 
167 class Test: public CppUnit::TestFixture {
168 public:
169     virtual void setUp();
170 
171     virtual void tearDown();
172 
173     void testCppEmpty1() { testEmpty1(getCppSupplier()); }
174 
175     void testCppEmpty2() { testEmpty2(getCppSupplier()); }
176 
177     void testCppFull() { testFull(getCppSupplier()); }
178 
179     void testJavaEmpty1() { testEmpty1(getJavaSupplier()); }
180 
181     void testJavaEmpty2() { testEmpty2(getJavaSupplier()); }
182 
183     void testJavaFull() { testFull(getJavaSupplier()); }
184 
185     CPPUNIT_TEST_SUITE(Test);
186     CPPUNIT_TEST(testCppEmpty1);
187     CPPUNIT_TEST(testCppEmpty2);
188     CPPUNIT_TEST(testCppFull);
189     CPPUNIT_TEST(testJavaEmpty1);
190     CPPUNIT_TEST(testJavaEmpty2);
191     CPPUNIT_TEST(testJavaFull);
192     CPPUNIT_TEST_SUITE_END();
193 
194 private:
195     css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier >
196     getCppSupplier() const;
197 
198     css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier >
199     getJavaSupplier() const;
200 
201     void testEmpty1(
202         css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier >
203         const & supplier) const;
204 
205     void testEmpty2(
206         css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier >
207         const & supplier) const;
208 
209     void testFull(
210         css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier >
211         const & supplier) const;
212 
213     css::uno::Reference< css::uno::XComponentContext > m_context;
214 };
215 
216 void Test::setUp() {
217     m_context = cppu::defaultBootstrap_InitialComponentContext();
218     CPPUNIT_ASSERT(m_context.is());
219 }
220 
221 void Test::tearDown() {
222     css::uno::Reference< css::lang::XComponent >(
223         m_context, css::uno::UNO_QUERY_THROW)->dispose();
224 }
225 
226 css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier >
227 Test::getCppSupplier() const
228 {
229     return test::cppuhelper::propertysetmixin::CppSupplier::create(m_context);
230 }
231 
232 css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier >
233 Test::getJavaSupplier() const
234 {
235     return test::cppuhelper::propertysetmixin::JavaSupplier::create(m_context);
236 }
237 
238 void Test::testEmpty1(
239     css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier >
240     const & supplier) const
241 {
242     css::uno::Reference< css::lang::XComponent > empty1(
243         supplier->getEmpty1(), css::uno::UNO_QUERY_THROW);
244     CPPUNIT_ASSERT(
245         !css::uno::Reference< css::beans::XPropertySet >(
246             empty1, css::uno::UNO_QUERY).is());
247     CPPUNIT_ASSERT(
248         !css::uno::Reference< css::beans::XFastPropertySet >(
249             empty1, css::uno::UNO_QUERY).is());
250     CPPUNIT_ASSERT(
251         !css::uno::Reference< css::beans::XPropertyAccess >(
252             empty1, css::uno::UNO_QUERY).is());
253     empty1->dispose();
254 }
255 
256 void Test::testEmpty2(
257     css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier >
258     const & supplier) const
259 {
260     css::uno::Reference< css::lang::XComponent > empty2(
261         supplier->getEmpty2(), css::uno::UNO_QUERY_THROW);
262     css::uno::Reference< css::beans::XPropertySet > empty2p(
263         empty2, css::uno::UNO_QUERY);
264     CPPUNIT_ASSERT(empty2p.is());
265     css::uno::Reference< css::beans::XPropertySetInfo > info(
266         empty2p->getPropertySetInfo());
267     CPPUNIT_ASSERT(info.is());
268     CPPUNIT_ASSERT_EQUAL(
269         static_cast< sal_Int32 >(0), info->getProperties().getLength());
270     try {
271         info->getPropertyByName(
272             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any")));
273         CPPUNIT_FAIL("exception expected");
274     } catch (css::beans::UnknownPropertyException &) {}
275     CPPUNIT_ASSERT(
276         !info->hasPropertyByName(
277             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any"))));
278     try {
279         empty2p->setPropertyValue(
280             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any")), css::uno::Any());
281         CPPUNIT_FAIL("exception expected");
282     } catch (css::beans::UnknownPropertyException &) {}
283     try {
284         empty2p->getPropertyValue(
285             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any")));
286         CPPUNIT_FAIL("exception expected");
287     } catch (css::beans::UnknownPropertyException &) {}
288     rtl::Reference< BoundListener > boundListener1(new BoundListener);
289     empty2p->addPropertyChangeListener(rtl::OUString(), boundListener1.get());
290     empty2p->addPropertyChangeListener(rtl::OUString(), boundListener1.get());
291     rtl::Reference< BoundListener > boundListener2(new BoundListener);
292     empty2p->removePropertyChangeListener(
293         rtl::OUString(), boundListener2.get());
294     rtl::Reference< VetoListener > vetoListener1(new VetoListener);
295     empty2p->addVetoableChangeListener(rtl::OUString(), vetoListener1.get());
296     empty2p->addVetoableChangeListener(rtl::OUString(), vetoListener1.get());
297     rtl::Reference< VetoListener > vetoListener2(new VetoListener);
298     empty2p->addVetoableChangeListener(rtl::OUString(), vetoListener2.get());
299     empty2p->removeVetoableChangeListener(rtl::OUString(), vetoListener2.get());
300     css::uno::Reference< css::beans::XFastPropertySet > empty2f(
301         empty2, css::uno::UNO_QUERY);
302     CPPUNIT_ASSERT(empty2f.is());
303     try {
304         empty2f->setFastPropertyValue(-1, css::uno::Any());
305         CPPUNIT_FAIL("exception expected");
306     } catch (css::beans::UnknownPropertyException &) {}
307     try {
308         empty2f->setFastPropertyValue(0, css::uno::Any());
309         CPPUNIT_FAIL("exception expected");
310     } catch (css::beans::UnknownPropertyException &) {}
311     try {
312         empty2f->getFastPropertyValue(-1);
313         CPPUNIT_FAIL("exception expected");
314     } catch (css::beans::UnknownPropertyException &) {}
315     try {
316         empty2f->getFastPropertyValue(0);
317         CPPUNIT_FAIL("exception expected");
318     } catch (css::beans::UnknownPropertyException &) {}
319     css::uno::Reference< css::beans::XPropertyAccess > empty2a(
320         empty2, css::uno::UNO_QUERY);
321     CPPUNIT_ASSERT(empty2a.is());
322     CPPUNIT_ASSERT_EQUAL(
323         static_cast< sal_Int32 >(0), empty2a->getPropertyValues().getLength());
324     empty2a->setPropertyValues(
325         css::uno::Sequence< css::beans::PropertyValue >());
326     css::uno::Sequence< css::beans::PropertyValue > vs(2);
327     vs[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any1"));
328     vs[0].Handle = -1;
329     vs[0].State = css::beans::PropertyState_DIRECT_VALUE;
330     vs[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any2"));
331     vs[0].Handle = -1;
332     vs[0].State = css::beans::PropertyState_DIRECT_VALUE;
333     try {
334         empty2a->setPropertyValues(vs);
335         CPPUNIT_FAIL("exception expected");
336     } catch (css::beans::UnknownPropertyException &) {}
337     CPPUNIT_ASSERT_EQUAL(0, boundListener1->count());
338     CPPUNIT_ASSERT_EQUAL(0, boundListener2->count());
339     CPPUNIT_ASSERT_EQUAL(0, vetoListener1->count());
340     CPPUNIT_ASSERT_EQUAL(0, vetoListener2->count());
341     empty2->dispose();
342     CPPUNIT_ASSERT_EQUAL(2, boundListener1->count());
343     CPPUNIT_ASSERT_EQUAL(0, boundListener2->count());
344     CPPUNIT_ASSERT_EQUAL(2, vetoListener1->count());
345     CPPUNIT_ASSERT_EQUAL(0, vetoListener2->count());
346     empty2p->removePropertyChangeListener(
347         rtl::OUString(), boundListener1.get());
348     empty2p->removePropertyChangeListener(
349         rtl::OUString(), boundListener2.get());
350     empty2p->removeVetoableChangeListener(rtl::OUString(), vetoListener1.get());
351     empty2p->removeVetoableChangeListener(rtl::OUString(), vetoListener2.get());
352     empty2p->addPropertyChangeListener(rtl::OUString(), boundListener1.get());
353     empty2p->addPropertyChangeListener(rtl::OUString(), boundListener2.get());
354     empty2p->addVetoableChangeListener(rtl::OUString(), vetoListener1.get());
355     empty2p->addVetoableChangeListener(rtl::OUString(), vetoListener2.get());
356     try {
357         empty2p->addPropertyChangeListener(
358             rtl::OUString(),
359             css::uno::Reference< css::beans::XPropertyChangeListener >());
360     } catch (css::uno::RuntimeException &) {}
361     try {
362         empty2p->addVetoableChangeListener(
363             rtl::OUString(),
364             css::uno::Reference< css::beans::XVetoableChangeListener >());
365     } catch (css::uno::RuntimeException &) {}
366     CPPUNIT_ASSERT_EQUAL(3, boundListener1->count());
367     CPPUNIT_ASSERT_EQUAL(1, boundListener2->count());
368     CPPUNIT_ASSERT_EQUAL(3, vetoListener1->count());
369     CPPUNIT_ASSERT_EQUAL(1, vetoListener2->count());
370 }
371 
372 void Test::testFull(
373     css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier >
374     const & supplier) const
375 {
376     css::uno::Reference< test::cppuhelper::propertysetmixin::XTest3 > full(
377         supplier->getFull(), css::uno::UNO_QUERY_THROW);
378     css::uno::Reference< css::beans::XPropertySet > fullp(
379         full, css::uno::UNO_QUERY);
380     CPPUNIT_ASSERT(fullp.is());
381     css::uno::Reference< css::beans::XPropertySetInfo > info(
382         fullp->getPropertySetInfo());
383     CPPUNIT_ASSERT(info.is());
384     CPPUNIT_ASSERT_EQUAL(
385         static_cast< sal_Int32 >(3), info->getProperties().getLength());
386     css::beans::Property prop(
387         info->getPropertyByName(
388             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First"))));
389     CPPUNIT_ASSERT_EQUAL(
390         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), prop.Name);
391     CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(0), prop.Handle);
392     CPPUNIT_ASSERT_EQUAL(getCppuType(static_cast< sal_Int32 * >(0)), prop.Type);
393     CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int16 >(0), prop.Attributes);
394     prop = info->getPropertyByName(
395         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")));
396     CPPUNIT_ASSERT_EQUAL(
397         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), prop.Name);
398     CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(1), prop.Handle);
399     CPPUNIT_ASSERT_EQUAL(getCppuType(static_cast< sal_Int32 * >(0)), prop.Type);
400     CPPUNIT_ASSERT_EQUAL(
401         static_cast< sal_Int16 >(
402             css::beans::PropertyAttribute::MAYBEVOID
403             | css::beans::PropertyAttribute::BOUND
404             | css::beans::PropertyAttribute::CONSTRAINED
405             | css::beans::PropertyAttribute::MAYBEAMBIGUOUS
406             | css::beans::PropertyAttribute::MAYBEDEFAULT
407             | css::beans::PropertyAttribute::OPTIONAL),
408         prop.Attributes);
409     try {
410         info->getPropertyByName(
411             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")));
412         CPPUNIT_FAIL("exception expected");
413     } catch (css::beans::UnknownPropertyException &) {}
414     prop = info->getPropertyByName(
415         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")));
416     CPPUNIT_ASSERT_EQUAL(
417         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")), prop.Name);
418     CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(3), prop.Handle);
419     CPPUNIT_ASSERT_EQUAL(getCppuType(static_cast< sal_Int32 * >(0)), prop.Type);
420     CPPUNIT_ASSERT_EQUAL(
421         static_cast< sal_Int16 >(css::beans::PropertyAttribute::OPTIONAL),
422         prop.Attributes);
423     try {
424         info->getPropertyByName(
425             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("first")));
426         CPPUNIT_FAIL("exception expected");
427     } catch (css::beans::UnknownPropertyException &) {}
428     CPPUNIT_ASSERT(
429         info->hasPropertyByName(
430             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First"))));
431     CPPUNIT_ASSERT(
432         info->hasPropertyByName(
433             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second"))));
434     CPPUNIT_ASSERT(
435         !info->hasPropertyByName(
436             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third"))));
437     CPPUNIT_ASSERT(
438         info->hasPropertyByName(
439             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth"))));
440     CPPUNIT_ASSERT(
441         !info->hasPropertyByName(
442             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("first"))));
443     CPPUNIT_ASSERT_EQUAL(
444         css::uno::makeAny(static_cast< sal_Int32 >(0)),
445         fullp->getPropertyValue(
446             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First"))));
447     fullp->setPropertyValue(
448         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")),
449         css::uno::makeAny(static_cast< sal_Int32 >(-100)));
450     CPPUNIT_ASSERT_EQUAL(
451         css::uno::makeAny(static_cast< sal_Int32 >(-100)),
452         fullp->getPropertyValue(
453             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First"))));
454     css::uno::Any voidAny;
455     CPPUNIT_ASSERT_EQUAL(
456         voidAny,
457         fullp->getPropertyValue(
458             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second"))));
459     fullp->setPropertyValue(
460         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")),
461         css::uno::makeAny(static_cast< sal_Int32 >(100)));
462     CPPUNIT_ASSERT_EQUAL(
463         css::uno::makeAny(static_cast< sal_Int32 >(100)),
464         fullp->getPropertyValue(
465             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second"))));
466     CPPUNIT_ASSERT(full->getSecond().Value.Value.IsPresent);
467     CPPUNIT_ASSERT_EQUAL(
468         static_cast< sal_Int32 >(100), full->getSecond().Value.Value.Value);
469     CPPUNIT_ASSERT(!full->getSecond().Value.IsDefaulted);
470     CPPUNIT_ASSERT(!full->getSecond().IsAmbiguous);
471     fullp->setPropertyValue(
472         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")),
473         css::uno::Any());
474     CPPUNIT_ASSERT_EQUAL(
475         voidAny,
476         fullp->getPropertyValue(
477             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second"))));
478     CPPUNIT_ASSERT(!full->getSecond().Value.Value.IsPresent);
479     CPPUNIT_ASSERT(!full->getSecond().Value.IsDefaulted);
480     CPPUNIT_ASSERT(!full->getSecond().IsAmbiguous);
481     try {
482         fullp->setPropertyValue(
483             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")),
484             css::uno::makeAny(static_cast< sal_Int32 >(100)));
485         CPPUNIT_FAIL("exception expected");
486     } catch (css::beans::UnknownPropertyException &) {}
487     try {
488         fullp->getPropertyValue(
489             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")));
490         CPPUNIT_FAIL("exception expected");
491     } catch (css::beans::UnknownPropertyException &) {}
492     try {
493         fullp->setPropertyValue(
494             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")),
495             css::uno::makeAny(static_cast< sal_Int32 >(100)));
496         CPPUNIT_FAIL("exception expected");
497     } catch (css::beans::UnknownPropertyException &) {}
498     try {
499         fullp->getPropertyValue(
500             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")));
501         CPPUNIT_FAIL("exception expected");
502     } catch (css::beans::UnknownPropertyException &) {}
503     try {
504         fullp->setPropertyValue(
505             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("first")),
506             css::uno::Any());
507         CPPUNIT_FAIL("exception expected");
508     } catch (css::beans::UnknownPropertyException &) {}
509     try {
510         fullp->getPropertyValue(
511             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("first")));
512         CPPUNIT_FAIL("exception expected");
513     } catch (css::beans::UnknownPropertyException &) {}
514     css::uno::Reference< css::beans::XFastPropertySet > fullf(
515         full, css::uno::UNO_QUERY);
516     CPPUNIT_ASSERT(fullf.is());
517     CPPUNIT_ASSERT_EQUAL(
518         css::uno::makeAny(static_cast< sal_Int32 >(-100)),
519         fullf->getFastPropertyValue(0));
520     fullf->setFastPropertyValue(
521         0, css::uno::makeAny(static_cast< sal_Int32 >(0)));
522     CPPUNIT_ASSERT_EQUAL(
523         css::uno::makeAny(static_cast< sal_Int32 >(0)),
524         fullf->getFastPropertyValue(0));
525     try {
526         fullf->getFastPropertyValue(-1);
527     } catch (css::beans::UnknownPropertyException &) {}
528     try {
529         fullf->setFastPropertyValue(-1, css::uno::Any());
530     } catch (css::beans::UnknownPropertyException &) {}
531     css::uno::Reference< css::beans::XPropertyAccess > fulla(
532         full, css::uno::UNO_QUERY);
533     CPPUNIT_ASSERT(fulla.is());
534     css::uno::Sequence< css::beans::PropertyValue > vs(
535         fulla->getPropertyValues());
536     CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(2), vs.getLength());
537     CPPUNIT_ASSERT_EQUAL(
538         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), vs[0].Name);
539     CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(0), vs[0].Handle);
540     CPPUNIT_ASSERT_EQUAL(
541         css::uno::makeAny(static_cast< sal_Int32 >(0)), vs[0].Value);
542     CPPUNIT_ASSERT_EQUAL(css::beans::PropertyState_DIRECT_VALUE, vs[0].State);
543     CPPUNIT_ASSERT_EQUAL(
544         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), vs[1].Name);
545     CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(1), vs[1].Handle);
546     CPPUNIT_ASSERT_EQUAL(voidAny, vs[1].Value);
547     CPPUNIT_ASSERT_EQUAL(css::beans::PropertyState_DIRECT_VALUE, vs[1].State);
548     vs[0].Value <<= static_cast< sal_Int32 >(-100);
549     vs[1].Value <<= static_cast< sal_Int32 >(100);
550     vs[1].State = css::beans::PropertyState_AMBIGUOUS_VALUE;
551     fulla->setPropertyValues(vs);
552     vs = fulla->getPropertyValues();
553     CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(2), vs.getLength());
554     CPPUNIT_ASSERT_EQUAL(
555         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), vs[0].Name);
556     CPPUNIT_ASSERT_EQUAL(
557         css::uno::makeAny(static_cast< sal_Int32 >(-100)), vs[0].Value);
558     CPPUNIT_ASSERT_EQUAL(css::beans::PropertyState_DIRECT_VALUE, vs[0].State);
559     CPPUNIT_ASSERT_EQUAL(
560         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), vs[1].Name);
561     CPPUNIT_ASSERT_EQUAL(
562         css::uno::makeAny(static_cast< sal_Int32 >(100)), vs[1].Value);
563     CPPUNIT_ASSERT_EQUAL(
564         css::beans::PropertyState_AMBIGUOUS_VALUE, vs[1].State);
565     CPPUNIT_ASSERT(full->getSecond().Value.Value.IsPresent);
566     CPPUNIT_ASSERT_EQUAL(
567         static_cast< sal_Int32 >(100), full->getSecond().Value.Value.Value);
568     CPPUNIT_ASSERT(!full->getSecond().Value.IsDefaulted);
569     CPPUNIT_ASSERT(full->getSecond().IsAmbiguous);
570     css::uno::Reference< css::beans::XPropertyChangeListener > boundListener(
571         new BoundListener);
572     fullp->addPropertyChangeListener(
573         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), boundListener);
574     fullp->removePropertyChangeListener(
575         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), boundListener);
576     fullp->addPropertyChangeListener(
577         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), boundListener);
578     fullp->removePropertyChangeListener(
579         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), boundListener);
580     try {
581         fullp->addPropertyChangeListener(
582             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")),
583             boundListener);
584         CPPUNIT_FAIL("exception expected");
585     } catch (css::beans::UnknownPropertyException &) {}
586     try {
587         fullp->removePropertyChangeListener(
588             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")),
589             boundListener);
590         CPPUNIT_FAIL("exception expected");
591     } catch (css::beans::UnknownPropertyException &) {}
592     fullp->addPropertyChangeListener(
593         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")), boundListener);
594     fullp->removePropertyChangeListener(
595         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")), boundListener);
596     try {
597         fullp->addPropertyChangeListener(
598             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fifth")),
599             boundListener);
600         CPPUNIT_FAIL("exception expected");
601     } catch (css::beans::UnknownPropertyException &) {}
602     try {
603         fullp->removePropertyChangeListener(
604             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fifth")),
605             boundListener);
606         CPPUNIT_FAIL("exception expected");
607     } catch (css::beans::UnknownPropertyException &) {}
608     css::uno::Reference< css::beans::XVetoableChangeListener > vetoListener(
609         new VetoListener);
610     fullp->addVetoableChangeListener(
611         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), vetoListener);
612     fullp->removeVetoableChangeListener(
613         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), vetoListener);
614     fullp->addVetoableChangeListener(
615         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), vetoListener);
616     fullp->removeVetoableChangeListener(
617         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), vetoListener);
618     try {
619         fullp->addVetoableChangeListener(
620             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")),
621             vetoListener);
622         CPPUNIT_FAIL("exception expected");
623     } catch (css::beans::UnknownPropertyException &) {}
624     try {
625         fullp->removeVetoableChangeListener(
626             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")),
627             vetoListener);
628         CPPUNIT_FAIL("exception expected");
629     } catch (css::beans::UnknownPropertyException &) {}
630     fullp->addVetoableChangeListener(
631         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")), vetoListener);
632     fullp->removeVetoableChangeListener(
633         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")), vetoListener);
634     try {
635         fullp->addVetoableChangeListener(
636             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fifth")),
637             vetoListener);
638         CPPUNIT_FAIL("exception expected");
639     } catch (css::beans::UnknownPropertyException &) {}
640     try {
641         fullp->removeVetoableChangeListener(
642             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fifth")),
643             vetoListener);
644         CPPUNIT_FAIL("exception expected");
645     } catch (css::beans::UnknownPropertyException &) {}
646 }
647 
648 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
649 
650 }
651 
652 CPPUNIT_PLUGIN_IMPLEMENT();
653