1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: importer.py,v $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
35 from com
.sun
.star
.lang
import EventObject
,IllegalArgumentException
,typeOfIllegalArgumentException
36 from test
.testtools
.bridgetest
.TestEnum
import TWO
37 from com
.sun
.star
.uno
.TypeClass
import UNSIGNED_LONG
,EXCEPTION
38 class ImporterTestCase(unittest
.TestCase
):
39 def __init__(self
,method
,ctx
):
40 unittest
.TestCase
.__init
__(self
,method
)
44 self
.tobj
= self
.ctx
.ServiceManager
.createInstanceWithContext( \
45 "com.sun.star.test.bridge.CppTestObject",self
.ctx
)
47 def testStandard( self
):
48 self
.failUnless( IllegalArgumentException
!= None, "none-test" )
49 self
.failUnlessRaises( IllegalArgumentException
, self
.tobj
.raiseException
, 1,"foo",self
.tobj
)
51 self
.failUnless( TWO
== uno
.Enum( "test.testtools.bridgetest.TestEnum","TWO"), "enum" )
52 self
.failUnless( UNSIGNED_LONG
== uno
.Enum( "com.sun.star.uno.TypeClass", "UNSIGNED_LONG" ) )
53 self
.failUnless( typeOfIllegalArgumentException
==
54 uno
.Type( "com.sun.star.lang.IllegalArgumentException", EXCEPTION
) )
56 # should not throw an exception
59 e
= EventObject( self
.ctx
)
62 def testDynamicComponentRegistration( self
):
63 ctx
= uno
.getComponentContext()
65 not ("com.sun.star.connection.Acceptor" in ctx
.ServiceManager
.getAvailableServiceNames()),
66 "precondition for dynamic component registration test is not fulfilled" )
68 not ("com.sun.star.connection.Connector" in ctx
.ServiceManager
.getAvailableServiceNames()),
69 "precondition for dynamic component registration test is not fulfilled" )
70 unohelper
.addComponentsToContext(
71 ctx
, ctx
, ("acceptor.uno","connector.uno"), "com.sun.star.loader.SharedLibrary" )
73 ("com.sun.star.connection.Acceptor" in ctx
.ServiceManager
.getAvailableServiceNames()) )
75 ("com.sun.star.connection.Connector" in ctx
.ServiceManager
.getAvailableServiceNames()))
78 suite
= unittest
.TestSuite()
79 suite
.addTest(ImporterTestCase("testStandard",ctx
))
80 suite
.addTest(ImporterTestCase("testDynamicComponentRegistration",ctx
))