Author: euluis
Date: 2007-11-05 19:59:21-0800
New Revision: 13729
Added:
trunk/tests/org/argouml/profile/
trunk/tests/org/argouml/profile/TestProfileFacade.java (contents, props changed)
trunk/tests/org/argouml/profile/TestProfileManager.java (contents, props changed)
trunk/tests/org/argouml/profile/TestSubsystemInit.java (contents, props changed)
trunk/tests/org/argouml/profile/internal/
trunk/tests/org/argouml/profile/internal/TestProfileManagerImpl.java (contents, props changed)
Log:
Issue #4885: first commit of the org.argouml.profile work, based (i.e. copied and slightly adapted from) org.argouml.uml.profile. Shows sub-system init and Facade as well as hides some of the details to other classes.
Added: trunk/tests/org/argouml/profile/TestProfileFacade.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/tests/org/argouml/profile/TestProfileFacade.java?view=auto&rev=13729
==============================================================================
--- (empty file)
+++ trunk/tests/org/argouml/profile/TestProfileFacade.java 2007-11-05 19:59:21-0800
@@ -0,0 +1,82 @@
+// $Id$
+// Copyright (c) 2007 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.profile;
+
+import org.easymock.MockControl;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ * @author Luis Sergio Oliveira (euluis)
+ */
+public class TestProfileFacade extends TestCase {
+
+ private MockControl managerCtrl;
+ private ProfileManager manager;
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ managerCtrl = MockControl.createControl(
+ ProfileManager.class);
+ manager = (ProfileManager) managerCtrl.getMock();
+ ProfileFacade.setManager(manager);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ ProfileFacade.reset();
+ super.tearDown();
+ }
+
+ public void testGetManagerBeforeInitialisationThrows() {
+ ProfileFacade.reset();
+ try {
+ ProfileFacade.getManager();
+ fail("Should throw RuntimeException!");
+ } catch (RuntimeException e) {
+ // expected
+ }
+ }
+
+ public void testRegister() {
+ manager.registerProfile(null);
+ managerCtrl.replay();
+
+ ProfileFacade.register(null);
+ managerCtrl.verify();
+ }
+
+ public void testRemove() {
+ manager.removeProfile(null);
+ managerCtrl.replay();
+
+ ProfileFacade.remove((Profile) null);
+ managerCtrl.verify();
+ }
+}
Added: trunk/tests/org/argouml/profile/TestProfileManager.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/tests/org/argouml/profile/TestProfileManager.java?view=auto&rev=13729
==============================================================================
--- (empty file)
+++ trunk/tests/org/argouml/profile/TestProfileManager.java 2007-11-05 19:59:21-0800
@@ -0,0 +1,114 @@
+// $Id$
+// Copyright (c) 2007 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.profile;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.argouml.model.InitializeModel;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for a ProfileManager implementation.
+ *
+ * @author Luis Sergio Oliveira (euluis)
+ */
+public class TestProfileManager extends TestCase {
+
+ private Profile mockProfile;
+ private ProfileManager manager;
+ private String mockProfileClassName;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ new InitProfileSubsystem().init();
+ mockProfile = new Profile() {
+ @Override
+ public String getDisplayName() {
+ return null;
+ }
+ @Override
+ public Collection<Object> getProfilePackages()
+ throws ProfileException {
+ return null;
+ }
+ };
+ manager = ProfileFacade.getManager();
+ assertNotNull(manager);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ ProfileFacade.reset();
+ super.tearDown();
+ }
+
+ public void testRegisterProfile() {
+ manager.registerProfile(mockProfile);
+ assertTrue(manager.getRegisteredProfiles().contains(mockProfile));
+ }
+
+ public void testRemoveProfile() {
+ assertFalse(manager.getRegisteredProfiles().contains(mockProfile));
+ manager.registerProfile(mockProfile);
+ assertTrue(manager.getRegisteredProfiles().contains(mockProfile));
+ manager.removeProfile(mockProfile);
+ assertFalse(manager.getRegisteredProfiles().contains(mockProfile));
+ }
+
+ public void testGetProfileForClass() {
+ mockProfileClassName = mockProfile.getClass().getName();
+ assertNull(manager.getProfileForClass(mockProfileClassName));
+ manager.registerProfile(mockProfile);
+ assertEquals(mockProfile, manager.getProfileForClass(
+ mockProfileClassName));
+ manager.removeProfile(mockProfile);
+ assertNull(manager.getProfileForClass(mockProfileClassName));
+ }
+
+ public void testDefaultProfilesManagement() {
+ List<Object> initialDefaultProfiles =
+ new ArrayList<Object>(manager.getDefaultProfiles());
+ assertNull(manager.getProfileForClass(mockProfileClassName));
+ manager.registerProfile(mockProfile);
+ manager.addToDefaultProfiles(mockProfile);
+ assertEquals(initialDefaultProfiles.size() + 1,
+ manager.getDefaultProfiles().size());
+ manager.removeFromDefaultProfiles(mockProfile);
+ assertEquals(initialDefaultProfiles.size(),
+ manager.getDefaultProfiles().size());
+ assertFalse(manager.getDefaultProfiles().contains(mockProfile));
+ }
+
+ public void testGetUMLProfile() throws Exception {
+ Profile uml = manager.getUMLProfile();
+ assertNotNull(uml);
+ assertTrue(uml.getDisplayName().indexOf("UML") != -1);
+ }
+}
Added: trunk/tests/org/argouml/profile/TestSubsystemInit.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/tests/org/argouml/profile/TestSubsystemInit.java?view=auto&rev=13729
==============================================================================
--- (empty file)
+++ trunk/tests/org/argouml/profile/TestSubsystemInit.java 2007-11-05 19:59:21-0800
@@ -0,0 +1,64 @@
+// $Id$
+// Copyright (c) 2007 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.profile;
+
+import org.argouml.application.api.InitSubsystem;
+import org.argouml.model.InitializeModel;
+
+import junit.framework.TestCase;
+
+/**
+ * Test cases for the initialization of the profile subsystem.
+ *
+ * @author Luis Sergio Oliveira (euluis)
+ */
+public class TestSubsystemInit extends TestCase {
+
+ private InitSubsystem initSubsystem;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ initSubsystem = new InitProfileSubsystem();
+ }
+
+ public void testInitMakesManagerAvailableInFacade() {
+ try {
+ ProfileFacade.getManager();
+ fail("ProfileFacade shouldn't be initialized!");
+ } catch (RuntimeException e) { }
+ initSubsystem.init();
+ assertNotNull(ProfileFacade.getManager());
+ }
+
+ public void testSettingsTabsEmpty() {
+ assertEquals(0, initSubsystem.getSettingsTabs().size());
+ }
+
+ public void testProjectSettingsTabsEmpty() {
+ assertEquals(0, initSubsystem.getProjectSettingsTabs().size());
+ }
+}
Added: trunk/tests/org/argouml/profile/internal/TestProfileManagerImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/tests/org/argouml/profile/internal/TestProfileManagerImpl.java?view=auto&rev=13729
==============================================================================
--- (empty file)
+++ trunk/tests/org/argouml/profile/internal/TestProfileManagerImpl.java 2007-11-05 19:59:21-0800
@@ -0,0 +1,89 @@
+// $Id$
+// Copyright (c) 2007 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.profile.internal;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.argouml.model.InitializeModel;
+import org.argouml.profile.Profile;
+import org.argouml.profile.ProfileManager;
+
+/**
+ * Tests for the ProfileManagerImpl class.
+ *
+ * @author Luis Sergio Oliveira (euluis)
+ */
+public class TestProfileManagerImpl extends TestCase {
+
+ private ProfileManager manager;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ manager = new ProfileManagerImpl();
+ }
+
+ public void testProfileManagerImpl() {
+ List<Profile> defaultProfiles = manager.getDefaultProfiles();
+ assertEquals(1, defaultProfiles.size());
+ assertEquals(ProfileUML.NAME,
+ defaultProfiles.iterator().next().getDisplayName());
+ List<Profile> registeredProfiles = manager.getRegisteredProfiles();
+ assertEquals(2, registeredProfiles.size());
+ Set<String> profileNameSet = new HashSet<String>();
+ for (Profile profile : registeredProfiles) {
+ assertTrue(profile.getDisplayName().equals(ProfileUML.NAME)
+ || profile.getDisplayName().equals(ProfileJava.NAME));
+ profileNameSet.add(profile.getDisplayName());
+ }
+ assertEquals(2, profileNameSet.size());
+ }
+
+ public void testRemoveProfileThatIsntDefault() {
+ Profile javaProfile = manager.getProfileForClass(
+ ProfileJava.class.getName());
+ assertNotNull(javaProfile);
+ assertTrue(manager.getRegisteredProfiles().contains(javaProfile));
+ manager.removeProfile(javaProfile);
+ assertFalse(manager.getRegisteredProfiles().contains(javaProfile));
+ }
+
+ public void testRemoveDefaultProfile() {
+ Profile umlProfile = manager.getProfileForClass(
+ ProfileUML.class.getName());
+ assertNotNull(umlProfile);
+ assertTrue(manager.getRegisteredProfiles().contains(umlProfile));
+ assertTrue(manager.getDefaultProfiles().contains(umlProfile));
+ manager.removeProfile(umlProfile);
+ assertFalse(manager.getRegisteredProfiles().contains(umlProfile));
+ assertFalse(manager.getDefaultProfiles().contains(umlProfile));
+ }
+
+}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.