/luni/src/test/java/libcore/java/sql/OldDriverPropertyInfoTest.java

https://bitbucket.org/aways/android_libcore · Java · 66 lines · 39 code · 10 blank · 17 comment · 0 complexity · 7ed1d93a1e703367abe9592362fa5122 MD5 · raw file

  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. package libcore.java.sql;
  18. import java.sql.Driver;
  19. import java.sql.DriverManager;
  20. import java.sql.DriverPropertyInfo;
  21. import java.util.Properties;
  22. import junit.framework.TestCase;
  23. public final class OldDriverPropertyInfoTest extends TestCase {
  24. static final String validName = "testname";
  25. static final String validValue = "testvalue";
  26. static final String connectionURL = "jdbc:sqlite:/" + "Test.db";
  27. static final String classname = "SQLite.JDBCDriver";
  28. public void testDriverPropertyInfoStringString() {
  29. DriverPropertyInfo aDriverPropertyInfo = new DriverPropertyInfo(
  30. validName, validValue);
  31. assertNotNull(aDriverPropertyInfo);
  32. assertEquals(aDriverPropertyInfo.name,validName);
  33. assertEquals(aDriverPropertyInfo.value,validValue);
  34. aDriverPropertyInfo = new DriverPropertyInfo(null, null);
  35. assertNotNull(aDriverPropertyInfo);
  36. assertNull(aDriverPropertyInfo.name);
  37. assertNull(aDriverPropertyInfo.value);
  38. }
  39. public void testPublicFields() throws Exception {
  40. Class.forName(classname).newInstance();
  41. Properties props = new Properties();
  42. Driver d = DriverManager.getDriver(connectionURL);
  43. DriverPropertyInfo[] info = d.getPropertyInfo(connectionURL,
  44. props);
  45. // get the property metadata
  46. String name = info[0].name;
  47. assertNotNull(name);
  48. assertEquals(name, "encoding");
  49. String[] choices = info[0].choices;
  50. assertNull(choices);
  51. boolean required = info[0].required;
  52. assertFalse(required);
  53. String description = info[0].description;
  54. assertNull(description);
  55. }
  56. }