1 57 58 package chartype; 59 60 import java.util.Collection ; 61 import java.util.HashMap ; 62 import java.util.Hashtable ; 63 import java.util.Iterator ; 64 65 import junit.framework.Test; 66 import junit.framework.TestCase; 67 import junit.framework.TestSuite; 68 69 import org.apache.wsif.WSIFMessage; 70 import org.apache.wsif.WSIFOperation; 71 import org.apache.wsif.WSIFPort; 72 import org.apache.wsif.WSIFService; 73 import org.apache.wsif.WSIFServiceFactory; 74 import util.TestUtilities; 75 76 85 public class CharTest extends TestCase { 86 87 private boolean debugMode = true; 88 private String wsdl = TestUtilities.getWsdlPath("java\\test\\chartype") + "CharService.wsdl";; 89 90 91 public static void main(java.lang.String [] args) { 92 junit.textui.TestRunner.run (suite()); 93 } 94 95 public static Test suite() { 96 return new TestSuite(CharTest.class); 97 } 98 99 public CharTest(String arg0) { 100 super(arg0); 101 } 102 103 protected void setUp() { 104 } 105 106 public void testJava() throws Exception { 107 WSIFServiceFactory factory = WSIFServiceFactory.newInstance(); 108 WSIFService service = factory.getService(wsdl, null, null, null, null); 109 110 WSIFPort port = service.getPort(); 111 112 WSIFOperation operation; 113 WSIFMessage inputMessage; 114 WSIFMessage outputMessage; 115 WSIFMessage faultMessage; 116 117 String tempString; 118 119 Object part; 120 boolean operationSucceeded; 121 122 125 operation = port.createOperation("setCharOperation"); 126 inputMessage = operation.createInputMessage(); 127 outputMessage = operation.createOutputMessage(); 128 faultMessage = operation.createFaultMessage(); 129 130 inputMessage.setObjectPart("in", "a"); 131 132 operationSucceeded = 133 operation.executeRequestResponseOperation( 134 inputMessage, 135 outputMessage, 136 faultMessage); 137 138 assertTrue("setChar failed!!", operationSucceeded); 139 140 if (operationSucceeded) { 141 assertTrue( 142 "setChar did not return a boolean", 143 outputMessage.getObjectPart("out") instanceof Boolean ); 144 assertTrue("setChar did not return true", ((Boolean ) outputMessage.getObjectPart("out")).booleanValue()); 145 debug("setChar returned "+ outputMessage.getObjectPart("out")); 146 } else { 147 debug("operation failed"); 148 } 149 150 153 operation = port.createOperation("getCharOperation"); 154 inputMessage = operation.createInputMessage(); 155 outputMessage = operation.createOutputMessage(); 156 faultMessage = operation.createFaultMessage(); 157 158 inputMessage.setBooleanPart("in", true); 159 160 operationSucceeded = 161 operation.executeRequestResponseOperation( 162 inputMessage, 163 outputMessage, 164 faultMessage); 165 166 assertTrue("getChar failed!!", operationSucceeded); 167 168 if (operationSucceeded) { 169 assertTrue( 170 "getChar did not return a String", 171 outputMessage.getObjectPart("out") instanceof String ); 172 debug("getChar returned "+ outputMessage.getObjectPart("out")); 173 } else { 174 debug("operation failed"); 175 } 176 177 180 operation = port.createOperation("setCharArrayOperation"); 181 inputMessage = operation.createInputMessage(); 182 outputMessage = operation.createOutputMessage(); 183 faultMessage = operation.createFaultMessage(); 184 185 String [][] sa = new String [][] {{"a", "b"},{"d", "e", "g"}}; 186 187 inputMessage.setObjectPart("in", sa); 188 189 operationSucceeded = 190 operation.executeRequestResponseOperation( 191 inputMessage, 192 outputMessage, 193 faultMessage); 194 195 assertTrue("setCharArray failed!!", operationSucceeded); 196 197 if (operationSucceeded) { 198 assertTrue( 199 "setCharArray did not return a boolean", 200 outputMessage.getObjectPart("out") instanceof Boolean ); 201 assertTrue("getCharArray did not return true", ((Boolean ) outputMessage.getObjectPart("out")).booleanValue()); 202 debug("setCharArray returned "+ outputMessage.getObjectPart("out")); 203 } else { 204 debug("operation failed"); 205 } 206 207 210 operation = port.createOperation("getCharArrayOperation"); 211 inputMessage = operation.createInputMessage(); 212 outputMessage = operation.createOutputMessage(); 213 faultMessage = operation.createFaultMessage(); 214 215 inputMessage.setBooleanPart("in", true); 216 217 operationSucceeded = 218 operation.executeRequestResponseOperation( 219 inputMessage, 220 outputMessage, 221 faultMessage); 222 223 assertTrue("getCharArray failed!!", operationSucceeded); 224 225 if (operationSucceeded) { 226 assertTrue( 227 "getCharArray did not return a String array", 228 outputMessage.getObjectPart("out") instanceof String [][]); 229 String [][] out = (String [][]) outputMessage.getObjectPart("out"); 230 debug("getCharArray returned "); 231 for (int i=0; i<out.length; i++) { 232 for (int j=0; j<out[i].length; j++) { 233 char c = 'X'; 234 debug(" out["+i+"]["+j+"] = "+out[i][j]); 235 } 236 } 237 } else { 238 debug("operation failed"); 239 } 240 } 241 242 private void debug(Object s) { 243 if (debugMode) 244 System.out.println(s); 245 } 246 } | Popular Tags |