unit test: why fails the second time?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

unit test: why fails the second time?

Mauro
I have this unit test:

class SupplierSpec extends Specification {
    Address address = new Address(street: "street1", streetNumber: "1", city: "city", prov: "prov", zipCode: "09100")
    Category category = new Category()

    def setup() {
        mockForConstraintsTests(Supplier, [new Supplier(referenceNumber: "123", referenceDate: new Date().parse("dd/mm/yyyy", "27/11/2013"),
            vatNumber: '1'*11, inps: "inps", inail: "inail")])
    }

    @Unroll
    void "test supplier referenceNumber constraint"() {
        when:
        Supplier supplier = new Supplier()
        supplier.referenceNumber = referenceNumber
        supplier.referenceDate = new Date().parse("dd/mm/yyyy", "27/11/2013")
        supplier.companyName = "Supplier1"
        supplier.vatNumber = '2'*11
        supplier.ethicQuality =  false
        supplier.iso9001 = false
        supplier.categories = [category]
        supplier.address = address
        supplier.validate()
       
        then:
        supplier.hasErrors() == invalid
        supplier.errors["referenceNumber"] == caused
   
        where:
        referenceNumber | invalid   | caused
        "12345/abc"     | false     | null
        "123"           | true      | "unique" 
        ""              | true      | "blank"
        null            | true      | "nullable"
    }


Address class is under src/groovy.
If I do:
>grails
>test-app supplierregister.Supplier

test is ok.
If I run test-app supplierregister.Supplier a second time it fails with:

Failure:  test supplier referenceNumber constraint[0](supplierregister.SupplierSpec)
|  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sessionFactory': FactoryBean which is currently in creation returned null from getObject
        at grails.test.MockUtils.addValidateMethod_closure87(MockUtils.groovy:1031)
        at grails.test.MockUtils.addValidateMethod_closure88(MockUtils.groovy:1083)
        at supplierregister.SupplierSpec.test supplier referenceNumber constraint(SupplierSpec.groovy:37)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sessionFactory': FactoryBean which is currently in creation returned null from getObject
        ... 3 more
Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sessionFactory': FactoryBean which is currently in creation returned null from getObject
        ... 3 more


it's a very strange thing.
Reply | Threaded
Open this post in threaded view
|

Re: unit test: why fails the second time?

Mauro
I'm using grails 2.3.7, it seems to me that with grails 2.3.6 I didn't have this problem.



Reply | Threaded
Open this post in threaded view
|

Re: unit test: why fails the second time?

Mauro
Am I the only one having this problem?



Reply | Threaded
Open this post in threaded view
|

Re: unit test: why fails the second time?

Graeme Rocher-2
Please raise a JIRA and attach an example that reproduces the problem

Cheers

On Wed, Mar 19, 2014 at 9:35 AM, Mauro Sanna <[hidden email]> wrote:
> Am I the only one having this problem?
>
>
>



--
Graeme Rocher
Grails Project Lead
SpringSource

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: unit test: why fails the second time?

Mauro


On 19 March 2014 14:19, Graeme Rocher <[hidden email]> wrote:
Please raise a JIRA and attach an example that reproduces the problem

Cheers

On Wed, Mar 19, 2014 at 9:35 AM, Mauro Sanna <[hidden email]> wrote:
> Am I the only one having this problem?
>
>
>



--
Graeme Rocher
Grails Project Lead
SpringSource

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: unit test: why fails the second time?

Mauro
I've attached the stacktrace in the JIRA.


On 19 March 2014 23:20, Mauro Sanna <[hidden email]> wrote:


On 19 March 2014 14:19, Graeme Rocher <[hidden email]> wrote:
Please raise a JIRA and attach an example that reproduces the problem

Cheers

On Wed, Mar 19, 2014 at 9:35 AM, Mauro Sanna <[hidden email]> wrote:
> Am I the only one having this problem?
>
>
>



--
Graeme Rocher
Grails Project Lead
SpringSource

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email