KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > model > repository > test > RepositoryModelResolverTest


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.verge.mvc.model.repository.test;
8
9
10 import java.util.HashMap JavaDoc;
11 import java.util.Map JavaDoc;
12
13 import com.inversoft.junit.WebTestCase;
14 import com.inversoft.verge.mvc.MVCRequest;
15 import com.inversoft.verge.mvc.model.ModelResolution;
16 import com.inversoft.verge.mvc.model.repository.RepositoryModelResolver;
17 import com.inversoft.verge.repository.Repository;
18 import com.inversoft.verge.repository.test.RepositoryTest;
19
20
21 /**
22  * <p>
23  * This class contains the TestCases for resolver.
24  * </p>
25  *
26  * @author Brian Pontarelli
27  * @since 2.0
28  * @version 2.0
29  */

30 public class RepositoryModelResolverTest extends WebTestCase {
31
32     /**
33      * Constructs a new <code>RepositoryModelResolverTest</code> TestCase instance
34      */

35     public RepositoryModelResolverTest(String JavaDoc name) {
36         super(name);
37         setLocal(true);
38     }
39
40
41     /**
42      * Tests the resolver works correctly
43      */

44     public void testAll() {
45
46         MVCRequest mvcRequest = new MVCRequest(request, response);
47         Map JavaDoc params = new HashMap JavaDoc();
48
49         try {
50             RepositoryTest rt = new RepositoryTest("testInitialization");
51             rt.setResponse(response);
52             rt.setRequest(request);
53             rt.setContext(context);
54             rt.testInitialization();
55
56             RepositoryModelResolver resolver = new RepositoryModelResolver();
57             ModelResolution resolution = resolver.resolve(mvcRequest, "item1.name", params);
58             Object JavaDoc item = Repository.getInstance().lookupItem(request, "item1");
59             assertEquals("Objects should be equal", resolution.getModel(), item);
60
61             // Make sure null does not effect the result
62
resolution = resolver.resolve(mvcRequest, "item1.name", null);
63             assertEquals("Objects should be equal", resolution.getModel(), item);
64         } catch (Exception JavaDoc e) {
65             fail(e.toString());
66         }
67     }
68 }
69
Popular Tags