Debian Codegraph @

test/wsdl/literal/SalesRankNPrice_ServiceTestCase.java

raw
1 /**
2 * SalesRankNPrice_ServiceTestCase.java
3 *
4 * This file was auto-generated from WSDL
5 * by the Apache Axis Wsdl2java emitter.
6 * Edited by hand to test a .NET web service on the internet.
7 *
8 *@author Tom Jordahl ([email protected])
9 */
10
11 package test.wsdl.literal;
12
13 import org.apache.axis.AxisFault;
14
15 import java.io.File;
16 import java.io.IOException;
17 import java.net.URL;
18
19 public class SalesRankNPrice_ServiceTestCase extends junit.framework.TestCase {
20
21 public static URL url;
22
23 public SalesRankNPrice_ServiceTestCase(String name) {
24 super(name);
25 }
26
27 private void printit(String result) {
28 System.out.println("Result: " + result);
29 }
30
31 private void printit(SalesRankNPrice1 r) {
32 System.out.println("price: " + r.getPrice());
33 System.out.println("rank: " + r.getSalesRank());
34 }
35
36 private void printit(Prices p) {
37 System.out.println(
38 " Amazon price:" + p.getAmazonPrice() + "\n" +
39 " BN price:" + p.getBNPrice() );
40 }
41
42 private void printit(SalesRanks s) {
43 System.out.println(
44 " Amazon rank:" + s.getAmazonSalesRank() + "\n" +
45 " BN rank:" + s.getBNSalesRank());
46 }
47
48 private void printit(All all) {
49 System.out.println(
50 " Amazon price:" + all.getAmazonPrice() + "\n" +
51 " Amazon rank:" + all.getAmazonSalesRank() + "\n" +
52 " BN price:" + all.getBNPrice() + "\n" +
53 " BN rank:" + all.getBNSalesRank());
54
55 }
56
57 // List of files which should be generated
58 private static String[] shouldExist= new String[] {
59 "SalesRankNPrice1.java",
60 "SalesRanks.java",
61 "Prices.java",
62 "All.java",
63 "SalesRankNPriceSoap.java",
64 "SalesRankNPriceSoapStub.java",
65 "SalesRankNPrice.java",
66 "SalesRankNPriceLocator.java"
67
68 };
69
70 // List of files which should NOT be generated
71 private static String[] shouldNotExist= new String[] {
72 "GetAmazonSalesRank.java",
73 "GetAmazonSalesRankResponse.java",
74 "GetAmazonUKSalesRank.java",
75 "GetAmazonUKSalesRankResponse.java",
76 "GetBNSalesRank.java",
77 "GetBNSalesRankResponse.java",
78 "GetAmazonPrice.java",
79 "GetAmazonPriceReponse.java",
80 "GetAmazonUKPrice.java",
81 "GetAmazonUKPriceResponse.java",
82 "GetBNPrice.java",
83 "GetBNPriceResponse.java",
84 "GetAmazonSalesRankNPrice.java",
85 "GetAmazonSalesRankNPriceResponse.java",
86 "GetBNSalesRankNPrice.java",
87 "GetBNSalesRankNPriceResponse.java",
88 "GetAmazonAndBNSalesRank.java",
89 "GetAmazonAndBNSalesRankResponse.java",
90 "GetAmazonAndBNPrice.java",
91 "GetAmazonAndBNPriceResponse.java",
92 "GetAll.java",
93 "GetAllResponse.java"
94 };
95
96 public void testFileGen() throws IOException {
97 String rootDir = "build"+ File.separator + "work" + File.separator +
98 "test" + File.separator + "wsdl" + File.separator + "literal";
99 // open up the output directory and check what files exist.
100 File outputDir = new File(rootDir);
101
102 String[] files = outputDir.list();
103
104 for (int i=0; i < shouldExist.length; i++) {
105 File f = new File(rootDir, shouldExist[i]);
106 assertTrue("File does not exist (and it should): " + shouldExist[i], f.exists());
107 }
108
109 for (int i=0; i < shouldNotExist.length; i++) {
110 File f = new File(rootDir, shouldNotExist[i]);
111 assertTrue("File exist (and it should NOT): " + shouldNotExist[i], !f.exists());
112 }
113 }
114
115 public void testSalesRankNPriceSoap() {
116 // This is the book to look up...
117 // "Building Web Services With Java" :)
118 java.lang.String ISBN = "0672321815";
119
120 boolean debug = true;
121
122 SalesRankNPriceSoap binding;
123 try {
124 if (url != null)
125 binding = new SalesRankNPriceLocator().getSalesRankNPriceSoap(url);
126 else
127 binding = new SalesRankNPriceLocator().getSalesRankNPriceSoap();
128 } catch (javax.xml.rpc.ServiceException jre) {
129 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre );
130 }
131
132 assertTrue("binding is null", binding != null);
133
134 try {
135 printit(binding.getAmazonSalesRank(ISBN));
136 printit(binding.getAmazonUKSalesRank(ISBN));
137 //printit(binding.getBNSalesRank(ISBN));
138 printit(binding.getAmazonPrice(ISBN));
139 printit(binding.getAmazonUKPrice(ISBN));
140 printit(binding.getBNPrice(ISBN));
141 printit(binding.getAmazonSalesRankNPrice(ISBN));
142 printit(binding.getBNSalesRankNPrice(ISBN));
143 printit(binding.getAmazonAndBNSalesRank(ISBN));
144 printit(binding.getAmazonAndBNPrice(ISBN));
145 printit(binding.getAll(ISBN));
146 } catch (java.rmi.RemoteException re) {
147 if (!(re instanceof AxisFault &&
148 ((((AxisFault) re).detail instanceof java.net.ConnectException)||
149 (((AxisFault) re).getFaultCode().getLocalPart().equals("HTTP"))))) {
150 throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re );
151 } else {
152 // A connection exception has been detected so report this and make the test succeed.
153 printit("Connect failure caused some of SalesRankNPrice_ServiceTestCase to be skipped.");
154 }
155 }
156 }
157
158 public static void main(String[] args) {
159 if (args.length == 1) {
160 try {
161 url = new URL(args[0]);
162 } catch (Exception e) {
163 }
164 }
165
166 junit.textui.TestRunner.run(new junit.framework.TestSuite(SalesRankNPrice_ServiceTestCase.class));
167 } // main
168
169 }