01: package org.vraptor.plugin.jpa;
02:
03: import java.util.Arrays;
04: import java.util.HashSet;
05:
06: import org.jmock.Expectations;
07: import org.jmock.Mockery;
08: import org.vraptor.AbstractTest;
09: import org.vraptor.component.ComponentManager;
10: import org.vraptor.component.ComponentType;
11: import org.vraptor.webapp.WebApplication;
12:
13: public class JavaPersistencePluginTest extends AbstractTest {
14:
15: private Mockery mockery;
16:
17: @Override
18: protected void setUp() throws Exception {
19: super .setUp();
20: mockery = new Mockery();
21: }
22:
23: public void testWrapsAPersistenceContextComponent()
24: throws Exception {
25: final WebApplication application = mockery
26: .mock(WebApplication.class);
27: mockery.checking(new Expectations() {
28: {
29: ComponentType component = createComponentType(EntityManagerDependent.class);
30: ComponentManager manager = mockery
31: .mock(ComponentManager.class);
32:
33: one(application).getComponentManager();
34: will(returnValue(manager));
35:
36: one(manager).getComponents();
37: will(returnValue(new HashSet<ComponentType>(Arrays
38: .asList(component))));
39:
40: one(manager).register(with(any(ComponentType.class)));
41: }
42: });
43: new JavaPersistencePlugin().init(application);
44: mockery.assertIsSatisfied();
45: }
46: }
|