01: /* Copyright 2005 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal.layout;
07:
08: import java.util.Properties;
09:
10: import org.jasig.portal.properties.PropertiesManager;
11:
12: import junit.framework.TestCase;
13:
14: /**
15: * JUnit testcase for UserLayoutStoreFactory.
16: * @version $Revision: 35809 $ $Date: 2005-05-17 13:53:55 -0700 (Tue, 17 May 2005) $
17: */
18: public class UserLayoutStoreFactoryTest extends TestCase {
19:
20: /**
21: * Test that when the property is set, we return an instance of the class defined by that
22: * property.
23: */
24: public void testGetUserLayoutStorePropertySet() {
25:
26: Properties properties = new Properties();
27: properties.put(
28: UserLayoutStoreFactory.LAYOUT_STORE_IMPL_PROPERTY,
29: UserLayoutStoreMock.class.getName());
30: PropertiesManager.setProperties(properties);
31: IUserLayoutStore store = UserLayoutStoreFactory
32: .getUserLayoutStoreImpl();
33: assertNotNull(store);
34: assertTrue(UserLayoutStoreMock.class == store.getClass());
35:
36: // now destroy the properties and test that UserLayoutStoreFactory still
37: // gives us that singleton.
38:
39: properties.put(
40: UserLayoutStoreFactory.LAYOUT_STORE_IMPL_PROPERTY,
41: "wombat");
42: PropertiesManager.setProperties(properties);
43:
44: IUserLayoutStore store2 = UserLayoutStoreFactory
45: .getUserLayoutStoreImpl();
46: assertSame(store, store2);
47:
48: }
49:
50: }
|