I haven't got time to get to this one. I will play with it tomorrow
and see if it covers what I have in mind.
./alex
--
.w( the_mindstorm )p.
1/ IIRC you can have Before/After Suite/Test methods defined in a
class and simply invoked by providing them in the suite definition
file. The @Factory part would be just a syntactic sugar.
2/ the real problem with this approach is that your test is not having
access to the ConfigurationMixin instance, so that it can use
resources from there. Imagine the classical scenario with DB
interaction. You start/stop the embedded db in the Before/AfterSuite
but you have no means to get the hands on a connection without either
statically referencing the suite @Configuration class or by having it
in your test hierarchy.
./alex
--
.w( the_mindstorm )p.
On 6/15/06, Cédric Beust ♔ <cbe...@google.com> wrote:
I've been thinking about this more and I think that this is not really
a replacement for my proposal. And here is why:
1/ IIRC you can have Before/After Suite/Test methods defined in a
class and simply invoked by providing them in the suite definition
file. The @Factory part would be just a syntactic sugar.
2/ the real problem with this approach is that your test is not having
access to the ConfigurationMixin instance, so that it can use
resources from there.
But how do you access these from your test? Say I have DbConfiguration
and MyTest classes. How can I access DbConfiguration instance from
MyTest?
./alex
--
.w( the_mindstorm )p.
> --
>
> Cédric
>
> >
>
Here is a small/draft example:
[code]
public class MyTest {
private DbConnectionFactory m_connectionFactory;
@ConfigurationFactory
public DbConnectionFactory initializeDataSource() {
m_connectionFactory= new DbConnectionFactory();
return m_connectionFactory;
}
@Test
public void sqlInsert() throws SqlException {
Connection conn= m_connectionFactory.getConnection();
// do the rest
}
}
public class DbConnectionFactory {
private Connection m_connection;
@BeforeClass
public void initializeConnection() {
m_connection = MySpringContext.getBean("dataSource").getConnection();
}
@AfterClass
public void closeConnection() throws SQLException {
m_connection.close;
}
public Connection getConnection() {
return m_connection;
}
}
[/code]
hope this clarifies my intention,
./alex
--
.w( the_mindstorm )p.
ps: Jesse I will try to re-read your message and see if I can put it in a better shape to impress
Cedric :-).
./alex
--
.w( the_mindstorm )p.