xref: /aoo42x/main/stoc/test/testproxyfac.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_stoc.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "sal/main.h"
32*cdf0e10cSrcweir #include "osl/diagnose.h"
33*cdf0e10cSrcweir #include "rtl/alloc.h"
34*cdf0e10cSrcweir #include "uno/environment.hxx"
35*cdf0e10cSrcweir #include "cppuhelper/servicefactory.hxx"
36*cdf0e10cSrcweir #include "cppuhelper/implbase1.hxx"
37*cdf0e10cSrcweir #include "cppuhelper/implbase3.hxx"
38*cdf0e10cSrcweir #include "com/sun/star/uno/XCurrentContext.hpp"
39*cdf0e10cSrcweir #include "com/sun/star/lang/DisposedException.hpp"
40*cdf0e10cSrcweir #include "com/sun/star/lang/XComponent.hpp"
41*cdf0e10cSrcweir #include "com/sun/star/lang/XServiceInfo.hpp"
42*cdf0e10cSrcweir #include "com/sun/star/registry/XSimpleRegistry.hpp"
43*cdf0e10cSrcweir #include "com/sun/star/registry/XImplementationRegistration.hpp"
44*cdf0e10cSrcweir #include "com/sun/star/beans/XPropertySet.hpp"
45*cdf0e10cSrcweir #include "com/sun/star/reflection/XProxyFactory.hpp"
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir #include <stdio.h>
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir using namespace ::rtl;
51*cdf0e10cSrcweir using namespace ::osl;
52*cdf0e10cSrcweir using namespace ::cppu;
53*cdf0e10cSrcweir using namespace ::com::sun::star;
54*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir typedef WeakImplHelper3< lang::XServiceInfo,
58*cdf0e10cSrcweir                          XCurrentContext,
59*cdf0e10cSrcweir                          reflection::XProxyFactory > t_impl;
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir //==============================================================================
62*cdf0e10cSrcweir class TargetObject : public t_impl
63*cdf0e10cSrcweir {
64*cdf0e10cSrcweir public:
65*cdf0e10cSrcweir     static int s_obj;
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir 	virtual ~TargetObject() {
68*cdf0e10cSrcweir         --s_obj;
69*cdf0e10cSrcweir         OSL_TRACE( "~TargetObject()" );
70*cdf0e10cSrcweir     }
71*cdf0e10cSrcweir     TargetObject()
72*cdf0e10cSrcweir         { ++s_obj; }
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir     Any SAL_CALL queryInterface( Type const & type )
75*cdf0e10cSrcweir         throw (RuntimeException);
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir 	// XServiceInfo
78*cdf0e10cSrcweir 	virtual OUString SAL_CALL getImplementationName() throw (RuntimeException)
79*cdf0e10cSrcweir 		{ return OUString::createFromAscii( "target" ); }
80*cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL supportsService( const OUString & /*rServiceName*/ )
81*cdf0e10cSrcweir         throw (RuntimeException)
82*cdf0e10cSrcweir 		{ return sal_False; }
83*cdf0e10cSrcweir 	virtual Sequence< OUString > SAL_CALL getSupportedServiceNames()
84*cdf0e10cSrcweir         throw (RuntimeException)
85*cdf0e10cSrcweir 		{ return Sequence< OUString >(); }
86*cdf0e10cSrcweir 	// XProxyFactory
87*cdf0e10cSrcweir     virtual Reference< XAggregation > SAL_CALL createProxy(
88*cdf0e10cSrcweir         const Reference< XInterface > & xTarget ) throw (RuntimeException)
89*cdf0e10cSrcweir 		{ return Reference< XAggregation >( xTarget, UNO_QUERY ); }
90*cdf0e10cSrcweir     // XCurrentContext
91*cdf0e10cSrcweir     virtual Any SAL_CALL getValueByName( OUString const & name )
92*cdf0e10cSrcweir         throw (RuntimeException)
93*cdf0e10cSrcweir         { return makeAny( name ); }
94*cdf0e10cSrcweir };
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir //______________________________________________________________________________
97*cdf0e10cSrcweir Any TargetObject::queryInterface( Type const & type )
98*cdf0e10cSrcweir     throw (RuntimeException)
99*cdf0e10cSrcweir {
100*cdf0e10cSrcweir     Any ret( t_impl::queryInterface( type ) );
101*cdf0e10cSrcweir     if (ret.hasValue())
102*cdf0e10cSrcweir         return ret;
103*cdf0e10cSrcweir     throw lang::DisposedException(
104*cdf0e10cSrcweir         OUString( RTL_CONSTASCII_USTRINGPARAM("my test exception") ),
105*cdf0e10cSrcweir         static_cast< OWeakObject * >(this) );
106*cdf0e10cSrcweir }
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir int TargetObject::s_obj = 0;
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir //==============================================================================
112*cdf0e10cSrcweir class TestMaster : public WeakImplHelper1< lang::XServiceInfo >
113*cdf0e10cSrcweir {
114*cdf0e10cSrcweir 	Reference< XAggregation > m_xProxyTarget;
115*cdf0e10cSrcweir     Reference<lang::XServiceInfo> m_xOtherProxyTargetBeforeSetDelegator;
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir     inline TestMaster() { ++s_obj; }
118*cdf0e10cSrcweir public:
119*cdf0e10cSrcweir     static int s_obj;
120*cdf0e10cSrcweir     static Reference< XInterface > create(
121*cdf0e10cSrcweir         Reference< reflection::XProxyFactory > const & xProxyFac );
122*cdf0e10cSrcweir     static Reference< XInterface > create(
123*cdf0e10cSrcweir         Reference< XInterface > const & xTarget,
124*cdf0e10cSrcweir         Reference< reflection::XProxyFactory > const & xProxyFac );
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir 	virtual ~TestMaster() {
127*cdf0e10cSrcweir         --s_obj;
128*cdf0e10cSrcweir         OSL_TRACE( "~TestMaster()" );
129*cdf0e10cSrcweir     }
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir     virtual Any SAL_CALL queryInterface( const Type & rType )
132*cdf0e10cSrcweir         throw (RuntimeException)
133*cdf0e10cSrcweir 	{
134*cdf0e10cSrcweir 		Any aRet(
135*cdf0e10cSrcweir             WeakImplHelper1< lang::XServiceInfo >::queryInterface( rType ) );
136*cdf0e10cSrcweir 		if (aRet.hasValue())
137*cdf0e10cSrcweir             return aRet;
138*cdf0e10cSrcweir         return m_xProxyTarget->queryAggregation( rType );
139*cdf0e10cSrcweir 	}
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 	// XServiceInfo
142*cdf0e10cSrcweir 	virtual OUString SAL_CALL getImplementationName() throw (RuntimeException)
143*cdf0e10cSrcweir 		{ return OUString::createFromAscii( "master" ); }
144*cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL supportsService( const OUString & /*rServiceName*/ )
145*cdf0e10cSrcweir         throw (RuntimeException)
146*cdf0e10cSrcweir 		{ return sal_False; }
147*cdf0e10cSrcweir 	virtual Sequence< OUString > SAL_CALL getSupportedServiceNames()
148*cdf0e10cSrcweir         throw (RuntimeException)
149*cdf0e10cSrcweir 		{ return Sequence< OUString >(); }
150*cdf0e10cSrcweir };
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir int TestMaster::s_obj = 0;
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir Reference< XInterface > TestMaster::create(
156*cdf0e10cSrcweir     Reference< XInterface > const & xTarget,
157*cdf0e10cSrcweir     Reference< reflection::XProxyFactory > const & xProxyFac )
158*cdf0e10cSrcweir {
159*cdf0e10cSrcweir     TestMaster * that = new TestMaster;
160*cdf0e10cSrcweir     Reference< XInterface > xRet( static_cast< OWeakObject * >( that ) );
161*cdf0e10cSrcweir     {
162*cdf0e10cSrcweir         Reference< XAggregation > xAgg( xProxyFac->createProxy( xTarget ) );
163*cdf0e10cSrcweir         // ownership take over
164*cdf0e10cSrcweir         that->m_xProxyTarget.set( xAgg, UNO_QUERY_THROW );
165*cdf0e10cSrcweir         that->m_xOtherProxyTargetBeforeSetDelegator.set(
166*cdf0e10cSrcweir             that->m_xProxyTarget, UNO_QUERY );
167*cdf0e10cSrcweir     }
168*cdf0e10cSrcweir     that->m_xProxyTarget->setDelegator( xRet );
169*cdf0e10cSrcweir     return xRet;
170*cdf0e10cSrcweir }
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir Reference< XInterface > TestMaster::create(
173*cdf0e10cSrcweir     Reference< reflection::XProxyFactory > const & xProxyFac )
174*cdf0e10cSrcweir {
175*cdf0e10cSrcweir     return create(
176*cdf0e10cSrcweir         static_cast< OWeakObject * >( new TargetObject ), xProxyFac );
177*cdf0e10cSrcweir }
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir static void test_proxyfac_(
181*cdf0e10cSrcweir     Reference< XInterface > const & xMaster, OUString const & test,
182*cdf0e10cSrcweir     Reference< reflection::XProxyFactory > const & /*xProxyFac*/ )
183*cdf0e10cSrcweir {
184*cdf0e10cSrcweir     (void)test;
185*cdf0e10cSrcweir     Reference< lang::XServiceInfo > xMaster_XServiceInfo(
186*cdf0e10cSrcweir         xMaster, UNO_QUERY_THROW );
187*cdf0e10cSrcweir 	OSL_ASSERT( xMaster_XServiceInfo->getImplementationName().equals( test ) );
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir     Reference< reflection::XProxyFactory > xTarget( xMaster, UNO_QUERY_THROW );
190*cdf0e10cSrcweir     Reference< XCurrentContext > xTarget_XCurrentContext(
191*cdf0e10cSrcweir         xTarget, UNO_QUERY_THROW );
192*cdf0e10cSrcweir     Reference< XCurrentContext > xMaster_XCurrentContext(
193*cdf0e10cSrcweir         xMaster, UNO_QUERY_THROW );
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir     OSL_ASSERT(
196*cdf0e10cSrcweir         xTarget_XCurrentContext->getValueByName( test ) == makeAny( test ) );
197*cdf0e10cSrcweir     OSL_ASSERT(
198*cdf0e10cSrcweir         xMaster_XCurrentContext->getValueByName( test ) == makeAny( test ) );
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir     Reference< XAggregation > xFakeAgg( xTarget->createProxy( xTarget ) );
201*cdf0e10cSrcweir     if (xFakeAgg.is())
202*cdf0e10cSrcweir     {
203*cdf0e10cSrcweir         OSL_ASSERT( xTarget == xFakeAgg );
204*cdf0e10cSrcweir         OSL_ASSERT( xMaster == xFakeAgg );
205*cdf0e10cSrcweir     }
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir     Reference< lang::XServiceInfo > xTarget_XServiceInfo(
208*cdf0e10cSrcweir         xTarget, UNO_QUERY_THROW );
209*cdf0e10cSrcweir 	OSL_ASSERT( xTarget_XServiceInfo->getImplementationName().equals( test ) );
210*cdf0e10cSrcweir     Reference< lang::XServiceInfo > xTarget_XServiceInfo2(
211*cdf0e10cSrcweir         xTarget, UNO_QUERY_THROW );
212*cdf0e10cSrcweir     OSL_ASSERT( xTarget_XServiceInfo2.get() == xTarget_XServiceInfo.get() );
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir     OSL_ASSERT( xTarget == xTarget_XCurrentContext );
215*cdf0e10cSrcweir     OSL_ASSERT( xTarget_XCurrentContext == xMaster );
216*cdf0e10cSrcweir     OSL_ASSERT(
217*cdf0e10cSrcweir         xTarget_XCurrentContext.get() == xMaster_XCurrentContext.get() );
218*cdf0e10cSrcweir     OSL_ASSERT( xTarget_XCurrentContext == xMaster );
219*cdf0e10cSrcweir     OSL_ASSERT( xTarget == xMaster );
220*cdf0e10cSrcweir     OSL_ASSERT( xTarget_XServiceInfo.get() == xMaster_XServiceInfo.get() );
221*cdf0e10cSrcweir     OSL_ASSERT( xTarget_XServiceInfo == xMaster );
222*cdf0e10cSrcweir     OSL_ASSERT( xMaster_XServiceInfo == xMaster );
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir     try
225*cdf0e10cSrcweir     {
226*cdf0e10cSrcweir         Reference< registry::XRegistryKey >(
227*cdf0e10cSrcweir             xMaster, UNO_QUERY_THROW );
228*cdf0e10cSrcweir     }
229*cdf0e10cSrcweir     catch (lang::DisposedException & exc)
230*cdf0e10cSrcweir     {
231*cdf0e10cSrcweir         if (! exc.Message.equalsAsciiL(
232*cdf0e10cSrcweir                 RTL_CONSTASCII_STRINGPARAM("my test exception") ))
233*cdf0e10cSrcweir             throw;
234*cdf0e10cSrcweir     }
235*cdf0e10cSrcweir }
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir static void test_proxyfac(
238*cdf0e10cSrcweir     Reference< XInterface > const & xMaster, OUString const & test,
239*cdf0e10cSrcweir     Reference< reflection::XProxyFactory > const & xProxyFac )
240*cdf0e10cSrcweir {
241*cdf0e10cSrcweir     test_proxyfac_( xMaster, test, xProxyFac );
242*cdf0e10cSrcweir     // proxy the proxy...
243*cdf0e10cSrcweir     Reference< XInterface > xNew( TestMaster::create( xMaster, xProxyFac ) );
244*cdf0e10cSrcweir     test_proxyfac_(
245*cdf0e10cSrcweir         xNew, OUString( RTL_CONSTASCII_USTRINGPARAM("master") ), xProxyFac );
246*cdf0e10cSrcweir }
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir SAL_IMPLEMENT_MAIN()
249*cdf0e10cSrcweir {
250*cdf0e10cSrcweir     bool success = true;
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir     Environment cpp_env;
253*cdf0e10cSrcweir     OUString cpp( RTL_CONSTASCII_USTRINGPARAM(
254*cdf0e10cSrcweir                       CPPU_CURRENT_LANGUAGE_BINDING_NAME) );
255*cdf0e10cSrcweir     uno_getEnvironment(
256*cdf0e10cSrcweir         reinterpret_cast< uno_Environment ** >( &cpp_env ),
257*cdf0e10cSrcweir         cpp.pData, 0 );
258*cdf0e10cSrcweir     OSL_ENSURE( cpp_env.is(), "### cannot get C++ uno env!" );
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir 	{
261*cdf0e10cSrcweir 		Reference< lang::XMultiServiceFactory > xMgr(
262*cdf0e10cSrcweir             createRegistryServiceFactory(
263*cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM("stoctest.rdb") ) ) );
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir 		try
266*cdf0e10cSrcweir 		{
267*cdf0e10cSrcweir 			Reference< registry::XImplementationRegistration > xImplReg(
268*cdf0e10cSrcweir 				xMgr->createInstance(
269*cdf0e10cSrcweir                     OUString(
270*cdf0e10cSrcweir                         RTL_CONSTASCII_USTRINGPARAM(
271*cdf0e10cSrcweir                             "com.sun.star.registry.ImplementationRegistration")
272*cdf0e10cSrcweir                         ) ),
273*cdf0e10cSrcweir                 UNO_QUERY );
274*cdf0e10cSrcweir 			OSL_ENSURE( xImplReg.is(), "### no impl reg!" );
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir 			OUString aLibName(
277*cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM("proxyfac.uno" SAL_DLLEXTENSION) );
278*cdf0e10cSrcweir 			xImplReg->registerImplementation(
279*cdf0e10cSrcweir 				OUString(
280*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
281*cdf0e10cSrcweir                         "com.sun.star.loader.SharedLibrary") ),
282*cdf0e10cSrcweir                 aLibName, Reference< registry::XSimpleRegistry >() );
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir 			Reference< reflection::XProxyFactory > xProxyFac(
285*cdf0e10cSrcweir                 xMgr->createInstance(
286*cdf0e10cSrcweir                     OUString::createFromAscii(
287*cdf0e10cSrcweir                         "com.sun.star.reflection.ProxyFactory") ),
288*cdf0e10cSrcweir                 UNO_QUERY_THROW );
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir             Reference< XAggregation > x(
291*cdf0e10cSrcweir                 xProxyFac->createProxy(
292*cdf0e10cSrcweir                     static_cast< OWeakObject * >( new TargetObject ) ) );
293*cdf0e10cSrcweir             // no call
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir             {
296*cdf0e10cSrcweir             Reference< XInterface > xMaster( TestMaster::create( xProxyFac ) );
297*cdf0e10cSrcweir 			test_proxyfac(
298*cdf0e10cSrcweir                 xMaster,
299*cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM("master") ),
300*cdf0e10cSrcweir                 xProxyFac );
301*cdf0e10cSrcweir             }
302*cdf0e10cSrcweir             {
303*cdf0e10cSrcweir             Reference< XInterface > xMaster( TestMaster::create( xProxyFac ) );
304*cdf0e10cSrcweir             // no call
305*cdf0e10cSrcweir             }
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir             {
308*cdf0e10cSrcweir             Reference< XInterface > xMaster( TestMaster::create( xProxyFac ) );
309*cdf0e10cSrcweir             Reference< reflection::XProxyFactory > xSlave_lives_alone(
310*cdf0e10cSrcweir                 xMaster, UNO_QUERY_THROW );
311*cdf0e10cSrcweir             xMaster.clear();
312*cdf0e10cSrcweir 			test_proxyfac(
313*cdf0e10cSrcweir                 xSlave_lives_alone,
314*cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM("master") ),
315*cdf0e10cSrcweir                 xProxyFac );
316*cdf0e10cSrcweir             uno_dumpEnvironment( stdout, cpp_env.get(), 0 );
317*cdf0e10cSrcweir             }
318*cdf0e10cSrcweir             {
319*cdf0e10cSrcweir             Reference< XInterface > xMaster( TestMaster::create( xProxyFac ) );
320*cdf0e10cSrcweir             Reference< reflection::XProxyFactory > xSlave_lives_alone(
321*cdf0e10cSrcweir                 xMaster, UNO_QUERY_THROW );
322*cdf0e10cSrcweir             // no call
323*cdf0e10cSrcweir             }
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir             test_proxyfac(
326*cdf0e10cSrcweir                 xProxyFac->createProxy(
327*cdf0e10cSrcweir                     static_cast< OWeakObject * >( new TargetObject ) ),
328*cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM("target") ),
329*cdf0e10cSrcweir                 xProxyFac );
330*cdf0e10cSrcweir             uno_dumpEnvironment( stdout, cpp_env.get(), 0 );
331*cdf0e10cSrcweir         }
332*cdf0e10cSrcweir 		catch (Exception & rExc)
333*cdf0e10cSrcweir 		{
334*cdf0e10cSrcweir             (void)rExc;
335*cdf0e10cSrcweir 			OSL_ENSURE(
336*cdf0e10cSrcweir                 ! __FILE__,
337*cdf0e10cSrcweir                 OUStringToOString(
338*cdf0e10cSrcweir                     rExc.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
339*cdf0e10cSrcweir             success = false;
340*cdf0e10cSrcweir 		}
341*cdf0e10cSrcweir 
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir 		Reference< lang::XComponent > xComp;
344*cdf0e10cSrcweir         Reference< beans::XPropertySet >(
345*cdf0e10cSrcweir             xMgr, UNO_QUERY_THROW )->getPropertyValue(
346*cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) )
347*cdf0e10cSrcweir                     >>= xComp;
348*cdf0e10cSrcweir         xComp->dispose();
349*cdf0e10cSrcweir 	}
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir     if (TestMaster::s_obj != 0)
352*cdf0e10cSrcweir         fprintf( stderr, "TestMaster objects: %d\n", TestMaster::s_obj );
353*cdf0e10cSrcweir     if (TargetObject::s_obj != 0)
354*cdf0e10cSrcweir         fprintf( stderr, "TargetObject objects: %d\n", TargetObject::s_obj );
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir     uno_dumpEnvironment( stdout, cpp_env.get(), 0 );
357*cdf0e10cSrcweir     void ** ppInterfaces;
358*cdf0e10cSrcweir     sal_Int32 len;
359*cdf0e10cSrcweir     uno_ExtEnvironment * env = cpp_env.get()->pExtEnv;
360*cdf0e10cSrcweir     (*env->getRegisteredInterfaces)(
361*cdf0e10cSrcweir         env, &ppInterfaces, &len, rtl_allocateMemory );
362*cdf0e10cSrcweir     if (len != 0)
363*cdf0e10cSrcweir         fprintf( stderr, "%d registered C++ interfaces left!\n", len );
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir     success &= (TestMaster::s_obj == 0 &&
366*cdf0e10cSrcweir                 TargetObject::s_obj == 0 &&
367*cdf0e10cSrcweir                 len == 0);
368*cdf0e10cSrcweir     if (success)
369*cdf0e10cSrcweir     {
370*cdf0e10cSrcweir         printf( "testproxyfac succeeded.\n" );
371*cdf0e10cSrcweir         return 0;
372*cdf0e10cSrcweir     }
373*cdf0e10cSrcweir     else
374*cdf0e10cSrcweir     {
375*cdf0e10cSrcweir         fprintf( stderr, "testproxyfac failed!\n" );
376*cdf0e10cSrcweir         return 1;
377*cdf0e10cSrcweir     }
378*cdf0e10cSrcweir }
379*cdf0e10cSrcweir 
380