-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Various updates and fixes to the test suite to get the hibernate test…
…s running
- Loading branch information
1 parent
b5093d2
commit edf1ea7
Showing
21 changed files
with
464 additions
and
31 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
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
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
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
85 changes: 85 additions & 0 deletions
85
...astore-gorm-hibernate/src/test/groovy/grails/gorm/tests/CommonTypesPersistenceSpec.groovy
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,85 @@ | ||
package grails.gorm.tests | ||
|
||
import java.io.Serializable; | ||
import java.net.URL; | ||
import java.util.Calendar; | ||
import java.util.Currency; | ||
import java.util.Date; | ||
import java.util.Locale; | ||
import java.util.TimeZone; | ||
|
||
/** | ||
* Created by IntelliJ IDEA. | ||
* User: graemerocher | ||
* Date: Aug 30, 2010 | ||
* Time: 11:49:01 AM | ||
* To change this template use File | Settings | File Templates. | ||
*/ | ||
class CommonTypesPersistenceSpec extends GormDatastoreSpec { | ||
|
||
def testPersistBasicTypes() { | ||
given: | ||
def now = new Date() | ||
def cal = new GregorianCalendar() | ||
def ct = new CommonTypes( | ||
l: 10L, | ||
b: 10 as byte, | ||
s: 10 as short, | ||
bool: true, | ||
i: 10, | ||
url: new URL("http://google.com"), | ||
date: now, | ||
c: cal, | ||
bd: 1.0, | ||
bi: 10 as BigInteger, | ||
d: 1.0 as Double, | ||
f: 1.0 as Float, | ||
tz: TimeZone.getTimeZone("GMT"), | ||
loc: Locale.UK, | ||
cur: Currency.getInstance("USD") | ||
) | ||
|
||
when: | ||
ct.save(flush:true) | ||
ct.discard() | ||
ct = CommonTypes.get(ct.id) | ||
|
||
then: | ||
ct | ||
10L == ct.l | ||
(10 as byte) == ct.b | ||
(10 as short) == ct.s | ||
true == ct.bool | ||
10 == ct.i | ||
new URL("http://google.com") == ct.url | ||
cal == ct.c | ||
1.0 == ct.bd | ||
10 as BigInteger == ct.bi | ||
(1.0 as Double) == ct.d | ||
(1.0 as Float) == ct.f | ||
TimeZone.getTimeZone("GMT") == ct.tz | ||
Locale.UK == ct.loc | ||
Currency.getInstance("USD") == ct.cur | ||
} | ||
|
||
} | ||
|
||
class CommonTypes implements Serializable{ | ||
Long id | ||
Long version | ||
Long l | ||
Byte b | ||
Short s | ||
Boolean bool | ||
Integer i | ||
URL url | ||
Date date | ||
Calendar c | ||
BigDecimal bd | ||
BigInteger bi | ||
Double d | ||
Float f | ||
TimeZone tz | ||
Locale loc | ||
Currency cur | ||
} |
41 changes: 41 additions & 0 deletions
41
grails-datastore-gorm-hibernate/src/test/groovy/grails/gorm/tests/GroovyProxySpec.groovy
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,41 @@ | ||
package grails.gorm.tests | ||
|
||
import spock.lang.Ignore; | ||
|
||
/** | ||
* Created by IntelliJ IDEA. | ||
* User: graemerocher | ||
* Date: Sep 3, 2010 | ||
* Time: 11:19:36 AM | ||
* To change this template use File | Settings | File Templates. | ||
*/ | ||
class GroovyProxySpec extends GormDatastoreSpec{ | ||
|
||
@Ignore | ||
void "Test creation and behavior of Groovy proxies"() { | ||
|
||
given: | ||
session.mappingContext.proxyFactory = new org.grails.datastore.gorm.proxy.GroovyProxyFactory() | ||
def id = new Location(name:"United Kingdom", code:"UK").save(flush:true)?.id | ||
session.clear() | ||
|
||
|
||
when: | ||
def location = Location.proxy(id) | ||
|
||
then: | ||
|
||
location != null | ||
id == location.id | ||
false == location.isInitialized() | ||
false == location.initialized | ||
|
||
"UK" == location.code | ||
"United Kingdom - UK" == location.namedAndCode() | ||
true == location.isInitialized() | ||
true == location.initialized | ||
null != location.target | ||
|
||
|
||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
grails-datastore-gorm-hibernate/src/test/groovy/grails/gorm/tests/ValidationSpec.groovy
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,87 @@ | ||
package grails.gorm.tests | ||
|
||
import org.springframework.validation.Errors | ||
import org.springframework.datastore.mapping.validation.ValidatingInterceptor | ||
import spock.lang.Ignore; | ||
|
||
/** | ||
* Abstract base class for testing validation semantics | ||
*/ | ||
|
||
@Ignore | ||
class ValidationSpec extends GormDatastoreSpec{ | ||
|
||
void "Test disable validation"() { | ||
session.datastore.addEntityInterceptor(new ValidatingInterceptor()) | ||
// test assumes name cannot be blank | ||
given: | ||
def t | ||
|
||
when: | ||
t = new TestEntity(name:"", child:new ChildEntity(name:"child")) | ||
Errors errors = t.errors | ||
|
||
then: | ||
t.validate() == false | ||
t.hasErrors() == true | ||
errors != null | ||
errors.hasErrors() == true | ||
|
||
when: | ||
t.save(validate:false, flush:true) | ||
|
||
then: | ||
t.id != null | ||
!t.hasErrors() | ||
|
||
} | ||
|
||
|
||
|
||
void "Test validate() method"() { | ||
// test assumes name cannot be blank | ||
given: | ||
def t | ||
when: | ||
t = new TestEntity(name:"") | ||
Errors errors = t.errors | ||
then: | ||
t.validate() == false | ||
t.hasErrors() == true | ||
errors != null | ||
errors.hasErrors() == true | ||
when: | ||
t.clearErrors() | ||
then: | ||
t.hasErrors() == false | ||
} | ||
void "Test that validate is called on save()"() { | ||
given: | ||
def t | ||
when: | ||
t = new TestEntity(name:"") | ||
then: | ||
t.save() == null | ||
t.hasErrors() == true | ||
0 == TestEntity.count() | ||
when: | ||
t.clearErrors() | ||
t.name = "Bob" | ||
t.age = 45 | ||
t.child = new ChildEntity(name:"Fred") | ||
t = t.save() | ||
then: | ||
t != null | ||
1 == TestEntity.count() | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...-datastore-gorm-hibernate/src/test/groovy/org/grails/datastore/gorm/HibernateSuite.groovy
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,57 @@ | ||
package org.grails.datastore.gorm | ||
|
||
import grails.gorm.tests.AttachMethodSpec | ||
import grails.gorm.tests.CircularOneToManySpec | ||
import grails.gorm.tests.CommonTypesPersistenceSpec | ||
import grails.gorm.tests.CriteriaBuilderSpec | ||
import grails.gorm.tests.CrudOperationsSpec | ||
import grails.gorm.tests.DomainEventsSpec | ||
import grails.gorm.tests.FindByMethodSpec | ||
import grails.gorm.tests.GormEnhancerSpec | ||
import grails.gorm.tests.GroovyProxySpec | ||
import grails.gorm.tests.InheritanceSpec | ||
import grails.gorm.tests.ListOrderBySpec | ||
import grails.gorm.tests.NamedQuerySpec | ||
import grails.gorm.tests.NegationSpec | ||
import grails.gorm.tests.OneToManySpec | ||
import grails.gorm.tests.OrderBySpec | ||
import grails.gorm.tests.ProxyLoadingSpec | ||
import grails.gorm.tests.QueryAfterPropertyChangeSpec | ||
import grails.gorm.tests.RangeQuerySpec | ||
import grails.gorm.tests.SaveAllSpec | ||
import grails.gorm.tests.UpdateWithProxyPresentSpec | ||
import grails.gorm.tests.ValidationSpec | ||
import grails.gorm.tests.WithTransactionSpec | ||
|
||
import org.junit.runner.RunWith | ||
import org.junit.runners.Suite | ||
import org.junit.runners.Suite.SuiteClasses | ||
|
||
@RunWith(Suite) | ||
@SuiteClasses([ | ||
ValidationSpec, | ||
// GroovyProxySpec, | ||
// CommonTypesPersistenceSpec, | ||
// OneToManySpec, | ||
// SaveAllSpec, | ||
// GormEnhancerSpec, | ||
// DomainEventsSpec, | ||
// ProxyLoadingSpec, | ||
// QueryAfterPropertyChangeSpec, | ||
// CircularOneToManySpec, | ||
// InheritanceSpec, | ||
// FindByMethodSpec, | ||
// ListOrderBySpec, | ||
// CriteriaBuilderSpec, | ||
// NegationSpec, | ||
// NamedQuerySpec, | ||
// OrderBySpec, | ||
// RangeQuerySpec, | ||
// UpdateWithProxyPresentSpec, | ||
// AttachMethodSpec, | ||
// WithTransactionSpec, | ||
CrudOperationsSpec | ||
]) | ||
class HibernateSuite { | ||
|
||
} |
Oops, something went wrong.