1*ef39d40dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ef39d40dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ef39d40dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ef39d40dSAndrew Rist * distributed with this work for additional information 6*ef39d40dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ef39d40dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ef39d40dSAndrew Rist * "License"); you may not use this file except in compliance 9*ef39d40dSAndrew Rist * with the License. You may obtain a copy of the License at 10*ef39d40dSAndrew Rist * 11*ef39d40dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*ef39d40dSAndrew Rist * 13*ef39d40dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ef39d40dSAndrew Rist * software distributed under the License is distributed on an 15*ef39d40dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ef39d40dSAndrew Rist * KIND, either express or implied. See the License for the 17*ef39d40dSAndrew Rist * specific language governing permissions and limitations 18*ef39d40dSAndrew Rist * under the License. 19*ef39d40dSAndrew Rist * 20*ef39d40dSAndrew Rist *************************************************************/ 21*ef39d40dSAndrew Rist 22*ef39d40dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package ifc.util; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import com.sun.star.util.URL; 27cdf0e10cSrcweir import com.sun.star.util.XURLTransformer; 28cdf0e10cSrcweir import lib.MultiMethodTest; 29cdf0e10cSrcweir 30cdf0e10cSrcweir /** 31cdf0e10cSrcweir * Testing <code>com.sun.star.util.XURLTransformer</code> 32cdf0e10cSrcweir * interface methods : 33cdf0e10cSrcweir * <ul> 34cdf0e10cSrcweir * <li><code> assemble() </code></li> 35cdf0e10cSrcweir * <li><code> parseStrict() </code></li> 36cdf0e10cSrcweir * <li><code> parseSmart() </code></li> 37cdf0e10cSrcweir * <li><code> getPresentation() </code></li> 38cdf0e10cSrcweir * </ul> <p> 39cdf0e10cSrcweir * Test is <b> NOT </b> multithread compilant. <p> 40cdf0e10cSrcweir * @see com.sun.star.util.XURLTransformer 41cdf0e10cSrcweir */ 42cdf0e10cSrcweir public class _XURLTransformer extends MultiMethodTest { 43cdf0e10cSrcweir 44cdf0e10cSrcweir public XURLTransformer oObj = null; 45cdf0e10cSrcweir 46cdf0e10cSrcweir URL url; 47cdf0e10cSrcweir 48cdf0e10cSrcweir final static String user = "user"; 49cdf0e10cSrcweir final static String invalidUserPrefix = "1"; 50cdf0e10cSrcweir final static String password = "password"; 51cdf0e10cSrcweir final static String server = "server"; 52cdf0e10cSrcweir final static String invalidServerPrefix = "1"; 53cdf0e10cSrcweir final static String port = "8080"; 54cdf0e10cSrcweir final static String path = "/pub/path"; 55cdf0e10cSrcweir final static String name = "file.txt"; 56cdf0e10cSrcweir final static String arguments = "a=b"; 57cdf0e10cSrcweir final static String mark = "mark"; 58cdf0e10cSrcweir 59cdf0e10cSrcweir final static String expectedCompleteHTTP = "http://" 60cdf0e10cSrcweir + server + ":" + port + path 61cdf0e10cSrcweir + "/" + name + "?" + arguments + "#" + mark; 62cdf0e10cSrcweir final static String expectedCompleteFTP = "ftp://" 63cdf0e10cSrcweir + user + ":" + password + "@" + server + ":" + port + path 64cdf0e10cSrcweir + "/" + name; 65cdf0e10cSrcweir 66cdf0e10cSrcweir /** 67cdf0e10cSrcweir * First the complete URL (all URL fields are filled) is 68cdf0e10cSrcweir * passed and assembled. Then incomplete URL (only 69cdf0e10cSrcweir * <code>Server</code> field is set) is passed. <p> 70cdf0e10cSrcweir * Has <b> OK </b> status if in the first case <code>true</code> 71cdf0e10cSrcweir * retruned and <code>Complete</code> field is set and in the 72cdf0e10cSrcweir * second case <code>false</code> is returned. <p> 73cdf0e10cSrcweir */ _assemble()74cdf0e10cSrcweir public void _assemble(){ 75cdf0e10cSrcweir URL[] url = new URL[1]; 76cdf0e10cSrcweir url[0] = new URL(); 77cdf0e10cSrcweir 78cdf0e10cSrcweir url[0].Protocol = "http://"; 79cdf0e10cSrcweir url[0].Server = server; 80cdf0e10cSrcweir url[0].Port = new Integer(port).shortValue(); 81cdf0e10cSrcweir url[0].Path = path; 82cdf0e10cSrcweir url[0].Name = name; 83cdf0e10cSrcweir url[0].Arguments = arguments; 84cdf0e10cSrcweir url[0].Mark = mark; 85cdf0e10cSrcweir url[0].Main = "http://" + server + ":" + 86cdf0e10cSrcweir port + path + "/" + name; 87cdf0e10cSrcweir 88cdf0e10cSrcweir boolean res = true; 89cdf0e10cSrcweir 90cdf0e10cSrcweir log.print("assemble http-URL: "); 91cdf0e10cSrcweir boolean complete = oObj.assemble(url); 92cdf0e10cSrcweir log.println(complete); 93cdf0e10cSrcweir res &= complete; 94cdf0e10cSrcweir 95cdf0e10cSrcweir if (!expectedCompleteHTTP.equals(url[0].Complete)) { 96cdf0e10cSrcweir log.println("assemble works wrong"); 97cdf0e10cSrcweir log.println("complete field : " + url[0].Complete); 98cdf0e10cSrcweir log.println("expected : " + expectedCompleteHTTP); 99cdf0e10cSrcweir res = false; 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 102cdf0e10cSrcweir url[0] = new URL(); 103cdf0e10cSrcweir url[0].Protocol = "ftp://"; 104cdf0e10cSrcweir url[0].User = user; 105cdf0e10cSrcweir url[0].Password = password; 106cdf0e10cSrcweir url[0].Server = server; 107cdf0e10cSrcweir url[0].Port = new Integer(port).shortValue(); 108cdf0e10cSrcweir url[0].Path = path; 109cdf0e10cSrcweir url[0].Name = name; 110cdf0e10cSrcweir url[0].Main = "ftp://" + user + ":" + password + "@" + server + ":" + 111cdf0e10cSrcweir port + path + "/" + name; 112cdf0e10cSrcweir 113cdf0e10cSrcweir log.print("assemble ftp-URL: "); 114cdf0e10cSrcweir complete = oObj.assemble(url); 115cdf0e10cSrcweir log.println(complete); 116cdf0e10cSrcweir res &= complete; 117cdf0e10cSrcweir 118cdf0e10cSrcweir if (!expectedCompleteFTP.equals(url[0].Complete)) { 119cdf0e10cSrcweir log.println("assemble works wrong"); 120cdf0e10cSrcweir log.println("complete field : " + url[0].Complete); 121cdf0e10cSrcweir log.println("expected : " + expectedCompleteFTP); 122cdf0e10cSrcweir res = false; 123cdf0e10cSrcweir } 124cdf0e10cSrcweir 125cdf0e10cSrcweir URL[] incompleteUrl = new URL[1]; 126cdf0e10cSrcweir incompleteUrl[0] = new URL(); 127cdf0e10cSrcweir incompleteUrl[0].Server = server; 128cdf0e10cSrcweir 129cdf0e10cSrcweir log.print("assemble incomplete URL: "); 130cdf0e10cSrcweir complete = oObj.assemble(incompleteUrl); 131cdf0e10cSrcweir log.println(complete); 132cdf0e10cSrcweir res &= !complete; 133cdf0e10cSrcweir 134cdf0e10cSrcweir // should be incomplete 135cdf0e10cSrcweir tRes.tested("assemble()", res); 136cdf0e10cSrcweir } 137cdf0e10cSrcweir 138cdf0e10cSrcweir /** 139cdf0e10cSrcweir * First the complete URL (<code>Complete</code> field is set 140cdf0e10cSrcweir * to proper URL) is passed and parsed. Then incomplete URL (only 141cdf0e10cSrcweir * <code>Server</code> field is set) is passed. <p> 142cdf0e10cSrcweir * Has <b> OK </b> status if in the first case <code>true</code> 143cdf0e10cSrcweir * retruned and all URL fields are set to proper values and in the 144cdf0e10cSrcweir * second case <code>false</code> is returned. <p> 145cdf0e10cSrcweir */ _parseStrict()146cdf0e10cSrcweir public void _parseStrict() { 147cdf0e10cSrcweir URL[] url = new URL[1]; 148cdf0e10cSrcweir 149cdf0e10cSrcweir url[0] = new URL(); 150cdf0e10cSrcweir url[0].Complete = expectedCompleteHTTP; 151cdf0e10cSrcweir 152cdf0e10cSrcweir boolean res = true; 153cdf0e10cSrcweir log.print("parseStrict(" + expectedCompleteHTTP + "): "); 154cdf0e10cSrcweir boolean complete = oObj.parseStrict(url); 155cdf0e10cSrcweir log.println(complete); 156cdf0e10cSrcweir res &= complete; 157cdf0e10cSrcweir 158cdf0e10cSrcweir if (!url[0].Protocol.equals("http://")) { 159cdf0e10cSrcweir log.println("parseStrict works wrong"); 160cdf0e10cSrcweir log.println("protocol field : " + url[0].Protocol); 161cdf0e10cSrcweir log.println("expected : http://"); 162cdf0e10cSrcweir res = false; 163cdf0e10cSrcweir } 164cdf0e10cSrcweir 165cdf0e10cSrcweir if (!url[0].Server.equals(server)) { 166cdf0e10cSrcweir log.println("parseStrict works wrong"); 167cdf0e10cSrcweir log.println("server field : " + url[0].Server); 168cdf0e10cSrcweir log.println("expected : " + server); 169cdf0e10cSrcweir res = false; 170cdf0e10cSrcweir } 171cdf0e10cSrcweir 172cdf0e10cSrcweir if (url[0].Port != new Integer(port).shortValue()) { 173cdf0e10cSrcweir log.println("parseStrict works wrong"); 174cdf0e10cSrcweir log.println("port field : " + url[0].Port); 175cdf0e10cSrcweir log.println("expected : " + port); 176cdf0e10cSrcweir res = false; 177cdf0e10cSrcweir } 178cdf0e10cSrcweir 179cdf0e10cSrcweir if ((!url[0].Path.equals(path)) && (!url[0].Path.equals(path + "/"))) { 180cdf0e10cSrcweir log.println("parseStrict works wrong"); 181cdf0e10cSrcweir log.println("path field : " + url[0].Path); 182cdf0e10cSrcweir log.println("expected : " + path); 183cdf0e10cSrcweir res = false; 184cdf0e10cSrcweir } 185cdf0e10cSrcweir 186cdf0e10cSrcweir if (!url[0].Name.equals(name)) { 187cdf0e10cSrcweir log.println("parseStrict works wrong"); 188cdf0e10cSrcweir log.println("name field : " + url[0].Name); 189cdf0e10cSrcweir log.println("expected : " + name); 190cdf0e10cSrcweir res = false; 191cdf0e10cSrcweir } 192cdf0e10cSrcweir 193cdf0e10cSrcweir if (!url[0].Arguments.equals(arguments)) { 194cdf0e10cSrcweir log.println("parseStrict works wrong"); 195cdf0e10cSrcweir log.println("arguments field : " + url[0].Arguments); 196cdf0e10cSrcweir log.println("expected : " + arguments); 197cdf0e10cSrcweir res = false; 198cdf0e10cSrcweir } 199cdf0e10cSrcweir 200cdf0e10cSrcweir if (!url[0].Mark.equals(mark)) { 201cdf0e10cSrcweir log.println("parseStrict works wrong"); 202cdf0e10cSrcweir log.println("mark field : " + url[0].Mark); 203cdf0e10cSrcweir log.println("expected : " + mark); 204cdf0e10cSrcweir res = false; 205cdf0e10cSrcweir } 206cdf0e10cSrcweir 207cdf0e10cSrcweir url[0] = new URL(); 208cdf0e10cSrcweir url[0].Complete = expectedCompleteFTP; 209cdf0e10cSrcweir 210cdf0e10cSrcweir log.print("parseStrict(" + expectedCompleteFTP + "): "); 211cdf0e10cSrcweir complete = oObj.parseStrict(url); 212cdf0e10cSrcweir log.println(complete); 213cdf0e10cSrcweir res &= complete; 214cdf0e10cSrcweir 215cdf0e10cSrcweir if (!url[0].Protocol.equals("ftp://")) { 216cdf0e10cSrcweir log.println("parseStrict works wrong"); 217cdf0e10cSrcweir log.println("protocol field : " + url[0].Protocol); 218cdf0e10cSrcweir log.println("expected : ftp://"); 219cdf0e10cSrcweir res = false; 220cdf0e10cSrcweir } 221cdf0e10cSrcweir 222cdf0e10cSrcweir if (!url[0].User.equals(user)) { 223cdf0e10cSrcweir log.println("parseStrict works wrong"); 224cdf0e10cSrcweir log.println("user field : " + url[0].User); 225cdf0e10cSrcweir log.println("expected : " + user); 226cdf0e10cSrcweir res = false; 227cdf0e10cSrcweir } 228cdf0e10cSrcweir 229cdf0e10cSrcweir if (!url[0].Password.equals(password)) { 230cdf0e10cSrcweir log.println("parseStrict works wrong"); 231cdf0e10cSrcweir log.println("password field : " + url[0].Password); 232cdf0e10cSrcweir log.println("expected : " + password); 233cdf0e10cSrcweir res = false; 234cdf0e10cSrcweir } 235cdf0e10cSrcweir 236cdf0e10cSrcweir if (!url[0].Server.equals(server)) { 237cdf0e10cSrcweir log.println("parseStrict works wrong"); 238cdf0e10cSrcweir log.println("server field : " + url[0].Server); 239cdf0e10cSrcweir log.println("expected : " + server); 240cdf0e10cSrcweir res = false; 241cdf0e10cSrcweir } 242cdf0e10cSrcweir 243cdf0e10cSrcweir if (url[0].Port != new Integer(port).shortValue()) { 244cdf0e10cSrcweir log.println("parseStrict works wrong"); 245cdf0e10cSrcweir log.println("port field : " + url[0].Port); 246cdf0e10cSrcweir log.println("expected : " + port); 247cdf0e10cSrcweir res = false; 248cdf0e10cSrcweir } 249cdf0e10cSrcweir 250cdf0e10cSrcweir if ((!url[0].Path.equals(path)) && (!url[0].Path.equals(path + "/"))) { 251cdf0e10cSrcweir log.println("parseStrict works wrong"); 252cdf0e10cSrcweir log.println("path field : " + url[0].Path); 253cdf0e10cSrcweir log.println("expected : " + path); 254cdf0e10cSrcweir res = false; 255cdf0e10cSrcweir } 256cdf0e10cSrcweir 257cdf0e10cSrcweir if (!url[0].Name.equals(name)) { 258cdf0e10cSrcweir log.println("parseStrict works wrong"); 259cdf0e10cSrcweir log.println("name field : " + url[0].Name); 260cdf0e10cSrcweir log.println("expected : " + name); 261cdf0e10cSrcweir res = false; 262cdf0e10cSrcweir } 263cdf0e10cSrcweir 264cdf0e10cSrcweir URL[] incompleteUrl = new URL[1]; 265cdf0e10cSrcweir incompleteUrl[0] = new URL(); 266cdf0e10cSrcweir incompleteUrl[0].Complete = server; 267cdf0e10cSrcweir 268cdf0e10cSrcweir log.print("parseStrict(" + server + "): "); 269cdf0e10cSrcweir complete = oObj.parseStrict(incompleteUrl); 270cdf0e10cSrcweir log.println(complete); 271cdf0e10cSrcweir // should be incomplete 272cdf0e10cSrcweir res &= !complete; 273cdf0e10cSrcweir 274cdf0e10cSrcweir tRes.tested("parseStrict()", res); 275cdf0e10cSrcweir } 276cdf0e10cSrcweir 277cdf0e10cSrcweir /** 278cdf0e10cSrcweir * Tries to parse WWW server name. <p> 279cdf0e10cSrcweir * Has <b> OK </b> status if the method return <code>true</code> 280cdf0e10cSrcweir * value and <code>Protocol, Server, Port</code> URL fields are 281cdf0e10cSrcweir * set properly. 282cdf0e10cSrcweir */ _parseSmart()283cdf0e10cSrcweir public void _parseSmart() { 284cdf0e10cSrcweir URL[] url = new URL[1]; 285cdf0e10cSrcweir 286cdf0e10cSrcweir String httpURL = invalidServerPrefix + server + ":" + port + path + "/" + name + "?" + 287cdf0e10cSrcweir arguments + "#" + mark; 288cdf0e10cSrcweir 289cdf0e10cSrcweir url[0] = new URL(); 290cdf0e10cSrcweir url[0].Complete = httpURL; 291cdf0e10cSrcweir 292cdf0e10cSrcweir boolean res = true; 293cdf0e10cSrcweir log.print("parseSmart('" + httpURL + "', 'http://'): "); 294cdf0e10cSrcweir boolean complete = oObj.parseSmart(url, "http://"); 295cdf0e10cSrcweir log.println(complete); 296cdf0e10cSrcweir res &= complete; 297cdf0e10cSrcweir 298cdf0e10cSrcweir if (!url[0].Protocol.equals("http://")) { 299cdf0e10cSrcweir log.println("parseSmart works wrong"); 300cdf0e10cSrcweir log.println("protocol field : " + url[0].Protocol); 301cdf0e10cSrcweir log.println("expected : http://"); 302cdf0e10cSrcweir res = false; 303cdf0e10cSrcweir } 304cdf0e10cSrcweir 305cdf0e10cSrcweir if (!url[0].Server.equals(invalidServerPrefix+server)) { 306cdf0e10cSrcweir log.println("parseSmart works wrong"); 307cdf0e10cSrcweir log.println("server field : " + url[0].Server); 308cdf0e10cSrcweir log.println("expected : " + server); 309cdf0e10cSrcweir res = false; 310cdf0e10cSrcweir } 311cdf0e10cSrcweir 312cdf0e10cSrcweir if (url[0].Port != new Integer(port).shortValue()) { 313cdf0e10cSrcweir log.println("parseSmart works wrong"); 314cdf0e10cSrcweir log.println("port field : " + url[0].Port); 315cdf0e10cSrcweir log.println("expected : " + port); 316cdf0e10cSrcweir res = false; 317cdf0e10cSrcweir } 318cdf0e10cSrcweir 319cdf0e10cSrcweir if ((!url[0].Path.equals(path)) && (!url[0].Path.equals(path + "/"))) { 320cdf0e10cSrcweir log.println("parseSmart works wrong"); 321cdf0e10cSrcweir log.println("path field : " + url[0].Path); 322cdf0e10cSrcweir log.println("expected : " + path); 323cdf0e10cSrcweir res = false; 324cdf0e10cSrcweir } 325cdf0e10cSrcweir 326cdf0e10cSrcweir if (!url[0].Name.equals(name)) { 327cdf0e10cSrcweir log.println("parseSmart works wrong"); 328cdf0e10cSrcweir log.println("name field : " + url[0].Name); 329cdf0e10cSrcweir log.println("expected : " + name); 330cdf0e10cSrcweir res = false; 331cdf0e10cSrcweir } 332cdf0e10cSrcweir 333cdf0e10cSrcweir if (!url[0].Arguments.equals(arguments)) { 334cdf0e10cSrcweir log.println("parseSmart works wrong"); 335cdf0e10cSrcweir log.println("arguments field : " + url[0].Arguments); 336cdf0e10cSrcweir log.println("expected : " + arguments); 337cdf0e10cSrcweir res = false; 338cdf0e10cSrcweir } 339cdf0e10cSrcweir 340cdf0e10cSrcweir if (!url[0].Mark.equals(mark)) { 341cdf0e10cSrcweir log.println("parseSmart works wrong"); 342cdf0e10cSrcweir log.println("mark field : " + url[0].Mark); 343cdf0e10cSrcweir log.println("expected : " + mark); 344cdf0e10cSrcweir res = false; 345cdf0e10cSrcweir } 346cdf0e10cSrcweir 347cdf0e10cSrcweir String ftpURL = invalidUserPrefix +user + ":" + password + "@" + server + ":" + 348cdf0e10cSrcweir port + path + "/" + name; 349cdf0e10cSrcweir 350cdf0e10cSrcweir url[0] = new URL(); 351cdf0e10cSrcweir url[0].Complete = ftpURL; 352cdf0e10cSrcweir log.print("parseSmart('" + ftpURL + "', 'ftp://'): "); 353cdf0e10cSrcweir complete = oObj.parseSmart(url, "ftp://"); 354cdf0e10cSrcweir log.println(complete); 355cdf0e10cSrcweir res &= complete; 356cdf0e10cSrcweir 357cdf0e10cSrcweir if (!url[0].Protocol.equals("ftp://")) { 358cdf0e10cSrcweir log.println("parseSmart works wrong"); 359cdf0e10cSrcweir log.println("protocol field : " + url[0].Protocol); 360cdf0e10cSrcweir log.println("expected : ftp://"); 361cdf0e10cSrcweir res = false; 362cdf0e10cSrcweir } 363cdf0e10cSrcweir 364cdf0e10cSrcweir if (!url[0].User.equals(invalidUserPrefix+user)) { 365cdf0e10cSrcweir log.println("parseSmart works wrong"); 366cdf0e10cSrcweir log.println("user field : " + url[0].User); 367cdf0e10cSrcweir log.println("expected : " + user); 368cdf0e10cSrcweir res = false; 369cdf0e10cSrcweir } 370cdf0e10cSrcweir 371cdf0e10cSrcweir if (!url[0].Password.equals(password)) { 372cdf0e10cSrcweir log.println("parseSmart works wrong"); 373cdf0e10cSrcweir log.println("password field : " + url[0].Password); 374cdf0e10cSrcweir log.println("expected : " + password); 375cdf0e10cSrcweir res = false; 376cdf0e10cSrcweir } 377cdf0e10cSrcweir 378cdf0e10cSrcweir if (!url[0].Server.equals(server)) { 379cdf0e10cSrcweir log.println("parseSmart works wrong"); 380cdf0e10cSrcweir log.println("server field : " + url[0].Server); 381cdf0e10cSrcweir log.println("expected : " + server); 382cdf0e10cSrcweir res = false; 383cdf0e10cSrcweir } 384cdf0e10cSrcweir 385cdf0e10cSrcweir if (url[0].Port != new Integer(port).shortValue()) { 386cdf0e10cSrcweir log.println("parseSmart works wrong"); 387cdf0e10cSrcweir log.println("port field : " + url[0].Port); 388cdf0e10cSrcweir log.println("expected : " + port); 389cdf0e10cSrcweir res = false; 390cdf0e10cSrcweir } 391cdf0e10cSrcweir 392cdf0e10cSrcweir if ((!url[0].Path.equals(path)) && (!url[0].Path.equals(path + "/"))) { 393cdf0e10cSrcweir log.println("parseSmart works wrong"); 394cdf0e10cSrcweir log.println("path field : " + url[0].Path); 395cdf0e10cSrcweir log.println("expected : " + path); 396cdf0e10cSrcweir res = false; 397cdf0e10cSrcweir } 398cdf0e10cSrcweir 399cdf0e10cSrcweir if (!url[0].Name.equals(name)) { 400cdf0e10cSrcweir log.println("parseSmart works wrong"); 401cdf0e10cSrcweir log.println("name field : " + url[0].Name); 402cdf0e10cSrcweir log.println("expected : " + name); 403cdf0e10cSrcweir res = false; 404cdf0e10cSrcweir } 405cdf0e10cSrcweir 406cdf0e10cSrcweir tRes.tested("parseSmart()", res); 407cdf0e10cSrcweir } 408cdf0e10cSrcweir 409cdf0e10cSrcweir /** 410cdf0e10cSrcweir * Gets the presentation of a URL. <p> 411cdf0e10cSrcweir * Has <b> OK </b> status if the method returns the same 412cdf0e10cSrcweir * URL as was passed in parameter. 413cdf0e10cSrcweir */ _getPresentation()414cdf0e10cSrcweir public void _getPresentation() { 415cdf0e10cSrcweir URL url = new URL(); 416cdf0e10cSrcweir 417cdf0e10cSrcweir url.Complete = expectedCompleteHTTP; 418cdf0e10cSrcweir 419cdf0e10cSrcweir log.println("getPresentation('" + expectedCompleteHTTP + "', true): "); 420cdf0e10cSrcweir String presentation = oObj.getPresentation(url, true); 421cdf0e10cSrcweir boolean res = presentation.equals(expectedCompleteHTTP); 422cdf0e10cSrcweir log.println("Resulted presentation: " + presentation); 423cdf0e10cSrcweir log.println("Expected presentation: " + expectedCompleteHTTP); 424cdf0e10cSrcweir log.println("Result: " + res); 425cdf0e10cSrcweir 426cdf0e10cSrcweir url.Complete = expectedCompleteFTP; 427cdf0e10cSrcweir log.println("getPresentation('" + expectedCompleteFTP + "', false): "); 428cdf0e10cSrcweir // the password must be masqurade with <****> 429cdf0e10cSrcweir String asterix = ""; 430cdf0e10cSrcweir for (int n = 0 ; n < password.length(); n++){ 431cdf0e10cSrcweir asterix += "*"; 432cdf0e10cSrcweir } 433cdf0e10cSrcweir asterix = "<" + asterix.substring(1,asterix.length()); 434cdf0e10cSrcweir asterix = asterix.substring(0,asterix.length()-1) + ">"; 435cdf0e10cSrcweir 436cdf0e10cSrcweir presentation = oObj.getPresentation(url, false); 437cdf0e10cSrcweir String expectedPresentation = "ftp://" + user + ":" + asterix + "@" + 438cdf0e10cSrcweir server + ":" + port + path + "/" + name; 439cdf0e10cSrcweir res &= presentation.equals(expectedPresentation); 440cdf0e10cSrcweir log.println("Resulted presentation: " + presentation); 441cdf0e10cSrcweir log.println("Expected presentation: " + expectedPresentation); 442cdf0e10cSrcweir log.println("Result: " + res); 443cdf0e10cSrcweir 444cdf0e10cSrcweir log.println("getPresentation('" + expectedCompleteFTP + "', true): "); 445cdf0e10cSrcweir presentation = oObj.getPresentation(url, true); 446cdf0e10cSrcweir expectedPresentation = "ftp://" + user + ":" + password + "@" + 447cdf0e10cSrcweir server + ":" + port + path + "/" + name; 448cdf0e10cSrcweir res &= presentation.equals(expectedPresentation); 449cdf0e10cSrcweir log.println("Resulted presentation: " + presentation); 450cdf0e10cSrcweir log.println("Expected presentation: " + expectedPresentation); 451cdf0e10cSrcweir log.println("Result: " + res); 452cdf0e10cSrcweir 453cdf0e10cSrcweir String incorrectURL = "*bla-bla*"; 454cdf0e10cSrcweir url.Complete = incorrectURL; 455cdf0e10cSrcweir log.println("getPresentation('" + incorrectURL + "', false): "); 456cdf0e10cSrcweir presentation = oObj.getPresentation(url, false); 457cdf0e10cSrcweir expectedPresentation = ""; 458cdf0e10cSrcweir res &= presentation.equals(expectedPresentation); 459cdf0e10cSrcweir log.println("Resulted presentation: " + presentation); 460cdf0e10cSrcweir log.println("Expected presentation: " + expectedPresentation); 461cdf0e10cSrcweir log.println("Result: " + res); 462cdf0e10cSrcweir 463cdf0e10cSrcweir tRes.tested("getPresentation()", res); 464cdf0e10cSrcweir } 465cdf0e10cSrcweir 466cdf0e10cSrcweir } // finish class _XURLTransformer 467cdf0e10cSrcweir 468