Re: Unit Testing DAOs

2011-02-04 Thread matt...@mustardgrain.com

On 2/4/11 1:49 PM, matt...@mustardgrain.com wrote:

On 2/4/11 1:45 PM, Thiago H. de Paula Figueiredo wrote:
On Fri, 04 Feb 2011 19:37:03 -0200, matt...@mustardgrain.com 
 wrote:



Hello,


Hi!

org.hibernate.MappingException: Unknown entity: 
com.mustardgrain.clientdailyupdate.entities.User

even though I'm using the import javax.persistence.Entity annotation.


You'll probably need to add your AppModule to the list of modules 
before building the Registry.


I've actually tried adding the AppModule before building as well, and 
when I added it I got this exception:
java.lang.IllegalArgumentException: Contribution 
com.mustardgrain.clientdailyupdate.services.AppModule.contributeRequestHandler(OrderedConfiguration, 
RequestFilter) (at AppModule.java:120) is for service 
'RequestHandler', which does not exist.


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Also when I created a MockModule class, which created an EasyMock 
RequestHandler I still ended up with  org.hibernate.MappingException: 
Unknown entity: com.mustardgrain.clientdailyupdate.entities.User



-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Unit Testing DAOs

2011-02-04 Thread matt...@mustardgrain.com

On 2/4/11 1:45 PM, Thiago H. de Paula Figueiredo wrote:
On Fri, 04 Feb 2011 19:37:03 -0200, matt...@mustardgrain.com 
 wrote:



Hello,


Hi!

org.hibernate.MappingException: Unknown entity: 
com.mustardgrain.clientdailyupdate.entities.User

even though I'm using the import javax.persistence.Entity annotation.


You'll probably need to add your AppModule to the list of modules 
before building the Registry.


I've actually tried adding the AppModule before building as well, and 
when I added it I got this exception:
java.lang.IllegalArgumentException: Contribution 
com.mustardgrain.clientdailyupdate.services.AppModule.contributeRequestHandler(OrderedConfiguration, 
RequestFilter) (at AppModule.java:120) is for service 'RequestHandler', 
which does not exist.


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Unit Testing DAOs

2011-02-04 Thread matt...@mustardgrain.com

Hello,

I'm attempting to unit test my Hibernate DAOs and I haven't yet been 
successful in connecting to the database and adding an entity, although 
I believe I'm close to getting something successfully added. Currently 
my test looks like this:


@Test
public void userTest() {
RegistryBuilder builder = new RegistryBuilder();

builder.add(DaoModule.class);
builder.add(HibernateCoreModule.class);
Registry reg = builder.build();

userDao = reg.getService(UserDao.class);
User user = createUser();

userDao.addUser(user);
}

and this is my DaoModule:

public class DaoModule {

public static UserDao buildUserDao 
(@InjectService("HibernateSessionManager")

HibernateSessionManager sessionManager) {
UserDao userDao = new UserDao();
userDao.setSessionManager(sessionManager);
return userDao;
}
}

The problem I'm having is that when I attempt to persist a User object 
via session.persist() I get the error:
org.hibernate.MappingException: Unknown entity: 
com.mustardgrain.clientdailyupdate.entities.User
even though I'm using the import javax.persistence.Entity annotation. Am 
I close to correctly testing here or am I barking up the wrong tree?


Thanks, Matthew

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org