1 4 5 9 10 package org.openlaszlo.compiler; 11 import java.io.*; 12 import java.util.*; 13 import org.jdom.Element; 14 import junit.framework.*; 15 import org.openlaszlo.xml.internal.XMLUtils; 16 17 25 26 public class Compiler_Test extends TestCase { 27 public Compiler_Test(String name) { 28 super(name); 29 } 30 31 public void setUp() { 32 } 33 34 public void testAdjustRelativePath() { 35 String tests[] = { 36 39 "from", "to", "base.ext", null, "from", "to", "dir/base.ext", null, "from", "to", "/dir/base.ext", null, "from", "to", "c:/dir/base.ext", null, 45 "from", "to", "http:///base.ext", null, "from", "to", "http:///dir/base.ext", null, 49 "from", "to", "http://host.com/base.ext", null, "from", "to", "http://host.com/dir/base.ext", null, 53 "", "", "http:base.ext", null, ".", "", "http:base.ext", null, "", ".", "http:base.ext", null, ".", ".", "http:base.ext", null, "from", "", "http:base.ext", "http:../base.ext", "", "to", "http:base.ext", "http:to/base.ext", "from", "to", "http:base.ext", "http:../to/base.ext", "/from", "/to", "http:base.ext", "http:../to/base.ext", "c:/from", "c:/to", "http:base.ext", "http:../to/base.ext", 64 "from", "to", "ftp:base.ext", "ftp:../to/base.ext", "from", "to", "http:base.ext?query", "http:../to/base.ext?query", 69 74 "/c/from", "/c/to", "http:base.ext", "http:../to/base.ext", 76 "c:/from", "c:/to", "http:base.ext", "http:../to/base.ext", 77 }; 78 int i = 0; 79 while (i < tests.length) { 80 File sourcedir = new File(tests[i++]); 81 File destdir = new File(tests[i++]); 82 String source = tests[i++]; 83 String dest = tests[i++]; 84 if (dest == null) { 85 dest = source; 86 } 87 String result = CompilationEnvironment.adjustRelativeURL( 88 source, sourcedir, destdir); 89 assertEquals("" + i/4 + ": adjustRelativeURL(\"" + source + "\", \"" + sourcedir + "\", \"" + destdir + "\")", result, dest); 90 } 91 } 92 93 public void testRlementRecognition() { 94 for (Iterator iter = Arrays.asList( 96 new String [] {"<dataset/>", 97 "<dataset SRC=\"local\"/>", 98 "<dataset SRC=\"c:/local\"/>", 99 }).iterator(); iter.hasNext(); ) { 100 String src = (String ) iter.next(); 101 Element elt = XMLUtils.parse(src); 102 assertTrue(src, DataCompiler.isElement(elt)); 103 } 104 for (Iterator iter = Arrays.asList( 106 new String [] {"<dataset type=\"soap\"/>", 107 "<dataset type=\"http\"/>", 108 "<dataset SRC=\"http:foo\"/>", 109 "<dataset SRC=\"https:foo\"/>", 110 "<dataset SRC=\"ftp:foo\"/>", 111 }).iterator(); iter.hasNext(); ) { 112 String src = (String ) iter.next(); 113 Element elt = XMLUtils.parse(src); 114 assertTrue(src, !DataCompiler.isElement(elt)); 115 } 116 } 117 } 118 | Popular Tags |