ReverseEngineeringOracleTest.java
上传用户:cccombo
上传日期:2021-01-31
资源大小:16445k
文件大小:3k
源码类别:

MySQL数据库

开发平台:

SQL

  1. package com.mysql.grt.modules;
  2. import junit.framework.TestCase;
  3. import junit.framework.Assert;
  4. import junit.framework.Test;
  5. import junit.framework.TestSuite;
  6. import com.mysql.grt.*;
  7. //import com.mysql.grt.db.oracle.*;
  8. /**
  9.  * Test of MyxReverseEngineeringOracle class
  10.  * 
  11.  * @author Mike
  12.  * @version 1.0, 11/29/04
  13.  */
  14. public class ReverseEngineeringOracleTest extends TestCase {
  15. public ReverseEngineeringOracleTest(String name) {
  16. super(name);
  17. }
  18. /**
  19.  * main function so the test can be executed
  20.  */
  21. public static void main(String[] args) {
  22. junit.textui.TestRunner.run(ReverseEngineeringOracleTest.class);
  23. }
  24. /**
  25.  * The suite function builds the testsuite
  26.  */
  27. public static Test suite() {
  28. TestSuite suite = new TestSuite();
  29. suite.addTest(new ReverseEngineeringOracleTest("testGetModuleInfo"));
  30. suite.addTest(new ReverseEngineeringOracleTest("testGetSchemata"));
  31. suite.addTest(new ReverseEngineeringOracleTest("testReverseEngineer"));
  32. return suite;
  33. }
  34. /**
  35.  * Test of the getModuleInfo function
  36.  */
  37. public void testGetModuleInfo() {
  38. String xml = ReverseEngineeringOracle.getModuleInfo();
  39. GrtHashMap moduleInfo = (GrtHashMap) Grt.getObjectsFromGrtXml(xml);
  40. Assert.assertNotNull(moduleInfo);
  41. //Check if functions are there
  42. GrtStringList functionList = (GrtStringList) moduleInfo
  43. .getObject("functions");
  44. Assert.assertNotNull(functionList);
  45. Assert.assertTrue(functionList
  46. .contains("getSchemata:(Ljava/lang/String;):"));
  47. Assert
  48. .assertTrue(functionList
  49. .contains("reverseEngineer:(Ljava/lang/String;Lcom/mysql/grt/GrtStringList;):"));
  50. //Check if extens is set correctly
  51. Assert.assertEquals(moduleInfo.getObject("extends"),
  52. "ReverseEngineering");
  53. }
  54. public void testGetSchemata() {
  55. /*GrtStringList schemataList = null;
  56. try {
  57. schemataList = ReverseEngineeringOracle.getSchemata(
  58. "oracle.jdbc.OracleDriver",
  59. "jdbc:oracle:thin:system/sys@mikesthinkpad:1521:mtt");
  60. } catch (Exception e) {
  61. e.printStackTrace();
  62. }
  63. Assert.assertNotNull(schemataList);*/
  64. }
  65. public void testReverseEngineer() {
  66. /*Catalog catalog = null;
  67. String xml = "<?xml version="1.0"?>"
  68. + "  <data>"
  69. + "   <value type="list" content-type="">"
  70. + "    <value type="string">jdbc:oracle:thin:system/sys@mikesthinkpad:1521:mtt</value>"
  71. + "    <value type="list" content-type="string">"
  72. + "      <value type="string">SCOTT</value>" + "    </value>"
  73. + "  </value>" + "</data>";
  74. String res = Grt.callModuleFunction(ReverseEngineeringOracle.class,
  75. "reverseEngineer",
  76. "(Ljava/lang/String;Lcom/mysql/grt/GrtStringList;)", xml);
  77. //System.out.println(res);
  78. //try a regular call
  79. GrtStringList schemata = new GrtStringList();
  80. schemata.add("SCOTT");
  81. try {
  82. catalog = (Catalog) ReverseEngineeringOracle.reverseEngineer(
  83. "oracle.jdbc.OracleDriver",
  84. "jdbc:oracle:thin:system/sys@mikesthinkpad:1521:mtt",
  85. schemata);
  86. } catch (Exception e) {
  87. e.printStackTrace();
  88. }
  89. Assert.assertNotNull(catalog);*/
  90. }
  91. }