1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package test.codemaker.javamaker.java15; 25 26 import com.sun.star.lang.XMultiComponentFactory; 27 import com.sun.star.uno.DeploymentException; 28 import com.sun.star.uno.XComponentContext; 29 import complexlib.ComplexTestCase; 30 31 public final class Test extends ComplexTestCase { getTestMethodNames()32 public String[] getTestMethodNames() { 33 return new String[] { 34 "testPlainPolyStruct", "testBooleanPolyStruct", "testStruct", 35 "testService" }; 36 } 37 testPlainPolyStruct()38 public void testPlainPolyStruct() { 39 PolyStruct s = new PolyStruct(); 40 assure(s.member1 == null); 41 assure(s.member2 == 0); 42 s = new PolyStruct("ABC", 5); 43 assure(s.member1.equals("ABC")); 44 assure(s.member2 == 5); 45 } 46 testBooleanPolyStruct()47 public void testBooleanPolyStruct() { 48 PolyStruct<Boolean,Object> s = new PolyStruct<Boolean,Object>(); 49 assure(s.member1 == null); 50 assure(s.member2 == 0); 51 s = new PolyStruct<Boolean,Object>(true, 5); 52 assure(s.member1 == true); 53 assure(s.member2 == 5); 54 } 55 testStruct()56 public void testStruct() { 57 Struct s = new Struct(); 58 assure(s.member.member1 == null); 59 assure(s.member.member2 == 0); 60 s = new Struct( 61 new PolyStruct<PolyStruct<boolean[], Object>, Integer>( 62 new PolyStruct<boolean[], Object>(new boolean[] { true }, 3), 63 4)); 64 assure(s.member.member1.member1.length == 1); 65 assure(s.member.member1.member1[0] == true); 66 assure(s.member.member1.member2 == 3); 67 assure(s.member.member2 == 4); 68 } 69 testService()70 public void testService() { 71 XComponentContext context = new XComponentContext() { 72 public Object getValueByName(String name) { 73 return null; 74 } 75 76 public XMultiComponentFactory getServiceManager() { 77 return null; 78 } 79 }; 80 try { 81 Service.create(context); 82 failed(); 83 } catch (DeploymentException e) {} 84 try { 85 Service.create( 86 context, false, (byte) 1, (short) 2, Integer.valueOf(4)); 87 failed(); 88 } catch (DeploymentException e) {} 89 } 90 91 private static final class Ifc implements XIfc { f1(PolyStruct<Integer, Integer> arg)92 public void f1(PolyStruct<Integer, Integer> arg) {} 93 f2(PolyStruct<Object, Object> arg)94 public void f2(PolyStruct<Object, Object> arg) {} 95 } 96 } 97