1/* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18package libcore.java.sql; 19 20import java.sql.Driver; 21import java.sql.DriverManager; 22import java.sql.DriverPropertyInfo; 23import java.util.Properties; 24import junit.framework.TestCase; 25 26public final class OldDriverPropertyInfoTest extends TestCase { 27 28 static final String validName = "testname"; 29 static final String validValue = "testvalue"; 30 static final String connectionURL = "jdbc:sqlite:/" + "Test.db"; 31 static final String classname = "SQLite.JDBCDriver"; 32 33 public void testDriverPropertyInfoStringString() { 34 DriverPropertyInfo aDriverPropertyInfo = new DriverPropertyInfo( 35 validName, validValue); 36 37 assertNotNull(aDriverPropertyInfo); 38 39 assertEquals(aDriverPropertyInfo.name,validName); 40 assertEquals(aDriverPropertyInfo.value,validValue); 41 42 aDriverPropertyInfo = new DriverPropertyInfo(null, null); 43 44 assertNotNull(aDriverPropertyInfo); 45 assertNull(aDriverPropertyInfo.name); 46 assertNull(aDriverPropertyInfo.value); 47 } 48 49 public void testPublicFields() throws Exception { 50 Class.forName(classname).newInstance(); 51 Properties props = new Properties(); 52 Driver d = DriverManager.getDriver(connectionURL); 53 DriverPropertyInfo[] info = d.getPropertyInfo(connectionURL, 54 props); 55 // get the property metadata 56 String name = info[0].name; 57 assertNotNull(name); 58 assertEquals(name, "encoding"); 59 String[] choices = info[0].choices; 60 assertNull(choices); 61 boolean required = info[0].required; 62 assertFalse(required); 63 String description = info[0].description; 64 assertNull(description); 65 } 66} 67