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: _XCloneable.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import lib
.MultiMethodTest
;
35 import com
.sun
.star
.lang
.XServiceInfo
;
36 import com
.sun
.star
.lang
.XTypeProvider
;
37 import com
.sun
.star
.uno
.UnoRuntime
;
38 import com
.sun
.star
.uno
.XInterface
;
39 import com
.sun
.star
.util
.XCloneable
;
42 * Testing <code>com.sun.star.util.XCloneable</code>
45 * <li><code> createClone()</code></li>
47 * @see com.sun.star.util.XCloneable
49 public class _XCloneable
extends MultiMethodTest
{
51 // oObj filled by MultiMethodTest
52 public XCloneable oObj
= null ;
53 protected XCloneable clone
= null;
56 * calls the method. <p>
57 * Has <b>OK</b> status if no exception has occured. <p>
59 public void _createClone() {
60 boolean result
= true;
61 clone
= oObj
.createClone();
63 //check if the implementaionname equals
64 result
&= checkImplementationName(oObj
,clone
);
66 //check ImplementationID
67 result
&= checkImplementationID(oObj
, clone
);
69 tRes
.tested("createClone()", result
) ;
72 protected byte[] getImplementationID(XInterface ifc
) {
73 byte[] res
= new byte[0];
74 XTypeProvider provider
= (XTypeProvider
)
75 UnoRuntime
.queryInterface(XTypeProvider
.class, ifc
);
76 if (provider
!= null) {
77 res
= provider
.getImplementationId();
82 protected boolean checkImplementationID(XInterface org
, XInterface clone
) {
83 boolean res
= getImplementationID(org
).equals(
84 getImplementationID(clone
));
85 if (res
&& getImplementationID(org
).length
> 0) {
86 log
.println("ImplementationID equals the clone has the same id as the original Object");
87 log
.println("------------------------------------------------------------------------");
92 protected String
getImplementationName(XInterface ifc
) {
94 XServiceInfo info
= (XServiceInfo
)
95 UnoRuntime
.queryInterface(XServiceInfo
.class, ifc
);
97 res
= info
.getImplementationName();
102 protected boolean checkImplementationName(XInterface org
, XInterface clone
) {
103 boolean res
= getImplementationName(org
).equals(
104 getImplementationName(clone
));
106 log
.println("ImplementationName differs: ");
107 log
.println("Expected: "+getImplementationName(org
));
108 log
.println("Gained: "+getImplementationName(clone
));
109 log
.println("----------------------------------------");
114 } // finish class _XCloneable