Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Spring 3 offers a new <code>jdbc</code> namespace that includes support for embedded databases, including HSQLDB. So that takes care of that part.</p> <p>I'm wondering what the "in-house solution" could be. You can use annotations (either JPA or Hibernate annotations) to ORM your domain objects, so why do you need an "in-house solution"? E.g.:</p> <pre><code>&lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" p:dataSource-ref="dataSource" p:packagesToScan="myapp.model" /&gt; </code></pre> <p>As far as implementing a test goes, use Spring's TestContext Framework. A test can look like this (again I'm assuming Spring 3 below, though it should work in Spring 2.5 simply by changing @Inject to @Autowired):</p> <pre><code>@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration({ "/beans-datasource-it.xml", "/beans-dao.xml", "/beans-service.xml", "/beans-web.xml" }) @Transactional public class ContactControllerIT { @Inject private ContactController controller; ... setUp() and tearDown() ... @Test public void testGetContact() { String viewName = controller.getContact(request, 1L, model); ... assertions ... } } </code></pre> <p>You'd put the embedded database inside <code>beans-datasource-it.xml</code>, for example. ('it' here stands for integration test, and the files are on the classpath.) The controller in this example lives in <code>beans-web.xml</code>, and will be autowired into the <code>ContactController</code> field.</p> <p>That's just an outline of what to do but hopefully it's enough to get you started.</p>
 

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