25.02.2015 Views

Introducing Spring Framework

Introducing Spring Framework

Introducing Spring Framework

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 7 ■ Testing Your <strong>Spring</strong> Application<br />

Extension: .url<br />

2014-02-16 17:46:45,839 DEBUG [main] Start Params:<br />

2014-02-16 17:46:45,839 DEBUG [main] Start Params:<br />

2014-02-16 17:46:45,839 DEBUG [main] End Result:[Lcom.apress.isf.java.model.<br />

Document;@bdd6a16<br />

2014-02-16 17:46:45,839 DEBUG [main] End Result: [com.apress.isf.java.model.<br />

Document@755fd06f, com.apress.isf.java.model.Document@656d639c, com.apress.isf.java.model.<br />

Document@70a6cac9, com.apress.isf.java.model.Document@564b8be6]<br />

2014-02-16 17:46:45,840 DEBUG [main] End Result: [com.apress.isf.java.model.<br />

Document@564b8be6]<br />

2014-02-16 17:46:45,840 DEBUG [main] Start Params:<br />

2014-02-16 17:46:45,840 DEBUG [main] Start Params:<br />

2014-02-16 17:46:45,840 DEBUG [main] End Result:[Lcom.apress.isf.java.model.<br />

Document;@79cdd54c<br />

2014-02-16 17:46:45,840 DEBUG [main] End Result: [com.apress.isf.java.model.<br />

Document@755fd06f, com.apress.isf.java.model.Document@656d639c, com.apress.isf.java.model.<br />

Document@70a6cac9, com.apress.isf.java.model.Document@564b8be6]<br />

This annotated feature simplifies and reduces the number of lines in your code, which makes it easier to read and<br />

understand. It also lets you focus on the real test.<br />

Using Profiles<br />

In Chapter 6, you saw how to use resource files, such as Properties files, that can help you to separate particular<br />

properties (for example, username, passwords, database connections, etc.) for different environments, such as<br />

Production or QA. Now, this is a nice solution if your project is small and doesn’t require too many changes, but what<br />

happens when you have a very large project and you have some beans that should be available only in QA or other<br />

beans in Production? The <strong>Spring</strong> <strong>Framework</strong> team must have had this in mind because with version 3.1 they added<br />

the Profiles feature to the <strong>Spring</strong> container. The Profiles feature can help you to separate environments and gives you<br />

an even better and easier way to test them.<br />

Let’s start modifying your test and see how the Profiles feature works. Let’s look at your XML configuration using<br />

Profiles (as shown in Listing 7-2).<br />

Listing 7-2. mydocuments-profiles-context.xml<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

77

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!