1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 # Copyright 2000, 2010 Oracle and/or its affiliates.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # This file is part of OpenOffice.org.
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.
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).
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.
26 #*************************************************************************
31 from com
.sun
.star
.lang
import EventObject
,IllegalArgumentException
,typeOfIllegalArgumentException
32 from test
.testtools
.bridgetest
.TestEnum
import TWO
33 from com
.sun
.star
.uno
.TypeClass
import UNSIGNED_LONG
,EXCEPTION
34 class ImporterTestCase(unittest
.TestCase
):
35 def __init__(self
,method
,ctx
):
36 unittest
.TestCase
.__init
__(self
,method
)
40 self
.tobj
= self
.ctx
.ServiceManager
.createInstanceWithContext( \
41 "com.sun.star.test.bridge.CppTestObject",self
.ctx
)
43 def testStandard( self
):
44 self
.failUnless( IllegalArgumentException
!= None, "none-test" )
45 self
.failUnlessRaises( IllegalArgumentException
, self
.tobj
.raiseException
, 1,"foo",self
.tobj
)
47 self
.failUnless( TWO
== uno
.Enum( "test.testtools.bridgetest.TestEnum","TWO"), "enum" )
48 self
.failUnless( UNSIGNED_LONG
== uno
.Enum( "com.sun.star.uno.TypeClass", "UNSIGNED_LONG" ) )
49 self
.failUnless( typeOfIllegalArgumentException
==
50 uno
.Type( "com.sun.star.lang.IllegalArgumentException", EXCEPTION
) )
52 # should not throw an exception
55 e
= EventObject( self
.ctx
)
58 def testDynamicComponentRegistration( self
):
59 ctx
= uno
.getComponentContext()
61 not ("com.sun.star.connection.Acceptor" in ctx
.ServiceManager
.getAvailableServiceNames()),
62 "precondition for dynamic component registration test is not fulfilled" )
64 not ("com.sun.star.connection.Connector" in ctx
.ServiceManager
.getAvailableServiceNames()),
65 "precondition for dynamic component registration test is not fulfilled" )
66 unohelper
.addComponentsToContext(
67 ctx
, ctx
, ("acceptor.uno","connector.uno"), "com.sun.star.loader.SharedLibrary" )
69 ("com.sun.star.connection.Acceptor" in ctx
.ServiceManager
.getAvailableServiceNames()) )
71 ("com.sun.star.connection.Connector" in ctx
.ServiceManager
.getAvailableServiceNames()))
74 suite
= unittest
.TestSuite()
75 suite
.addTest(ImporterTestCase("testStandard",ctx
))
76 suite
.addTest(ImporterTestCase("testDynamicComponentRegistration",ctx
))