ChoiceServiceTestCasepublic class ChoiceServiceTestCase extends TestCase
Constructors Summary |
---|
public ChoiceServiceTestCase(String name)
super(name);
|
Methods Summary |
---|
private void | deployServer()
final String INPUT_FILE = "server-deploy.wsdd";
InputStream is = getClass().getResourceAsStream(INPUT_FILE);
if (is == null) {
// try current directory
try {
is = new FileInputStream(INPUT_FILE);
} catch (FileNotFoundException e) {
is = null;
}
}
assertNotNull("Unable to find " + INPUT_FILE + ". Make sure it is on the classpath or in the current directory.", is);
AdminClient admin = new AdminClient();
try {
Options opts = new Options( null );
opts.setDefaultURL("http://localhost:8080/axis/services/AdminService");
admin.process(opts, is);
} catch (Exception e) {
assertTrue("Unable to deploy " + INPUT_FILE + ". ERROR: " + e, false);
}
| public void | testChoiceSerialization()
ChoiceServiceSoap binding;
try {
ChoiceServiceLocator locator = new ChoiceServiceLocator();
binding = locator.getChoiceServiceSoap();
deployServer();
}
catch (javax.xml.rpc.ServiceException jre) {
throw new AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
}
catch (Exception e) {
throw new AssertionFailedError("Binding initialization Exception caught: " + e);
}
assertTrue("binding is null", binding != null);
FaultPropertyType fp1;
Record1 r1;
Record2 r2;
// serialize f1
FaultType f1 = new FaultType();
f1.setDescription("foo");
f1.setCommand("bar");
fp1 = new FaultPropertyType();
fp1.setFault1(f1);
r1 = new Record1();
r1.setElem(fp1);
r2 = binding.get(r1);
assertTrue(r2 != null);
// serialize f2
StagingFaultType f2 = new StagingFaultType();
f2.setDescription("foo1");
f2.setCommand("bar1");
f2.setAttribute("moo");
fp1 = new FaultPropertyType();
fp1.setFault2(f2);
r1 = new Record1();
r1.setElem(fp1);
r2 = binding.get(r1);
assertTrue(r2 != null);
| public void | testSerialization()
ChoiceServiceSoap binding;
try {
ChoiceServiceLocator locator = new ChoiceServiceLocator();
binding = locator.getChoiceServiceSoap();
deployServer();
}
catch (javax.xml.rpc.ServiceException jre) {
throw new AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
}
catch (Exception e) {
throw new AssertionFailedError("Binding initialization Exception caught: " + e);
}
assertTrue("binding is null", binding != null);
FaultPropertyType fp1;
FaultPropertyType fp2;
Record1 r1;
Record2 r2;
// test 1
FaultType f1 = new FaultType();
f1.setDescription("foo");
f1.setCommand("bar");
fp1 = new FaultPropertyType();
fp1.setFault1(f1);
r1 = new Record1();
r1.setElem(fp1);
r2 = binding.get(r1);
assertTrue(r2 != null);
fp2 = r2.getElem();
assertTrue(fp2 != null);
assertTrue(fp2.getFault1() != null);
assertTrue(fp2.getFault1() instanceof FaultType);
assertEquals("foo",
((FaultType)fp2.getFault1()).getDescription());
assertEquals("bar",
((FaultType)fp2.getFault1()).getCommand());
// test 2
StagingFaultType f2 = new StagingFaultType();
f2.setDescription("foo1");
f2.setCommand("bar1");
f2.setAttribute("moo");
fp1 = new FaultPropertyType();
fp1.setFault2(f2);
r1 = new Record1();
r1.setElem(fp1);
r2 = binding.get(r1);
assertTrue(r2 != null);
fp2 = r2.getElem();
assertTrue(fp2 != null);
assertTrue(fp2.getFault2() != null);
assertTrue(fp2.getFault2() instanceof StagingFaultType);
assertEquals("foo1",
((FaultType)fp2.getFault2()).getDescription());
assertEquals("bar1",
((FaultType)fp2.getFault2()).getCommand());
assertEquals("moo",
((StagingFaultType)fp2.getFault2()).getAttribute());
|
|