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 ************************************************************************/
30 import lib
.MultiMethodTest
;
32 import com
.sun
.star
.lang
.XServiceInfo
;
33 import com
.sun
.star
.lang
.XTypeProvider
;
34 import com
.sun
.star
.uno
.UnoRuntime
;
35 import com
.sun
.star
.uno
.XInterface
;
36 import com
.sun
.star
.util
.XCloneable
;
39 * Testing <code>com.sun.star.util.XCloneable</code>
42 * <li><code> createClone()</code></li>
44 * @see com.sun.star.util.XCloneable
46 public class _XCloneable
extends MultiMethodTest
{
48 // oObj filled by MultiMethodTest
49 public XCloneable oObj
= null ;
50 protected XCloneable clone
= null;
53 * calls the method. <p>
54 * Has <b>OK</b> status if no exception has occurred. <p>
56 public void _createClone() {
57 boolean result
= true;
58 clone
= oObj
.createClone();
60 //check if the implementaionname equals
61 result
&= checkImplementationName(oObj
,clone
);
63 //check ImplementationID
64 result
&= checkImplementationID(oObj
, clone
);
66 tRes
.tested("createClone()", result
) ;
69 protected byte[] getImplementationID(XInterface ifc
) {
70 byte[] res
= new byte[0];
71 XTypeProvider provider
= (XTypeProvider
)
72 UnoRuntime
.queryInterface(XTypeProvider
.class, ifc
);
73 if (provider
!= null) {
74 res
= provider
.getImplementationId();
79 protected boolean checkImplementationID(XInterface org
, XInterface clone
) {
80 boolean res
= getImplementationID(org
).equals(
81 getImplementationID(clone
));
82 if (res
&& getImplementationID(org
).length
> 0) {
83 log
.println("ImplementationID equals the clone has the same id as the original Object");
84 log
.println("------------------------------------------------------------------------");
89 protected String
getImplementationName(XInterface ifc
) {
91 XServiceInfo info
= (XServiceInfo
)
92 UnoRuntime
.queryInterface(XServiceInfo
.class, ifc
);
94 res
= info
.getImplementationName();
99 protected boolean checkImplementationName(XInterface org
, XInterface clone
) {
100 boolean res
= getImplementationName(org
).equals(
101 getImplementationName(clone
));
103 log
.println("ImplementationName differs: ");
104 log
.println("Expected: "+getImplementationName(org
));
105 log
.println("Gained: "+getImplementationName(clone
));
106 log
.println("----------------------------------------");
111 } // finish class _XCloneable