forked from lucee/extension-hibernate
/
configXMLTest.cfc
79 lines (73 loc) · 2.33 KB
/
configXMLTest.cfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
component extends="testbox.system.BaseSpec" {
public void function run(){
/**
* TODO: Get these tests to pass!
*/
describe( "ormConfig.xml", () => {
beforeEach( () => {
var result = _internalRequest( "/tests/testApp/index.cfm?reinitApp=true" );
variables.ormSettings = {
dbcreate : "dropcreate",
ormConfig : "/tests/resources/hibernate.cfg.xml"
};
} );
it( "can set ad hoc config properties in Hibernate SessionFactory", () => {
var xml = "
<!DOCTYPE hibernate-configuration PUBLIC
""-//Hibernate/Hibernate Configuration DTD 3.0//EN""
""http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"">
<hibernate-configuration>
<session-factory>
<property name=""hibernate.session_factory_name"">OrtusForTheWin</property>
<property name=""hibernate.globally_quoted_identifiers"">true</property>
</session-factory>
</hibernate-configuration>";
fileWrite( "/tests/resources/hibernate.cfg.xml", xml );
var theTest = () => {
ormReload();
ormGetSession();
var factoryName = ormGetSessionFactory().getSessionFactoryOptions().getSessionFactoryName();
if ( factoryName != "OrtusForTheWin" ) {
throw( "expected factoryName '#factoryName#' to be 'bla-bla.test'" );
}
};
var result = _internalRequest(
template: "/tests/testApp/index.cfm",
forms : {
ormSettings : serializeJSON( variables.ormSettings ),
closure : serialize( theTest )
}
);
} );
/**
* We ensure invalid XML files do not throw, for backwards compatibility.
*
* TODO: Next major bump should flip this to a .toThrow() test.
*/
it( "DOES NOT throw on invalid XML", () => {
var xml = "
<?xml version = ""1.0"" encoding = ""utf-8""?>
<!DOCTYPE hibernate-configuration SYSTEM
""http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"">
<hibernate-configuration>
<ba ba black sheep...
</hibernate-configuration>
";
fileWrite( "/tests/resources/hibernate.cfg.xml", xml );
ormGetSession();
var theTest = () => {
};
expect( () => {
_internalRequest(
template: "/tests/testApp/index.cfm",
url : { "ormReload" : true },
forms : {
ormSettings : serializeJSON( variables.ormSettings ),
closure : serialize( theTest )
}
);
} ).notToThrow();
} );
} )
}
}