Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring DSL in Grails - resources.groovy - bean configuration in a different file?
    primarykey
    data
    text
    <p>This question <a href="https://stackoverflow.com/questions/2276823/grails-config-of-spring-beans-in-different-files">already exists in a way</a>, but the existing question is missing some important links.</p> <p>I'm trying to move the configuration of beans for my tests into separate files that end in <code>*TestsSpringBeans.groovy</code></p> <p>I've attempted to do this after reading <a href="http://grails.org/doc/1.3.7/guide/14.%20Grails%20and%20Spring.html" rel="nofollow noreferrer">"Loading Bean Definitions from the File System"</a> (search for it) in the Groovy documentation. </p> <p>Here are the relevant code segments:</p> <pre><code>import grails.util.* beans = { ... switch(Environment.current) { case Environment.TEST: loadBeans("classpath:*TestsSpringBeans.groovy") break } } </code></pre> <p><strong>resources.groovy</strong> - Loading the *TestSpringBeans files from the File System.</p> <hr> <pre><code>somePlace(jobdb.Company) { name = "SomeCompany" addr1 = "addr1" addr2 = "addr2" city = "city" email = "somedude@h0tmail.com" fax = "555-555-5555" phone = "444-444-4444" state = "PA" zip = "19608" version: 0 created = new Date() updated = new Date() website = "http://www.yahoo.com" deleted = false } </code></pre> <h2><strong>CompanyServiceTestsSpringBeans.groovy</strong> - Defining a bean for the Integration Test</h2> <pre><code>// Retrieve configured bean from Company someplace = ApplicationHolder.getApplication().getMainContext().getBean('somePlace') </code></pre> <p><strong>CompanyServiceTests.groovy</strong> - Obtain the bean <code>somePlace</code> within the Integration Test...</p> <p>Upon calling <code>getBean('somePlace')</code> within the test an error is displayed which reads that <code>No bean named 'somePlace' is defined</code></p> <p>The <code>CompanyServiceTests.groovy</code> file is stored with my integration tests, should I be storing this file somewhere else in the project directory structure?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload