| 1 |
/* |
| 2 |
* Copyright 2001-2004 The Apache Software Foundation. |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
* you may not use this file except in compliance with the License. |
| 6 |
* You may obtain a copy of the License at |
| 7 |
* |
| 8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
* |
| 10 |
* Unless required by applicable law or agreed to in writing, software |
| 11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
* See the License for the specific language governing permissions and |
| 14 |
* limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
package test.functional; |
| 18 |
|
| 19 |
import junit.framework.TestCase; |
| 20 |
import org.apache.axis.AxisFault; |
| 21 |
import org.apache.axis.client.AdminClient; |
| 22 |
import org.apache.axis.components.logger.LogFactory; |
| 23 |
import org.apache.commons.logging.Log; |
| 24 |
import samples.transport.FileTest; |
| 25 |
|
| 26 |
|
| 27 |
/** Test the stock sample code. |
| 28 |
*/ |
| 29 |
public class TestTransportSample extends TestCase { |
| 30 |
static Log log = |
| 31 |
LogFactory.getLog(TestTransportSample.class.getName()); |
| 32 |
|
| 33 |
public TestTransportSample(String name) { |
| 34 |
super(name); |
| 35 |
} |
| 36 |
|
| 37 |
public void doTestDeploy () throws Exception { |
| 38 |
String[] args = { "-llocal:", "samples/transport/deploy.wsdd" }; |
| 39 |
AdminClient.main(args); |
| 40 |
} |
| 41 |
|
| 42 |
/* NOT RECOMMENDED -- this calls out to xmltoday.com which is flaky. |
| 43 |
Verify that it either succeeds, or that it produces a specific |
| 44 |
failure. */ |
| 45 |
|
| 46 |
public void doTestIBM () throws Exception { |
| 47 |
String[] args = { "IBM" }; |
| 48 |
try { |
| 49 |
FileTest.main(args); |
| 50 |
} catch (AxisFault e) { |
| 51 |
String fault = e.getFaultString(); |
| 52 |
if (fault == null) throw e; |
| 53 |
if (fault.indexOf("java.net.UnknownHost")<0) { |
| 54 |
int start = fault.indexOf(": "); |
| 55 |
log.info(fault.substring(start+2)); |
| 56 |
} else if (fault.equals("timeout")) { |
| 57 |
log.info("timeout"); |
| 58 |
} else { |
| 59 |
throw e; |
| 60 |
} |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
public void doTestXXX () throws Exception { |
| 65 |
String[] args = { "XXX" }; |
| 66 |
FileTest.main(args); |
| 67 |
} |
| 68 |
|
| 69 |
public void testService () throws Exception { |
| 70 |
try { |
| 71 |
log.info("Testing transport sample."); |
| 72 |
log.info("Testing deployment..."); |
| 73 |
doTestDeploy(); |
| 74 |
log.info("Testing service with symbol IBM..."); |
| 75 |
doTestIBM(); |
| 76 |
log.info("Testing service with symbol XXX..."); |
| 77 |
doTestXXX(); |
| 78 |
log.info("Test complete."); |
| 79 |
} |
| 80 |
catch( Exception e ) { |
| 81 |
e.printStackTrace(); |
| 82 |
throw new Exception("Fault returned from test: "+e); |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
* bogus 'main' |
| 88 |
*/ |
| 89 |
public static void main (String[] args) throws Exception { |
| 90 |
new TestTransportSample("foo").testService(); |
| 91 |
} |
| 92 |
} |
| 93 |
|