<?xml version="1.0" ?>
<Root>
    <TestCase name="testExportSales">
        <Resource name="output">
            <![CDATA[CREATE OR REPLACE FOREIGN DATA WRAPPER "SYS_COLUMN_STORE" LIBRARY 'class com.lucidera.lcs.LcsDataWrapper'
LANGUAGE JAVA;

CREATE OR REPLACE FOREIGN DATA WRAPPER "SYS_FILE_WRAPPER" LIBRARY 'class net.sf.farrago.namespace.flatfile.FlatFileDataWrapper'
LANGUAGE JAVA;

CREATE OR REPLACE FOREIGN DATA WRAPPER "SYS_FTRS" LIBRARY 'class net.sf.farrago.namespace.ftrs.FtrsDataWrapper'
LANGUAGE JAVA;

CREATE OR REPLACE FOREIGN DATA WRAPPER "SYS_JDBC" LIBRARY '${FARRAGO_HOME}/plugin/FarragoMedJdbc.jar'
LANGUAGE JAVA;

CREATE OR REPLACE FOREIGN DATA WRAPPER "SYS_MDR" LIBRARY 'class net.sf.farrago.namespace.mdr.MedMdrForeignDataWrapper'
LANGUAGE JAVA;

CREATE OR REPLACE FOREIGN DATA WRAPPER "SYS_MOCK" LIBRARY 'class net.sf.farrago.namespace.mock.MedMockLocalDataWrapper'
LANGUAGE JAVA;

CREATE OR REPLACE FOREIGN DATA WRAPPER "SYS_MOCK_FOREIGN" LIBRARY 'class net.sf.farrago.namespace.mock.MedMockForeignDataWrapper'
LANGUAGE JAVA;

CREATE OR REPLACE SCHEMA "SALES";

CREATE OR REPLACE SERVER "SYS_COLUMN_STORE_DATA_SERVER"
FOREIGN DATA WRAPPER "SYS_COLUMN_STORE";

CREATE OR REPLACE SERVER "SYS_FTRS_DATA_SERVER"
FOREIGN DATA WRAPPER "SYS_FTRS";

CREATE OR REPLACE SERVER "HSQLDB_DEMO"
FOREIGN DATA WRAPPER "SYS_JDBC"
OPTIONS (
  "DRIVER_CLASS" 'org.hsqldb.jdbcDriver',
  "TABLE_TYPES" 'TABLE,VIEW',
  "URL" 'jdbc:hsqldb:testcases/hsqldb/scott',
  "USER_NAME" 'SA'
);

CREATE OR REPLACE SERVER "SYS_CWM"
FOREIGN DATA WRAPPER "SYS_MDR"
OPTIONS (
  "ROOT_PACKAGE_NAME" 'CWM'
);

CREATE OR REPLACE SERVER "SYS_FEM"
FOREIGN DATA WRAPPER "SYS_MDR"
OPTIONS (
  "ROOT_PACKAGE_NAME" 'FEM'
);

CREATE OR REPLACE SERVER "SYS_MOF"
FOREIGN DATA WRAPPER "SYS_MDR"
OPTIONS (
  "ROOT_PACKAGE_NAME" 'MOF',
  "SCHEMA_NAME" 'MODEL'
);

CREATE OR REPLACE SERVER "SYS_MOCK_DATA_SERVER"
FOREIGN DATA WRAPPER "SYS_MOCK";

CREATE OR REPLACE SERVER "SYS_MOCK_FOREIGN_DATA_SERVER"
FOREIGN DATA WRAPPER "SYS_MOCK_FOREIGN";

CREATE OR REPLACE FUNCTION "DECRYPT_PUBLIC_KEY"(
  "K" VARBINARY(50))
RETURNS VARCHAR(25)
SPECIFIC "DECRYPT_PUBLIC_KEY"
LANGUAGE JAVA
NO SQL
NOT DETERMINISTIC
EXTERNAL NAME 'class net.sf.farrago.test.FarragoTestUDR.decryptPublicKey';

CREATE OR REPLACE FUNCTION "MAYBE_FEMALE"(
  "GENDER" CHAR(1))
RETURNS BOOLEAN
SPECIFIC "MAYBE_FEMALE"
LANGUAGE SQL
CONTAINS SQL
NOT DETERMINISTIC
RETURN NOT (("GENDER" = 'F') IS FALSE);

CREATE TABLE "DEPTS" (
   "DEPTNO" INTEGER NOT NULL,
   "NAME" VARCHAR(128) NOT NULL,
   PRIMARY KEY ("DEPTNO")
);

CREATE TABLE "EMPS" (
   "EMPNO" INTEGER NOT NULL,
   "NAME" VARCHAR(128) NOT NULL,
   "DEPTNO" INTEGER NOT NULL,
   "GENDER" CHAR(1) DEFAULT 'M',
   "CITY" VARCHAR(128),
   "EMPID" INTEGER NOT NULL,
   "AGE" INTEGER,
   "PUBLIC_KEY" VARBINARY(50),
   "SLACKER" BOOLEAN,
   "MANAGER" BOOLEAN NOT NULL,
   PRIMARY KEY ("EMPNO","DEPTNO")
);

CREATE TABLE "TEMPS" (
   "EMPNO" INTEGER NOT NULL,
   "NAME" VARCHAR(128) NOT NULL,
   "DEPTNO" INTEGER NOT NULL,
   "GENDER" CHAR(1),
   "CITY" VARCHAR(128),
   "EMPID" INTEGER DEFAULT 999 NOT NULL,
   "AGE" INTEGER,
   "PUBLIC_KEY" VARBINARY(50),
   "SLACKER" BOOLEAN,
   "MANAGER" BOOLEAN NOT NULL,
   PRIMARY KEY ("EMPNO","DEPTNO")
);

CREATE INDEX "EMPS_UX" ON "EMPS" ("NAME");

SET SCHEMA '"SALES"';
CREATE OR REPLACE VIEW "EMPSVIEW" AS
select empno, name from emps;

CREATE OR REPLACE VIEW "JOINVIEW" AS
select depts.name as dname,emps.name as ename
from emps inner join depts
on emps.deptno=depts.deptno;

CREATE OR REPLACE VIEW "TEMPSVIEW" AS
select empno, name from temps;

]]>
        </Resource>
        <Resource name="output-hibernate">
            <![CDATA[CREATE OR REPLACE FOREIGN DATA WRAPPER "SYS_COLUMN_STORE" LIBRARY 'class com.lucidera.lcs.LcsDataWrapper'
LANGUAGE JAVA;

CREATE OR REPLACE FOREIGN DATA WRAPPER "SYS_FILE_WRAPPER" LIBRARY 'class net.sf.farrago.namespace.flatfile.FlatFileDataWrapper'
LANGUAGE JAVA;

CREATE OR REPLACE FOREIGN DATA WRAPPER "SYS_FTRS" LIBRARY 'class net.sf.farrago.namespace.ftrs.FtrsDataWrapper'
LANGUAGE JAVA;

CREATE OR REPLACE FOREIGN DATA WRAPPER "SYS_JDBC" LIBRARY '${FARRAGO_HOME}/plugin/FarragoMedJdbc.jar'
LANGUAGE JAVA;

CREATE OR REPLACE FOREIGN DATA WRAPPER "SYS_MDR" LIBRARY 'class net.sf.farrago.namespace.mdr.MedMdrForeignDataWrapper'
LANGUAGE JAVA;

CREATE OR REPLACE FOREIGN DATA WRAPPER "SYS_MOCK" LIBRARY 'class net.sf.farrago.namespace.mock.MedMockLocalDataWrapper'
LANGUAGE JAVA;

CREATE OR REPLACE FOREIGN DATA WRAPPER "SYS_MOCK_FOREIGN" LIBRARY 'class net.sf.farrago.namespace.mock.MedMockForeignDataWrapper'
LANGUAGE JAVA;

CREATE OR REPLACE SCHEMA "SALES";

CREATE OR REPLACE SERVER "SYS_COLUMN_STORE_DATA_SERVER"
FOREIGN DATA WRAPPER "SYS_COLUMN_STORE";

CREATE OR REPLACE SERVER "SYS_FTRS_DATA_SERVER"
FOREIGN DATA WRAPPER "SYS_FTRS";

CREATE OR REPLACE SERVER "HSQLDB_DEMO"
FOREIGN DATA WRAPPER "SYS_JDBC"
OPTIONS (
  "DRIVER_CLASS" 'org.hsqldb.jdbcDriver',
  "TABLE_TYPES" 'TABLE,VIEW',
  "URL" 'jdbc:hsqldb:testcases/hsqldb/scott',
  "USER_NAME" 'SA'
);

CREATE OR REPLACE SERVER "SYS_CWM"
FOREIGN DATA WRAPPER "SYS_JDBC"
OPTIONS (
  "JNDI_NAME" 'java:ENKI_DATASOURCE',
  "SCHEMA_NAME" 'DUMMY',
  "TABLE_PREFIX_MAPPING" '%.FEM_VT_Behavioral_%:Behavioral.%;%.FEM_VT_Core_%:Core.%;%.FEM_VT_DataTypes_%:DataTypes.%;%.FEM_VT_Instance_%:Instance.%;%.FEM_VT_KeysIndexes_%:KeysIndexes.%;%.FEM_VT_Relational_%:Relational.%'
);

CREATE OR REPLACE SERVER "SYS_FEM"
FOREIGN DATA WRAPPER "SYS_JDBC"
OPTIONS (
  "JNDI_NAME" 'java:ENKI_DATASOURCE',
  "SCHEMA_NAME" 'DUMMY',
  "TABLE_PREFIX_MAPPING" '%.FEM_VT_Config_%:Config.%;%.FEM_VT_Med_%:MED.%;%.FEM_VT_Security_%:Security.%;%.FEM_VT_Sql2003_%:SQL2003.%'
);

CREATE OR REPLACE SERVER "SYS_MOF"
FOREIGN DATA WRAPPER "SYS_MDR"
OPTIONS (
  "ROOT_PACKAGE_NAME" 'MOF',
  "SCHEMA_NAME" 'MODEL'
);

CREATE OR REPLACE SERVER "SYS_MOCK_DATA_SERVER"
FOREIGN DATA WRAPPER "SYS_MOCK";

CREATE OR REPLACE SERVER "SYS_MOCK_FOREIGN_DATA_SERVER"
FOREIGN DATA WRAPPER "SYS_MOCK_FOREIGN";

CREATE OR REPLACE FUNCTION "DECRYPT_PUBLIC_KEY"(
  "K" VARBINARY(50))
RETURNS VARCHAR(25)
SPECIFIC "DECRYPT_PUBLIC_KEY"
LANGUAGE JAVA
NO SQL
NOT DETERMINISTIC
EXTERNAL NAME 'class net.sf.farrago.test.FarragoTestUDR.decryptPublicKey';

CREATE OR REPLACE FUNCTION "MAYBE_FEMALE"(
  "GENDER" CHAR(1))
RETURNS BOOLEAN
SPECIFIC "MAYBE_FEMALE"
LANGUAGE SQL
CONTAINS SQL
NOT DETERMINISTIC
RETURN NOT (("GENDER" = 'F') IS FALSE);

CREATE TABLE "DEPTS" (
   "DEPTNO" INTEGER NOT NULL,
   "NAME" VARCHAR(128) NOT NULL,
   PRIMARY KEY ("DEPTNO")
);

CREATE TABLE "EMPS" (
   "EMPNO" INTEGER NOT NULL,
   "NAME" VARCHAR(128) NOT NULL,
   "DEPTNO" INTEGER NOT NULL,
   "GENDER" CHAR(1) DEFAULT 'M',
   "CITY" VARCHAR(128),
   "EMPID" INTEGER NOT NULL,
   "AGE" INTEGER,
   "PUBLIC_KEY" VARBINARY(50),
   "SLACKER" BOOLEAN,
   "MANAGER" BOOLEAN NOT NULL,
   PRIMARY KEY ("EMPNO","DEPTNO")
);

CREATE TABLE "TEMPS" (
   "EMPNO" INTEGER NOT NULL,
   "NAME" VARCHAR(128) NOT NULL,
   "DEPTNO" INTEGER NOT NULL,
   "GENDER" CHAR(1),
   "CITY" VARCHAR(128),
   "EMPID" INTEGER DEFAULT 999 NOT NULL,
   "AGE" INTEGER,
   "PUBLIC_KEY" VARBINARY(50),
   "SLACKER" BOOLEAN,
   "MANAGER" BOOLEAN NOT NULL,
   PRIMARY KEY ("EMPNO","DEPTNO")
);

CREATE INDEX "EMPS_UX" ON "EMPS" ("NAME");

SET SCHEMA '"SALES"';
CREATE OR REPLACE VIEW "EMPSVIEW" AS
select empno, name from emps;

CREATE OR REPLACE VIEW "JOINVIEW" AS
select depts.name as dname,emps.name as ename
from emps inner join depts
on emps.deptno=depts.deptno;

CREATE OR REPLACE VIEW "TEMPSVIEW" AS
select empno, name from temps;

]]>
        </Resource>
    </TestCase>
    <TestCase name="testDdlGeneration">
        <Resource name="output">
            <![CDATA[CREATE OR REPLACE FOREIGN DATA WRAPPER "TESTWRAPPER"
LANGUAGE JAVA

CREATE OR REPLACE SERVER "TESTSERVER"
FOREIGN DATA WRAPPER "TESTWRAPPER"

CREATE OR REPLACE FOREIGN DATA WRAPPER "TESTWRAPPER" LIBRARY 'net.sf.farrago.TestWrapper'
LANGUAGE JAVA

CREATE OR REPLACE SERVER "TESTSERVER" TYPE 'TESTTYPE'
FOREIGN DATA WRAPPER "TESTWRAPPER"

CREATE OR REPLACE SERVER "TESTSERVER" TYPE 'TESTTYPE' VERSION 'TESTVERSION'
FOREIGN DATA WRAPPER "TESTWRAPPER"

DROP SERVER "TESTSERVER"

DROP FOREIGN DATA WRAPPER "TESTWRAPPER"

]]>
        </Resource>
    </TestCase>
    <TestCase name="testCustomSchema">
        <Resource name="output">
            <![CDATA[CREATE OR REPLACE FOREIGN DATA WRAPPER "SYS_COLUMN_STORE" LIBRARY 'class com.lucidera.lcs.LcsDataWrapper'
LANGUAGE JAVA;

CREATE OR REPLACE FOREIGN DATA WRAPPER "SYS_FILE_WRAPPER" LIBRARY 'class net.sf.farrago.namespace.flatfile.FlatFileDataWrapper'
LANGUAGE JAVA;

CREATE OR REPLACE FOREIGN DATA WRAPPER "SYS_FTRS" LIBRARY 'class net.sf.farrago.namespace.ftrs.FtrsDataWrapper'
LANGUAGE JAVA;

CREATE OR REPLACE FOREIGN DATA WRAPPER "SYS_JDBC" LIBRARY '${FARRAGO_HOME}/plugin/FarragoMedJdbc.jar'
LANGUAGE JAVA;

CREATE OR REPLACE FOREIGN DATA WRAPPER "SYS_MDR" LIBRARY 'class net.sf.farrago.namespace.mdr.MedMdrForeignDataWrapper'
LANGUAGE JAVA;

CREATE OR REPLACE FOREIGN DATA WRAPPER "SYS_MOCK" LIBRARY 'class net.sf.farrago.namespace.mock.MedMockLocalDataWrapper'
LANGUAGE JAVA;

CREATE OR REPLACE FOREIGN DATA WRAPPER "SYS_MOCK_FOREIGN" LIBRARY 'class net.sf.farrago.namespace.mock.MedMockForeignDataWrapper'
LANGUAGE JAVA;

CREATE OR REPLACE FOREIGN DATA WRAPPER "TEST_MDR" LIBRARY 'class net.sf.farrago.namespace.mdr.MedMdrForeignDataWrapper'
LANGUAGE JAVA
DESCRIPTION 'private data wrapper for mdr';

CREATE OR REPLACE SCHEMA "DDLGEN";

CREATE OR REPLACE SERVER "SYS_COLUMN_STORE_DATA_SERVER"
FOREIGN DATA WRAPPER "SYS_COLUMN_STORE";

CREATE OR REPLACE SERVER "SYS_FTRS_DATA_SERVER"
FOREIGN DATA WRAPPER "SYS_FTRS";

CREATE OR REPLACE SERVER "HSQLDB_DEMO"
FOREIGN DATA WRAPPER "SYS_JDBC"
OPTIONS (
  "DRIVER_CLASS" 'org.hsqldb.jdbcDriver',
  "URL" 'jdbc:hsqldb:testcases/hsqldb/scott',
  "USER_NAME" 'SA',
  "TABLE_TYPES" 'TABLE,VIEW'
);

CREATE OR REPLACE SERVER "SYS_CWM"
FOREIGN DATA WRAPPER "SYS_MDR"
OPTIONS (
  "ROOT_PACKAGE_NAME" 'CWM'
);

CREATE OR REPLACE SERVER "SYS_FEM"
FOREIGN DATA WRAPPER "SYS_MDR"
OPTIONS (
  "ROOT_PACKAGE_NAME" 'FEM'
);

CREATE OR REPLACE SERVER "SYS_MOF"
FOREIGN DATA WRAPPER "SYS_MDR"
OPTIONS (
  "ROOT_PACKAGE_NAME" 'MOF',
  "SCHEMA_NAME" 'MODEL'
);

CREATE OR REPLACE SERVER "SYS_MOCK_DATA_SERVER"
FOREIGN DATA WRAPPER "SYS_MOCK";

CREATE OR REPLACE SERVER "SYS_MOCK_FOREIGN_DATA_SERVER"
FOREIGN DATA WRAPPER "SYS_MOCK_FOREIGN";

CREATE OR REPLACE SERVER "MOF_SERVER_TEST"
FOREIGN DATA WRAPPER "TEST_MDR"
OPTIONS (
  "EXTENT_NAME" 'MOF',
  "SCHEMA_NAME" 'Model',
  "org.netbeans.mdr.persistence.Dir" 'unitsql/ddl/mdr'
)
DESCRIPTION 'a server';

CREATE OR REPLACE TYPE "SIMOLEAN_CURRENCY" AS DOUBLE
FINAL
INSTANTIABLE
DESCRIPTION 'a distinct type';

CREATE OR REPLACE TYPE "PLAYING_CARD" AS (
   "CARD_SUIT" CHAR(1),
   "CARD_RANK" INTEGER
)
FINAL
INSTANTIABLE
DESCRIPTION 'an object type'
CONSTRUCTOR METHOD "PLAYING_CARD" (
  "CARD_SUIT_INIT" CHAR(1),
  "CARD_RANK_INIT" INTEGER)
RETURNS DDLGEN.PLAYING_CARD
SELF AS RESULT
SPECIFIC "PLAYING_CARD"
LANGUAGE SQL
CONTAINS SQL
NOT DETERMINISTIC;

CREATE OR REPLACE FUNCTION "DECRYPT_PUBLIC_KEY"(
  "K" VARBINARY(50))
RETURNS VARCHAR(25)
SPECIFIC "DECRYPT_PUBLIC_KEY"
LANGUAGE JAVA
NO SQL
NOT DETERMINISTIC
EXTERNAL NAME 'class net.sf.farrago.test.FarragoTestUDR.decryptPublicKey';

CREATE OR REPLACE SPECIFIC METHOD "PLAYING_CARD"
FOR "PLAYING_CARD"
BEGIN SET SELF."CARD_SUIT" = "CARD_SUIT_INIT"; SET SELF."CARD_RANK" = "CARD_RANK_INIT"; RETURN SELF; END;

CREATE TABLE "TEMPTAB" (
   "X" CHAR(3) NOT NULL,
   "Y" VARBINARY(10),
   PRIMARY KEY ("X")
)
DESCRIPTION 'a temp table';

CREATE FOREIGN TABLE "MOF_EXCEPTION" (
   "NAME" CHAR(20),
   "ANNOTATION" VARCHAR(128),
   "CONTAINER" VARCHAR(128),
   "SCOPE" VARCHAR(128),
   "VISIBILITY" VARCHAR(128),
   "mofId" VARCHAR(128),
   "mofClassName" VARCHAR(128)
)
SERVER "MOF_SERVER_TEST"
OPTIONS (
  "CLASS_NAME" 'Exception'
)
DESCRIPTION 'a foreign table';

CREATE OR REPLACE FUNCTION "COMPARE_CARDS_SPADES_TRUMP"(
  "C1" PLAYING_CARD,
  "C2" PLAYING_CARD)
RETURNS INTEGER
SPECIFIC "COMPARE_CARDS_SPADES_TRUMP"
LANGUAGE SQL
CONTAINS SQL
DETERMINISTIC
RETURN CASE WHEN "C1"."CARD_SUIT" = 'S' AND "C2"."CARD_SUIT" <> 'S' THEN 1 WHEN "C2"."CARD_SUIT" = 'S' AND "C1"."CARD_SUIT" <> 'S' THEN -1 WHEN "C1"."CARD_RANK" > "C2"."CARD_RANK" THEN 1 WHEN "C1"."CARD_RANK" < "C2"."CARD_RANK" THEN -1 ELSE 0 END;

CREATE OR REPLACE VIEW "V"
DESCRIPTION 'a view' AS
select * FROM ddlgen.temptab WHERE x IS NOT NULL;

CREATE OR REPLACE VIEW "V2" AS
select * FROM v, temptab;

CREATE OR REPLACE VIEW "V3" AS
select * FROM v, v2;

CREATE OR REPLACE VIEW "AVIEW" AS
select decrypt_public_key(v3.y) FROM v3, v;

]]>
        </Resource>
    </TestCase>
    <TestCase name="testCascade">
    	<Resource name="output">
    		<![CDATA[DROP SCHEMA "CASCADE_TEST" CASCADE

DROP SCHEMA "CASCADE_TEST"

DROP TABLE "FOO" CASCADE

DROP TABLE "FOO"

DROP VIEW "BAR" CASCADE

DROP VIEW "BAR"

]]>
    	</Resource>
    </TestCase>
</Root>
