Add test for abstract exception (marked @Ignore) and add test for List type
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1039012 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1b68f70a40
commit
f1c1be59f2
11 changed files with 123 additions and 11 deletions
|
@ -24,8 +24,10 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
|||
/**
|
||||
* The abstract exception class
|
||||
*/
|
||||
@XmlJavaTypeAdapter(TestAdapter.class)
|
||||
@XmlJavaTypeAdapter(ExceptionAdapter.class)
|
||||
public abstract class AbstractException extends Exception {
|
||||
|
||||
public abstract String getGreeting();
|
||||
|
||||
public abstract void setGreeting(String greeting);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package jtest;
|
||||
|
||||
/**
|
||||
* The test abstract exception class on-the-wire representation
|
||||
*/
|
||||
public class AbstractExceptionImpl {
|
||||
|
||||
public String className;
|
||||
|
||||
public String testGreeting;
|
||||
|
||||
}
|
|
@ -37,4 +37,8 @@ public class ConcreteException extends AbstractException {
|
|||
public String getGreeting() {
|
||||
return greeting;
|
||||
}
|
||||
|
||||
public void setGreeting(String greeting) {
|
||||
this.greeting = greeting;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package jtest;
|
||||
|
||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||
|
||||
/**
|
||||
* The test XML exception adapter class
|
||||
*/
|
||||
public class ExceptionAdapter extends XmlAdapter<AbstractExceptionImpl, AbstractException> {
|
||||
public AbstractException unmarshal(AbstractExceptionImpl ai) throws Exception {
|
||||
AbstractException a = (AbstractException)this.getClass().getClassLoader().loadClass(ai.className).newInstance();
|
||||
a.setGreeting(ai.testGreeting);
|
||||
return a;
|
||||
}
|
||||
public AbstractExceptionImpl marshal(AbstractException v) throws Exception {
|
||||
AbstractExceptionImpl ai = new AbstractExceptionImpl();
|
||||
ai.className = v.getClass().getName();
|
||||
ai.testGreeting = "Hi there!";
|
||||
return ai;
|
||||
}
|
||||
}
|
|
@ -26,7 +26,7 @@ public interface TestClient {
|
|||
|
||||
void runAbstractTypeTest();
|
||||
|
||||
/*
|
||||
void runAbstractExceptionTest();
|
||||
*/
|
||||
|
||||
void runListTypeTest();
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
package jtest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.osoa.sca.annotations.Remotable;
|
||||
|
||||
import jtest.AbstractException;
|
||||
|
@ -32,7 +34,7 @@ public interface TestService {
|
|||
|
||||
void sendAbstract(TestAbstract data);
|
||||
|
||||
/*
|
||||
void throwAbstract() throws AbstractException;
|
||||
*/
|
||||
|
||||
void sendList(List<String> data);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package jtest;
|
||||
|
||||
import java.util.List;
|
||||
import javax.jws.WebMethod;
|
||||
import javax.jws.WebService;
|
||||
|
||||
|
@ -26,4 +27,10 @@ public interface TestWebService {
|
|||
|
||||
@WebMethod
|
||||
void sendAbstract(TestAbstract testData);
|
||||
|
||||
@WebMethod
|
||||
void throwAbstract() throws AbstractException;
|
||||
|
||||
@WebMethod
|
||||
void sendList(List<String> data);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package jtest.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import org.osoa.sca.annotations.Reference;
|
||||
import org.osoa.sca.annotations.Service;
|
||||
|
||||
|
@ -48,7 +49,6 @@ public class TestClientImpl implements TestClient {
|
|||
ref.sendAbstract(data2);
|
||||
}
|
||||
|
||||
/*
|
||||
public void runAbstractExceptionTest() {
|
||||
try {
|
||||
ref.throwAbstract();
|
||||
|
@ -57,5 +57,11 @@ public class TestClientImpl implements TestClient {
|
|||
System.out.println(e.getGreeting());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public void runListTypeTest() {
|
||||
ArrayList<String> data = new ArrayList<String>();
|
||||
data.add("Hello,");
|
||||
data.add("World!");
|
||||
ref.sendList(data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
package jtest.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.osoa.sca.annotations.Service;
|
||||
|
||||
import jtest.AbstractException;
|
||||
|
@ -39,9 +41,11 @@ public class TestServiceImpl implements TestService {
|
|||
System.out.println(data.getGreeting());
|
||||
}
|
||||
|
||||
/*
|
||||
public void throwAbstract() throws AbstractException {
|
||||
throw new ConcreteException();
|
||||
}
|
||||
*/
|
||||
|
||||
public void sendList(List<String> data) {
|
||||
System.out.println(data.get(0) + " " + data.get(1));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,11 @@
|
|||
*/
|
||||
package jtest.impl;
|
||||
|
||||
import java.util.List;
|
||||
import javax.jws.WebService;
|
||||
|
||||
import jtest.AbstractException;
|
||||
import jtest.ConcreteException;
|
||||
import jtest.TestAbstract;
|
||||
import jtest.TestWebService;
|
||||
|
||||
|
@ -29,4 +32,12 @@ public class TestWebServiceImpl implements TestWebService {
|
|||
public void sendAbstract(TestAbstract testData) {
|
||||
System.out.println(testData.getGreeting());
|
||||
}
|
||||
|
||||
public void throwAbstract() throws AbstractException {
|
||||
throw new ConcreteException();
|
||||
}
|
||||
|
||||
public void sendList(List<String> data) {
|
||||
System.out.println(data.get(0) + " " + data.get(1));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,15 +47,21 @@ public class DatatypesTestCase {
|
|||
testClient.runAbstractTypeTest();
|
||||
}
|
||||
|
||||
/*
|
||||
@Test
|
||||
@Ignore
|
||||
public void runAbstractExceptionTest() {
|
||||
SCAClient client = (SCAClient)node;
|
||||
TestClient testClient = client.getService(TestClient.class, "TestClient");
|
||||
testClient.runAbstractExceptionTest();
|
||||
}
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void runListTypeTest() {
|
||||
SCAClient client = (SCAClient)node;
|
||||
TestClient testClient = client.getService(TestClient.class, "TestClient");
|
||||
testClient.runListTypeTest();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownAfterClass() throws Exception {
|
||||
if (node != null) {
|
||||
|
|
Loading…
Add table
Reference in a new issue