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 testtools.servicetests;
25 
26 import com.sun.star.lang.NoSupportException;
27 import com.sun.star.lang.XServiceInfo;
28 import com.sun.star.lang.XSingleComponentFactory;
29 /*import com.sun.star.uno.OptionalPropertyException;*/
30 /*import com.sun.star.uno.VoidPropertyException;*/
31 import com.sun.star.uno.XComponentContext;
32 
33 public final class TestService implements XServiceInfo, XSingleComponentFactory
34 {
getImplementationName()35     public String getImplementationName() {
36         return getClass().getName();
37     }
38 
supportsService(String serviceName)39     public boolean supportsService(String serviceName) {
40         return serviceName.equals(SERVICE_NAME);
41     }
42 
getSupportedServiceNames()43     public String[] getSupportedServiceNames() {
44         return new String[] { SERVICE_NAME };
45     }
46 
createInstanceWithContext(XComponentContext context)47     public Object createInstanceWithContext(XComponentContext context)
48         throws com.sun.star.uno.Exception
49     {
50         return new Service();
51     }
52 
createInstanceWithArgumentsAndContext( Object[] arguments, XComponentContext context)53     public Object createInstanceWithArgumentsAndContext(
54         Object[] arguments, XComponentContext context)
55         throws com.sun.star.uno.Exception
56     {
57         throw new NoSupportException(
58             "createInstanceWithArgumentsAndContext", this);
59     }
60 
61     private static final class Service implements TestService2, XTestService3 {
fn1()62         public int fn1() {
63             return 1;
64         }
65 
getProp1()66         public int getProp1() {
67             return prop1;
68         }
69 
setProp1(int value)70         public void setProp1(int value) {
71             prop1 = value;
72         }
73 
getProp2()74         public int getProp2() {
75             return 2;
76         }
77 
78         /*public int getProp3Void() throws VoidPropertyException {
79             throw new VoidPropertyException("Prop3Void", this);
80         }*/
81 
getProp3Long()82         public int getProp3Long() /*throws VoidPropertyException*/ {
83             return 3;
84         }
85 
86         /*public int getProp4None() throws OptionalPropertyException {
87             throw new OptionalPropertyException("Prop4None", this);
88         }*/
89 
getProp4Long()90         public int getProp4Long() /*throws OptionalPropertyException*/ {
91             return 4;
92         }
93 
94         /*public int getProp5None()
95             throws OptionalPropertyException, VoidPropertyException
96         {
97             throw new OptionalPropertyException("Prop4None", this);
98         }*/
99 
100         /*public int getProp5Void()
101             throws OptionalPropertyException, VoidPropertyException
102         {
103             throw new VoidPropertyException("Prop4None", this);
104         }*/
105 
getProp5Long()106         public int getProp5Long()
107             /*throws OptionalPropertyException, VoidPropertyException*/
108         {
109             return 5;
110         }
111 
getProp6()112         public int getProp6() /*throws VoidPropertyException*/ {
113             /*if (prop6 == null) {
114                 throw new VoidPropertyException("Prop6", this);
115             } else {*/
116                 return prop6.intValue();
117             /*}*/
118         }
119 
setProp6(int value)120         public void setProp6(int value) {
121             prop6 = new Integer(value);
122         }
123 
124         /*public void clearProp6() {
125             prop6 = null;
126         }*/
127 
128         /*public int getProp7None()
129             throws OptionalPropertyException, VoidPropertyException
130         {
131             throw new OptionalPropertyException("Prop7None", this);
132         }*/
133 
134         /*public void setProp7None(int value) throws OptionalPropertyException {
135             throw new OptionalPropertyException("Prop7None", this);
136         }*/
137 
138         /*public void clearProp7None() throws OptionalPropertyException {
139             throw new OptionalPropertyException("Prop7None", this);
140         }*/
141 
getProp7()142         public int getProp7()
143             /*throws OptionalPropertyException, VoidPropertyException*/
144         {
145             /*if (prop7 == null) {
146                 throw new VoidPropertyException("Prop7", this);
147             } else {*/
148                 return prop7.intValue();
149             /*}*/
150         }
151 
setProp7(int value)152         public void setProp7(int value) /*throws OptionalPropertyException*/ {
153             prop7 = new Integer(value);
154         }
155 
156         /*public void clearProp7() throws OptionalPropertyException {
157             prop7 = null;
158         }*/
159 
160         /*public int getProp8None() throws OptionalPropertyException {
161             throw new OptionalPropertyException("Prop8None", this);
162         }*/
163 
164         /*public void setProp8None(int value) throws OptionalPropertyException {
165             throw new OptionalPropertyException("Prop8None", this);
166         }*/
167 
getProp8Long()168         public int getProp8Long() /*throws OptionalPropertyException*/ {
169             return prop8;
170         }
171 
setProp8Long(int value)172         public void setProp8Long(int value) /*throws OptionalPropertyException*/
173         {
174             prop8 = value;
175         }
176 
fn2()177         public int fn2() {
178             return 2;
179         }
180 
fn3()181         public int fn3() {
182             return 3;
183         }
184 
185         private int prop1 = 1;
186         private Integer prop6 = new Integer(6);
187         private Integer prop7 = new Integer(7);
188         private int prop8 = 8;
189     }
190 
191     private static final String SERVICE_NAME
192     = "testtools.servicetests.TestService2";
193 }
194