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