01: package org.andromda.repositories.mdr.uml14;
02:
03: import java.net.URL;
04:
05: import junit.framework.TestCase;
06:
07: import org.andromda.core.common.AndroMDALogger;
08: import org.andromda.core.metafacade.ModelAccessFacade;
09: import org.andromda.core.namespace.NamespaceComponents;
10: import org.andromda.core.repository.Repositories;
11: import org.andromda.repositories.mdr.MDRepositoryFacade;
12: import org.apache.log4j.Logger;
13: import org.omg.uml.UmlPackage;
14:
15: /**
16: * Implements the JUnit test case for <code>org.andromda.repositories.MDRepositoryFacade</code>
17: * using the UML 1.4 metamodel.
18: *
19: * @author <A HREF="http://www.amowers.com">Anthony Mowers </A>
20: * @author Chad Brandon
21: */
22: public class MDRepositoryFacadeTest extends TestCase {
23: private static final Logger logger = Logger
24: .getLogger(MDRepositoryFacadeTest.class);
25: private URL modelURL = null;
26: private MDRepositoryFacade repository = null;
27:
28: /**
29: * Constructor for MDRepositoryFacadeTest.
30: *
31: * @param name the test name
32: */
33: public MDRepositoryFacadeTest(String name) {
34: super (name);
35: }
36:
37: /**
38: * @see TestCase#setUp()
39: */
40: protected void setUp() throws Exception {
41: super .setUp();
42: AndroMDALogger.initialize();
43: if (modelURL == null) {
44: this .modelURL = TestModel.getModel();
45: if (logger.isInfoEnabled()) {
46: logger.info("found model --> '" + modelURL + "'");
47: }
48:
49: NamespaceComponents.instance().discover();
50: Repositories.instance().initialize();
51: repository = (MDRepositoryFacade) Repositories.instance()
52: .getImplementation("netBeansMDR");
53: repository.open();
54: }
55: }
56:
57: public void testGetModel() {
58: repository
59: .readModel(new String[] { modelURL.toString() }, null);
60: final ModelAccessFacade model = repository.getModel();
61: assertNotNull(model);
62: assertNotNull(model.getModel());
63: assertTrue(model.getModel() instanceof UmlPackage);
64: }
65:
66: /**
67: * @see TestCase#tearDown()
68: */
69: protected void tearDown() throws Exception {
70: this.repository.clear();
71: this.repository = null;
72: super.tearDown();
73: }
74: }
|