1 24 25 package org.objectweb.cjdbc.scenario.standalone.driver; 26 27 import java.io.File ; 28 import java.io.FileReader ; 29 import java.io.IOException ; 30 import java.sql.SQLException ; 31 32 import org.objectweb.cjdbc.driver.Driver; 33 import org.objectweb.cjdbc.scenario.templates.NoTemplate; 34 import org.objectweb.cjdbc.scenario.tools.util.MyBufferedReader; 35 36 42 public class DriverTest extends NoTemplate 43 { 44 45 public static final String URLS_FILE = getTextPath("urls.txt"); 46 47 48 private Driver driver; 49 50 53 protected void setUp() 54 { 55 driver = new Driver(); 56 } 57 58 61 public void testAcceptURL() 62 { 63 String url = null; 64 int countTest = 0; 65 try 66 { 67 File file = new File (URLS_FILE); 68 MyBufferedReader in = new MyBufferedReader(new FileReader (file), "URLs"); 69 String line; 70 while ((line = in.readLine()) != null) 71 { 72 if (line.equals("") || line.startsWith("//")) 73 continue; 74 url = line; 75 System.out.println("Test[" + (countTest++) + "]:" + url); 76 boolean valid = in.readBoolean(); 77 try 78 { 79 if (valid) 80 { 81 assertTrue("Failed to accept a valid URL", driver.acceptsURL(url)); 82 in.readLine(); 83 in.readLine(); 84 in.readLine(); 85 } 86 else 87 { 88 assertFalse("Accepted an incorrect URL", driver.acceptsURL(url)); 89 } 90 } 91 catch (SQLException e) 92 { 93 fail("Unexpected exception thrown: " + e); 94 } 95 } 96 } 97 catch (IOException e) 98 { 99 if (url == null) 100 fail("An error occurs while parsing urls file: " + e); 101 else 102 fail("An error occurs while parsing urls file: " + e + " (URL: '" + url 103 + "')"); 104 } 105 } 106 } 107 | Popular Tags |