-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
752 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
component extends="org.lucee.cfml.test.LuceeTestCase" labels="orm" { | ||
|
||
public void function testAutoGenMap(){ | ||
|
||
local.uri=createURI("autogenmap/index.cfm"); | ||
local.result=_InternalRequest(uri); | ||
expect( result.status ).toBe( 200 ); | ||
// var res = deserializeJson(result.fileContent); | ||
// if (len(res.errors)){ | ||
// loop array=res.errors, item="local.err"{ | ||
// systemOutput("ERROR: " & err.error, true, true); | ||
// } | ||
// } | ||
} | ||
|
||
private string function createURI(string calledName){ | ||
systemOutput("", true); | ||
systemOutput("-------------- #calledName#----------------", true); | ||
var baseURI = getDirectoryFromPath( contractPath( getCurrentTemplatePath() ) ); | ||
return baseURI&""&calledName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
component { | ||
|
||
this.name = "orm-autogenmap"; | ||
this.datasources["h2"] = server.getDatasource("h2", "#getDirectoryFromPath(getCurrentTemplatePath())#/datasource/db" ); | ||
this.datasources["h2_otherDB"] = server.getDatasource("h2", "#getDirectoryFromPath(getCurrentTemplatePath())#/datasource/otherDB" ); | ||
this.ormEnabled = true; | ||
this.ormSettings = { | ||
dbcreate: "dropcreate", | ||
dialect: "h2", | ||
skipCFCWithError : false, | ||
datasource : "h2", | ||
autogenmap : false | ||
}; | ||
|
||
function onApplicationStart() { | ||
} | ||
|
||
public function onRequestStart() { | ||
setting requesttimeout=10; | ||
if ( url.keyExists( "flushcache" ) ){ | ||
componentCacheClear(); | ||
} | ||
} | ||
|
||
function onRequestEnd() { | ||
var javaIoFile=createObject("java","java.io.File"); | ||
loop array = DirectoryList( | ||
path = getDirectoryFromPath( getCurrentTemplatePath() ), | ||
recurse = true, filter="*.db") item="local.path" { | ||
fileDeleteOnExit(javaIoFile,path); | ||
} | ||
} | ||
|
||
private function fileDeleteOnExit(required javaIoFile, required string path) { | ||
var file=javaIoFile.init(arguments.path); | ||
if(!file.isFile())file=javaIoFile.init(expandPath(arguments.path)); | ||
if(file.isFile()) file.deleteOnExit(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
component persistent="true" { | ||
|
||
property name="id" type="string" fieldtype="id" ormtype="string"; | ||
property name="make" type="string"; | ||
property name="model" type="string"; | ||
|
||
this.name = "Auto"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> | ||
<hibernate-mapping> | ||
<class entity-name="Auto" lazy="true" node="testAdditional.autogenmap.Auto" table="Auto"> | ||
<id name="id" type="string"> | ||
<column name="id"/> | ||
</id> | ||
<property name="make" type="string"> | ||
<column name="make"/> | ||
</property> | ||
<property name="model" type="string"> | ||
<column name="model"/> | ||
</property> | ||
</class> | ||
</hibernate-mapping> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
component persistent="true" datasource="h2_otherDB" { | ||
|
||
property name="id" type="string" fieldtype="id" ormtype="string"; | ||
property name="name" type="string"; | ||
|
||
this.name = "Dealership"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> | ||
<hibernate-mapping> | ||
<class entity-name="Dealership" lazy="true" node="testAdditional.autogenmap.Dealership" table="Dealership"> | ||
<id name="id" type="string"> | ||
<column name="id"/> | ||
</id> | ||
<property name="name" type="string"> | ||
<column name="name"/> | ||
</property> | ||
</class> | ||
</hibernate-mapping> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<cfscript> | ||
transaction{ | ||
car = entityNew( "Auto" ); | ||
car.setId( createUUID() ); | ||
car.setMake( "Ford" ); | ||
car.setModel( "F-150" ); | ||
entitySave( car ); | ||
dealer = entityNew( "Dealership" ); | ||
dealer.setId( createUUID() ); | ||
dealer.setName( "Sedgewick Subaru" ); | ||
entitySave( dealer ); | ||
ormFlush(); | ||
} | ||
autoResults = queryExecute( "SELECT * FROM Auto WHERE id=:id", { id : car.getId() }, { datasource: "h2" } ); | ||
if ( !autoResults.recordCount ){ | ||
throw( "auto #car.getId()# not found in datasource table" ); | ||
} | ||
dealerResults = queryExecute( "SELECT * FROM Dealership WHERE id=:id", { id : dealer.getId() }, { datasource: "h2_otherDB" } ); | ||
if ( !dealerResults.recordCount ){ | ||
throw( "Dealership #dealer.getId()# not found in datasource table" ); | ||
} | ||
</cfscript> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
component extends="org.lucee.cfml.test.LuceeTestCase" labels="orm" { | ||
|
||
public void function testDatasources(){ | ||
|
||
local.uri=createURI("datasources/index.cfm"); | ||
local.result=_InternalRequest(uri); | ||
expect( result.status ).toBe( 200 ); | ||
// var res = deserializeJson(result.fileContent); | ||
// if (len(res.errors)){ | ||
// loop array=res.errors, item="local.err"{ | ||
// systemOutput("ERROR: " & err.error, true, true); | ||
// } | ||
// } | ||
} | ||
|
||
private string function createURI(string calledName){ | ||
systemOutput("", true); | ||
systemOutput("-------------- #calledName#----------------", true); | ||
var baseURI = getDirectoryFromPath( contractPath( getCurrentTemplatePath() ) ); | ||
return baseURI&""&calledName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
component { | ||
|
||
this.name = "orm-datasources"; | ||
this.datasources["h2"] = server.getDatasource("h2", "#getDirectoryFromPath(getCurrentTemplatePath())#/datasource/db" ); | ||
this.datasources["h2_otherDB"] = server.getDatasource("h2", "#getDirectoryFromPath(getCurrentTemplatePath())#/datasource/otherDB" ); | ||
this.ormEnabled = true; | ||
this.ormSettings = { | ||
dbcreate: "dropcreate", | ||
dialect: "h2", | ||
skipCFCWithError : false, | ||
datasource : "h2", | ||
saveMapping : false | ||
}; | ||
|
||
function onApplicationStart() { | ||
} | ||
|
||
public function onRequestStart() { | ||
setting requesttimeout=10; | ||
if ( url.keyExists( "flushcache" ) ){ | ||
componentCacheClear(); | ||
} | ||
} | ||
|
||
function onRequestEnd() { | ||
var javaIoFile=createObject("java","java.io.File"); | ||
loop array = DirectoryList( | ||
path = getDirectoryFromPath( getCurrentTemplatePath() ), | ||
recurse = true, filter="*.db") item="local.path" { | ||
fileDeleteOnExit(javaIoFile,path); | ||
} | ||
} | ||
|
||
private function fileDeleteOnExit(required javaIoFile, required string path) { | ||
var file=javaIoFile.init(arguments.path); | ||
if(!file.isFile())file=javaIoFile.init(expandPath(arguments.path)); | ||
if(file.isFile()) file.deleteOnExit(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
component persistent="true" { | ||
|
||
property name="id" type="string" fieldtype="id" ormtype="string"; | ||
property name="make" type="string"; | ||
property name="model" type="string"; | ||
|
||
this.name = "Auto"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> | ||
<hibernate-mapping> | ||
<!-- | ||
source:/home/michael/server/lucee/extension-hibernate/tests/datasources/Auto.cfc | ||
compilation-time:{ts '2023-02-01 14:31:06'} | ||
datasource:h2 | ||
--> | ||
<class entity-name="Auto" lazy="true" node="testAdditional.datasources.Auto" table="Auto"> | ||
<id name="id" type="string"> | ||
<column name="id"/> | ||
</id> | ||
<property name="make" type="string"> | ||
<column name="make"/> | ||
</property> | ||
<property name="model" type="string"> | ||
<column name="model"/> | ||
</property> | ||
</class> | ||
</hibernate-mapping> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
component persistent="true" datasource="h2_otherDB" { | ||
|
||
property name="id" type="string" fieldtype="id" ormtype="string"; | ||
property name="name" type="string"; | ||
|
||
this.name = "Dealership"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> | ||
<hibernate-mapping> | ||
<!-- | ||
source:/home/michael/server/lucee/extension-hibernate/tests/datasources/Dealership.cfc | ||
compilation-time:{ts '2023-02-01 14:31:06'} | ||
datasource:h2_otherDB | ||
--> | ||
<class entity-name="Dealership" lazy="true" node="testAdditional.datasources.Dealership" table="Dealership"> | ||
<id name="id" type="string"> | ||
<column name="id"/> | ||
</id> | ||
<property name="name" type="string"> | ||
<column name="name"/> | ||
</property> | ||
</class> | ||
</hibernate-mapping> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<cfscript> | ||
transaction{ | ||
car = entityNew( "Auto" ); | ||
car.setId( createUUID() ); | ||
car.setMake( "Ford" ); | ||
car.setModel( "F-150" ); | ||
entitySave( car ); | ||
dealer = entityNew( "Dealership" ); | ||
dealer.setId( createUUID() ); | ||
dealer.setName( "Sedgewick Subaru" ); | ||
entitySave( dealer ); | ||
ormFlush(); | ||
} | ||
autoResults = queryExecute( "SELECT * FROM Auto WHERE id=:id", { id : car.getId() }, { datasource: "h2" } ); | ||
if ( !autoResults.recordCount ){ | ||
throw( "auto #car.getId()# not found in datasource table" ); | ||
} | ||
dealerResults = queryExecute( "SELECT * FROM Dealership WHERE id=:id", { id : dealer.getId() }, { datasource: "h2_otherDB" } ); | ||
if ( !dealerResults.recordCount ){ | ||
throw( "Dealership #dealer.getId()# not found in datasource table" ); | ||
} | ||
</cfscript> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
version: "3.9" | ||
services: | ||
|
||
mysql: | ||
platform: linux/x86_64 # Needed for Mac's on the M1 chip | ||
image: mysql:5 | ||
environment: | ||
MYSQL_DATABASE: ${MYSQL_DATABASE} | ||
MYSQL_ROOT_PASSWORD: ${MYSQL_PASSWORD} | ||
ports: | ||
- "${MYSQL_PORT}:3306" | ||
|
||
postgres: | ||
image: postgres:11.3 | ||
environment: | ||
POSTGRES_USER: ${POSTGRES_USERNAME} | ||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} | ||
POSTGRES_DB: ${POSTGRES_DATABASE} | ||
ports: | ||
- "${POSTGRES_PORT}:5432" | ||
|
||
mssql: | ||
image: mcr.microsoft.com/mssql/server:2017-latest | ||
environment: | ||
MSSQL_SA_PASSWORD: ${MSSQL_PASSWORD} | ||
ACCEPT_EULA: "Y" | ||
MSSQL_PID: "Developer" | ||
volumes: | ||
# Mounted entrypoint for initdb scripts | ||
- ./docker/mssql:/docker-entrypoint-initdb.d | ||
ports: | ||
- "${MSSQL_PORT}:1433" | ||
entrypoint: /docker-entrypoint-initdb.d/entrypoint.sh /opt/mssql/bin/sqlservr | ||
|
||
# TODO: Re-enable when MongoDB testing is fixed in Lucee 6 | ||
# mongo: | ||
# image: mongo | ||
# environment: | ||
# MONGO_INITDB_ROOT_USERNAME: ${MONGODB_USERNAME} | ||
# MONGO_INITDB_ROOT_PASSWORD: ${MONGODB_PASSWORD} | ||
# MONGO_INITDB_DATABASE: ${MONGODB_DB} | ||
# volumes: | ||
# - ./docker/mongo:/docker-entrypoint-initdb.d | ||
# ports: | ||
# - "${MONGODB_PORT}:27017" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CREATE DATABASE hibernateDB; | ||
GO | ||
USE hibernateDB; | ||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
if [ "$1" = '/opt/mssql/bin/sqlservr' ]; then | ||
# If this is the container's first run, initialize the application database | ||
if [ ! -f /tmp/app-initialized ]; then | ||
# Initialize the application database asynchronously in a background process. This allows a) the SQL Server process to be the main process in the container, which allows graceful shutdown and other goodies, and b) us to only start the SQL Server process once, as opposed to starting, stopping, then starting it again. | ||
function initialize_app_database() { | ||
# Wait a bit for SQL Server to start. SQL Server's process doesn't provide a clever way to check if it's up or not, and it needs to be up before we can import the application database | ||
sleep 10s | ||
|
||
#run the setup script to create the DB and the schema in the DB | ||
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P hib3rnate_DB -d master -i /docker-entrypoint-initdb.d/create.sql | ||
|
||
# Note that the container has been initialized so future starts won't wipe changes to the data | ||
touch /tmp/app-initialized | ||
} | ||
initialize_app_database & | ||
fi | ||
fi | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
component extends="org.lucee.cfml.test.LuceeTestCase" labels="orm" { | ||
|
||
public void function testEHCache(){ | ||
|
||
local.uri=createURI("ehcache/index.cfm"); | ||
local.result=_InternalRequest(uri); | ||
expect( result.status ).toBe( 200 ); | ||
// var res = deserializeJson(result.fileContent); | ||
// if (len(res.errors)){ | ||
// loop array=res.errors, item="local.err"{ | ||
// systemOutput("ERROR: " & err.error, true, true); | ||
// } | ||
// } | ||
} | ||
|
||
private string function createURI(string calledName){ | ||
systemOutput("", true); | ||
systemOutput("-------------- #calledName#----------------", true); | ||
var baseURI = getDirectoryFromPath( contractPath( getCurrentTemplatePath() ) ); | ||
return baseURI&""&calledName; | ||
} | ||
} |
Oops, something went wrong.