2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package test
.java_remote
;
21 import com
.sun
.star
.bridge
.XInstanceProvider
;
22 import com
.sun
.star
.uno
.Any
;
23 import com
.sun
.star
.uno
.Type
;
24 import com
.sun
.star
.uno
.UnoRuntime
;
25 import com
.sun
.star
.uno
.XComponentContext
;
26 import complexlib
.ComplexTestCase
;
27 import test
.lib
.TestBed
;
29 public final class PolyStructTest
extends ComplexTestCase
{
30 public String
[] getTestMethodNames() {
31 return new String
[] { "test" };
34 public void test() throws Exception
{
37 new TestBed().execute(new Provider(), false, Client
.class, 0));
40 public static final class Client
extends TestBed
.Client
{
41 public static void main(String
[] args
) {
42 new Client().execute();
45 protected boolean run(XComponentContext context
) throws Throwable
{
46 TestTransport t
= UnoRuntime
.queryInterface(
47 TestTransport
.class, getBridge(context
).getInstance(""));
50 Boolean
.FALSE
, t
.transportBoolean(new TestPolyStruct()).member
);
53 t
.transportBoolean(new TestPolyStruct(Boolean
.FALSE
)).member
);
56 t
.transportBoolean(new TestPolyStruct(Boolean
.TRUE
)).member
);
60 t
.transportByte(new TestPolyStruct()).member
);
62 new Byte(Byte
.MIN_VALUE
),
64 new TestPolyStruct(new Byte(Byte
.MIN_VALUE
))).member
);
66 new Byte(Byte
.MAX_VALUE
),
68 new TestPolyStruct(new Byte(Byte
.MAX_VALUE
))).member
);
72 t
.transportShort(new TestPolyStruct()).member
);
74 new Short(Short
.MIN_VALUE
),
76 new TestPolyStruct(new Short(Short
.MIN_VALUE
))).member
);
78 new Short(Short
.MAX_VALUE
),
80 new TestPolyStruct(new Short(Short
.MAX_VALUE
))).member
);
83 new Integer(0), t
.transportLong(new TestPolyStruct()).member
);
85 new Integer(Integer
.MIN_VALUE
),
87 new TestPolyStruct(new Integer(Integer
.MIN_VALUE
))).member
);
89 new Integer(Integer
.MAX_VALUE
),
91 new TestPolyStruct(new Integer(Integer
.MAX_VALUE
))).member
);
94 new Long(0L), t
.transportHyper(new TestPolyStruct()).member
);
96 new Long(Long
.MIN_VALUE
),
98 new TestPolyStruct(new Long(Long
.MIN_VALUE
))).member
);
100 new Long(Long
.MAX_VALUE
),
102 new TestPolyStruct(new Long(Long
.MAX_VALUE
))).member
);
105 new Float(0.0f
), t
.transportFloat(new TestPolyStruct()).member
);
107 new Float(Float
.MIN_VALUE
),
109 new TestPolyStruct(new Float(Float
.MIN_VALUE
))).member
);
111 new Float(Float
.MAX_VALUE
),
113 new TestPolyStruct(new Float(Float
.MAX_VALUE
))).member
);
117 t
.transportDouble(new TestPolyStruct()).member
);
119 new Double(Double
.MIN_VALUE
),
121 new TestPolyStruct(new Double(Double
.MIN_VALUE
))).member
);
123 new Double(Double
.MAX_VALUE
),
125 new TestPolyStruct(new Double(Double
.MAX_VALUE
))).member
);
128 new Character(Character
.MIN_VALUE
),
129 t
.transportChar(new TestPolyStruct()).member
);
131 new Character(Character
.MIN_VALUE
),
134 new Character(Character
.MIN_VALUE
))).member
);
136 new Character(Character
.MAX_VALUE
),
139 new Character(Character
.MAX_VALUE
))).member
);
141 assertEquals("", t
.transportString(new TestPolyStruct()).member
);
143 "ABC", t
.transportString(new TestPolyStruct("ABC")).member
);
146 Type
.VOID
, t
.transportType(new TestPolyStruct()).member
);
149 "[]com.sun.star.lib.uno.bridges.javaremote.TestPolyStruct"
154 "[]com.sun.star.lib.uno.bridges.javaremote."
155 + "TestPolyStruct<long>"))).member
);
157 assertEquals(null, t
.transportAny(new TestPolyStruct()).member
);
159 Any
.VOID
, t
.transportAny(new TestPolyStruct(Any
.VOID
)).member
);
160 assertEquals(null, t
.transportAny(new TestPolyStruct(null)).member
);
162 new Any(Type
.UNSIGNED_LONG
, new Integer(5)),
165 new Any(Type
.UNSIGNED_LONG
, new Integer(5)))).member
);
168 TestEnum
.VALUE1
, t
.transportEnum(new TestPolyStruct()).member
);
171 t
.transportEnum(new TestPolyStruct(TestEnum
.VALUE1
)).member
);
174 t
.transportEnum(new TestPolyStruct(TestEnum
.VALUE2
)).member
);
179 private void assertEquals(Object expected
, Object actual
) {
180 if (!(expected
== null ? actual
== null : expected
.equals(actual
)))
182 new RuntimeException(
183 "failed; expected " + expected
+ ", got " + actual
).
189 private boolean success
= true;
192 private static final class Provider
implements XInstanceProvider
{
193 public Object
getInstance(String instanceName
) {
194 return new TestTransport() {
195 public TestPolyStruct
transportBoolean(TestPolyStruct s
) {
199 public TestPolyStruct
transportByte(TestPolyStruct s
) {
203 public TestPolyStruct
transportShort(TestPolyStruct s
) {
207 public TestPolyStruct
transportLong(TestPolyStruct s
) {
211 public TestPolyStruct
transportHyper(TestPolyStruct s
) {
215 public TestPolyStruct
transportFloat(TestPolyStruct s
) {
219 public TestPolyStruct
transportDouble(TestPolyStruct s
) {
223 public TestPolyStruct
transportChar(TestPolyStruct s
) {
227 public TestPolyStruct
transportString(TestPolyStruct s
) {
231 public TestPolyStruct
transportType(TestPolyStruct s
) {
235 public TestPolyStruct
transportAny(TestPolyStruct s
) {
239 public TestPolyStruct
transportEnum(TestPolyStruct s
) {