svn commit: r13301 - branches/gsoc2007/b00__1/tests: . .settings org org/argouml org/argouml/application org/argouml/application/api org/argouml/cognitive org/argouml/cognitive/critics org/argouml/i18n org/argouml/kernel org/argouml/language org/argouml/language/java org/argouml/language/java/generator org/argouml/model org/argouml/moduleloader org/argouml/notation org/argouml/notation/providers org/argouml/notation/providers/java org/argouml/notation/providers/uml org/argouml/persistence org/argouml/ui org/argouml/ui/cmd org/argouml/ui/targetmanager org/argouml/uml org/argouml/uml/cognitive org/argouml/uml/cognitive/critics org/argouml/uml/diagram org/argouml/uml/diagram/activity org/argouml/uml/diagram/activity/ui org/argouml/uml/diagram/collaboration org/argouml/uml/diagram/collaborat ion/ui org/argouml/uml/diagram/deployment org/argouml/uml/diagram/deployment/ui org/argouml
[email protected] 13 Aug 2007 16:07:56 -0000
Newsgroups
gmane.comp.lang.uml.argouml.cvs
Message-ID
<[email protected] >
Author: b00__1
Date: 2007-08-13 09:07:56-0700
New Revision: 13301
Added:
branches/gsoc2007/b00__1/tests/
branches/gsoc2007/b00__1/tests/.checkclipse
branches/gsoc2007/b00__1/tests/.classpath
branches/gsoc2007/b00__1/tests/.project
branches/gsoc2007/b00__1/tests/.settings/
branches/gsoc2007/b00__1/tests/.settings/de.mvmsoft.checkclipse.prefs
branches/gsoc2007/b00__1/tests/.settings/org.eclipse.jdt.core.prefs
branches/gsoc2007/b00__1/tests/.settings/org.eclipse.jdt.ui.prefs
branches/gsoc2007/b00__1/tests/Model all tests.launch
branches/gsoc2007/b00__1/tests/log4j.properties (contents, props changed)
branches/gsoc2007/b00__1/tests/org/
branches/gsoc2007/b00__1/tests/org/argouml/
branches/gsoc2007/b00__1/tests/org/argouml/TestDependencies.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/application/
branches/gsoc2007/b00__1/tests/org/argouml/application/api/
branches/gsoc2007/b00__1/tests/org/argouml/application/api/FalseActionExit.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/application/api/GUITestCommandLineInterface.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/application/api/package.html
branches/gsoc2007/b00__1/tests/org/argouml/cognitive/
branches/gsoc2007/b00__1/tests/org/argouml/cognitive/TestCritic.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/cognitive/TestItemUID.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/cognitive/TestResolvedCritic.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/cognitive/critics/
branches/gsoc2007/b00__1/tests/org/argouml/cognitive/package.html
branches/gsoc2007/b00__1/tests/org/argouml/i18n/
branches/gsoc2007/b00__1/tests/org/argouml/i18n/TestTranslator.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/kernel/
branches/gsoc2007/b00__1/tests/org/argouml/kernel/TestProject.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/kernel/TestProjectManager.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/kernel/TestProjectSettings.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/kernel/package.html
branches/gsoc2007/b00__1/tests/org/argouml/language/
branches/gsoc2007/b00__1/tests/org/argouml/language/java/
branches/gsoc2007/b00__1/tests/org/argouml/language/java/generator/
branches/gsoc2007/b00__1/tests/org/argouml/language/java/generator/TestGeneratorJava.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/
branches/gsoc2007/b00__1/tests/org/argouml/model/AllTests.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/CheckUMLModelHelper.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/GenericUmlObjectTestFixture.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/InitializeModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/MockModelImplementation.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestAGHelperWithMock.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestActivityGraphsFactory.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestActivityGraphsHelper.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestAgainstUmlModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestCollaborationsFactory.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestCollaborationsHelper.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestCommonBehaviorFactory.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestCommonBehaviorHelper.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestCopyHelper.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestCoreFactory.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestCoreHelper.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestCoreHelperWithMock.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestDataTypesFactory.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestExtensionMechanismsFactory.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestExtensionMechanismsHelper.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestModel2.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestModelEventPump.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestModelFacade2.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestModelFacade3.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestModelManagementFactory.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestModelManagementHelper.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestStateMachinesFactory.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestStateMachinesHelper.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestUml.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlActor.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlExtend.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlFactoryBuildNode.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlGeneralization.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlModelElement.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlUseCase.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestUseCasesFactory.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/TestUseCasesHelper.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/model/package.html
branches/gsoc2007/b00__1/tests/org/argouml/moduleloader/
branches/gsoc2007/b00__1/tests/org/argouml/moduleloader/GUITestModuleLoader2.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/moduleloader/ModuleInterfaceForTesting1.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/notation/
branches/gsoc2007/b00__1/tests/org/argouml/notation/TestNotationProvider.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/
branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/TestNotation.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/TestNotationProviderFactory2.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/java/
branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/java/TestModelElementNameNotationJava.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/
branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestAttributeAndOperationNotationUml.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestCallStateNotationUml.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestClassifierRoleNotationUml.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestMessageNotationUml.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestStateBodyNotationUml.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestTransitionNotationUml.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/persistence/
branches/gsoc2007/b00__1/tests/org/argouml/persistence/TestPersistenceManager.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/persistence/TestXmiFilePersister.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/persistence/TestZargoFilePersister.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/persistence/package.html
branches/gsoc2007/b00__1/tests/org/argouml/ui/
branches/gsoc2007/b00__1/tests/org/argouml/ui/GUITestMultiEditorPane.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/ui/GUITestProjectBrowser.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/ui/TestDetailsPane.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/ui/TestMultiEditorPane.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/ui/TestPropertyPanels.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/ui/TestStylePanel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/ui/cmd/
branches/gsoc2007/b00__1/tests/org/argouml/ui/cmd/GUITestActionGotoDiagram.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/ui/cmd/package.html
branches/gsoc2007/b00__1/tests/org/argouml/ui/package.html
branches/gsoc2007/b00__1/tests/org/argouml/ui/targetmanager/
branches/gsoc2007/b00__1/tests/org/argouml/ui/targetmanager/TestTargetManager.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/ui/targetmanager/package.html
branches/gsoc2007/b00__1/tests/org/argouml/uml/
branches/gsoc2007/b00__1/tests/org/argouml/uml/TestProfileJava.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/TestUUIDManager.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/AbstractTestCrTooMany.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/AbstractTestMissingName.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrAssocNameConflict.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrDupParamName.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrInvalidHistory.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrInvalidInitial.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrMissingAttrName.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrMissingClassName.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrMissingOperName.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrMissingStateName.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrNameConflict.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrNoAssociations.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrNoInitialState.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrTooManyAssoc.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrTooManyAttr.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrTooManyOper.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrTooManyStates.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrTooManyTransitions.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrUnconventionalAttrName.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrUnconventionalClassName.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrUnconventionalOperName.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrUnconventionalPackName.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/package.html
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/activity/
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/activity/ui/
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/activity/ui/TestUMLActivityDiagram.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/collaboration/
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/collaboration/ui/
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/collaboration/ui/TestUMLCollaborationDiagram.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/deployment/
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/deployment/ui/
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/deployment/ui/TestUMLDeploymentDiagram.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/sequence/
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/sequence/ui/
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/sequence/ui/TestUMLSequenceDiagram.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/state/
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/state/ui/
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/state/ui/TestFigClonable.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/state/ui/TestUMLStateDiagram.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/state/ui/package.html
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/static_structure/
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/static_structure/ui/
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/static_structure/ui/TestUMLClassDiagram.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/ui/
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/ui/TestActionAddAllClassesFromModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/ui/TestTabDiagram.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/ui/package.html
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/use_case/
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/use_case/ui/
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/use_case/ui/TestFigClonable.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/use_case/ui/TestUMLUseCaseDiagram.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/use_case/ui/package.html
branches/gsoc2007/b00__1/tests/org/argouml/uml/notation/
branches/gsoc2007/b00__1/tests/org/argouml/uml/package.html
branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/
branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/DummyImportSettings.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/TestJavaImportClass.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/TestJavaImportEnumeration.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/TestJavaImportInterface.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/TestJavaImportUnicode.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/package.html
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/AbstractTestActionAddDiagram.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/AbstractUMLModelElementListModel2Test.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/GUITestActionOpenProject.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/GUITestActionSaveGraphics.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/MockUMLUserInterfaceContainer.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestActionClassDiagram.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestActionCollaborationDiagram.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestActionDeploymentDiagram.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestActionStateDiagram.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestActionUseCaseDiagram.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestSourcePathController.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestTabStyle.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestUMLTagDefinitionComboBoxModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationEndRoleBaseListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleAssociationEndRoleListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleBaseComboBoxModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleMessageListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLClassifierRoleAvailableContentsListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLClassifierRoleAvailableFeaturesListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLClassifierRoleBaseListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLCollaborationConstraintListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLCollaborationRepresentedClassifierComboBoxModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLCollaborationRepresentedOperationComboBoxModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLInteractionCollaborationListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLInteractionMessagesListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLMessageActionListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLMessageActivatorComboBoxModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLMessagePredecessorListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLMessageReceiverListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLMessageSenderListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/package.html
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/common_behavior/
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/common_behavior/TestActionNewReception.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/common_behavior/TestUMLReceptionSignalComboBoxModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/common_behavior/package.html
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/use_cases/
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/use_cases/TestUMLExtendExtensionPointListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/use_cases/TestUMLExtensionPointExtendListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/use_cases/TestUMLExtensionPointLocationDocument.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/use_cases/TestUMLExtensionPointUseCaseListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/use_cases/TestUMLUseCaseExtendListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/use_cases/TestUMLUseCaseExtensionPointListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/use_cases/TestUMLUseCaseIncludeListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/use_cases/package.html
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/foundation/
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/foundation/core/
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/foundation/core/TestActionAddAttribute.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/foundation/core/TestActionAddEnumerationLiteral.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/foundation/core/TestUMLCollaborationInteractionListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/foundation/core/TestUMLFeatureOwnerScopeCheckBox.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/foundation/core/TestUMLGeneralizationPowertypeComboBoxModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/foundation/core/TestUMLModelElementClientDependencyListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/foundation/core/TestUMLModelElementConstraintListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/foundation/core/TestUMLModelElementElementResidenceListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/foundation/core/TestUMLModelElementNameDocument.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/foundation/core/TestUMLModelElementNamespaceListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/foundation/core/TestUMLModelElementSourceFlowListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/foundation/core/TestUMLModelElementSupplierDependencyListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/foundation/core/TestUMLModelElementTargetFlowListModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/foundation/core/TestUMLStructuralFeatureTypeComboBoxModel.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/foundation/core/package.html
branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/package.html
branches/gsoc2007/b00__1/tests/org/argouml/uml/util/
branches/gsoc2007/b00__1/tests/org/argouml/uml/util/namespace/
branches/gsoc2007/b00__1/tests/org/argouml/uml/util/namespace/TestStringNamespace.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/uml/util/namespace/package.html
branches/gsoc2007/b00__1/tests/org/argouml/util/
branches/gsoc2007/b00__1/tests/org/argouml/util/CheckMain.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/util/CheckResourceBundle.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/util/DoAllTests.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/util/TestMyTokenizer.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/util/osdep/
branches/gsoc2007/b00__1/tests/org/argouml/util/osdep/TestOsUtil.java (contents, props changed)
branches/gsoc2007/b00__1/tests/org/argouml/util/package.html
branches/gsoc2007/b00__1/tests/testmodels/
branches/gsoc2007/b00__1/tests/testmodels/uml13/
branches/gsoc2007/b00__1/tests/testmodels/uml13/Alittlebitofeverything.zargo (contents, props changed)
branches/gsoc2007/b00__1/tests/testmodels/uml13/Empty.zargo (contents, props changed)
branches/gsoc2007/b00__1/tests/testmodels/uml13/EmptyProject0161.zargo (contents, props changed)
branches/gsoc2007/b00__1/tests/testmodels/uml13/GUITestPropertyPanels.zargo (contents, props changed)
branches/gsoc2007/b00__1/tests/testmodels/uml13/Garbage.zargo (contents, props changed)
branches/gsoc2007/b00__1/tests/testmodels/uml14/
branches/gsoc2007/b00__1/tests/testmodels/uml14/Alittlebitofeverything.zargo (contents, props changed)
branches/gsoc2007/b00__1/tests/testmodels/uml14/EmptyProject024.zargo (contents, props changed)
branches/gsoc2007/b00__1/tests/testmodels/uml14/GUITestPropertyPanels.zargo (contents, props changed)
branches/gsoc2007/b00__1/tests/testmodels/uml14/SequenceDiagram.zargo (contents, props changed)
Log:
cloned trunk/tests
Added: branches/gsoc2007/b00__1/tests/.checkclipse
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/.checkclipse?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/.checkclipse 2007-08-13 09:07:56-0700
@@ -0,0 +1,6 @@
+#Fri May 26 11:19:53 CEST 2006
+filenames.properties=/argouml-core-tools/checkstyle/checkstyle.properties
+enabled=true
+projectclassloader=false
+filenames.config=/argouml-core-tools/checkstyle/checkstyle_argouml.xml
+filenames.filter=/argouml-core-tools/checkstyle/checkclipse.filefilters
Added: branches/gsoc2007/b00__1/tests/.classpath
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/.classpath?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/.classpath 2007-08-13 09:07:56-0700
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry excluding=".settings/|bin/|build-eclipse/|src/" kind="src" path=""/>
+ <classpathentry combineaccessrules="false" kind="src" path="/argouml"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/argouml-core-model"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/argouml-core-lib"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/argouml-core-tools"/>
+ <classpathentry kind="lib" path="/argouml-core-tools/jdepend-2.9/lib/jdepend-2.9.jar" sourcepath="/argouml-core-tools/jdepend-2.9/src/"/>
+ <classpathentry kind="output" path="build-eclipse"/>
+</classpath>
Added: branches/gsoc2007/b00__1/tests/.project
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/.project?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/.project 2007-08-13 09:07:56-0700
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>argouml-core-tests</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>de.mvmsoft.checkclipse.CheckclipseBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>de.mvmsoft.checkclipse.CheckclipseNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: branches/gsoc2007/b00__1/tests/.settings/de.mvmsoft.checkclipse.prefs
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/.settings/de.mvmsoft.checkclipse.prefs?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/.settings/de.mvmsoft.checkclipse.prefs 2007-08-13 09:07:56-0700
@@ -0,0 +1,6 @@
+#Mon Nov 27 04:50:12 EST 2006
+filenames.properties=/argouml-core-tools/checkstyle/checkstyle.properties
+enabled=true
+projectclassloader=true
+filenames.config=/argouml-core-tools/checkstyle/checkstyle_argouml.xml
+filenames.filter=/argouml-core-tools/checkstyle/checkclipse.filefilters
Added: branches/gsoc2007/b00__1/tests/.settings/org.eclipse.jdt.core.prefs
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/.settings/org.eclipse.jdt.core.prefs?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/.settings/org.eclipse.jdt.core.prefs 2007-08-13 09:07:56-0700
@@ -0,0 +1,70 @@
+#Tue Jul 03 10:40:15 CEST 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=enabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=ignore
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.5
Added: branches/gsoc2007/b00__1/tests/.settings/org.eclipse.jdt.ui.prefs
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/.settings/org.eclipse.jdt.ui.prefs?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/.settings/org.eclipse.jdt.ui.prefs 2007-08-13 09:07:56-0700
@@ -0,0 +1,3 @@
+#Sun Apr 22 20:33:13 CEST 2007
+eclipse.preferences.version=1
+internal.default.compliance=default
Added: branches/gsoc2007/b00__1/tests/Model all tests.launch
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/Model%20all%20tests.launch?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/Model all tests.launch 2007-08-13 09:07:56-0700
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.argouml.model.AllTests"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="argouml-core-tests" path="1" type="4"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry path="3" projectName="argouml-core-model-mdr" type="1"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/jmi.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/jmiutils.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/mdrapi.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/mof.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/nbmdr.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/openide-util.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry path="3" projectName="argouml-core-model" type="1"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry path="3" projectName="argouml-core-lib" type="1"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-lib/antlrall-2.7.2.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-lib/commons-logging-1.0.2.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-lib/log4j-1.2.6.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-lib/ocl-argo-1.1.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-lib/swidgets-0.1.4.jar" path="3" sourceAttachmentPath="/swidgets/src" sourceRootPath="" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-lib/toolbar-1.4.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-lib/gef-0.12.4M4.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-tools/junit-3.8.1/junit.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-tools/lib/easymock12.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="argouml-core-tests"/> </runtimeClasspathEntry> "/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="argouml-core-tests"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx64M -Dtest.model.uml=${resource_loc:/argouml-core-model-mdr/src/org/argouml/model/mdr/mof/01-02-15.xml} -Dlog4j.configuration=${resource_loc:/argouml/org/argouml/resource/default_console.lcf} -Djava.awt.headless="true" -Dargouml.tests.dir=${project_loc}"/>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
+</launchConfiguration>
Added: branches/gsoc2007/b00__1/tests/log4j.properties
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/log4j.properties?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/log4j.properties 2007-08-13 09:07:56-0700
@@ -0,0 +1,11 @@
+#
+log4j.rootLogger=INFO, TESTING
+log4j.category.org.argouml=INFO
+#
+log4j.appender.TESTING=org.apache.log4j.RollingFileAppender
+log4j.appender.TESTING.File=argouml.log
+log4j.appender.TESTING.MaxFileSize=1MB
+log4j.appender.TESTING.MaxBackupIndex=1
+log4j.appender.TESTING.layout=org.apache.log4j.PatternLayout
+log4j.appender.TESTING.layout.ConversionPattern=%5p: %m (%F:%L)%n
+log4j.appender.TESTING.Threshold=INFO
Added: branches/gsoc2007/b00__1/tests/org/argouml/TestDependencies.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/TestDependencies.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/TestDependencies.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,320 @@
+// $Id:TestDependencies.java 12987 2007-07-05 14:28:59Z mvw $
+// 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;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import jdepend.framework.JDepend;
+import jdepend.framework.JavaPackage;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Test for Dependency cycles with JDepend. <p>
+ *
+ * This test will guarantee that once
+ * a package is made free of dependency-cycles,
+ * (and it has been added here,)
+ * it will stay dependency-cycle free. <p>
+ *
+ * It also checks that the top level package(s) are
+ * (and remain) unused by other packages. <p>
+ *
+ * It also checks that low level packages do not
+ * use other argouml packages.
+ *
+ * @author Michiel
+ */
+public class TestDependencies extends TestCase {
+ /**
+ * Tests that a list of packages does not contain
+ * any package dependency cycles.
+ *
+ * @return a list of tests.
+ */
+ public static Test suite() {
+ JDepend jdepend = new JDepend();
+
+ try {
+ jdepend.addDirectory("../argouml");
+ } catch (IOException e) {
+ // Ignore if the directory does not exist.
+ // This error will throw when running from the ant setup.
+ System.out.println("Assuming running from ant!");
+ }
+
+ try {
+ jdepend.addDirectory("../build/classes");
+ } catch (IOException e) {
+ // Ignore if the directory does not exist.
+ // This error will throw when running from the Eclipse setup.
+ System.out.println("Assuming running from Eclipse!");
+ }
+
+ jdepend.analyze();
+
+ TestSuite suite =
+ new TestSuite("Tests for dependencies using Jdepend");
+
+ String[] clean = {
+ "org.argouml.application.api",
+ "org.argouml.application.events",
+ "org.argouml.application.helpers",
+ "org.argouml.application.security",
+ "org.argouml.cognitive.checklist",
+ //"org.argouml.cognitive.critics",
+ "org.argouml.configuration",
+ "org.argouml.i18n",
+ "org.argouml.gefext",
+ "org.argouml.language.ui",
+ "org.argouml.moduleloader",
+ //"org.argouml.notation.providers",//fails because sub-packages fail (?)
+ //"org.argouml.notation.providers.java",
+ //"org.argouml.notation.providers.uml",
+ //"org.argouml.notation",//fails because sub-packages fail (?)
+ //"org.argouml.notation.ui",
+ "org.argouml.swingext",
+ "org.argouml.taskmgmt",
+ "org.argouml.uml.diagram.layout",
+ "org.argouml.uml.generator",
+ "org.argouml.uml.util.namespace",
+ "org.argouml.util.logging",
+ "org.argouml.util.osdep.win32",
+ "org.argouml.util.osdep",
+ "org.argouml.util",
+ // There was a comment saying that the below has no cycles, but
+ // Classycle thinks there's a cycle here too, so I believe there
+ // really is one - tfm 20070702
+// "org.argouml.uml.cognitive.critics",
+ };
+ for (int i = 0; i < clean.length; i++) {
+ suite.addTest(new CheckDependencyCycle(jdepend, clean[i]));
+ }
+
+ String[] top = {
+ "org.argouml.application",
+ // The following 2 are not supposed to pass, but they do.
+ // Hence these packages are not used anywhere:
+ "org.argouml.cognitive.checklist.ui",
+ "org.argouml.util.osdep.win32",
+ };
+ for (int i = 0; i < top.length; i++) {
+ suite.addTest(new CheckTopLevel(jdepend, top[i]));
+ }
+
+ String[] low = {
+ "org.argouml.application.security",
+ "org.argouml.configuration",
+ "org.argouml.i18n",
+ "org.argouml.swingext",
+ "org.argouml.taskmgmt",
+ "org.argouml.util.logging",
+ "org.argouml.util.osdep",
+ "org.argouml.util.osdep.win32",
+ };
+ for (int i = 0; i < low.length; i++) {
+ suite.addTest(new CheckLowLevel(jdepend, low[i]));
+ }
+
+ String[][] dep = {
+ // There shall not be a dependency from ... to ...
+ {"org.argouml.persistence", "org.argouml.ui"},
+ {"org.argouml.moduleloader", "org.argouml.persistence"},
+ {"org.argouml.language.java.generator", "org.argouml.notation"},
+ {"org.argouml.notation", "org.argouml.notation.ui"},
+ {"org.argouml.ui.targetmanager", "org.argouml.ui"},
+ {"org.argouml.ui", "org.argouml.moduleloader"},
+ {"org.argouml.cognitive", "org.argouml.ui"},
+ {"org.argouml.cognitive.critics", "org.argouml.cognitive.ui"},
+ {"org.argouml.ui", "org.argouml.cognitive.critics.ui"},
+//TODO:{"org.argouml.ui", "org.argouml.cognitive.ui"},
+//TODO:{"org.argouml.cognitive", "org.argouml.cognitive.critics"},
+ {"org.argouml.uml.diagram", "org.argouml.ui"},
+ {"org.argouml.ui", "org.argouml.notation.ui"},
+ {"org.argouml.util", "org.argouml.ui.cmd"},
+ {"org.argouml.moduleloader", "org.argouml.ui"},
+ //{"org.argouml.uml.reveng", "org.argouml.ui"},
+ //{"org.argouml.language.java.generator", "org.argouml.kernel"},
+ };
+ for (int i = 0; i < dep.length; i++) {
+ suite.addTest(new CheckNoDependency(jdepend, dep[i]));
+ }
+
+ return suite;
+ }
+
+ static class CheckDependencyCycle extends TestCase {
+ private String packageName;
+ private JDepend jdepend;
+
+ CheckDependencyCycle(JDepend jd, String name) {
+ super("Check dependency cycle in " + name);
+ jdepend = jd;
+ packageName = name;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void runTest() {
+ JavaPackage p = jdepend.getPackage(packageName);
+ assertNotNull(p);
+ if (p.containsCycle()) {
+ StringBuffer msg = new StringBuffer(
+ "JDepend indicates a dependency cycle in ");
+ msg.append(p.getName());
+ List<JavaPackage> firstCycle = new ArrayList<JavaPackage>();
+ p.collectCycle(firstCycle);
+ msg.append("(" + firstCycle.size());
+ msg.append(" packages in first cycle: ");
+ for (JavaPackage cp : firstCycle) {
+ msg.append(cp.getName()).append(" ");
+ }
+ msg.append(") -- ");
+ List<JavaPackage> otherCycles = new ArrayList<JavaPackage>();
+ p.collectAllCycles(otherCycles);
+ otherCycles.removeAll(firstCycle);
+ if (!otherCycles.isEmpty()) {
+ msg.append("(" + otherCycles.size());
+ msg.append(" packages in additional cycle(s): ");
+ for (JavaPackage cp : otherCycles) {
+ msg.append(cp.getName()).append(" ");
+ }
+ msg.append(") -- ");
+ }
+
+// msg.append("(" + p.getClassCount() + " classes: ");
+// Collection<JavaClass> c = p.getClasses();
+// for (JavaClass jc : c) {
+// msg.append(jc.getName());
+// msg.append(" ");
+// }
+// msg.append(")");
+ assertTrue(msg.toString(), false);
+ }
+ }
+ }
+
+ static class CheckTopLevel extends TestCase {
+ private String packageName;
+ private JDepend jdepend;
+
+ CheckTopLevel(JDepend jd, String name) {
+ super("Check top level dependencies for " + name);
+ jdepend = jd;
+ packageName = name;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void runTest() {
+ JavaPackage p = jdepend.getPackage(packageName);
+ assertNotNull(p);
+ Collection<JavaPackage> afferents = p.getAfferents();
+ if (afferents.size() > 0) {
+ StringBuffer msg = new StringBuffer("JDepend "
+ + "indicates an afferent dependency "
+ + "in a top level package: ");
+ msg.append(p.getName());
+ msg.append(" is used by ");
+ msg.append(afferents.size());
+ msg.append(" packages: ");
+ for (JavaPackage jp : afferents) {
+ msg.append(jp.getName());
+ msg.append(" ");
+ }
+ assertTrue(msg.toString(), false);
+ }
+ }
+ }
+
+ static class CheckLowLevel extends TestCase {
+ private String packageName;
+ private JDepend jdepend;
+
+ CheckLowLevel(JDepend jd, String name) {
+ super("Check low level dependencies for " + name);
+ jdepend = jd;
+ packageName = name;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void runTest() {
+ JavaPackage p = jdepend.getPackage(packageName);
+ assertNotNull(p);
+ Collection<JavaPackage> efferents = p.getEfferents();
+ Collection<JavaPackage> wrong = new ArrayList<JavaPackage>();
+ for (JavaPackage jp : efferents) {
+ if (jp.getName().startsWith("org.argouml")) {
+ wrong.add(jp);
+ }
+ if (!wrong.isEmpty()) {
+ StringBuffer msg = new StringBuffer("JDepend "
+ + "indicates a dependency from "
+ + "the low level package ");
+ msg.append(p.getName());
+ msg.append(" to the argouml package(s)");
+ for (JavaPackage jpWrong : wrong) {
+ msg.append(" ");
+ msg.append(jpWrong.getName());
+ }
+ assertTrue(msg.toString(), false);
+ }
+ }
+ }
+ }
+
+ static class CheckNoDependency extends TestCase {
+ private String nameFrom;
+ private String nameTo;
+ private JDepend jdepend;
+
+ CheckNoDependency(JDepend jd, String[] name) {
+ super("Check for dependency from " + name[0] + " to " + name[1]);
+ jdepend = jd;
+ nameFrom = name[0];
+ nameTo = name[1];
+ }
+
+ @SuppressWarnings("unchecked")
+ public void runTest() {
+ JavaPackage packageFrom = jdepend.getPackage(nameFrom);
+ JavaPackage packageTo = jdepend.getPackage(nameTo);
+ assertNotNull("Missing package", packageFrom);
+ Collection<JavaPackage> efferents = packageFrom.getEfferents();
+ for (JavaPackage jp : efferents) {
+ if (jp.equals(packageTo)) {
+ StringBuffer msg = new StringBuffer(
+ "JDepend indicates a dependency from ");
+ msg.append(nameFrom);
+ msg.append(" to ");
+ msg.append(nameTo);
+ assertTrue(msg.toString(), false);
+ }
+ }
+ }
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/application/api/FalseActionExit.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/application/api/FalseActionExit.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/application/api/FalseActionExit.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,69 @@
+// $Id:FalseActionExit.java 11517 2006-11-25 05:27:15Z tfmorris $
+// Copyright (c) 2004-2006 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.application.api;
+
+import org.argouml.ui.cmd.ActionExit;
+
+/**
+ * Help to test ActionExit since we don't want to really do exit in the
+ * test case.
+ */
+public class FalseActionExit extends ActionExit {
+ private boolean isExited = false;
+ private String argument = null;
+ private static FalseActionExit lastInvoked = null;
+
+ /*
+ * @see org.argouml.application.api.CommandLineInterface#doCommand(java.lang.String)
+ */
+ public boolean doCommand(String args) {
+ lastInvoked = this;
+ argument = args;
+ isExited = true;
+ return true;
+ }
+
+ /**
+ * @return returns the argument
+ */
+ public String getArgument() {
+ return argument;
+ }
+
+ /**
+ * @return returns true if exited
+ */
+ public boolean isExited() {
+ return isExited;
+ }
+
+ /**
+ * @return returns the last invoked instance of this class
+ */
+ public static FalseActionExit getLast() {
+ return lastInvoked;
+ }
+}
+
Added: branches/gsoc2007/b00__1/tests/org/argouml/application/api/GUITestCommandLineInterface.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/application/api/GUITestCommandLineInterface.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/application/api/GUITestCommandLineInterface.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,67 @@
+// $Id:GUITestCommandLineInterface.java 12475 2007-05-01 10:40:51Z mvw $
+// Copyright (c) 2004-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.application.api;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+import org.argouml.util.CheckMain;
+
+/**
+ * This is to test the CommandLineInterface functions.<p>
+ *
+ * Note that:<ul>
+ * <li>We can't do the real ActionExit() here because that would exit
+ * the jvm running the test case.
+ * <li>As a consequence, we can't use the -batch command line option
+ * since that would invoke ActionExit().
+ * <li>After calling main we must reset the ArgoSecurityManager or else
+ * the test case will not be able to exit. For this reason use
+ * {@link CheckMain#doCommand(List)} instead of a direct call.
+ * @author Linus Tolke
+ */
+public class GUITestCommandLineInterface extends TestCase {
+ /**
+ * Constructor.
+ *
+ * @param name the name of the test case
+ */
+ public GUITestCommandLineInterface(String name) {
+ super(name);
+ }
+
+ /**
+ * Test the simplest possible action.
+ */
+ public void testActionExit() {
+ List<String> c = new ArrayList<String>();
+ c.add("org.argouml.application.api.FalseActionExit");
+ CheckMain.doCommand(c);
+
+ assertTrue(FalseActionExit.getLast().isExited());
+ }
+}
+
Added: branches/gsoc2007/b00__1/tests/org/argouml/application/api/package.html
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/application/api/package.html?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/application/api/package.html 2007-08-13 09:07:56-0700
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+ Copyright (c) 1996-2004 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.
+-->
+</head>
+<body bgcolor="white">
+<!--
+##### TYPE YOUR PACKAGE COMMENTS HERE. BEGIN WITH A #####
+##### ONE-SENTENCE SUMMARY STARTING WITH A VERB LIKE: #####
+Provides for....
+-->
+
+</body>
+</html>
Added: branches/gsoc2007/b00__1/tests/org/argouml/cognitive/TestCritic.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/cognitive/TestCritic.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/cognitive/TestCritic.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,57 @@
+// $Id:TestCritic.java 12920 2007-06-28 22:10:30Z linus $
+// Copyright (c) 2005-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.cognitive;
+
+import junit.framework.TestCase;
+
+/**
+ * Testing the creation of a Critic.
+ */
+public class TestCritic extends TestCase {
+
+ private Critic cr;
+
+ public TestCritic(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ cr = new Critic();
+ }
+
+ /**
+ * Test some basic functions.
+ */
+ public void testBasics() {
+ assertFalse(cr.predicate(null, null));
+
+ assertTrue(cr.isActive());
+ cr.beInactive();
+ assertFalse(cr.isActive());
+ cr.beActive();
+ assertTrue(cr.isActive());
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/cognitive/TestItemUID.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/cognitive/TestItemUID.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/cognitive/TestItemUID.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,241 @@
+// $Id:TestItemUID.java 12954 2007-07-01 18:40:32Z mvw $
+// Copyright (c) 2002-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.cognitive;
+
+// Diagrams
+import junit.framework.TestCase;
+
+import org.argouml.model.InitializeModel;
+import org.argouml.model.Model;
+import org.argouml.uml.CommentEdge;
+import org.argouml.uml.diagram.activity.ui.FigActionState;
+import org.argouml.uml.diagram.activity.ui.UMLActivityDiagram;
+import org.argouml.uml.diagram.collaboration.ui.FigClassifierRole;
+import org.argouml.uml.diagram.collaboration.ui.UMLCollaborationDiagram;
+import org.argouml.uml.diagram.deployment.ui.FigComponent;
+import org.argouml.uml.diagram.deployment.ui.FigComponentInstance;
+import org.argouml.uml.diagram.deployment.ui.FigMNode;
+import org.argouml.uml.diagram.deployment.ui.FigNodeInstance;
+import org.argouml.uml.diagram.deployment.ui.FigObject;
+import org.argouml.uml.diagram.deployment.ui.UMLDeploymentDiagram;
+import org.argouml.uml.diagram.sequence.ui.UMLSequenceDiagram;
+import org.argouml.uml.diagram.state.ui.FigBranchState;
+import org.argouml.uml.diagram.state.ui.FigCompositeState;
+import org.argouml.uml.diagram.state.ui.FigDeepHistoryState;
+import org.argouml.uml.diagram.state.ui.FigFinalState;
+import org.argouml.uml.diagram.state.ui.FigForkState;
+import org.argouml.uml.diagram.state.ui.FigInitialState;
+import org.argouml.uml.diagram.state.ui.FigJoinState;
+import org.argouml.uml.diagram.state.ui.FigShallowHistoryState;
+import org.argouml.uml.diagram.state.ui.FigTransition;
+import org.argouml.uml.diagram.state.ui.UMLStateDiagram;
+import org.argouml.uml.diagram.static_structure.ui.FigEdgeNote;
+import org.argouml.uml.diagram.static_structure.ui.FigInstance;
+import org.argouml.uml.diagram.static_structure.ui.FigInterface;
+import org.argouml.uml.diagram.static_structure.ui.FigLink;
+import org.argouml.uml.diagram.static_structure.ui.UMLClassDiagram;
+import org.argouml.uml.diagram.use_case.ui.FigActor;
+import org.argouml.uml.diagram.use_case.ui.FigExtend;
+import org.argouml.uml.diagram.use_case.ui.FigInclude;
+import org.argouml.uml.diagram.use_case.ui.FigUseCase;
+import org.argouml.uml.diagram.use_case.ui.UMLUseCaseDiagram;
+
+
+/**
+ * Test the ItemUID class.
+ *
+ */
+public class TestItemUID extends TestCase {
+
+ /**
+ * The constructor.
+ *
+ * @param name the name of the test.
+ */
+ public TestItemUID(String name) {
+ super(name);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test the constructors.
+ */
+ public void testConstructors() {
+ String[] strs = {
+ "a", "b", "c", "d", "e",
+ };
+ ItemUID[] uids = new ItemUID[10];
+ ItemUID[] uids2 = new ItemUID[strs.length];
+ int i, j;
+
+ for (i = 0; i < uids.length; i++) {
+ uids[i] = new ItemUID();
+ for (j = 0; j < i; j++) {
+ assertTrue(
+ "ItemUID() does not generate unique UIDs",
+ !uids[j].toString().equals(uids[i].toString()));
+ }
+ }
+
+ for (i = 0; i < strs.length; i++) {
+ uids2[i] = new ItemUID(strs[i]);
+
+ assertTrue(
+ "ItemUID(sss) does not preserve UIDs",
+ strs[i].equals(uids2[i].toString()));
+
+ for (j = 0; j < i; j++) {
+ assertTrue(
+ "ItemUID(sss) does not generate unique UIDs",
+ !uids2[j].toString().equals(uids2[i].toString()));
+ }
+ }
+ }
+
+ /**
+ * Test assigning IDs to objects.
+ */
+ public void testAssignIDsToObjects() {
+ Object testmc = Model.getCoreFactory().buildClass();
+ CommentEdge commentedge = new CommentEdge();
+ UMLActivityDiagram actdiag = new UMLActivityDiagram();
+ UMLClassDiagram classdiag = new UMLClassDiagram();
+ UMLCollaborationDiagram colldiag = new UMLCollaborationDiagram();
+ UMLDeploymentDiagram depdiag = new UMLDeploymentDiagram();
+ UMLSequenceDiagram seqdiag = new UMLSequenceDiagram();
+ UMLStateDiagram statediag = new UMLStateDiagram();
+ UMLUseCaseDiagram ucdiag = new UMLUseCaseDiagram();
+
+ FigActionState figactionstate = new FigActionState();
+
+ // FigAssociationRole figassociationrole = new FigAssociationRole();
+ FigClassifierRole figclassifierrole = new FigClassifierRole();
+
+ FigComponent figcomponent = new FigComponent();
+ FigComponentInstance figcomponentinstance = new FigComponentInstance();
+ FigMNode figmnode = new FigMNode();
+ FigNodeInstance figmnodeinstance = new FigNodeInstance();
+ FigObject figobject = new FigObject();
+
+ FigBranchState figbranchstate = new FigBranchState();
+ FigCompositeState figcompositestate = new FigCompositeState();
+ FigDeepHistoryState figdeephistorystate = new FigDeepHistoryState();
+ FigFinalState figfinalstate = new FigFinalState();
+ FigForkState figforkstate = new FigForkState();
+ //FigHistoryState fighistorystate = new FigHistoryState();
+ FigInitialState figinitialstate = new FigInitialState();
+ FigJoinState figjoinstate = new FigJoinState();
+ FigShallowHistoryState figshallowhistorystate =
+ new FigShallowHistoryState();
+ //FigState figstate = new FigState();
+ FigTransition figtransition = new FigTransition();
+
+// FigClass figclass = new FigClass();
+ FigEdgeNote figedgenote = new FigEdgeNote();
+ FigInstance figinstance = new FigInstance();
+ FigInterface figinterface = new FigInterface();
+ FigLink figlink = new FigLink();
+// FigPackage figpackage = new FigPackage();
+
+ FigActor figactor = new FigActor();
+ FigExtend figextend = new FigExtend();
+ FigInclude figinclude = new FigInclude();
+ FigUseCase figusecase = new FigUseCase();
+
+ checkAssignIDToObject(testmc, true, true);
+ checkAssignIDToObject(commentedge, false, true);
+ checkAssignIDToObject(actdiag, true, true);
+ checkAssignIDToObject(classdiag, true, true);
+ checkAssignIDToObject(colldiag, true, true);
+ checkAssignIDToObject(depdiag, true, true);
+ checkAssignIDToObject(seqdiag, true, true);
+ checkAssignIDToObject(statediag, true, true);
+ checkAssignIDToObject(ucdiag, true, true);
+
+ checkAssignIDToObject(figactionstate, true, true);
+
+ //checkAssignIDToObject(figassociationrole, true, true);
+ checkAssignIDToObject(figclassifierrole, true, true);
+
+ checkAssignIDToObject(figcomponent, true, true);
+ checkAssignIDToObject(figcomponentinstance, true, true);
+ checkAssignIDToObject(figmnode, true, true);
+ checkAssignIDToObject(figmnodeinstance, true, true);
+ checkAssignIDToObject(figobject, true, true);
+
+ checkAssignIDToObject(figbranchstate, true, true);
+ checkAssignIDToObject(figcompositestate, true, true);
+ checkAssignIDToObject(figdeephistorystate, true, true);
+ checkAssignIDToObject(figfinalstate, true, true);
+ checkAssignIDToObject(figforkstate, true, true);
+ //checkAssignIDToObject(fighistorystate, true, true);
+ checkAssignIDToObject(figinitialstate, true, true);
+ checkAssignIDToObject(figjoinstate, true, true);
+ checkAssignIDToObject(figshallowhistorystate, true, true);
+ //checkAssignIDToObject(figstate, true, true);
+ checkAssignIDToObject(figtransition, true, true);
+
+// checkAssignIDToObject(figclass, true, true);
+ checkAssignIDToObject(figedgenote, true, true);
+ checkAssignIDToObject(figinstance, true, true);
+ checkAssignIDToObject(figinterface, true, true);
+ checkAssignIDToObject(figlink, true, true);
+ //checkAssignIDToObject(figpackage, true, true);
+
+ checkAssignIDToObject(figactor, true, true);
+ checkAssignIDToObject(figextend, true, true);
+ checkAssignIDToObject(figinclude, true, true);
+ checkAssignIDToObject(figusecase, true, true);
+ }
+
+ private void checkAssignIDToObject(
+ Object obj,
+ boolean canCreate,
+ boolean willSucceed) {
+ String uid, uid2;
+ uid = ItemUID.getIDOfObject(obj, canCreate);
+ uid2 = ItemUID.getIDOfObject(obj, false);
+ assertTrue(
+ "Assign ID to object "
+ + obj.getClass().getName()
+ + " "
+ + (willSucceed ? "failed" : "succeeded")
+ + " unexpectedly",
+ (uid != null) == willSucceed);
+ assertTrue(
+ "Assign ID to object "
+ + obj.getClass().getName()
+ + " yielded different results",
+ (uid == null && uid2 == null)
+ || (uid != null && uid2 != null && uid.equals(uid2)));
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/cognitive/TestResolvedCritic.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/cognitive/TestResolvedCritic.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/cognitive/TestResolvedCritic.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,183 @@
+// $Id:TestResolvedCritic.java 12949 2007-07-01 08:09:16Z tfmorris $
+// Copyright (c) 2002-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.cognitive;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.argouml.model.InitializeModel;
+import org.argouml.model.Model;
+
+/**
+ * Test the ResolvedCritic class.
+ *
+ */
+public class TestResolvedCritic extends TestCase {
+
+ /**
+ * The constructor.
+ *
+ * @param name the name of the test
+ */
+ public TestResolvedCritic(String name) {
+ super(name);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test the constructors.
+ */
+ public void testConstructors() {
+ Object testmc = Model.getCoreFactory().buildClass();
+ Critic c = new Critic();
+ String crString = "class org.argouml.cognitive.Critic";
+ ResolvedCritic rc;
+ List<String> list = new ArrayList<String>();
+ ListSet set = new ListSet();
+
+ /* ResolvedCritic(String, Vector) */
+
+ rc = new ResolvedCritic("rc", (List<String>) null);
+ assertTrue("getCritic simple", "rc".equals(rc.getCritic()));
+ assertTrue(
+ "getOffenderList simple",
+ (rc.getOffenderList() == null
+ || rc.getOffenderList().size() == 0));
+
+ list.add("str1");
+ rc = new ResolvedCritic("rc2", list);
+ assertTrue("getCritic 2nd", "rc2".equals(rc.getCritic()));
+ assertTrue(
+ "getOffenderList 2nd",
+ rc.getOffenderList() != null
+ && "str1".equals(rc.getOffenderList().get(0)));
+
+ /* ResolvedCritic(Critic, VectorSet) */
+
+ try {
+ rc = new ResolvedCritic(c, null);
+ System.out.println(rc.getCritic());
+ assertTrue("getCritic 1", crString.equals(rc.getCritic()));
+ assertTrue(
+ "getOffenderList 1",
+ rc.getOffenderList() == null
+ || rc.getOffenderList().size() == 0);
+ } catch (UnresolvableException ure1) {
+ assertTrue("create 1 with MClass", false);
+ }
+
+ set.add(testmc);
+ try {
+ rc = new ResolvedCritic(c, set);
+
+ assertTrue("getCritic 2", crString.equals(rc.getCritic()));
+ assertTrue(
+ "assigns id 2",
+ ItemUID.getIDOfObject(testmc, false) != null);
+ assertTrue(
+ "getOffenderList 2",
+ rc.getOffenderList() != null
+ && (ItemUID.getIDOfObject(testmc, false).equals(
+ rc.getOffenderList().get(0))));
+ } catch (UnresolvableException ure1) {
+ assertTrue("create 2 with MClass", false);
+ }
+
+ /* ResolvedCritic(Critic, VectorSet, boolean) */
+
+ /* testmc should now have an ItemUID so we should be able to
+ * create without adding a new ItemUID */
+ try {
+ rc = new ResolvedCritic(c, set, false);
+
+ assertTrue("getCritic 3", crString.equals(rc.getCritic()));
+ assertTrue(
+ "assigns id 3",
+ ItemUID.getIDOfObject(testmc, false) != null);
+ assertTrue(
+ "getOffenderList 3",
+ rc.getOffenderList() != null
+ && (ItemUID.getIDOfObject(testmc, false).equals(
+ rc.getOffenderList().get(0))));
+ } catch (UnresolvableException ure1) {
+ assertTrue("create 3 with Class", false);
+ }
+ set.remove(testmc);
+ }
+
+ /**
+ * Test the equals() method.
+ */
+ public void testEquals() {
+ Critic c = new Critic();
+ ResolvedCritic rc1, rc2;
+ List<String> list = new ArrayList<String>();
+ ListSet set = new ListSet();
+
+ rc1 = new ResolvedCritic("RC", (List<String>) null);
+ rc2 = new ResolvedCritic("RC", (List<String>) null);
+ assertTrue("Same empty ctor", rc1.equals(rc2) && rc2.equals(rc1));
+
+ rc2 = new ResolvedCritic("RC", list);
+ assertTrue("Empty vec ctor", rc1.equals(rc2) && rc2.equals(rc1));
+
+ list.add("a");
+ rc2 = new ResolvedCritic("RC", list);
+ assertTrue("Bigger rc2 - 1", rc1.equals(rc2));
+ assertTrue("Bigger rc2 - 2", !rc2.equals(rc1));
+
+ rc1 = new ResolvedCritic("RC", list);
+ assertTrue("Same vec ctor", rc1.equals(rc2) && rc2.equals(rc1));
+
+ list.clear();
+ list.add("b");
+ rc2 = new ResolvedCritic("RC", list);
+ assertTrue("Diff rc2 - 1", !rc1.equals(rc2));
+ assertTrue("Diff rc2 - 2", !rc2.equals(rc1));
+
+ try {
+ rc1 = new ResolvedCritic(c, null);
+ rc2 = new ResolvedCritic(c, null);
+ assertTrue(
+ "Same empty ctor (c)",
+ rc1.equals(rc2) && rc2.equals(rc1));
+
+ rc2 = new ResolvedCritic(c, set);
+ assertTrue("Empty set ctor", rc1.equals(rc2) && rc2.equals(rc1));
+ } catch (UnresolvableException ure) {
+ assertTrue("Test error URE", false);
+ }
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/cognitive/package.html
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/cognitive/package.html?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/cognitive/package.html 2007-08-13 09:07:56-0700
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+ Copyright (c) 1996-2004 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.
+-->
+</head>
+<body bgcolor="white">
+<!--
+##### TYPE YOUR PACKAGE COMMENTS HERE. BEGIN WITH A #####
+##### ONE-SENTENCE SUMMARY STARTING WITH A VERB LIKE: #####
+Provides for....
+-->
+
+</body>
+</html>
Added: branches/gsoc2007/b00__1/tests/org/argouml/i18n/TestTranslator.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/i18n/TestTranslator.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/i18n/TestTranslator.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,83 @@
+// $Id:TestTranslator.java 12449 2007-04-29 06:59:20Z mvw $
+// Copyright (c) 2005-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.i18n;
+
+import java.util.Locale;
+
+import junit.framework.TestCase;
+
+/**
+ * Test the Translator class.
+ */
+public class TestTranslator extends TestCase {
+
+ public TestTranslator(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testGetLocales() {
+ assertTrue("The list of supported locales is too small",
+ Translator.getLocales().length > 9);
+ }
+
+ public void testSetLocaleString() {
+ try {
+ Translator.setLocale((String) null);
+ fail();
+ } catch (NullPointerException e) {
+ }
+ }
+
+ public void testSetLocaleLocale() {
+ try {
+ Translator.setLocale((Locale) null);
+ } catch (NullPointerException e) {
+ }
+ }
+
+ public void testGetSystemDefaultLocale() {
+ Translator.getSystemDefaultLocale();
+ }
+
+ public void testLocalizeString() {
+ try {
+ Translator.localize(null);
+ fail();
+ } catch (IllegalArgumentException e) {
+ }
+ }
+
+ public void testMessageFormat() {
+ try {
+ Translator.messageFormat(null, null);
+ } catch (IllegalArgumentException e) {
+ }
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/kernel/TestProject.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/kernel/TestProject.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/kernel/TestProject.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,477 @@
+// $Id:TestProject.java 13031 2007-07-10 18:05:27Z tfmorris $
+// Copyright (c) 1996-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.kernel;
+
+import java.util.Collection;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.i18n.Translator;
+import org.argouml.model.Model;
+import org.argouml.ui.targetmanager.TargetManager;
+import org.argouml.uml.diagram.activity.ui.UMLActivityDiagram;
+import org.argouml.uml.diagram.state.ui.UMLStateDiagram;
+import org.argouml.uml.diagram.static_structure.ui.UMLClassDiagram;
+
+
+/**
+ * @since Nov 17, 2002
+ * @author [email protected]
+ */
+public class TestProject extends TestCase {
+
+ /**
+ * Constructor for TestProject.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestProject(String arg0) {
+ super(arg0);
+ }
+
+ /**
+ * Test the makeUntitledProject() function.
+ */
+ public void testMakeUntitledProject() {
+ Project p = ProjectManager.getManager().getCurrentProject();
+ assertEquals(2, p.getDiagramList().size());
+ assertEquals(Translator.localize("misc.untitled-model"),
+ Model.getFacade().getName(p.getModel()));
+ // maybe next test is going to change in future
+ assertEquals(p.getRoot(), p.getModel());
+ }
+
+ /**
+ * Test the moveToTrash function for package and content.
+ */
+ public void testTrashcanPackageContent() {
+ Project p = ProjectManager.getManager().getCurrentProject();
+ // test with a class in a package
+ Object package1 =
+ Model.getModelManagementFactory().buildPackage("test1", null);
+ Model.getCoreHelper().setNamespace(package1, p.getRoot());
+ Object cls1 = Model.getCoreFactory().buildClass(package1);
+ Object cls2 = Model.getCoreFactory().buildClass(package1);
+ Object cls3 = Model.getCoreFactory().buildClass(package1);
+ Object cls4 = Model.getCoreFactory().buildClass(p.getRoot());
+ Object c1 = Model.getFacade().getOwnedElements(p.getRoot());
+ assertTrue(c1 instanceof Collection);
+ // Let's make it a bit more difficult by setting the target:
+ TargetManager.getInstance().setTarget(cls2);
+
+ p.moveToTrash(package1);
+ Model.getPump().flushModelEvents();
+
+ //TODO: We should also test that the object
+ //have been removed from their namespace.
+ //Collection c = Model.getFacade().getOwnedElements(p.getRoot());
+ assertTrue("Package not in trash", p.isInTrash(package1));
+ assertTrue("Package not deleted",
+ Model.getUmlFactory().isRemoved(package1));
+ assertTrue("Class 1 not deleted",
+ Model.getUmlFactory().isRemoved(cls1));
+ assertTrue("Class 2 not deleted",
+ Model.getUmlFactory().isRemoved(cls2));
+ assertTrue("Class 3 not deleted",
+ Model.getUmlFactory().isRemoved(cls3));
+ assertTrue("Class 4 has been deleted",
+ !Model.getUmlFactory().isRemoved(cls4));
+ }
+
+ /**
+ * Test the moveToTrash function for class and content.
+ */
+ public void testTrashcanClassContent() {
+ Project p = ProjectManager.getManager().getCurrentProject();
+ // test with a class and an inner class
+ Object aClass = Model.getCoreFactory().buildClass("Test", p.getRoot());
+ Object cls1 = Model.getCoreFactory().buildClass(aClass);
+ Object cls2 = Model.getCoreFactory().buildClass(aClass);
+ Object cls3 = Model.getCoreFactory().buildClass(aClass);
+ Object typ = Model.getCoreFactory().buildClass(p.getRoot());
+ Object oper2a = Model.getCoreFactory().buildOperation(cls2, cls3);
+ assertNotNull(oper2a);
+ Object oper2b = Model.getCoreFactory().buildOperation(cls2, typ);
+ assertNotNull(oper2b);
+
+ p.moveToTrash(aClass);
+ Model.getPump().flushModelEvents();
+
+ assertTrue("Package not in trash", p.isInTrash(aClass));
+ assertTrue("Package not deleted",
+ Model.getUmlFactory().isRemoved(aClass));
+ assertTrue("Class 1 not deleted",
+ Model.getUmlFactory().isRemoved(cls1));
+ assertTrue("Class 2 not deleted",
+ Model.getUmlFactory().isRemoved(cls2));
+ assertTrue("Class 3 not deleted",
+ Model.getUmlFactory().isRemoved(cls3));
+ }
+
+
+
+ /**
+ * Test deleting a package that contains a Class diagram.
+ * The diagram should be deleted, too.
+ */
+ public void testDeletePackageWithClassDiagram() {
+ Project p = ProjectManager.getManager().getCurrentProject();
+ assertEquals(2, p.getDiagramList().size());
+ assertEquals(Translator.localize("misc.untitled-model"),
+ Model.getFacade().getName(p.getModel()));
+ assertEquals(p.getRoot(), p.getModel());
+
+ int sizeMembers = p.getMembers().size();
+ int sizeDiagrams = p.getDiagramList().size();
+
+ // test with a class and class diagram
+ Object package1 =
+ Model.getModelManagementFactory().buildPackage("test1", null);
+ assertNotNull(package1);
+ Object package2 =
+ Model.getModelManagementFactory().buildPackage("test2", null);
+
+ UMLClassDiagram cDiag = new UMLClassDiagram(package2);
+ p.addMember(cDiag);
+ assertEquals(sizeDiagrams + 1, p.getDiagramList().size());
+ assertEquals(sizeMembers + 1, p.getMembers().size());
+ p.moveToTrash(package2);
+ Model.getPump().flushModelEvents();
+
+ assertEquals(sizeDiagrams, p.getDiagramList().size());
+ assertEquals(sizeMembers, p.getMembers().size());
+ }
+
+ /**
+ * Test deleting a class that contains a Statechart diagram.
+ * The diagram should be deleted, too.
+ */
+ public void testDeleteClassWithStateDiagram() {
+ Project p = ProjectManager.getManager().getCurrentProject();
+ assertEquals(2, p.getDiagramList().size());
+
+ int sizeMembers = p.getMembers().size();
+ int sizeDiagrams = p.getDiagramList().size();
+
+ // test with a class and class diagram
+ Object package1 =
+ Model.getModelManagementFactory().buildPackage("test1", null);
+ Object aClass = Model.getCoreFactory().buildClass(package1);
+
+
+ // try with Statediagram
+ Object machine =
+ Model.getStateMachinesFactory().buildStateMachine(aClass);
+ UMLStateDiagram d =
+ new UMLStateDiagram(
+ Model.getFacade().getNamespace(machine),
+ machine);
+ p.addMember(d);
+ assertEquals("Diagram count incorrect", sizeDiagrams + 1,
+ p.getDiagramList().size());
+ assertEquals("Member count incorrect", sizeMembers + 1,
+ p.getMembers().size());
+ p.moveToTrash(aClass);
+ Model.getPump().flushModelEvents();
+
+ assertTrue("Statemachine not in trash", p.isInTrash(machine));
+ assertTrue("Class not in trash", p.isInTrash(aClass));
+ assertEquals("Diagram count incorrect after trash", sizeDiagrams,
+ p.getDiagramList().size());
+ assertEquals("Member count incorrect after trash", sizeMembers,
+ p.getMembers().size());
+ }
+
+ /**
+ * Test deleting a statechart diagram directly.
+ */
+ public void testDeleteStateDiagram() {
+ Project p = ProjectManager.getManager().getCurrentProject();
+ assertEquals(2, p.getDiagramList().size());
+
+ int sizeMembers = p.getMembers().size();
+ int sizeDiagrams = p.getDiagramList().size();
+
+ // test with a class and class diagram
+ Object package1 =
+ Model.getModelManagementFactory().buildPackage("test1", null);
+ Object aClass = Model.getCoreFactory().buildClass(package1);
+
+
+ // try with Statediagram
+ Object machine =
+ Model.getStateMachinesFactory().buildStateMachine(aClass);
+ UMLStateDiagram d =
+ new UMLStateDiagram(
+ Model.getFacade().getNamespace(machine),
+ machine);
+ p.addMember(d);
+ assertEquals(sizeDiagrams + 1, p.getDiagramList().size());
+ assertEquals(sizeMembers + 1, p.getMembers().size());
+ p.moveToTrash(d);
+ Model.getPump().flushModelEvents();
+
+ assertTrue("Statediagram not in trash", p.isInTrash(d));
+ assertEquals(sizeDiagrams, p.getDiagramList().size());
+ assertEquals(sizeMembers, p.getMembers().size());
+ }
+
+ /**
+ * Test deleting a class that contains a Class.
+ * The inner class should be deleted, too.
+ */
+ public void testDeleteClassWithInnerClass() {
+ Project p = ProjectManager.getManager().getCurrentProject();
+ assertEquals(2, p.getDiagramList().size());
+
+ // test with a class and an inner class
+ Object aClass = Model.getCoreFactory().buildClass("Test");
+ Object bClass = Model.getCoreFactory().buildClass(aClass);
+
+ p.moveToTrash(aClass);
+ Model.getPump().flushModelEvents();
+
+ assertTrue("Class not in trash", p.isInTrash(aClass));
+ assertTrue("Inner Class not in trash",
+ Model.getUmlFactory().isRemoved(bClass));
+ }
+
+ /**
+ * Test deleting a package that contains a Class.
+ * The class should be deleted, too.
+ */
+ public void testDeletePackageWithClass() {
+ Project p = ProjectManager.getManager().getCurrentProject();
+ assertEquals(2, p.getDiagramList().size());
+
+ // test with a class and class diagram
+ Object package1 =
+ Model.getModelManagementFactory().buildPackage("test1", null);
+ Object aClass = Model.getCoreFactory().buildClass(package1);
+
+ p.moveToTrash(package1);
+ Model.getPump().flushModelEvents();
+
+ assertTrue("Class not in trash",
+ Model.getUmlFactory().isRemoved(aClass));
+ }
+
+
+ /**
+ * Test deleting a package that contains a Class with Statechart diagram.
+ * The diagram should be deleted, too.
+ */
+ public void testDeletePackageWithStateDiagram() {
+ Project p = ProjectManager.getManager().getCurrentProject();
+ assertEquals(2, p.getDiagramList().size());
+
+ int sizeMembers = p.getMembers().size();
+ int sizeDiagrams = p.getDiagramList().size();
+
+ // test with a class and class diagram
+ Object package1 =
+ Model.getModelManagementFactory().buildPackage("test1", null);
+ Object aClass = Model.getCoreFactory().buildClass(package1);
+
+
+ // try with Statediagram
+ Object machine =
+ Model.getStateMachinesFactory().buildStateMachine(aClass);
+ UMLStateDiagram d =
+ new UMLStateDiagram(
+ Model.getFacade().getNamespace(machine),
+ machine);
+ p.addMember(d);
+ assertEquals(sizeDiagrams + 1, p.getDiagramList().size());
+ assertEquals(sizeMembers + 1, p.getMembers().size());
+
+ p.moveToTrash(package1);
+ Model.getPump().flushModelEvents();
+
+ assertTrue("Class not in trash",
+ Model.getUmlFactory().isRemoved(aClass));
+ assertTrue("Statemachine not in trash",
+ Model.getUmlFactory().isRemoved(machine));
+ assertEquals(sizeDiagrams, p.getDiagramList().size());
+ assertEquals(sizeMembers, p.getMembers().size());
+ }
+
+ /**
+ * Test deleting an operation that contains a statechart diagram.
+ * The diagram should be deleted, too.
+ */
+ public void testDeleteOperationWithStateDiagram() {
+ Project p = ProjectManager.getManager().getCurrentProject();
+ assertEquals(2, p.getDiagramList().size());
+
+ int sizeMembers = p.getMembers().size();
+ int sizeDiagrams = p.getDiagramList().size();
+
+ // test with a class and class diagram
+ Object package1 =
+ Model.getModelManagementFactory().buildPackage("test1", null);
+ Object aClass = Model.getCoreFactory().buildClass(package1);
+
+ Object voidType = p.getDefaultReturnType();
+ Object oper =
+ Model.getCoreFactory().buildOperation(
+ aClass,
+ voidType);
+
+ // try with Statediagram
+ Object machine =
+ Model.getStateMachinesFactory().buildStateMachine(oper);
+ UMLStateDiagram d =
+ new UMLStateDiagram(
+ Model.getFacade().getNamespace(machine),
+ machine);
+ p.addMember(d);
+ assertEquals(sizeDiagrams + 1, p.getDiagramList().size());
+ assertEquals(sizeMembers + 1, p.getMembers().size());
+
+ p.moveToTrash(oper);
+ Model.getPump().flushModelEvents();
+
+ assertTrue("Operation not in trash", p.isInTrash(oper));
+ /* Changed by issue 4281: */
+ assertTrue("Statemachine in trash",
+ !Model.getUmlFactory().isRemoved(machine));
+ assertEquals(sizeDiagrams + 1, p.getDiagramList().size());
+ assertEquals(sizeMembers + 1, p.getMembers().size());
+ /* After issue 4284 will be solved, we
+ * may even delete the class, and the diagram
+ * should still exist. */
+ }
+
+
+ /**
+ * Test deleting a package with a Class with a Activity diagram.
+ * The diagram should be deleted, too.
+ */
+ public void testDeletePackageWithClassWithActivityDiagram() {
+ Project p = ProjectManager.getManager().getCurrentProject();
+ assertEquals(2, p.getDiagramList().size());
+
+ int sizeMembers = p.getMembers().size();
+ int sizeDiagrams = p.getDiagramList().size();
+
+ // test with a package and a class and activity diagram
+ Object package1 =
+ Model.getModelManagementFactory().buildPackage("test1", null);
+ Object aClass = Model.getCoreFactory().buildClass(package1);
+
+ // build the Activity Diagram
+ Object actgrph =
+ Model.getActivityGraphsFactory().buildActivityGraph(aClass);
+ UMLActivityDiagram d =
+ new UMLActivityDiagram(
+ Model.getFacade().getNamespace(actgrph),
+ actgrph);
+ p.addMember(d);
+ assertEquals(sizeDiagrams + 1, p.getDiagramList().size());
+ assertEquals(sizeMembers + 1, p.getMembers().size());
+
+ p.moveToTrash(package1);
+ Model.getPump().flushModelEvents();
+
+ assertTrue("Class not in trash",
+ Model.getUmlFactory().isRemoved(aClass));
+ assertTrue("ActivityGraph not in trash",
+ Model.getUmlFactory().isRemoved(actgrph));
+ assertEquals(sizeDiagrams, p.getDiagramList().size());
+ assertEquals(sizeMembers, p.getMembers().size());
+ }
+
+
+ /**
+ * Test deleting a package with a package with a Activity diagram.
+ * The diagram should be deleted, too.
+ */
+ public void testDeletePackageWithPackageWithActivityDiagram() {
+ Project p = ProjectManager.getManager().getCurrentProject();
+ assertEquals(2, p.getDiagramList().size());
+
+ int sizeMembers = p.getMembers().size();
+ int sizeDiagrams = p.getDiagramList().size();
+
+ // test with a package and a class and activity diagram
+ Object package1 =
+ Model.getModelManagementFactory().buildPackage("test1", null);
+ Model.getCoreHelper().setNamespace(package1, p.getModel());
+ Object package2 =
+ Model.getModelManagementFactory().buildPackage("test2", null);
+ Model.getCoreHelper().setNamespace(package2, package1);
+
+ // build the Activity Diagram
+ Object actgrph =
+ Model.getActivityGraphsFactory().buildActivityGraph(package2);
+ UMLActivityDiagram d =
+ new UMLActivityDiagram(
+ Model.getFacade().getNamespace(actgrph), actgrph);
+ p.addMember(d);
+ assertEquals(sizeDiagrams + 1, p.getDiagramList().size());
+ assertEquals(sizeMembers + 1, p.getMembers().size());
+
+ p.moveToTrash(package1);
+ Model.getPump().flushModelEvents();
+
+ assertTrue("Package 2 not in trash",
+ Model.getUmlFactory().isRemoved(package2));
+ assertTrue("ActivityGraph not in trash",
+ Model.getUmlFactory().isRemoved(actgrph));
+ assertEquals(sizeDiagrams, p.getDiagramList().size());
+ assertEquals(sizeMembers, p.getMembers().size());
+ }
+
+ /**
+ * Check that there is only one searchPath.
+ * See issue 1671.
+ */
+ public void testAddSearchPath() {
+ Project p = ProjectManager.getManager().getCurrentProject();
+ assertNotNull(p.getSearchPathList());
+ assertTrue(p.getSearchPathList().size() == 1);
+
+ p.addSearchPath("PROJECT_DIR");
+ assertTrue(p.getSearchPathList().size() == 1);
+
+ p.addSearchPath("foo");
+ p.addSearchPath("foo");
+ assertTrue(p.getSearchPathList().size() == 2);
+
+ }
+
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ ProjectManager.getManager().setCurrentProject(null);
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/kernel/TestProjectManager.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/kernel/TestProjectManager.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/kernel/TestProjectManager.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,65 @@
+// $Id:TestProjectManager.java 13024 2007-07-10 17:51:08Z tfmorris $
+// Copyright (c) 1996-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.kernel;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.i18n.Translator;
+import org.argouml.model.Model;
+
+/**
+ * @since Nov 22, 2002
+ * @author [email protected]
+ */
+public class TestProjectManager extends TestCase {
+
+ /**
+ * Constructor for TestProjectManager.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestProjectManager(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test the makeEmptyProject() function.
+ */
+ public void testMakeEmptyProject() {
+ Project p = ProjectManager.getManager().makeEmptyProject();
+ assertEquals(2, p.getDiagramList().size());
+ assertEquals(Translator.localize("misc.untitled-model"),
+ Model.getFacade().getName(p.getModel()));
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/kernel/TestProjectSettings.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/kernel/TestProjectSettings.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/kernel/TestProjectSettings.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,324 @@
+// $Id:TestProjectSettings.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 2006-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.kernel;
+
+import java.beans.PropertyChangeEvent;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.application.events.ArgoEventPump;
+import org.argouml.application.events.ArgoNotationEvent;
+import org.argouml.application.events.ArgoNotationEventListener;
+import org.argouml.configuration.Configuration;
+import org.argouml.notation.Notation;
+
+/**
+ * Tests for the ProjectSettings.
+ *
+ * @author michiel
+ */
+public class TestProjectSettings extends TestCase {
+
+ private ArgoNotationEvent rxdEvent;
+
+ /**
+ * Constructor.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestProjectSettings(String arg0) {
+ super(arg0);
+ }
+
+ /**
+ * Test if the settings are copied correctly
+ * from the default into the project. <p>
+ *
+ * For this test, only the shadow-width is used.
+ */
+ public void testProjectSettingsCreation() {
+ Configuration.setInteger(
+ Notation.KEY_DEFAULT_SHADOW_WIDTH, 2);
+ Project p1 = ProjectManager.getManager().makeEmptyProject();
+ assertTrue("Default Setting is not copied",
+ p1.getProjectSettings().getDefaultShadowWidthValue() == 2);
+ Configuration.setInteger(
+ Notation.KEY_DEFAULT_SHADOW_WIDTH, 3);
+ assertTrue("Project Setting is altered",
+ p1.getProjectSettings().getDefaultShadowWidth().equals("2"));
+ ProjectManager.getManager().removeProject(p1);
+
+ /* In the next line, replacing makeEmptyProject
+ * by getCurrentProject fails the test,
+ * except when run in Eclipse.
+ * MVW: I have no idea why.*/
+ Project p2 = ProjectManager.getManager().makeEmptyProject();
+ assertTrue("New project does not get Default Setting",
+ p2.getProjectSettings().getDefaultShadowWidthValue() == 3);
+ p2.getProjectSettings().setDefaultShadowWidth(4);
+ assertTrue("Default is altered by project-setting",
+ Configuration.getInteger(
+ Notation.KEY_DEFAULT_SHADOW_WIDTH) == 3);
+ }
+
+ /**
+ * Test the use of Guillemots.
+ */
+ public void testGuillemots() {
+ Configuration.setBoolean(Notation.KEY_USE_GUILLEMOTS, false);
+ Project p = ProjectManager.getManager().makeEmptyProject();
+ assertTrue("Guillemots not correct",
+ !p.getProjectSettings().getUseGuillemotsValue());
+ assertTrue("Guillemots string not set correctly",
+ "<<".equals(p.getProjectSettings().getLeftGuillemot()));
+ assertTrue("Guillemots string not set correctly",
+ ">>".equals(p.getProjectSettings().getRightGuillemot()));
+
+ p.getProjectSettings().setUseGuillemots(true);
+ assertTrue("Guillemots not correct",
+ p.getProjectSettings().getUseGuillemotsValue());
+ assertTrue("Guillemots string not set correctly",
+ "\u00ab".equals(p.getProjectSettings().getLeftGuillemot()));
+ assertTrue("Guillemots string not set correctly",
+ "\u00bb".equals(p.getProjectSettings().getRightGuillemot()));
+
+ p.getProjectSettings().setUseGuillemots(Boolean.toString(false));
+ assertTrue("Guillemots not correct",
+ !p.getProjectSettings().getUseGuillemotsValue());
+ }
+
+ /**
+ * Test the project setting for showing Visibility.
+ */
+ public void testVisibility() {
+ Configuration.setBoolean(Notation.KEY_SHOW_VISIBILITY, false);
+ Project p = ProjectManager.getManager().makeEmptyProject();
+
+ assertTrue("Visibility not correct",
+ !p.getProjectSettings().getShowVisibilityValue());
+ String showem = p.getProjectSettings().getShowVisibility();
+ assertTrue("Visibility string not set correctly",
+ !Boolean.valueOf(showem).booleanValue());
+
+ p.getProjectSettings().setShowVisibility(true);
+ assertTrue("Visibility not correct",
+ p.getProjectSettings().getShowVisibilityValue());
+ showem = p.getProjectSettings().getShowVisibility();
+ assertTrue("Visibility string not set correctly",
+ Boolean.valueOf(showem).booleanValue());
+
+ p.getProjectSettings().setShowVisibility(Boolean.toString(false));
+ assertTrue("Visibility not correct",
+ !p.getProjectSettings().getShowVisibilityValue());
+ }
+
+ /**
+ * Test the project setting for showing Multiplicity.
+ */
+ public void testMultiplicity() {
+ Configuration.setBoolean(Notation.KEY_SHOW_MULTIPLICITY, false);
+ Project p = ProjectManager.getManager().makeEmptyProject();
+
+ assertTrue("Multiplicity not correct",
+ !p.getProjectSettings().getShowMultiplicityValue());
+ String showem = p.getProjectSettings().getShowMultiplicity();
+ assertTrue("Multiplicity string not set correctly",
+ !Boolean.valueOf(showem).booleanValue());
+
+ p.getProjectSettings().setShowMultiplicity(true);
+ assertTrue("Multiplicity not correct",
+ p.getProjectSettings().getShowMultiplicityValue());
+ showem = p.getProjectSettings().getShowMultiplicity();
+ assertTrue("Multiplicity string not set correctly",
+ Boolean.valueOf(showem).booleanValue());
+
+ p.getProjectSettings().setShowMultiplicity(Boolean.toString(false));
+ assertTrue("Multiplicity not correct",
+ !p.getProjectSettings().getShowMultiplicityValue());
+ }
+
+ /**
+ * Test the project setting for showing Visibility.
+ */
+ public void testVisibilityEvents() {
+ Configuration.setBoolean(Notation.KEY_SHOW_VISIBILITY, false);
+ Project p = ProjectManager.getManager().makeEmptyProject();
+
+ ArgoEventPump.addListener(new EventCatcher());
+
+ rxdEvent = null;
+ p.getProjectSettings().setShowVisibility(Boolean.toString(true));
+ /* This assumes events are dispatched on the same thread. */
+ assertTrue("Got no notation event", rxdEvent != null);
+
+ rxdEvent = null;
+ p.getProjectSettings().setShowVisibility(Boolean.toString(false));
+ /* This assumes events are dispatched on the same thread. */
+ assertTrue("Got no notation event", rxdEvent != null);
+
+ PropertyChangeEvent pce = (PropertyChangeEvent) rxdEvent.getSource();
+ assertTrue("Wrong event name",
+ pce.getPropertyName().equals(
+ Notation.KEY_SHOW_VISIBILITY.getKey()));
+ assertTrue("Wrong old event value", Boolean.valueOf(
+ (String) pce.getOldValue()).booleanValue());
+ assertTrue("Wrong new event value", !Boolean.valueOf(
+ (String) pce.getNewValue()).booleanValue());
+ }
+
+ /**
+ * Test the events generated by project settings changes.
+ */
+ public void testMoreEvents() {
+ PropertyChangeEvent pce;
+
+ Configuration.setBoolean(Notation.KEY_SHOW_INITIAL_VALUE, false);
+ Configuration.setBoolean(Notation.KEY_SHOW_PROPERTIES, false);
+ Configuration.setBoolean(Notation.KEY_SHOW_TYPES, false);
+ Configuration.setBoolean(Notation.KEY_SHOW_STEREOTYPES, false);
+ Configuration.setInteger(Notation.KEY_DEFAULT_SHADOW_WIDTH, 4);
+ Configuration.setString(Notation.KEY_DEFAULT_NOTATION, "UML 1.4");
+
+ Project p = ProjectManager.getManager().makeEmptyProject();
+ ArgoEventPump.addListener(new EventCatcher());
+
+ rxdEvent = null;
+ p.getProjectSettings().setShowInitialValue(true);
+ /* This assumes events are dispatched on the same thread. */
+ assertTrue("Got no notation event", rxdEvent != null);
+ pce = (PropertyChangeEvent) rxdEvent.getSource();
+ assertTrue("Wrong event name",
+ pce.getPropertyName().equals(
+ Notation.KEY_SHOW_INITIAL_VALUE.getKey()));
+ assertTrue("Wrong old event value", !Boolean.valueOf(
+ (String) pce.getOldValue()).booleanValue());
+ assertTrue("Wrong new event value", Boolean.valueOf(
+ (String) pce.getNewValue()).booleanValue());
+
+ rxdEvent = null;
+ p.getProjectSettings().setShowProperties(true);
+ /* This assumes events are dispatched on the same thread. */
+ assertTrue("Got no notation event", rxdEvent != null);
+ pce = (PropertyChangeEvent) rxdEvent.getSource();
+ assertTrue("Wrong event name",
+ pce.getPropertyName().equals(
+ Notation.KEY_SHOW_PROPERTIES.getKey()));
+ assertTrue("Wrong old event value", !Boolean.valueOf(
+ (String) pce.getOldValue()).booleanValue());
+ assertTrue("Wrong new event value", Boolean.valueOf(
+ (String) pce.getNewValue()).booleanValue());
+
+ rxdEvent = null;
+ p.getProjectSettings().setShowTypes(true);
+ /* This assumes events are dispatched on the same thread. */
+ assertTrue("Got no notation event", rxdEvent != null);
+ pce = (PropertyChangeEvent) rxdEvent.getSource();
+ assertTrue("Wrong event name",
+ pce.getPropertyName().equals(
+ Notation.KEY_SHOW_TYPES.getKey()));
+ assertTrue("Wrong old event value", !Boolean.valueOf(
+ (String) pce.getOldValue()).booleanValue());
+ assertTrue("Wrong new event value", Boolean.valueOf(
+ (String) pce.getNewValue()).booleanValue());
+
+ rxdEvent = null;
+ p.getProjectSettings().setShowStereotypes(true);
+ /* This assumes events are dispatched on the same thread. */
+ assertTrue("Got no notation event", rxdEvent != null);
+ pce = (PropertyChangeEvent) rxdEvent.getSource();
+ assertTrue("Wrong event name",
+ pce.getPropertyName().equals(
+ Notation.KEY_SHOW_STEREOTYPES.getKey()));
+ assertTrue("Wrong old event value", !Boolean.valueOf(
+ (String) pce.getOldValue()).booleanValue());
+ assertTrue("Wrong new event value", Boolean.valueOf(
+ (String) pce.getNewValue()).booleanValue());
+
+ rxdEvent = null;
+ p.getProjectSettings().setDefaultShadowWidth(2);
+ /* This assumes events are dispatched on the same thread. */
+ assertTrue("Got no notation event", rxdEvent != null);
+ pce = (PropertyChangeEvent) rxdEvent.getSource();
+ assertTrue("Wrong event name",
+ pce.getPropertyName().equals(
+ Notation.KEY_DEFAULT_SHADOW_WIDTH.getKey()));
+ String value = (String) pce.getOldValue();
+ int i = Integer.parseInt(value);
+ assertTrue("Wrong old event value", i == 4);
+ assertTrue("Wrong new event value",
+ ((String) pce.getNewValue()).equals("2"));
+
+ rxdEvent = null;
+ p.getProjectSettings().setNotationLanguage("Java");
+ /* This assumes events are dispatched on the same thread. */
+ assertTrue("Got no notation event", rxdEvent != null);
+ pce = (PropertyChangeEvent) rxdEvent.getSource();
+ assertTrue("Wrong event name",
+ pce.getPropertyName().equals(
+ Notation.KEY_DEFAULT_NOTATION.getKey()));
+ value = (String) pce.getOldValue();
+ assertTrue("Wrong old event value", "UML 1.4".equals(value));
+ value = (String) pce.getNewValue();
+ assertTrue("Wrong new event value", "Java".equals(value));
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ /* Needed for initialisations: */
+ ProjectManager.getManager().getCurrentProject();
+ }
+
+ /**
+ * Catcher of Events.
+ *
+ * @author michiel
+ */
+ protected class EventCatcher implements ArgoNotationEventListener {
+ public void notationChanged(ArgoNotationEvent e) {
+ rxdEvent = e;
+ }
+
+ public void notationAdded(ArgoNotationEvent e) {
+ rxdEvent = e;
+ }
+
+ public void notationRemoved(ArgoNotationEvent e) {
+ rxdEvent = e;
+ }
+
+ public void notationProviderAdded(ArgoNotationEvent e) {
+ rxdEvent = e;
+ }
+
+ public void notationProviderRemoved(ArgoNotationEvent e) {
+ rxdEvent = e;
+ }
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/kernel/package.html
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/kernel/package.html?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/kernel/package.html 2007-08-13 09:07:56-0700
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+ Copyright (c) 1996-99 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.
+-->
+</head>
+<body bgcolor="white">
+<!--
+##### TYPE YOUR PACKAGE COMMENTS HERE. BEGIN WITH A #####
+##### ONE-SENTENCE SUMMARY STARTING WITH A VERB LIKE: #####
+Provides for....
+-->
+
+</body>
+</html>
Added: branches/gsoc2007/b00__1/tests/org/argouml/language/java/generator/TestGeneratorJava.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/language/java/generator/TestGeneratorJava.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/language/java/generator/TestGeneratorJava.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,187 @@
+// $Id:TestGeneratorJava.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 1996-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.language.java.generator;
+
+import org.argouml.model.Model;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+/**
+ * @author MarkusK
+ */
+public class TestGeneratorJava extends TestCase {
+
+ private Object namespace;
+
+ private Object class1;
+
+ private Object innerClass;
+
+ private Object inter1;
+
+ /**
+ * Constructor for TestGeneratorJava.
+ *
+ * @param name The name.
+ */
+ public TestGeneratorJava(String name) {
+ super(name);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ Object mmodel = Model.getModelManagementFactory().createModel();
+ Model.getCoreHelper().setName(mmodel, "untitledModel");
+ Model.getModelManagementFactory().setRootModel(mmodel);
+ namespace = Model.getModelManagementFactory().createPackage();
+ class1 = Model.getCoreFactory().buildClass("Class1", namespace);
+ innerClass = Model.getCoreFactory().buildClass("InnerClass", class1);
+ inter1 = Model.getCoreFactory().buildInterface("Inter1", namespace);
+
+ }
+
+ /**
+ * check the Java Code Generator does not generate a protected class ....
+ * These tests are applicable for outer classes (inside a package).
+ */
+ public void testGenerateClassifierStart() {
+ StringBuffer result;
+
+ Model.getCoreHelper().setVisibility(class1,
+ Model.getVisibilityKind().getPublic());
+ result = GeneratorJava.getInstance().generateClassifierStart(class1);
+ assertTrue(Model.getFacade().isAPackage(
+ Model.getFacade().getNamespace(class1)));
+ assertTrue("A class should have public in its specification", result
+ .indexOf("public") == 0);
+
+ Model.getCoreHelper().setVisibility(class1,
+ Model.getVisibilityKind().getProtected());
+ assertTrue(Model.getFacade().isAPackage(
+ Model.getFacade().getNamespace(class1)));
+ result = GeneratorJava.getInstance().generateClassifierStart(class1);
+ assertTrue("A class should not have protected in its specification",
+ result.indexOf("protected") == -1);
+
+ Model.getCoreHelper().setVisibility(class1,
+ Model.getVisibilityKind().getPackage());
+ assertTrue(Model.getFacade().isAPackage(
+ Model.getFacade().getNamespace(class1)));
+ result = GeneratorJava.getInstance().generateClassifierStart(class1);
+ assertTrue("A class with default visibility should not have "
+ + "public in its specification",
+ result.indexOf("public") == -1);
+ assertTrue("A class with package (default) visibility should not have "
+ + "protected in its specification",
+ result.indexOf("protected") == -1);
+ }
+
+ /**
+ * Check the Java Code Generator does not generate
+ * a protected interface ....
+ */
+ public void testGenerateClassifierStart2() {
+ StringBuffer result;
+
+ Model.getCoreHelper().setVisibility(inter1,
+ Model.getVisibilityKind().getPublic());
+ result = GeneratorJava.getInstance().generateClassifierStart(inter1);
+ assertTrue(Model.getFacade().isAPackage(
+ Model.getFacade().getNamespace(inter1)));
+ assertTrue("A interface should have public in its specification",
+ result.indexOf("public") == 0);
+
+ Model.getCoreHelper().setVisibility(inter1,
+ Model.getVisibilityKind().getProtected());
+ result = GeneratorJava.getInstance().generateClassifierStart(inter1);
+ assertTrue(Model.getFacade().isAPackage(
+ Model.getFacade().getNamespace(inter1)));
+ assertTrue(
+ "A interface should not have protected in its specification",
+ result.indexOf("protected") == -1);
+
+ Model.getCoreHelper().setVisibility(inter1,
+ Model.getVisibilityKind().getPackage());
+ result = GeneratorJava.getInstance().generateClassifierStart(inter1);
+ assertTrue(Model.getFacade().isAPackage(
+ Model.getFacade().getNamespace(inter1)));
+ assertTrue(
+ "An interface with package (default) visiblity should not have "
+ + "public keyword in its specification",
+ result.indexOf("public") == -1);
+ assertTrue(
+ "An interface with package (default) visiblity should not have "
+ + "protected keyword in its specification",
+ result.indexOf("protected") == -1);
+ }
+
+ /**
+ * check the Java Code Generator does not generate a protected class ....
+ * These tests are applicable for inner classes (inside a class).
+ */
+ public void testGenerateClassifierStart3() {
+ StringBuffer result;
+
+ Model.getCoreHelper().setVisibility(innerClass,
+ Model.getVisibilityKind().getPublic());
+ result =
+ GeneratorJava.getInstance()
+ .generateClassifierStart(innerClass);
+ assertTrue(Model.getFacade().isAClass(
+ Model.getFacade().getNamespace(innerClass)));
+ assertTrue("A class should have public in its specification",
+ result.indexOf("public") == 0);
+
+ Model.getCoreHelper().setVisibility(innerClass,
+ Model.getVisibilityKind().getProtected());
+ assertTrue(Model.getFacade().isAClass(
+ Model.getFacade().getNamespace(innerClass)));
+ result =
+ GeneratorJava.getInstance()
+ .generateClassifierStart(innerClass);
+ assertTrue("A class should have protected in its specification",
+ result.indexOf("protected") == 0);
+
+ Model.getCoreHelper().setVisibility(innerClass,
+ Model.getVisibilityKind().getPackage());
+ assertTrue(Model.getFacade().isAClass(
+ Model.getFacade().getNamespace(innerClass)));
+ result =
+ GeneratorJava.getInstance()
+ .generateClassifierStart(innerClass);
+ assertTrue("A inner class with package (default) visibility should not"
+ + " have protected in its specification",
+ result.indexOf("protected") == -1);
+ assertTrue("A inner class with package (default) visibility should not"
+ + " have public in its specification",
+ result.indexOf("public") == -1);
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/AllTests.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/AllTests.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/AllTests.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,78 @@
+// $Id:AllTests.java 12805 2007-06-10 15:47:09Z tfmorris $
+// Copyright (c) 2006-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.model;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Test suite automatically generated by Eclipse
+ * Update using "Recreate Test Suite..." from context menu in Eclipse
+ * NOTE: Mock tests are not compatible with suite
+ */
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("Test for org.argouml.model");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(TestModelFacade2.class);
+ suite.addTestSuite(TestDataTypesFactory.class);
+ suite.addTestSuite(TestCommonBehaviorHelper.class);
+ suite.addTestSuite(TestUmlFactoryBuildNode.class);
+ suite.addTestSuite(TestUmlExtend.class);
+ suite.addTest(TestModel.suite());
+ suite.addTestSuite(TestModelManagementHelper.class);
+ suite.addTestSuite(TestCommonBehaviorFactory.class);
+ suite.addTestSuite(TestCoreHelper.class);
+ suite.addTestSuite(TestUseCasesHelper.class);
+ suite.addTestSuite(TestModelEventPump.class);
+ suite.addTestSuite(TestExtensionMechanismsFactory.class);
+ suite.addTestSuite(TestUml.class);
+ suite.addTestSuite(TestModelManagementFactory.class);
+ suite.addTestSuite(TestUmlModel.class);
+ suite.addTestSuite(TestUmlActor.class);
+ suite.addTest(TestAgainstUmlModel.suite());
+ suite.addTestSuite(TestModel2.class);
+ suite.addTestSuite(TestUmlUseCase.class);
+ suite.addTestSuite(TestActivityGraphsHelper.class);
+// suite.addTestSuite(TestCoreHelperWithMock.class);
+ suite.addTestSuite(TestUseCasesFactory.class);
+ suite.addTestSuite(TestCoreFactory.class);
+ suite.addTest(TestModelFacade3.suite());
+// suite.addTestSuite(TestAGHelperWithMock.class);
+ suite.addTestSuite(TestCollaborationsHelper.class);
+ suite.addTestSuite(TestUmlModelElement.class);
+ suite.addTestSuite(TestExtensionMechanismsHelper.class);
+ suite.addTestSuite(TestUmlGeneralization.class);
+ suite.addTestSuite(TestCopyHelper.class);
+ suite.addTestSuite(TestCollaborationsFactory.class);
+ suite.addTestSuite(TestStateMachinesFactory.class);
+ suite.addTestSuite(TestActivityGraphsFactory.class);
+ suite.addTestSuite(TestStateMachinesHelper.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/CheckUMLModelHelper.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/CheckUMLModelHelper.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/CheckUMLModelHelper.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,413 @@
+// $Id:CheckUMLModelHelper.java 13240 2007-08-03 21:49:06Z tfmorris $
+// Copyright (c) 2002-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.model;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+/**
+ * This class is a helper class of tests that test
+ * the model stuff.<p>
+ *
+ * This class is used for testing the Model subsystem. It should not have any
+ * dependency on any specific implementation.
+ *
+ * @author Linus Tolke
+ * @since 0.11.2
+ */
+public final class CheckUMLModelHelper {
+ /**
+ * Constructor to forbid creation.
+ */
+ private CheckUMLModelHelper() {
+ }
+
+ /**
+ * Delete a model object, frees the reference and then checks that
+ * the object is reclaimed.
+ *
+ * This must be called with just one reference to the object or
+ * else it will fail.
+ *
+ * @param mo the model object that we try to delete, release and reclaim.
+ */
+ public static void deleteAndRelease(Object mo) {
+ Class c = mo.getClass();
+
+ // Call methods that exists for all objects and that always return
+ // something meaningfull.
+ TestCase.assertTrue("toString() corrupt in " + c,
+ mo.toString() != null);
+
+ Model.getUmlFactory().delete(mo);
+ Model.getPump().flushModelEvents();
+
+ TestCase.assertTrue("Could not delete " + c,
+ Model.getUmlFactory().isRemoved(mo));
+ }
+
+ /**
+ * Delete a model object, frees the reference and then checks that
+ * the object is reclaimed.
+ *
+ * This must be called with just one reference to the object or
+ * else it will fail.
+ *
+ * @param mo the model object that we try to delete, release and reclaim.
+ * @param name the class name of the uml object
+ */
+ private static void deleteAndRelease(Object mo, String name) {
+ Class c = mo.getClass();
+
+ // Call methods that exists for all objects and that always return
+ // something meaningfull.
+ TestCase.assertTrue("toString() corrupt in " + c,
+ mo.toString() != null);
+ TestCase.assertTrue("getUMLClassName() corrupt in " + c,
+ Model.getFacade().getUMLClassName(mo) != null);
+ TestCase.assertTrue(
+ "getUMLClassName() different from expected in " + c,
+ name.equals(Model.getFacade().getUMLClassName(mo)));
+
+ Model.getUmlFactory().delete(mo);
+ Model.getPump().flushModelEvents();
+
+ TestCase.assertTrue("Could not delete " + c,
+ Model.getUmlFactory().isRemoved(mo));
+ }
+
+ /**
+ * Create a UML modelelement (i.e. check if a creation function exists).
+ * Then deletes it, looses the reference and then checks that
+ * the object is reclaimed.
+ *
+ * @param factory the DataTypesFactory
+ * @param names the UML elements to test
+ * @param arguments the arguments of the UML elements
+ */
+ public static void createAndRelease(Object factory,
+ String[] names,
+ Object[] arguments) {
+ Class [] argTypes = new Class[arguments.length];
+ for (int i = 0; i < arguments.length; i++) {
+ argTypes[i] = arguments[i].getClass();
+ }
+
+ // Multiplicity, MultiplicityRange, and all Expression subtypes
+ // don't have 0-argument create methods, so we special case them.
+ Integer[] multArgs = {1, 1};
+ Class[] multArgTypes = {int.class, int.class};
+ String [] exprArgs = {"body text", "language text"};
+ Class[] exprArgTypes = {String.class, String.class};
+
+ for (int i = 0; i < names.length; i++) {
+ Class[] types;
+ Object[] args;
+ if (names[i] == null) {
+ continue;
+ } else if (names[i].startsWith("Multiplicity")) {
+ types = multArgTypes;
+ args = multArgs;
+ } else if (names[i].endsWith("Expression")) {
+ types = exprArgTypes;
+ args = exprArgs;
+ } else {
+ types = argTypes;
+ args = arguments;
+ }
+ String methodName = "create" + names[i];
+ Method createMethod;
+
+ // Find the create method in the offical API
+ createMethod = findMethod(factory.getClass(), Factory.class,
+ methodName, types);
+ if (createMethod == null) {
+ TestCase.fail("Method " + methodName
+ + " does not exist in any interface of factory "
+ + factory.getClass().getName());
+ return;
+ }
+
+
+ Method isAMethod;
+ String isAMethodName = "isA" + names[i];
+ Object facade = Model.getFacade();
+ try {
+ // Now get the factory implementation method to be invoked
+ isAMethod =
+ Facade.class.getDeclaredMethod(
+ isAMethodName,
+ new Class[] {Object.class});
+ } catch (NoSuchMethodException e) {
+ TestCase.fail("Method " + isAMethodName
+ + " does not exist in Facade");
+ return;
+ }
+
+ try {
+ // Extra careful now, not to keep any references to the
+ // second argument.
+ try {
+ Object element = invoke(createMethod, factory, args);
+ TestCase.assertTrue("Facade method " + isAMethodName
+ + " returned false", (Boolean) invoke(
+ isAMethod, facade, new Object[] {
+ element
+ }));
+
+ deleteAndRelease(
+ createMethod.invoke(factory, args), names[i]);
+ } catch (ClassCastException e) {
+ // Here it is another object sent to the test.
+ deleteAndRelease(createMethod.invoke(factory, args));
+ } catch (IllegalArgumentException e) {
+ // Here it is another object sent to the test.
+ deleteAndRelease(createMethod.invoke(factory, args));
+ }
+ } catch (IllegalAccessException e) {
+ TestCase.fail("Method create" + names[i]
+ + " in " + factory + " cannot be called");
+ return;
+ } catch (InvocationTargetException e) {
+ TestCase.fail("Method create" + names[i]
+ + " in " + factory + " throws an exception.");
+ return;
+ }
+ }
+ }
+
+ /**
+ * Convenience method to invoke a method and convert any thrown exceptions
+ * to test failures with a useful message.
+ */
+ private static Object invoke(Method method, Object object, Object[] args) {
+ try {
+ return method.invoke(object, args);
+ } catch (IllegalAccessException e) {
+ TestCase.fail("Method " + method.getName() + " in " + object
+ + " cannot be called");
+ } catch (InvocationTargetException e) {
+ TestCase.fail("Method " + method.getName() + " in " + object
+ + " throws an exception.");
+ }
+ return null;
+ }
+
+
+ /**
+ * Check all interfaces of the given class for an interface which both: 1)
+ * extends the given marker interface (in our case called 'Factory') 2)
+ * contains the given method.
+ * <p>
+ *
+ * This extra check is to make sure that the public methods of the given
+ * factory are actually part of the public API interface.
+ *
+ * @param factory
+ * the factory class to test
+ * @param markerInterface
+ * the class of the marker interface to look for
+ * @param methodName
+ * the name of the object that we want to create
+ * @param argTypes
+ * the types of the arguments for the method
+ * @return the requested method or null if no match is found
+ */
+ private static Method findMethod(Class factory,
+ Class markerInterface, String methodName, Class[] argTypes) {
+ Class[] interfaces = factory.getInterfaces();
+ for (int i = 0; i < interfaces.length; i++) {
+ if (markerInterface.equals(interfaces[i])) {
+ Method m = getMethod(factory, methodName, argTypes);
+ if (m != null) {
+ return m;
+ }
+ } else {
+ Method m =
+ findMethod(
+ interfaces[i], markerInterface, methodName,
+ argTypes);
+ if (m != null) {
+ return m;
+ }
+ }
+ }
+ return null;
+ }
+
+ private static Method getMethod(Class clazz, String methodName,
+ Class[] classes) {
+ try {
+ return clazz.getDeclaredMethod(methodName, classes);
+ } catch (NoSuchMethodException e) {
+ return null;
+ }
+ }
+
+ /**
+ * @param f
+ * the DataTypesFactory
+ * @param names
+ * the UML elements to test
+ */
+ public static void createAndRelease(Object f, String[] names) {
+ Object[] noarguments = {
+ };
+ createAndRelease(f, names, noarguments);
+ }
+
+ public static void createAndRelease(Object f, List<String>names) {
+ Object[] noarguments = {
+ };
+ String[] elementNames = new String[names.size()];
+ names.toArray(elementNames);
+ createAndRelease(f, elementNames, noarguments);
+ }
+
+ /**
+ * Test the presence of deletion methods for a list of modelelements.
+ *
+ * @param f the model factory that provides the "delete" methods
+ * for the modelelements
+ * @param names the names of the modelelements
+ */
+ public static void hasDeleteMethod(Object f, String[] names) {
+ for (int i = 0; i < names.length; i++) {
+ String methodName = "delete" + names[i];
+ try {
+ f.getClass().getDeclaredMethod(methodName,
+ new Class[] {Object.class});
+ } catch (SecurityException se) {
+ TestCase.fail(
+ "SecurityException while retrieving all methods from "
+ + f.getClass().getName());
+ return;
+ } catch (NoSuchMethodException e) {
+ TestCase.fail("Method " + methodName + " not found in "
+ + f.getClass().getName());
+ }
+ }
+ }
+
+ /**
+ * Check if for every metamodel element name a create function exists.
+ *
+ * @param factory the modelfactory that should contain the create function
+ * @param names the metamodel class names
+ */
+ public static void metaModelNameCorrect(Object factory, String[] names) {
+ try {
+ for (int i = 0; i < names.length; i++) {
+ Method m = findMethod(factory.getClass(), Factory.class,
+ "create" + names[i], new Class[] {});
+ TestCase.assertNotNull("Failed to find method create"
+ + names[i], m);
+ Object element = m.invoke(factory, new Object[] {});
+ TestCase.assertTrue("Not a UML Element",
+ Model.getFacade().isAUMLElement(element));
+ String metaName =
+ Model.getExtensionMechanismsHelper().getMetaModelName(
+ element);
+ TestCase.assertTrue(
+ "not a valid metaModelName " + names[i],
+ metaName.equals(names[i]));
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ TestCase.fail(
+ "Exception during test metaModelnameCorrect. Message: "
+ + ex.getMessage());
+ }
+ }
+
+ public static void metaModelNameCorrect(Object factory,
+ List<String> names) {
+ metaModelNameCorrect(factory, names.toArray(new String[names.size()]));
+ }
+
+ /**
+ * Try creating a stereotype for every modelelement type.
+ *
+ * @param f the factory containing the creation function for
+ * all the given metamodel element names
+ * @param names the metamodel element names
+ */
+ public static void isValidStereoType(Object f, String[] names) {
+ try {
+ Object ns = Model.getModelManagementFactory().createPackage();
+ Object clazz = Model.getCoreFactory().buildClass(ns);
+ Object stereo1 =
+ Model.getExtensionMechanismsFactory()
+ .buildStereotype(clazz, "test1", ns);
+ for (int i = 0; i < names.length; i++) {
+ Method m = findMethod(f.getClass(), Factory.class,
+ "create" + names[i], new Class[] {});
+ if (m == null) {
+ TestCase.fail("Failed to find method create" + names[i]);
+ }
+ Object base = m.invoke(f, new Object[] {});
+ if (Model.getFacade().isAModelElement(base)) {
+ Object stereo2 =
+ Model.getExtensionMechanismsFactory()
+ .buildStereotype(base, "test2", ns);
+ TestCase.assertTrue(
+ "Unexpected invalid stereotype",
+ Model.getExtensionMechanismsHelper()
+ .isValidStereotype(base, stereo2));
+ if (!(Model.getFacade().isAClass(base))) {
+ TestCase.assertTrue(
+ "Stereotype with base class of Class"
+ + " incorrectly allowed for this metaclass",
+ !Model.getExtensionMechanismsHelper()
+ .isValidStereotype(base, stereo1));
+ } else {
+ Object inter =
+ Model.getCoreFactory().createInterface();
+ Object stereo3 =
+ Model.getExtensionMechanismsFactory()
+ .buildStereotype(inter, "test3", ns);
+ TestCase.assertTrue(
+ "Unexpected invalid stereotype",
+ !Model.getExtensionMechanismsHelper()
+ .isValidStereotype(base, stereo3));
+ }
+ }
+
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ TestCase.fail(
+ "Exception during test metaModelnameCorrect. Message: "
+ + ex.getMessage());
+ }
+ }
+
+ public static void isValidStereoType(Object f, List<String> names) {
+ isValidStereoType(f, names.toArray(new String[names.size()]));
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/GenericUmlObjectTestFixture.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/GenericUmlObjectTestFixture.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/GenericUmlObjectTestFixture.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,256 @@
+// $Id:GenericUmlObjectTestFixture.java 13231 2007-08-03 21:20:07Z tfmorris $
+// Copyright (c) 2003-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.model;
+
+import java.util.HashMap;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Thierry Lach
+ */
+public abstract class GenericUmlObjectTestFixture extends TestCase {
+
+ private HashMap truths = new HashMap();
+
+ private boolean validated = false;
+
+ private Object entity;
+
+ /**
+ * Constructor for GenericObjectFixture.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public GenericUmlObjectTestFixture(String arg0) {
+ super(arg0);
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Set the entity.
+ *
+ * @param ent the model entity
+ */
+ public void setEntity(Object ent) {
+ entity = ent;
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ if (!validated) {
+ fail("Test case did not self-validate itself");
+ }
+ }
+
+ private void assertNotProhibitedClass(Class c) {
+ if (c != null && !c.getName().startsWith("org.argouml")) {
+ fail("Found non-ArgoUML class " + c.getName());
+ }
+ }
+
+ /**
+ * Ensure that the calling class does not reference non-ArgoUML classes in
+ * any way.
+ *
+ * @param self
+ * the testcase
+ */
+ protected void validateTestClassIsGeneric(TestCase self) {
+ // TODO: Use reflection against the test case to ensure that it
+ // does not import non-ArgoUML classes
+
+ // Check superclass.
+ //Make sure this class does not extend or reference non-ArgoUML classes
+ assertNotProhibitedClass(self.getClass().getSuperclass());
+
+ // Enumerate declaring class
+
+ // Enumerate constructors
+
+ // Enumerate methods
+ // Enumerate method arguments
+
+ // Enumerate fields
+
+ // Indicate that the test was validated
+ validated = true;
+ }
+
+ /**
+ * Indicate if the class being tested should be a type of the
+ * testcase class.
+ *
+ * @param class1 the model element
+ * @param b the value
+ */
+ protected void setTruth(Object class1, boolean b) {
+ truths.put(class1, new Boolean(b));
+ }
+
+ /**
+ * @param o the given object for the tests
+ */
+ protected void runTruthTests(Object o) {
+ runTruthTest(Model.getFacade().isAModelElement(o), true, null);
+ runTruthTest(
+ Model.getFacade().isAAbstraction(o),
+ Model.getMetaTypes().getAbstraction());
+ runTruthTest(
+ Model.getFacade().isAAssociation(o),
+ Model.getMetaTypes().getAssociation());
+ runTruthTest(Model.getFacade().isAAssociationEnd(o),
+ Model.getMetaTypes().getAssociationEnd());
+ runTruthTest(Model.getFacade().isAAssociationRole(o),
+ Model.getMetaTypes().getAssociationRole());
+ runTruthTest(Model.getFacade().isAClass(o),
+ Model.getMetaTypes().getUMLClass());
+ runTruthTest(
+ Model.getFacade().isAClassifier(o),
+ Model.getMetaTypes().getClassifier());
+ runTruthTest(Model.getFacade().isAComment(o),
+ Model.getMetaTypes().getComment());
+ runTruthTest(
+ Model.getFacade().isAComponent(o),
+ Model.getMetaTypes().getComponent());
+ runTruthTest(Model.getFacade().isAComponentInstance(o),
+ Model.getMetaTypes().getComponentInstance());
+ runTruthTest(
+ Model.getFacade().isADataType(o),
+ Model.getMetaTypes().getDataType());
+ runTruthTest(
+ Model.getFacade().isADependency(o),
+ Model.getMetaTypes().getDependency());
+ runTruthTest(Model.getFacade().isACompositeState(o),
+ Model.getMetaTypes().getCompositeState());
+
+ // Not currently present as token in Model.getFacade().
+ // NIF: runTruthTest(Model.getFacade().isAElement(o),
+ // Model.getFacade().ELEMENT);
+ // NIF: runTruthTest(Model.getFacade().isAExpression(o),
+ // Model.getFacade().EXPRESSION);
+ // NIF: runTruthTest(Model.getFacade().isAExtensionPoint(o),
+ // Model.getFacade().EXTENSION_POINT);
+ // NIF: runTruthTest(Model.getFacade().isAFeature(o),
+ // Model.getFacade().FEATURE);
+ runTruthTest(Model.getFacade().isAGeneralizableElement(o),
+ Model.getMetaTypes().getGeneralizableElement());
+ runTruthTest(Model.getFacade().isAGeneralization(o),
+ Model.getMetaTypes().getGeneralization());
+
+ runTruthTest(Model.getFacade().isAInstance(o),
+ Model.getMetaTypes().getInstance());
+ // NIF: runTruthTest(Model.getFacade().isAInteraction(o),
+ // Model.getFacade().INTERACTION);
+
+ runTruthTest(
+ Model.getFacade().isAInterface(o),
+ Model.getMetaTypes().getInterface());
+ runTruthTest(Model.getFacade().isALink(o),
+ Model.getMetaTypes().getLink());
+ // NIF: unTruthTest(Model.getFacade().isAMethod(o),
+ // Model.getMetaTypes().getMethod());
+ runTruthTest(Model.getFacade().isAModel(o),
+ Model.getMetaTypes().getModel());
+ runTruthTest(
+ Model.getFacade().isAModelElement(o),
+ Model.getMetaTypes().getModelElement());
+ runTruthTest(
+ Model.getFacade().isANamespace(o),
+ Model.getMetaTypes().getNamespace());
+ runTruthTest(Model.getFacade().isANode(o),
+ Model.getMetaTypes().getNode());
+ runTruthTest(
+ Model.getFacade().isANodeInstance(o),
+ Model.getMetaTypes().getNodeInstance());
+
+ runTruthTest(Model.getFacade().isAOperation(o),
+ Model.getMetaTypes().getOperation());
+
+ runTruthTest(Model.getFacade().isAObject(o),
+ Model.getMetaTypes().getObject());
+ runTruthTest(
+ Model.getFacade().isAPermission(o),
+ Model.getMetaTypes().getPermission());
+ runTruthTest(
+ Model.getFacade().isAPackageImport(o),
+ Model.getMetaTypes().getPackageImport());
+ runTruthTest(Model.getFacade().isAPackage(o),
+ Model.getMetaTypes().getPackage());
+ runTruthTest(
+ Model.getFacade().isAReception(o),
+ Model.getMetaTypes().getReception());
+ // runTruthTest(Model.getFacade().isARelationship(o),
+ // Model.getMetaTypes().getRelationship());
+ runTruthTest(
+ Model.getFacade().isAStateMachine(o),
+ Model.getMetaTypes().getStateMachine());
+ runTruthTest(
+ Model.getFacade().isAStateVertex(o),
+ Model.getMetaTypes().getStateVertex());
+ runTruthTest(
+ Model.getFacade().isAStereotype(o),
+ Model.getMetaTypes().getStereotype());
+ // NIF: runTruthTest(Model.getFacade().isAStructuralFeature(o),
+ // Model.getMetaTypes().getStructuralFeature());
+ // NIF: runTruthTest(Model.getFacade().isATaggedValue(o),
+ // Model.getMetaTypes().getTaggedValue());
+ runTruthTest(
+ Model.getFacade().isATransition(o),
+ Model.getMetaTypes().getTransition());
+ runTruthTest(Model.getFacade().isAUseCase(o),
+ Model.getMetaTypes().getUseCase());
+ runTruthTest(Model.getFacade().isAActor(o),
+ Model.getMetaTypes().getActor());
+ }
+
+ /**
+ * @param result
+ * @param expected
+ * @param class1
+ */
+ private void runTruthTest(boolean result, boolean expected,
+ Object class1) {
+ assertEquals("Failure testing " + class1,
+ expected,
+ result);
+ }
+
+ /**
+ * @param result
+ * @param class1
+ */
+ private void runTruthTest(boolean result, Object class1) {
+ // TODO: Look up class in truth table
+ Boolean truth = (Boolean) truths.get(class1);
+ if (truth == null) {
+ truth = Boolean.FALSE;
+ }
+ runTruthTest(result, truth.booleanValue(), class1);
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/InitializeModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/InitializeModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/InitializeModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,102 @@
+// $Id:InitializeModel.java 12791 2007-06-08 15:47:35Z tfmorris $
+// 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.model;
+
+import junit.framework.TestCase;
+
+/**
+ * Class to initialize the model.
+ *
+ * @author lito
+ */
+public final class InitializeModel {
+
+ /**
+ * The default model implementation to start.
+ */
+ private static final String DEFAULT_MODEL_IMPLEMENTATION =
+ "org.argouml.model.mdr.MDRModelImplementation";
+
+
+ /**
+ * This is never instantiated.
+ */
+ private InitializeModel() {
+ }
+
+ /**
+ * Initialize the Model subsystem with the default ModelImplementation.
+ */
+ public static void initializeDefault() {
+ String className =
+ System.getProperty(
+ "argouml.model.implementation",
+ DEFAULT_MODEL_IMPLEMENTATION);
+ initializeModelImplementation(className);
+ }
+
+ /**
+ * Initialize the Model subsystem with the MDR ModelImplementation.
+ */
+ public static void initializeMDR() {
+ initializeModelImplementation(
+ "org.argouml.model.mdr.MDRModelImplementation");
+ }
+
+ /**
+ * Initialize the Model subsystem with the Mock Implementation.
+ *
+ * @return the newly created MockModelImplementation.
+ */
+ public static MockModelImplementation initializeMock() {
+ return (MockModelImplementation)
+ initializeModelImplementation(
+ "org.argouml.model.MockModelImplementation");
+ }
+
+ private static ModelImplementation initializeModelImplementation(
+ String name) {
+ ModelImplementation impl = null;
+
+ Class implType;
+ try {
+ implType =
+ Class.forName(name);
+ } catch (ClassNotFoundException e) {
+ TestCase.fail(e.toString());
+ return null;
+ }
+
+ try {
+ impl = (ModelImplementation) implType.newInstance();
+ } catch (InstantiationException e) {
+ TestCase.fail(e.toString());
+ } catch (IllegalAccessException e) {
+ TestCase.fail(e.toString());
+ }
+ Model.setImplementation(impl);
+ return impl;
+ }
+}
\ No newline at end of file
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/MockModelImplementation.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/MockModelImplementation.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/MockModelImplementation.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,662 @@
+// $Id:MockModelImplementation.java 12781 2007-06-08 07:50:19Z tfmorris $
+// Copyright (c) 2006-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.model;
+
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.easymock.MockControl;
+
+/**
+ * A mock ModelImplementation.<p>
+ *
+ * The Facade, the ModelEventPump, the Factories and Helpers are all
+ * created as mock objects using EasyMock. For each of them, there
+ * should also be a possibility to access their {@link MockControl}
+ * object.
+ * TODO: Create the rest of the getters for the control objects.
+ *
+ * @author Linus Tolke
+ */
+class MockModelImplementation implements ModelImplementation {
+
+ /**
+ * A list of all the control objects.
+ */
+ private List controls;
+
+ /**
+ * The instance that was just created.
+ */
+ private static MockModelImplementation lastCreatedInstance;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlFacade;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlDIM;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlMEP;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlAGF;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlAGH;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlCF;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlCH;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlCBF;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlCBH;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlCoreFactory;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlCoreHelper;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlDTF;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlDTH;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlEMF;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlEMH;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlMMF;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlMMH;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlSMF;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlSMH;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlUmlFactory;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlUmlHelper;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlUCF;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlUCH;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlMT;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlCK;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlAK;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlPK;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlSK;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlConK;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlDK;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlOK;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlVK;
+
+ /**
+ * Control object.
+ */
+ private MockControl controlCopyHelper;
+
+ /**
+ * Constructor.
+ */
+ public MockModelImplementation() {
+ controls = new ArrayList();
+ lastCreatedInstance = this;
+
+ controlFacade = MockControl.createControl(Facade.class);
+ controls.add(controlFacade);
+
+ controlDIM = MockControl.createControl(DiagramInterchangeModel.class);
+ controls.add(controlDIM);
+
+ controlMEP = MockControl.createControl(ModelEventPump.class);
+ controls.add(controlMEP);
+
+ createBehaviorControls();
+
+ createFoundationControls();
+
+ controlMMF = MockControl.createControl(ModelManagementFactory.class);
+ controls.add(controlMMF);
+
+ controlMMH = MockControl.createControl(ModelManagementHelper.class);
+ controls.add(controlMMH);
+
+ controlUmlFactory = MockControl.createControl(UmlFactory.class);
+ controls.add(controlUmlFactory);
+
+ controlUmlHelper = MockControl.createControl(UmlHelper.class);
+ controls.add(controlUmlHelper);
+
+ controlCopyHelper = MockControl.createControl(CopyHelper.class);
+ controls.add(controlCopyHelper);
+
+ controlMT = MockControl.createControl(MetaTypes.class);
+ controls.add(controlMT);
+
+ createKindControls();
+ }
+
+ /**
+ * Create the controls for the foundation factories and helpers.
+ */
+ private void createFoundationControls() {
+ controlCoreFactory = MockControl.createControl(CoreFactory.class);
+ controls.add(controlCoreFactory);
+
+ controlCoreHelper = MockControl.createControl(CoreHelper.class);
+ controls.add(controlCoreHelper);
+
+ controlDTF = MockControl.createControl(DataTypesFactory.class);
+ controls.add(controlDTF);
+
+ controlDTH = MockControl.createControl(DataTypesHelper.class);
+ controls.add(controlDTH);
+
+ controlEMF =
+ MockControl.createControl(ExtensionMechanismsFactory.class);
+ controls.add(controlEMF);
+
+ controlEMH = MockControl.createControl(ExtensionMechanismsHelper.class);
+ controls.add(controlEMH);
+ }
+
+ /**
+ * Create the controls for all behavior elements' factories and helpers.
+ */
+ private void createBehaviorControls() {
+ controlAGH = MockControl.createControl(ActivityGraphsHelper.class);
+ controls.add(controlAGH);
+
+ controlAGF = MockControl.createControl(ActivityGraphsFactory.class);
+ controls.add(controlAGF);
+
+ controlCF = MockControl.createControl(CollaborationsFactory.class);
+ controls.add(controlCF);
+
+ controlCH = MockControl.createControl(CollaborationsHelper.class);
+ controls.add(controlCH);
+
+ controlCBF = MockControl.createControl(CommonBehaviorFactory.class);
+ controls.add(controlCBF);
+
+ controlCBH = MockControl.createControl(CommonBehaviorHelper.class);
+ controls.add(controlCBH);
+
+ controlSMF = MockControl.createControl(StateMachinesFactory.class);
+ controls.add(controlSMF);
+
+ controlSMH = MockControl.createControl(StateMachinesHelper.class);
+ controls.add(controlSMH);
+
+ controlUCF = MockControl.createControl(UseCasesFactory.class);
+ controls.add(controlUCF);
+
+ controlUCH = MockControl.createControl(UseCasesHelper.class);
+ controls.add(controlUCH);
+ }
+
+ /**
+ * Create the controls for the Kinds.
+ */
+ private void createKindControls() {
+ controlCK = MockControl.createControl(ChangeableKind.class);
+ controls.add(controlCK);
+
+ controlAK = MockControl.createControl(AggregationKind.class);
+ controls.add(controlAK);
+
+ controlPK = MockControl.createControl(PseudostateKind.class);
+ controls.add(controlPK);
+
+ controlSK = MockControl.createControl(ScopeKind.class);
+ controls.add(controlSK);
+
+ controlConK = MockControl.createControl(ConcurrencyKind.class);
+ controls.add(controlConK);
+
+ controlDK = MockControl.createControl(DirectionKind.class);
+ controls.add(controlDK);
+
+ controlOK = MockControl.createControl(OrderingKind.class);
+ controls.add(controlOK);
+
+ controlVK = MockControl.createControl(VisibilityKind.class);
+ controls.add(controlVK);
+ }
+
+ /**
+ * @return The last created MockModelImplementation.
+ */
+ public static MockModelImplementation getLatest() {
+ return lastCreatedInstance;
+ }
+
+ /**
+ * Reset all mock objects.
+ */
+ public void reset() {
+ Iterator iter = controls.iterator();
+ while (iter.hasNext()) {
+ MockControl control = (MockControl) iter.next();
+ control.reset();
+ }
+ }
+
+ /**
+ * Replay all mock objects.
+ */
+ public void replay() {
+ Iterator iter = controls.iterator();
+ while (iter.hasNext()) {
+ MockControl control = (MockControl) iter.next();
+ control.replay();
+ }
+ }
+ /**
+ * Verify all mock objects.
+ */
+ public void verify() {
+ Iterator iter = controls.iterator();
+ while (iter.hasNext()) {
+ MockControl control = (MockControl) iter.next();
+ control.verify();
+ }
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getFacade()
+ */
+ public Facade getFacade() {
+ return (Facade) controlFacade.getMock();
+ }
+
+ /**
+ * @return The {@link MockControl} object for the Facade.
+ */
+ public MockControl getFacadeControl() {
+ return controlFacade;
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getDiagramInterchangeModel()
+ */
+ public DiagramInterchangeModel getDiagramInterchangeModel() {
+ return (DiagramInterchangeModel) controlDIM.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getModelEventPump()
+ */
+ public ModelEventPump getModelEventPump() {
+ return (ModelEventPump) controlMEP.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getActivityGraphsFactory()
+ */
+ public ActivityGraphsFactory getActivityGraphsFactory() {
+ return (ActivityGraphsFactory) controlAGF.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getActivityGraphsHelper()
+ */
+ public ActivityGraphsHelper getActivityGraphsHelper() {
+ return (ActivityGraphsHelper) controlAGH.getMock();
+ }
+
+ /**
+ * @return The {@link MockControl} object for the ActivityGraphsHelper.
+ */
+ public MockControl getActivityGraphsHelperControl() {
+ return controlAGH;
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getCollaborationsFactory()
+ */
+ public CollaborationsFactory getCollaborationsFactory() {
+ return (CollaborationsFactory) controlCF.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getCollaborationsHelper()
+ */
+ public CollaborationsHelper getCollaborationsHelper() {
+ return (CollaborationsHelper) controlCH.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getCommonBehaviorFactory()
+ */
+ public CommonBehaviorFactory getCommonBehaviorFactory() {
+ return (CommonBehaviorFactory) controlCBF.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getCommonBehaviorHelper()
+ */
+ public CommonBehaviorHelper getCommonBehaviorHelper() {
+ return (CommonBehaviorHelper) controlCBH.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getCoreFactory()
+ */
+ public CoreFactory getCoreFactory() {
+ return (CoreFactory) controlCoreFactory.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getCoreHelper()
+ */
+ public CoreHelper getCoreHelper() {
+ return (CoreHelper) controlCoreHelper.getMock();
+ }
+
+ /**
+ * @return The {@link MockControl} object for the CoreHelper.
+ */
+ public MockControl getCoreHelperControl() {
+ return controlCoreHelper;
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getDataTypesFactory()
+ */
+ public DataTypesFactory getDataTypesFactory() {
+ return (DataTypesFactory) controlDTF.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getDataTypesHelper()
+ */
+ public DataTypesHelper getDataTypesHelper() {
+ return (DataTypesHelper) controlDTH.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getExtensionMechanismsFactory()
+ */
+ public ExtensionMechanismsFactory getExtensionMechanismsFactory() {
+ return (ExtensionMechanismsFactory) controlEMF.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getExtensionMechanismsHelper()
+ */
+ public ExtensionMechanismsHelper getExtensionMechanismsHelper() {
+ return (ExtensionMechanismsHelper) controlEMH.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getModelManagementFactory()
+ */
+ public ModelManagementFactory getModelManagementFactory() {
+ return (ModelManagementFactory) controlMMF.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getModelManagementHelper()
+ */
+ public ModelManagementHelper getModelManagementHelper() {
+ return (ModelManagementHelper) controlMMH.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getStateMachinesFactory()
+ */
+ public StateMachinesFactory getStateMachinesFactory() {
+ return (StateMachinesFactory) controlSMF.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getStateMachinesHelper()
+ */
+ public StateMachinesHelper getStateMachinesHelper() {
+ return (StateMachinesHelper) controlSMH.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getUmlFactory()
+ */
+ public UmlFactory getUmlFactory() {
+ return (UmlFactory) controlUmlFactory.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getUmlHelper()
+ */
+ public UmlHelper getUmlHelper() {
+ return (UmlHelper) controlUmlHelper.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getUseCasesFactory()
+ */
+ public UseCasesFactory getUseCasesFactory() {
+ return (UseCasesFactory) controlUCF.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getUseCasesHelper()
+ */
+ public UseCasesHelper getUseCasesHelper() {
+ return (UseCasesHelper) controlUCH.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getMetaTypes()
+ */
+ public MetaTypes getMetaTypes() {
+ return (MetaTypes) controlMT.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getChangeableKind()
+ */
+ public ChangeableKind getChangeableKind() {
+ return (ChangeableKind) controlCK.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getAggregationKind()
+ */
+ public AggregationKind getAggregationKind() {
+ return (AggregationKind) controlAK.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getPseudostateKind()
+ */
+ public PseudostateKind getPseudostateKind() {
+ return (PseudostateKind) controlPK.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getScopeKind()
+ */
+ public ScopeKind getScopeKind() {
+ return (ScopeKind) controlSK.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getConcurrencyKind()
+ */
+ public ConcurrencyKind getConcurrencyKind() {
+ return (ConcurrencyKind) controlConK.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getDirectionKind()
+ */
+ public DirectionKind getDirectionKind() {
+ return (DirectionKind) controlDK.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getOrderingKind()
+ */
+ public OrderingKind getOrderingKind() {
+ return (OrderingKind) controlOK.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getVisibilityKind()
+ */
+ public VisibilityKind getVisibilityKind() {
+ return (VisibilityKind) controlVK.getMock();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getXmiReader()
+ */
+ public XmiReader getXmiReader() throws UmlException {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getXmiWriter(java.lang.Object, java.io.Writer, java.lang.String)
+ */
+ public XmiWriter getXmiWriter(Object model, Writer writer, String version)
+ throws UmlException {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * @see org.argouml.model.ModelImplementation#getCopyHelper()
+ */
+ public CopyHelper getCopyHelper() {
+ return (CopyHelper) controlCopyHelper.getMock();
+ }
+
+ public XmiWriter getXmiWriter(Object model, OutputStream stream,
+ String version) throws UmlException {
+ throw new NotImplementedException();
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestAGHelperWithMock.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestAGHelperWithMock.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestAGHelperWithMock.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,82 @@
+// $Id:TestAGHelperWithMock.java 12681 2007-05-26 22:54:04Z tfmorris $
+// Copyright (c) 2006-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.model;
+
+import org.easymock.MockControl;
+
+import junit.framework.TestCase;
+
+/**
+ * This is an extremely simple example for testing with a mock model.
+ * The purpose of this is to show how to set up the Mock Model correctly.
+ *
+ * @author Linus Tolke
+ */
+public class TestAGHelperWithMock extends TestCase {
+ private MockModelImplementation mockModelImplementation;
+ private MockControl controlAGH;
+
+ /**
+ * Constructor.
+ *
+ * @param arg0 The name of the test case.
+ */
+ public TestAGHelperWithMock(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() {
+ mockModelImplementation = InitializeModel.initializeMock();
+
+ assertNotNull("MockModelImplementation not created",
+ mockModelImplementation);
+
+ // Must be called after setImplementation.
+ mockModelImplementation.reset();
+ }
+
+ /*
+ * @see junit.framework.TestCase#tearDown()
+ */
+ public void tearDown() {
+ mockModelImplementation.verify();
+ }
+
+ /**
+ * Testing ActivityGraphsHelper.
+ */
+ public void testAGHelper() {
+ mockModelImplementation.getActivityGraphsHelper()
+ .isAddingActivityGraphAllowed(null);
+ mockModelImplementation.getActivityGraphsHelperControl()
+ .setReturnValue(false);
+ mockModelImplementation.replay();
+
+ Model.getActivityGraphsHelper().isAddingActivityGraphAllowed(null);
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestActivityGraphsFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestActivityGraphsFactory.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestActivityGraphsFactory.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,99 @@
+// $Id:TestActivityGraphsFactory.java 12576 2007-05-09 14:19:16Z tfmorris $
+// Copyright (c) 2002-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.model;
+
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Test the ActivityGraphsFactoryImpl class.
+ *
+ */
+public class TestActivityGraphsFactory extends TestCase {
+
+ /**
+ * All the ModelElements we are going to test.
+ */
+ private static String[] allModelElements = {
+ "ActivityGraph",
+ "ActionState",
+ "CallState",
+ "ClassifierInState",
+ "ObjectFlowState",
+ "Partition",
+ "SubactivityState",
+ };
+
+ /**
+ * The constructor.
+ *
+ * @param n the name
+ */
+ public TestActivityGraphsFactory(String n) {
+ super(n);
+ InitializeModel.initializeDefault();
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /**
+ * Test the singleton pattern for the ActivityGraphsFactoryImpl class.
+ */
+ public void testSingleton() {
+ Object o1 = Model.getActivityGraphsFactory();
+ Object o2 = Model.getActivityGraphsFactory();
+ assertTrue("Different singletons", o1 == o2);
+ }
+
+ /**
+ * The test for creation.
+ */
+ public void testCreates() {
+ CheckUMLModelHelper.createAndRelease(Model.getActivityGraphsFactory(),
+ getTestableModelElements());
+ }
+
+ /**
+ * @return Returns the allModelElements.
+ */
+ static String[] getAllModelElements() {
+ return allModelElements;
+ }
+
+ /**
+ * @return all testable model elements
+ */
+ static List<String> getTestableModelElements() {
+ return Arrays.asList(allModelElements);
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestActivityGraphsHelper.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestActivityGraphsHelper.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestActivityGraphsHelper.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,69 @@
+// $Id:TestActivityGraphsHelper.java 12576 2007-05-09 14:19:16Z tfmorris $
+// Copyright (c) 1996-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.model;
+
+import junit.framework.TestCase;
+
+/**
+ * @since Oct 10, 2002
+ * @author [email protected]
+ */
+public class TestActivityGraphsHelper extends TestCase {
+
+ /**
+ * Constructor for TestActivityGraphsHelper.
+ *
+ * @param arg0 is the test case name.
+ */
+ public TestActivityGraphsHelper(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test if the metamodel name is correct.
+ */
+ public void testGetMetaModelName() {
+ CheckUMLModelHelper.metaModelNameCorrect(
+ Model.getActivityGraphsFactory(),
+ TestActivityGraphsFactory.getTestableModelElements());
+ }
+
+ /**
+ * Test if the stereotype is valid.
+ */
+ public void testIsValidStereoType() {
+ CheckUMLModelHelper.isValidStereoType(
+ Model.getActivityGraphsFactory(),
+ TestActivityGraphsFactory.getTestableModelElements());
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestAgainstUmlModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestAgainstUmlModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestAgainstUmlModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,407 @@
+// $Id:TestAgainstUmlModel.java 12806 2007-06-10 15:48:53Z tfmorris $
+// Copyright (c) 2003-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.model;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * Test against the UML model.
+ */
+public class TestAgainstUmlModel extends TestCase {
+
+ private static Set<String> dontTest = new HashSet<String>();
+
+ private static Hashtable<String, String> remap =
+ new Hashtable<String, String>();
+
+ private static boolean uml2 = false;
+
+ /**
+ * The constructor.
+ *
+ * @param n the name
+ */
+ public TestAgainstUmlModel(String n) {
+ super(n);
+ }
+
+ /**
+ * @throws SAXException when things go wrong with SAX
+ * @throws IOException when there's an IO error
+ * @throws ParserConfigurationException when the parser finds wrong syntax
+ *
+ * TODO: Unused?
+ */
+ public void testDataModel()
+ throws SAXException,
+ IOException,
+ ParserConfigurationException {
+ Document doc = prepareDocument();
+ if (doc == null) {
+ return; // Could not find model.
+ }
+
+ List<String> classNames = getMetaclassNames(doc);
+ for (String className : classNames ) {
+ processClass (className);
+ }
+ }
+
+ /*
+ * Get a list of UML metaclass names from the XMI document.
+ * <p>
+ * Though some of the DOM methods such as getAttributes
+ * may return null values under other conditions,
+ * in the context of this test
+ * and assuming a valid XMI file
+ * none should occur.
+ * <p>
+ * Hence there is no special checking for those abnormal
+ * cases, allowing the test to fail simply with a
+ * NullPointerException, with this comment indicating that
+ * either the input data is incorrect or the test needs
+ * to be improved.
+ */
+ private static List<String> getMetaclassNames(Document doc) {
+ List<String> result = new ArrayList<String>();
+ int abstractCount = 0;
+ if (uml2) {
+ // The UML 2.1.1 metamodel is a MOF 2.0 CMOF model, so
+ // we want nodes with
+ // tag="ownedMember", attribute xmi:type="cmof:Class"
+ // TODO: This code is untested - tfm
+ NodeList list = doc.getElementsByTagName("ownedMember");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node node = list.item(i);
+ Node typeAttr = node.getAttributes().getNamedItem("xmi:type");
+ if ("cmof:Class".equals(typeAttr.getNodeValue())) {
+ if (!isAbstract(node)) {
+ result.add(getNames(node));
+ } else {
+ abstractCount++;
+ }
+ }
+ }
+ } else {
+ // Handle UML 1.4 metamodel which is a MOF 1.3 model
+ NodeList list = doc.getElementsByTagName("Model:Class");
+ for (int i = 0; i < list.getLength(); i++) {
+ Node node = list.item(i);
+ if (!isAbstract(node)) {
+ result.add(getNames(node));
+ } else {
+ abstractCount++;
+ }
+ }
+ }
+ System.out.println("Skipping " + abstractCount + " abstract elements");
+ return result;
+ }
+
+ /*
+ * Get a node's name along with the name of its parent (which we'll use to
+ * find the factory to create it with.
+ */
+ private static String getNames(Node node) {
+ // TODO: Do we want the top level package here instead of the immediate
+ // parent?
+
+ // Because UML 1.4 & 2.1 metamodels are organized differently we need
+ // to traverse the hierarchy looking for our owning Package.
+ Node pkg = node;
+ while (pkg != null && !isPackage(pkg)) {
+ pkg = pkg.getParentNode();
+ }
+ if (pkg == null) {
+ return getName(node);
+ }
+ return getName(pkg) + ":" + getName(node);
+ }
+
+ private static boolean isPackage(Node node) {
+ if ("Model:Package".equals(node.getNodeName())) {
+ // UML 1.4
+ return true;
+ } else {
+ Node type = node.getAttributes().getNamedItem("xmi:type");
+ if (type != null && "cmof:Package".equals(type.getNodeValue())) {
+ // UML 2.x
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static String getName(Node node) {
+ return node.getAttributes().getNamedItem("name").getNodeValue();
+ }
+
+ private static boolean isAbstract(Node node) {
+ Node isAbstract = node.getAttributes().getNamedItem("isAbstract");
+ return isAbstract != null && "true".equals(isAbstract.getNodeValue());
+ }
+
+
+ /**
+ * Print a message that this test case is inconclusive because of
+ * the UML file missing.
+ *
+ * @param message that is to me printed.
+ */
+ private static void printInconclusiveMessage(String message) {
+ System.out.println(TestAgainstUmlModel.class.getName()
+ + ": WARNING: INCONCLUSIVE TEST!");
+ System.out.println(message);
+ System.out.println("You will have to fetch the model using the command"
+ + " ant junit-get-model");
+ }
+
+ /**
+ * Make all preparations for the tests by preparing the document.
+ *
+ * @return the document or null if not available.
+ * @throws SAXException when things go wrong with SAX
+ * @throws IOException when there's an IO error
+ * @throws ParserConfigurationException when the parser finds wrong syntax
+ */
+ private static Document prepareDocument()
+ throws ParserConfigurationException, SAXException, IOException {
+ DocumentBuilder builder =
+ DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ String fileName = System.getProperty("test.model.uml");
+ if (fileName == null) {
+ printInconclusiveMessage("The property test.model.uml "
+ + "is not set.");
+ return null;
+ }
+ File file = new File(fileName);
+ if (!file.exists()) {
+ printInconclusiveMessage("The file " + fileName
+ + " cannot be found.");
+ return null;
+ }
+ Document document = builder.parse(file);
+
+ Element root = document.getDocumentElement();
+ NamedNodeMap attributes = root.getAttributes();
+ Node versionNode = attributes.getNamedItem("xmi:version"); // XMI 2.1
+ if (versionNode == null) {
+ versionNode = attributes.getNamedItem("xmi.version"); // XMI 1.1
+ }
+ String version = versionNode.getNodeValue();
+
+ // This is the XMI version used to encode the metamodel. We could
+ // parse deeper to pull out the actual UML version. The UML 1.4
+ // version is at XMI/XMI.header/XMI.model[@xmi.version]. The UML 2.1.1
+ // metamodel doesn't actually seem to contain its version.
+ if ("1.1".equals(version)) {
+ uml2 = false;
+ } else if ("2.1".equals(version)) {
+ uml2 = true;
+ } else {
+ System.out.println("Unknown metamodel type");
+ }
+
+ return document;
+ }
+
+
+ /**
+ * Walk through the UML Classes found.
+
+ */
+ private void processClass(String className) {
+
+ // Remap specific classes
+ String name;
+ if (remap.containsKey(className)) {
+ name = remap.get(className);
+ } else {
+ name = className;
+ }
+
+ String[] pieces = name.split(":");
+ String umlclass = pieces[1];
+
+ String pkgName = pieces[0].replaceAll("_", "");
+ // Only remap package if we didn't remap specific class
+ if (className.equals(name) && remap.containsKey(pkgName)) {
+ pkgName = remap.get(pkgName);
+ }
+
+ String getter = "get" + pkgName + "Factory";
+ try {
+ Method getMethod = Model.class.getMethod(getter, new Class[0]);
+ Object factory = getMethod.invoke(null, new Object[0]);
+ if (!(factory instanceof Factory)) {
+ fail("Factory for " + name
+ + "isn't an instanceof Model.Factory");
+ }
+ if ( dontTest.contains(umlclass) || dontTest.contains(name)) {
+ System.out.println("Skipping " + name);
+ return;
+ }
+ String[] classarg = {umlclass, null};
+ CheckUMLModelHelper.createAndRelease(factory, classarg);
+ } catch (Exception e) {
+ fail("Failed to get factory for " + name + " - " + e);
+ }
+
+
+ }
+
+ /**
+ * @return the test suite
+ */
+ public static Test suite() {
+ TestSuite suite =
+ new TestSuite("Tests for "
+ + TestAgainstUmlModel.class.getPackage().getName());
+
+ Document doc = null;
+ try {
+ doc = prepareDocument();
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace();
+ } catch (SAXException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ if (doc == null) {
+ return suite; // Could not find model.
+ }
+
+ for (String metaclassName : getMetaclassNames(doc)) {
+ suite.addTest(new TestAgainstUmlModel(metaclassName));
+ }
+
+ return suite;
+ }
+
+ protected void runTest() throws Throwable {
+ processClass(getName());
+ }
+
+
+
+ /**
+ * Initialize the lookup map to link the uml class names
+ * to the factories.
+ *
+ * This brute force method should be investigated
+ * in favor of determining the Uml Class namespace from
+ * the UML metamodel and computing the factory
+ * at run time.
+ *
+ * Certain classes that cannot be tested directly in this way
+ * should be calculated. Event and StateVertex, for example,
+ * are marked abstract in the model. But we need to make sure
+ * that the reverse is true, that there are no elements
+ * marked abstract in the model that in fact are instantiable
+ * by the model subsystem.
+ */
+
+ static {
+ InitializeModel.initializeDefault();
+
+ /*
+ * The following UML 1.4 elements have been removed from UML 2.x, so we
+ * don't bother testing them.
+ */
+ dontTest.add("ProgrammingLanguageDataType");
+ dontTest.add("UseCaseInstance");
+
+ dontTest.add("ArgListsExpression");
+ dontTest.add("BooleanExpression");
+ dontTest.add("IterationExpression");
+ dontTest.add("MappingExpression");
+ dontTest.add("ObjectSetExpression");
+ dontTest.add("ProcedureExpression");
+ dontTest.add("TimeExpression");
+ dontTest.add("TypeExpression");
+
+ /*
+ * A few of our factories are slightly different than as declared in the
+ * UML 1.4 metamodel, so we remap them here. <metamodel, argouml>
+ */
+ remap.put("Core:Stereotype", "ExtensionMechanisms:Stereotype");
+ remap.put("Core:TaggedValue", "ExtensionMechanisms:TaggedValue");
+ remap.put("Core:TagDefinition", "ExtensionMechanisms:TagDefinition");
+
+ /*
+ * The UML 2.x package structure is *entirely* different, so we have to
+ * remap a bunch of stuff. Names without embedded colons (:) indicate
+ * that the entire package is remapped. e.g. Kernel->Core As a matter of
+ * fact the only package which did NOT get renamed or moved is UseCases.
+ *
+ * TODO: This section is very incomplete. - tfm
+ */
+ // Specific classes to be remapped
+// remap.put("", "");
+ remap.put("Kernel:PrimitiveType", "Core:Primitive");
+ remap.put("Kernel:Expression", "DataTypes:Expression");
+
+ // Packages to be remapped
+ remap.put("Kernel", "Core");
+ remap.put("Interfaces", "Core");
+ remap.put("Dependencies", "Core");
+ remap.put("Nodes", "Core");
+ remap.put("SimpleTime", "Core");
+ remap.put("AssociationClasses", "Core");
+ remap.put("Communications", "StateMachines");
+ remap.put("BehaviorStateMachines", "StateMachines");
+ remap.put("ProtocolStateMachines", "StateMachines");
+ remap.put("Models", "ModelManagement");
+ }
+
+
+
+}
+
+
+
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestCollaborationsFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestCollaborationsFactory.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestCollaborationsFactory.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,188 @@
+// $Id:TestCollaborationsFactory.java 12576 2007-05-09 14:19:16Z tfmorris $
+// Copyright (c) 2005-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.model;
+
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Test the collaborations factory for all model implementations.<p>
+ *
+ * No imports from org.argouml.model.uml or other subpackage!
+ */
+public class TestCollaborationsFactory extends TestCase {
+
+ /**
+ * All the ModelElements we are going to test.
+ */
+ private static String[] allModelElements =
+ {
+ "AssociationEndRole",
+ "AssociationRole",
+ "ClassifierRole",
+ "Collaboration",
+ "Interaction",
+ "Message",
+ };
+
+ /**
+ * The constructor.
+ *
+ * @param n the name
+ */
+ public TestCollaborationsFactory(String n) {
+ super(n);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() {
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * @return Returns the allModelElements.
+ */
+ static String[] getAllModelElements() {
+ return allModelElements;
+ }
+
+ /**
+ * @return all testable model elements
+ */
+ static List<String> getTestableModelElements() {
+ return Arrays.asList(allModelElements);
+ }
+
+ /**
+ * Test the creation of the elements.
+ */
+ public void testCreates() {
+ CheckUMLModelHelper.createAndRelease(
+ Model.getCollaborationsFactory(), getTestableModelElements());
+ }
+
+ /**
+ * Test for delete methods.
+ */
+ public void testAllDeleteMethodsAvailable() {
+ CheckUMLModelHelper.hasDeleteMethod(Model.getCollaborationsFactory(),
+ allModelElements);
+ }
+
+ /**
+ * Test to check whether elements which are attached to a ClassifierRole get
+ * deleted upon deletion of the ClassifierRole. These elements are
+ * Message and AssociationRole.
+ */
+ public void testDeleteClassifierRole() {
+ Object model = Model.getModelManagementFactory().createModel();
+
+ Object collab =
+ Model.getCollaborationsFactory().buildCollaboration(model);
+ Object cr1 = Model.getCollaborationsFactory().createClassifierRole();
+ Object cr2 = Model.getCollaborationsFactory().createClassifierRole();
+ // Set namespace so buildAssocationRole works
+ Model.getCoreHelper().setNamespace(cr1, collab);
+ Model.getCoreHelper().setNamespace(cr2, collab);
+ Object role =
+ Model.getCollaborationsFactory().buildAssociationRole(cr1, cr2);
+ assertNotNull("Failed to create role", role);
+ Object inter =
+ Model.getCollaborationsFactory().buildInteraction(collab);
+ assertNotNull("Failed to build interaction", inter);
+ Object message =
+ Model.getCollaborationsFactory().buildMessage(inter, role);
+ assertNotNull("Failed to build message", message);
+
+ Model.getUmlFactory().delete(cr1);
+ Model.getPump().flushModelEvents();
+
+ assertTrue("ClassifierRole not removed",
+ Model.getUmlFactory().isRemoved(cr1));
+ assertTrue("AssociationRole not removed",
+ Model.getUmlFactory().isRemoved(role));
+ assertTrue("Message not removed",
+ Model.getUmlFactory().isRemoved(message));
+ /*
+ * This comment was included in a previous version (before 1/2005)
+ * of the test which had this assertion commented out:
+ * ------
+ * Interaction should not be removed when removing ClassifierRole...
+ * maybe if the last message is removed from the interaction but even
+ * then it's doubtfull since it will probably lead to backward
+ * compatibility problems in save formats.
+ * ------
+ * but my reading of the UML 1.4 specification is that an Interaction
+ * without at least one message is definitely illegal, so MDR is
+ * doing the right thing by removing it in this case where we only
+ * have a single message, which then gets deleted. - tfm
+ */
+ assertTrue("Interaction not removed",
+ Model.getUmlFactory().isRemoved(inter));
+ }
+
+
+ /**
+ * Test that an Exception is thrown when a null is sent. We don't
+ * really care which exception is thrown.
+ */
+ public void testExpectedArgumentException() {
+ try {
+ Model.getCollaborationsFactory().buildActivator(null, null);
+ fail("Exception missing");
+ } catch (Exception e) {
+ // Correct Exception was thrown.
+ }
+
+ try {
+ Model.getCollaborationsFactory().buildMessage(null, null);
+ fail("Exception missing");
+ } catch (Exception e) {
+ // Correct Exception was thrown.
+ }
+
+ Object collab = Model.getCollaborationsFactory().createCollaboration();
+ try {
+ Model.getCollaborationsFactory().buildMessage(collab, null);
+ fail("Exception missing");
+ } catch (Exception e) {
+ // Correct Exception was thrown.
+ }
+
+ Object inter = Model.getCollaborationsFactory().createInteraction();
+ try {
+ Model.getCollaborationsFactory().buildMessage(inter, null);
+ fail("Exception missing");
+ } catch (Exception e) {
+ // Correct Exception was thrown.
+ }
+
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestCollaborationsHelper.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestCollaborationsHelper.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestCollaborationsHelper.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,67 @@
+// $Id:TestCollaborationsHelper.java 12485 2007-05-03 05:59:35Z linus $
+// Copyright (c) 1996-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.
+
+// $header$
+package org.argouml.model;
+
+import junit.framework.TestCase;
+
+/**
+ * @since Oct 10, 2002
+ * @author [email protected]
+ */
+public class TestCollaborationsHelper extends TestCase {
+
+ /**
+ * Constructor for TestCollaborationsHelper.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestCollaborationsHelper(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test for the metamodel name.
+ */
+ public void testGetMetaModelName() {
+ CheckUMLModelHelper.metaModelNameCorrect(
+ Model.getCollaborationsFactory(),
+ TestCollaborationsFactory.getAllModelElements());
+ }
+
+ /**
+ * Test if the stereotype is valid.
+ */
+ public void testIsValidStereoType() {
+ CheckUMLModelHelper.isValidStereoType(
+ Model.getCollaborationsFactory(),
+ TestCollaborationsFactory.getAllModelElements());
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestCommonBehaviorFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestCommonBehaviorFactory.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestCommonBehaviorFactory.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,110 @@
+// $Id:TestCommonBehaviorFactory.java 12576 2007-05-09 14:19:16Z tfmorris $
+// Copyright (c) 2002-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.model;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Test the CommonBehaviorFactory.
+ */
+public class TestCommonBehaviorFactory extends TestCase {
+
+ /**
+ * All the ModelElements that we will test.
+ */
+ private static String[] allModelElements =
+ {
+ "Action", // abstract
+ "ActionSequence",
+ "Argument",
+ "AttributeLink",
+ "CallAction",
+ "ComponentInstance",
+ "CreateAction",
+ "DataValue",
+ "DestroyAction",
+ "Exception",
+ "Instance", // abstract
+ "Link",
+ "LinkEnd",
+ "LinkObject",
+ "NodeInstance",
+ "Object",
+ "Reception",
+ "ReturnAction",
+ "SendAction",
+ "Signal",
+ "Stimulus",
+ "TerminateAction",
+ "UninterpretedAction",
+ };
+
+ /**
+ * The constructor.
+ *
+ * @param n the name
+ */
+ public TestCommonBehaviorFactory(String n) {
+ super(n);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() {
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * @return concrete ModelElement types
+ */
+ static List<String> getTestableModelElements() {
+ ArrayList c = new ArrayList(Arrays.asList(allModelElements));
+ c.remove("Action");
+ c.remove("Instance");
+ return c;
+ }
+
+ /**
+ * @return Returns the allModelElements.
+ */
+ static String[] getAllModelElements() {
+ return allModelElements;
+ }
+
+ /**
+ * Test for creation.
+ */
+ public void testCreates() {
+ CheckUMLModelHelper.createAndRelease(
+ Model.getCommonBehaviorFactory(), getTestableModelElements());
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestCommonBehaviorHelper.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestCommonBehaviorHelper.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestCommonBehaviorHelper.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,71 @@
+// $Id:TestCommonBehaviorHelper.java 12673 2007-05-26 21:28:12Z tfmorris $
+// Copyright (c) 1996-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.model;
+
+import junit.framework.TestCase;
+
+/**
+ * @since Oct 10, 2002
+ * @author [email protected]
+ */
+public class TestCommonBehaviorHelper extends TestCase {
+
+ /**
+ * Constructor for TestCommonBehaviorHelper.
+ *
+ * @param arg0 is the test case name.
+ */
+ public TestCommonBehaviorHelper(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Override
+ public void setUp() {
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test the metamodel name.
+ */
+ public void testGetMetaModelName() {
+ CheckUMLModelHelper.metaModelNameCorrect(
+ Model.getCommonBehaviorFactory(),
+ TestCommonBehaviorFactory.getTestableModelElements());
+ }
+
+ /**
+ * Test if the stereotype is valid.
+ */
+ public void testIsValidStereoType() {
+ CheckUMLModelHelper.isValidStereoType(
+ Model.getCommonBehaviorFactory(),
+ TestCommonBehaviorFactory.getTestableModelElements());
+ }
+
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestCopyHelper.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestCopyHelper.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestCopyHelper.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,516 @@
+// $Id:TestCopyHelper.java 12481 2007-05-02 16:50:34Z linus $
+// Copyright (c) 2003-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.model;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+/**
+ * Non-gui tests of the CopyHelper class.
+ */
+public class TestCopyHelper extends TestCase {
+
+ private static final String TV_TYPE = "TVType";
+ private static final String TV_VALUE1 = "TVValue";
+ private static final String TV_VALUE2 = "TVNewValue";
+
+ /*
+ * @see junit.framework.TestCase#TestCase(String)
+ */
+ public TestCopyHelper(String name) {
+ super(name);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() {
+ InitializeModel.initializeDefault();
+
+ // Make sure we have a root model for TagDefinitions to get put in.
+ ModelManagementFactory mmf = Model.getModelManagementFactory();
+ mmf.setRootModel(mmf.createModel());
+ }
+
+ /**
+ * Testing the existance of public static members.
+ */
+ public void compileTestPublicStaticMembers() {
+ Model.getCopyHelper();
+ }
+
+ /**
+ * Testing the existance of public members.
+ */
+ public void compileTestPublicMembers() {
+ CopyHelper h = Model.getCopyHelper();
+
+ h.copy(Model.getCoreFactory().createComment(),
+ Model.getModelManagementFactory().createPackage());
+ }
+
+ /**
+ * Testing the copying of a class.
+ */
+ public void testCopyClass() {
+ Object m1 = Model.getModelManagementFactory().createModel();
+ Object m2 = Model.getModelManagementFactory().createModel();
+ CopyHelper helper = Model.getCopyHelper();
+
+ Object o;
+ Object c;
+ Object c2;
+ Object k;
+ Object st;
+
+ k = Model.getCoreFactory().createClass();
+ Model.getCoreHelper().addOwnedElement(m1, k);
+
+ st = Model.getExtensionMechanismsFactory().buildStereotype("clsStT", k);
+ Model.getCoreHelper().addOwnedElement(m1, st);
+
+ // See if we can copy a class right off
+ o = helper.copy(k, m2);
+ assertNotNull(o);
+ assertTrue(o.getClass() == k.getClass());
+ c = o;
+ assertTrue(Model.getFacade().getNamespace(c) == m2);
+ checkClassCopy(k, c);
+
+ // Change things
+ Model.getCoreHelper().setName(k, "TestClass");
+ Model.getCoreHelper().setVisibility(k,
+ Model.getVisibilityKind().getPublic());
+ Model.getCoreHelper().setSpecification(k, true);
+ addNewTaggedValue(k, TV_TYPE, TV_VALUE1);
+ Model.getCoreHelper().setActive(k, false);
+ c = helper.copy(k, m2);
+ checkClassCopy(k, c);
+
+ // Assert that the copy isn't modified when the source changes
+ Model.getCoreHelper().setName(k, "TestClass2");
+ Model.getCoreHelper().setVisibility(k,
+ Model.getVisibilityKind().getProtected());
+ Model.getCoreHelper().setSpecification(k, false);
+ updateTaggedValue(k, TV_TYPE, TV_VALUE2);
+
+ Model.getCoreHelper().setActive(k, true);
+ Model.getExtensionMechanismsHelper().addCopyStereotype(k, st);
+ assertEquals("TestClass", Model.getFacade().getName(c));
+ assertTrue(Model.getFacade().getVisibility(c)
+ == Model.getVisibilityKind().getPublic());
+ assertTrue(Model.getFacade().isSpecification(c));
+ assertTrue(!Model.getFacade().isActive(c));
+ assertEquals(TV_VALUE1, Model.getFacade().getValueOfTag(
+ Model.getFacade().getTaggedValue(c, TV_TYPE)));
+
+ // See if the other copy was just a lucky shot
+ c = helper.copy(k, m2);
+ checkClassCopy(k, c);
+
+ // See if two copies look like copies of eachother
+ c2 = helper.copy(k, m2);
+ checkClassCopy(c, c2);
+ }
+
+ /**
+ * Testing the copying of a data type.
+ */
+ public void testCopyDataType() {
+ Object m1 = Model.getModelManagementFactory().createModel();
+ Object m2 = Model.getModelManagementFactory().createModel();
+ CopyHelper helper = Model.getCopyHelper();
+
+ Object o;
+ Object c;
+ Object c2;
+ Object d;
+ Object st;
+
+ d = Model.getCoreFactory().createDataType();
+ Model.getCoreHelper().addOwnedElement(m1, d);
+
+ st = Model.getExtensionMechanismsFactory().buildStereotype("dttStT", d);
+ Model.getCoreHelper().addOwnedElement(m1, st);
+
+ // See if we can copy a datatype right off
+ o = helper.copy(d, m2);
+ assertNotNull(o);
+ assertTrue(o.getClass() == d.getClass());
+ c = o;
+ assertTrue(Model.getFacade().getNamespace(c) == m2);
+ checkDataTypeCopy(d, c);
+
+ // Change things
+ Model.getCoreHelper().setName(d, "TestDataType");
+ Model.getCoreHelper().setVisibility(d,
+ Model.getVisibilityKind().getPublic());
+ Model.getCoreHelper().setSpecification(d, true);
+ addNewTaggedValue(d, TV_TYPE, TV_VALUE1);
+ c = helper.copy(d, m2);
+ checkDataTypeCopy(d, c);
+
+ // Assert that the copy isn't modified when the source changes
+ Model.getCoreHelper().setName(d, "TestDataType2");
+ Model.getCoreHelper().setVisibility(d,
+ Model.getVisibilityKind().getProtected());
+ Model.getCoreHelper().setSpecification(d, false);
+ updateTaggedValue(d, TV_TYPE, TV_VALUE2);
+ Model.getExtensionMechanismsHelper().addCopyStereotype(d, st);
+ assertEquals("TestDataType", Model.getFacade().getName(c));
+ assertTrue(Model.getFacade().getVisibility(c)
+ == Model.getVisibilityKind().getPublic());
+ assertTrue(Model.getFacade().isSpecification(c));
+ assertEquals(TV_VALUE1, Model.getFacade().getValueOfTag(
+ Model.getFacade().getTaggedValue(c, TV_TYPE)));
+
+ // See if the other copy was just a lucky shot
+ c = helper.copy(d, m2);
+ checkDataTypeCopy(d, c);
+
+ // See if two copies look like copies of each other
+ c2 = helper.copy(d, m2);
+ checkDataTypeCopy(c, c2);
+ }
+
+ /**
+ * Testing the copying of an interface.
+ */
+ public void testCopyInterface() {
+ Object m1 = Model.getModelManagementFactory().createModel();
+ Object m2 = Model.getModelManagementFactory().createModel();
+ CopyHelper helper = Model.getCopyHelper();
+
+ Object o;
+ Object c;
+ Object c2;
+ Object i;
+ Object st;
+
+ i = Model.getCoreFactory().createInterface();
+ Model.getCoreHelper().addOwnedElement(m1, i);
+
+ st = Model.getExtensionMechanismsFactory().buildStereotype("intStT", i);
+ Model.getExtensionMechanismsHelper().addBaseClass(st, "Interface");
+ Model.getCoreHelper().addOwnedElement(m1, st);
+
+ // See if we can copy an interface right off
+ o = helper.copy(i, m2);
+ assertNotNull(o);
+ assertTrue(o.getClass() == i.getClass());
+ c = o;
+ assertTrue(Model.getFacade().getNamespace(c) == m2);
+ checkInterfaceCopy(i, c);
+
+ // Change things
+ Model.getCoreHelper().setName(i, "TestInterface");
+ Model.getCoreHelper().setVisibility(i,
+ Model.getVisibilityKind().getPublic());
+ Model.getCoreHelper().setSpecification(i, true);
+ addNewTaggedValue(i, TV_TYPE, TV_VALUE1);
+ c = helper.copy(i, m2);
+ checkInterfaceCopy(i, c);
+
+ // Assert that the copy isn't modified when the source changes
+ Model.getCoreHelper().setName(i, "TestInterface2");
+ Model.getCoreHelper().setVisibility(i,
+ Model.getVisibilityKind().getProtected());
+ Model.getCoreHelper().setSpecification(i, false);
+ updateTaggedValue(i, TV_TYPE, TV_VALUE2);
+
+ Model.getExtensionMechanismsHelper().addCopyStereotype(i, st);
+ assertEquals("TestInterface", Model.getFacade().getName(c));
+ assertTrue(Model.getFacade().getVisibility(c)
+ == Model.getVisibilityKind().getPublic());
+ assertTrue(Model.getFacade().isSpecification(c));
+ assertEquals(TV_VALUE1, Model.getFacade().getValueOfTag(
+ Model.getFacade().getTaggedValue(c, TV_TYPE)));
+
+ // See if the other copy was just a lucky shot
+ c = helper.copy(i, m2);
+ checkInterfaceCopy(i, c);
+
+ // See if two copies look like copies of eachother
+ c2 = helper.copy(i, m2);
+ checkInterfaceCopy(c, c2);
+ }
+
+ /*
+ * Create a new tagged value with the given type and value
+ * and add it to a ModelElement.
+ */
+ private void addNewTaggedValue(Object element, String type,
+ String dataValue) {
+ Model.getExtensionMechanismsHelper().addTaggedValue(
+ element,
+ Model.getExtensionMechanismsFactory().buildTaggedValue(
+ type, dataValue));
+ }
+
+
+ /*
+ * Update an existing tagged value on a model element.
+ */
+ private void updateTaggedValue(Object element, String type,
+ String dataValue) {
+ Object tv = Model.getFacade().getTaggedValue(element, type);
+ Model.getExtensionMechanismsHelper().setValueOfTag(tv, dataValue);
+ }
+
+ /**
+ * Testing the copying of a package.
+ */
+ public void testCopyPackage() {
+ Object m1 = Model.getModelManagementFactory().createModel();
+ Object m2 = Model.getModelManagementFactory().createModel();
+ CopyHelper helper = Model.getCopyHelper();
+
+ Object o;
+ Object c;
+ Object c2;
+ Object p;
+ Object st;
+
+ p = Model.getModelManagementFactory().createPackage();
+ Model.getCoreHelper().addOwnedElement(m1, p);
+
+ st = Model.getExtensionMechanismsFactory().buildStereotype("pkgStT", p);
+ Model.getCoreHelper().addOwnedElement(m1, st);
+
+ // See if we can copy a package right off
+ o = helper.copy(p, m2);
+ assertNotNull(o);
+ assertTrue(o.getClass() == p.getClass());
+ c = o;
+ assertTrue(Model.getFacade().getNamespace(c) == m2);
+ checkPackageCopy(p, c);
+
+ // Change things
+ Model.getCoreHelper().setName(p, "TestPackage");
+ Model.getCoreHelper().setVisibility(p,
+ Model.getVisibilityKind().getPublic());
+ Model.getCoreHelper().setSpecification(p, true);
+ addNewTaggedValue(p, TV_TYPE, TV_VALUE1);
+ c = helper.copy(p, m2);
+ checkPackageCopy(p, c);
+
+ // Assert that the copy isn't modified when the source changes
+ Model.getCoreHelper().setName(p, "TestPackage2");
+ Model.getCoreHelper().setVisibility(p,
+ Model.getVisibilityKind().getProtected());
+ Model.getCoreHelper().setSpecification(p, false);
+ updateTaggedValue(p, TV_TYPE, TV_VALUE2);
+ Model.getExtensionMechanismsHelper().addCopyStereotype(p, st);
+ assertEquals("TestPackage", Model.getFacade().getName(c));
+ assertTrue(Model.getFacade().getVisibility(c)
+ == Model.getVisibilityKind().getPublic());
+ assertTrue(Model.getFacade().isSpecification(c));
+ assertEquals(TV_VALUE1, Model.getFacade().getValueOfTag(
+ Model.getFacade().getTaggedValue(c, TV_TYPE)));
+
+ // See if the other copy was just a lucky shot
+ c = helper.copy(p, m2);
+ checkPackageCopy(p, c);
+
+ // See if two copies look like copies of eachother
+ c2 = helper.copy(p, m2);
+ checkPackageCopy(c, c2);
+ }
+
+ /**
+ * Testing the copying of a stereotype.
+ */
+ public void testCopyStereotype() {
+ Object m1 = Model.getModelManagementFactory().createModel();
+ Object m2 = Model.getModelManagementFactory().createModel();
+ CopyHelper helper = Model.getCopyHelper();
+
+ Object o;
+ Object c;
+ Object c2;
+ Object s;
+ Object st;
+
+ s = Model.getExtensionMechanismsFactory().buildStereotype(null, m1);
+ Model.getCoreHelper().addOwnedElement(m1, s);
+
+ st =
+ Model.getExtensionMechanismsFactory()
+ .buildStereotype("sttStT", m1);
+ Model.getCoreHelper().addOwnedElement(m1, st);
+
+ // See if we can copy a stereotype right off
+ o = helper.copy(s, m2);
+ assertNotNull(o);
+ assertTrue(o.getClass() == s.getClass());
+ c = o;
+ assertTrue(Model.getFacade().getNamespace(c) == m2);
+ checkStereotypeCopy(s, c);
+
+ // Change things
+ Model.getCoreHelper().setName(s, "TestStereotype");
+ Model.getCoreHelper().setVisibility(s,
+ Model.getVisibilityKind().getPublic());
+ Model.getCoreHelper().setSpecification(s, true);
+ addNewTaggedValue(s, TV_TYPE, TV_VALUE1);
+ Model.getExtensionMechanismsHelper().removeBaseClass(s, "Model");
+ Model.getExtensionMechanismsHelper().addBaseClass(s, "ModelElement");
+ Model.getExtensionMechanismsHelper().setIcon(s, "Icon1");
+ c = helper.copy(s, m2);
+ checkStereotypeCopy(s, c);
+
+ // Assert that the copy isn't modified when the source changes
+ Model.getCoreHelper().setName(s, "TestStereotype2");
+ Model.getCoreHelper().setVisibility(s,
+ Model.getVisibilityKind().getProtected());
+ Model.getCoreHelper().setSpecification(s, false);
+ updateTaggedValue(s, TV_TYPE, TV_VALUE2);
+ Model.getExtensionMechanismsHelper().addCopyStereotype(s, st);
+ Model.getExtensionMechanismsHelper().addBaseClass(st, "ClassifierRole");
+ Model.getExtensionMechanismsHelper().setIcon(s, "Icon2");
+ assertEquals("TestStereotype", Model.getFacade().getName(c));
+ assertTrue(Model.getFacade().getVisibility(c) == Model
+ .getVisibilityKind().getPublic());
+ assertTrue(Model.getFacade().isSpecification(c));
+ Collection bases = Model.getFacade().getBaseClasses(c);
+ assertEquals(1, bases.size());
+ assertEquals("ModelElement", bases.iterator().next());
+ assertEquals("Icon1", Model.getFacade().getIcon(c));
+ assertEquals(TV_VALUE1, Model.getFacade().getValueOfTag(
+ Model.getFacade().getTaggedValue(c, TV_TYPE)));
+
+ // See if the other copy was just a lucky shot
+ c = helper.copy(s, m2);
+ checkStereotypeCopy(s, c);
+
+ // See if two copies look like copies of eachother
+ c2 = helper.copy(s, m2);
+ checkStereotypeCopy(c, c2);
+ }
+
+ private void checkClassCopy(Object c1, Object c2) {
+ checkClassifierCopy(c1, c2);
+ assertTrue(Model.getFacade().isActive(c1) == Model.getFacade()
+ .isActive(c2));
+ }
+
+ private void checkClassifierCopy(Object c1, Object c2) {
+ checkNamespaceCopy(c1, c2);
+ checkGeneralizableElementCopy(c1, c2);
+ }
+
+ private void checkDataTypeCopy(Object d1, Object d2) {
+ checkClassifierCopy(d1, d2);
+ }
+
+ private void checkGeneralizableElementCopy(
+ Object e1,
+ Object e2) {
+ checkModelElementCopy(e1, e2);
+
+ assertTrue(Model.getFacade().isAbstract(e1) == Model.getFacade()
+ .isAbstract(e2));
+ assertTrue(Model.getFacade().isLeaf(e1)
+ == Model.getFacade().isLeaf(e2));
+ assertTrue(Model.getFacade().isRoot(e1)
+ == Model.getFacade().isRoot(e2));
+ }
+
+ private void checkInterfaceCopy(Object i1, Object i2) {
+ checkClassifierCopy(i1, i2);
+ }
+
+ private void checkModelElementCopy(Object e1, Object e2) {
+ // Parent is Element, but it has no attributes or associations to check
+ // checkElementCopy(e1, e2);
+ if (Model.getFacade().getName(e1) == null) {
+ assertNull(Model.getFacade().getName(e2));
+ } else {
+ assertEquals(Model.getFacade().getName(e1), Model.getFacade()
+ .getName(e2));
+ }
+ assertEquals(Model.getFacade().getVisibility(e1),
+ Model.getFacade().getVisibility(e2));
+ assertEquals(Model.getFacade().isSpecification(e1),
+ Model.getFacade().isSpecification(e2));
+ assertEquals(Model.getFacade().getTaggedValuesCollection(e1).size(),
+ Model.getFacade().getTaggedValuesCollection(e2).size());
+
+ Iterator it = Model.getFacade().getTaggedValues(e1);
+ while (it.hasNext()) {
+ Object tv = it.next();
+ Object e2Tv =
+ Model.getFacade().getTaggedValue(e2,
+ Model.getFacade().getTag(tv));
+ if (Model.getFacade().getValueOfTag(tv) == null) {
+ assertNull(Model.getFacade().getValueOfTag(e2Tv));
+ } else {
+ assertEquals(Model.getFacade().getValueOfTag(tv),
+ Model.getFacade().getValueOfTag(e2Tv));
+ }
+ }
+
+ if (Model.getFacade().getStereotypes(e1) == null) {
+ assertNull(Model.getFacade().getStereotypes(e2));
+ } else if (Model.getFacade().getStereotypes(e1).isEmpty()) {
+ assertTrue(Model.getFacade().getStereotypes(e2).isEmpty());
+ } else {
+ assertTrue(!Model.getFacade().getStereotypes(e2).isEmpty());
+ Object firstStereoOfe1 =
+ Model.getFacade().getStereotypes(e1).iterator().next();
+ Object firstStereoOfe2 =
+ Model.getFacade().getStereotypes(e2).iterator().next();
+ assertNotNull(Model.getFacade().getName(firstStereoOfe2));
+ assertEquals(Model.getFacade().getName(firstStereoOfe1),
+ Model.getFacade().getName(firstStereoOfe2));
+ }
+ }
+
+ private void checkNamespaceCopy(Object n1, Object n2) {
+ checkModelElementCopy(n1, n2);
+ }
+
+ private void checkPackageCopy(Object p1, Object p2) {
+ checkNamespaceCopy(p1, p2);
+ }
+
+ private void checkStereotypeCopy(Object s1, Object s2) {
+ checkGeneralizableElementCopy(s1, s2);
+ assertEquals(Model.getFacade().getBaseClasses(s1), Model.getFacade()
+ .getBaseClasses(s2));
+
+ if (Model.getFacade().getIcon(s1) == null) {
+ assertNull(Model.getFacade().getIcon(s2));
+ } else {
+ assertEquals(Model.getFacade().getIcon(s1), Model.getFacade()
+ .getIcon(s2));
+ }
+
+ // TODO: constraints
+ // TODO: required tags
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestCoreFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestCoreFactory.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestCoreFactory.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,583 @@
+// $Id:TestCoreFactory.java 13254 2007-08-06 17:33:09Z tfmorris $
+// Copyright (c) 2002-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.model;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Test the CoreFactory interface and implementation beyond.
+ */
+public class TestCoreFactory extends TestCase {
+
+ /**
+ * The model elements to test.
+ */
+ private static String[] allModelElements =
+ {
+ "Abstraction",
+ "Association",
+ "AssociationClass",
+ "AssociationEnd",
+ "Attribute",
+ "BehavioralFeature",
+ "Binding",
+ "Class",
+ "Classifier",
+ "Comment",
+ "Component",
+ "Constraint",
+ "DataType",
+ "Dependency",
+ "Element",
+ "ElementResidence",
+ "Feature",
+ "Flow",
+ "GeneralizableElement",
+ "Generalization",
+ "Interface",
+ "Method",
+ "ModelElement",
+ "Namespace",
+ "Node",
+ "Operation",
+ "Parameter",
+ "Permission",
+ "PresentationElement",
+ "Relationship",
+ "StructuralFeature",
+ "TemplateArgument",
+ "TemplateParameter",
+ "Usage",
+ };
+
+ /**
+ * The constructor.
+ *
+ * @param n the name of the test
+ */
+ public TestCoreFactory(String n) {
+ super(n);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * @return Returns the allModelElements.
+ */
+ static String[] getAllModelElements() {
+ return allModelElements;
+ }
+
+ /**
+ * @return the concrete ModelElements which are testable
+ */
+ static List<String> getTestableModelElements() {
+ List<String> c = new ArrayList<String>(Arrays.asList(allModelElements));
+ c.remove("BehavioralFeature");
+ c.remove("Element");
+ c.remove("ModelElement");
+ c.remove("Namespace");
+ c.remove("GeneralizableElement");
+ c.remove("Classifier");
+ c.remove("Feature");
+ c.remove("StructuralFeature");
+ c.remove("BehavioralFeature");
+ c.remove("Relationship");
+ c.remove("PresentationElement");
+ return c;
+ }
+
+ /**
+ * Test creation of metatypes.
+ *
+ * TODO: we could add tests here to make sure that
+ * we can NOT create abstract types
+ */
+ public void testCreates() {
+ CheckUMLModelHelper.createAndRelease(
+ Model.getCoreFactory(), getTestableModelElements());
+ }
+
+ /**
+ * Test complete deletion.
+ */
+ public void testDeleteComplete() {
+ CheckUMLModelHelper.hasDeleteMethod(Model.getCoreFactory(),
+ allModelElements);
+ }
+
+ /**
+ * Test that deleting a classifier also deletes a binary association.
+ */
+ public void testDeleteClassifier1() {
+ Object model = Model.getModelManagementFactory().createModel();
+ Object class1 = Model.getCoreFactory().buildClass(model);
+ Object class2 = Model.getCoreFactory().buildClass(model);
+ Object assoc = Model.getCoreFactory().buildAssociation(class1, class2);
+ Model.getUmlFactory().delete(class1);
+ Model.getPump().flushModelEvents();
+
+ assertTrue("class not removed",
+ Model.getUmlFactory().isRemoved(class1));
+ assertTrue("binary association not removed",
+ Model.getUmlFactory().isRemoved(assoc));
+ }
+
+ /**
+ * Test if deleting a classifier from a 3 way
+ * association results in a binary association
+ * remaining between the other classifiers.
+ */
+ public void testDeleteClassifierAssociation() {
+ Object model = Model.getModelManagementFactory().createModel();
+ Object class1 = Model.getCoreFactory().buildClass(model);
+ Object class2 = Model.getCoreFactory().buildClass(model);
+ Object assoc = Model.getCoreFactory().buildAssociation(class1, class2);
+ Model.getCoreHelper().addConnection(assoc,
+ Model.getCoreFactory().createAssociationEnd());
+ Model.getUmlFactory().delete(class1);
+ Model.getPump().flushModelEvents();
+ assertTrue("class not removed",
+ Model.getUmlFactory().isRemoved(class1));
+ // Check to see if association still exists
+ Collection ends = Model.getFacade().getAssociationEnds(class2);
+ assertEquals(1, ends.size());
+ Object assoc1 =
+ Model.getFacade()
+ .getAssociation(ends.iterator().next());
+ assertEquals(2, Model.getFacade().getConnections(assoc1).size());
+ }
+
+ /**
+ * Test if deleting a class also deletes its dependency.
+ */
+ public void testDeleteModelelementDependency() {
+ Object model = Model.getModelManagementFactory().createModel();
+ Object class1 = Model.getCoreFactory().buildClass(model);
+ Object class2 = Model.getCoreFactory().buildClass(model);
+ Model.getCoreFactory().buildDependency(class1, class2);
+ assertEquals("client dependency invalid",
+ 1, Model.getFacade().getClientDependencies(class1).size());
+ assertEquals("supplier dependency invalid",
+ 1, Model.getFacade().getSupplierDependencies(class2).size());
+
+ Model.getUmlFactory().delete(class1);
+ Model.getPump().flushModelEvents();
+
+ assertTrue("class not removed",
+ Model.getUmlFactory().isRemoved(class1));
+ assertEquals("invalid supplier dependency not removed",
+ 0, Model.getFacade().getSupplierDependencies(class2).size());
+ }
+
+ /**
+ * Test that deleting a class doesn't delete a valid dependency.
+ * <pre>
+ * Build 2
+ * / \
+ * 1 3
+ * </pre>
+ * delete 1 and confirm that dependency still exists
+ */
+ public void testDeleteModelelementDependencyClient() {
+ Object model = Model.getModelManagementFactory().createModel();
+ Object class1 = Model.getCoreFactory().buildClass(model);
+ Object class2 = Model.getCoreFactory().buildClass(model);
+ Object dep = Model.getCoreFactory().buildDependency(class1, class2);
+ Model.getCoreHelper().setNamespace(dep, model);
+ Object class3 = Model.getCoreFactory().buildClass(model);
+ Model.getCoreHelper().addClient(dep, class3);
+ Model.getPump().flushModelEvents();
+ assertEquals(
+ "client dependency invalid",
+ 1,
+ Model.getFacade().getClientDependencies(class1).size());
+ assertEquals(
+ "client dependency invalid",
+ 1,
+ Model.getFacade().getClientDependencies(class3).size());
+ assertEquals(
+ "supplier dependency invalid",
+ 1,
+ Model.getFacade().getSupplierDependencies(class2).size());
+
+ Model.getUmlFactory().delete(class1);
+ Model.getPump().flushModelEvents();
+
+ assertTrue("class not removed",
+ Model.getUmlFactory().isRemoved(class1));
+ assertEquals("valid client dependency removed",
+ 1, Model.getFacade().getClientDependencies(class3).size());
+ assertEquals("valid supplier dependency removed",
+ 1, Model.getFacade().getSupplierDependencies(class2).size());
+ }
+
+ /**
+ * Test that deleting a class doesn't leave an invalid dependency.
+ * <pre>
+ * Build 2
+ * / \
+ * 1 3
+ * </pre>
+ * delete 2 and confirm that the dependency is deleted
+ */
+ public void testDeleteModelelementDependencyClient2() {
+ Object model = Model.getModelManagementFactory().createModel();
+ Object class1 = Model.getCoreFactory().buildClass(model);
+ Object class2 = Model.getCoreFactory().buildClass(model);
+ Object dep = Model.getCoreFactory().buildDependency(class1, class2);
+ Object class3 = Model.getCoreFactory().buildClass(model);
+ Model.getCoreHelper().addClient(dep, class3);
+
+ Model.getUmlFactory().delete(class2);
+ Model.getPump().flushModelEvents();
+
+ assertTrue("class not removed",
+ Model.getUmlFactory().isRemoved(class2));
+ assertTrue("Invalid dependency not removed",
+ Model.getFacade().getClientDependencies(class3).isEmpty());
+ assertTrue("Invalid dependency not removed",
+ Model.getFacade().getClientDependencies(class1).isEmpty());
+ }
+
+ /**
+ * Test if deleting a class with a dependency containing two suppliers
+ * also deletes the invalid dependency.
+ * <pre>
+ * Build 2 3
+ * \ /
+ * 1
+ * </pre>
+ * Delete 1 and confirm that dependency gets deleted
+ */
+ public void testDeleteModelelementDependencySupplier() {
+ Object model = Model.getModelManagementFactory().createModel();
+ Object class1 = Model.getCoreFactory().buildClass(model);
+ Object class2 = Model.getCoreFactory().buildClass(model);
+ Object dep = Model.getCoreFactory().buildDependency(class1, class2);
+ Object class3 = Model.getCoreFactory().buildClass(model);
+ Model.getCoreHelper().addSupplier(dep, class3);
+
+ Model.getUmlFactory().delete(class1);
+ Model.getPump().flushModelEvents();
+
+ assertTrue("class not removed",
+ Model.getUmlFactory().isRemoved(class1));
+ assertEquals(
+ "Invalid dependency not removed",
+ 0,
+ Model.getFacade().getSupplierDependencies(class2).size());
+ assertEquals(
+ "Invalid dependency not removed",
+ 0,
+ Model.getFacade().getSupplierDependencies(class3).size());
+ }
+
+ /**
+ * Test if deleting a class which is one of two suppliers to a dependency
+ * leaves the dependency intact.
+ * <pre>
+ * Build 2 3
+ * \ /
+ * 1
+ * </pre>
+ * Delete 2 and confirm that dependency remains
+ */
+ public void testDeleteModelelementDependencySupplier2() {
+ Object model = Model.getModelManagementFactory().createModel();
+ Object class1 = Model.getCoreFactory().buildClass(model);
+ Object class2 = Model.getCoreFactory().buildClass(model);
+ Object dep = Model.getCoreFactory().buildDependency(class1, class2);
+ Object class3 = Model.getCoreFactory().buildClass(model);
+ Model.getCoreHelper().addSupplier(dep, class3);
+
+ Model.getUmlFactory().delete(class2);
+ Model.getPump().flushModelEvents();
+
+ assertTrue("class not removed",
+ Model.getUmlFactory().isRemoved(class2));
+ assertEquals(
+ "Invalid dependency not removed",
+ 1,
+ Model.getFacade().getClientDependencies(class1).size());
+ assertEquals(
+ "Invalid dependency not removed",
+ 1,
+ Model.getFacade().getSupplierDependencies(class3).size());
+ }
+
+ /**
+ * Construct a class, with two self associations and delete the class.
+ * Test if both associations were deleted in the process.
+ */
+ public void testDeleteModelelementClassSelfAssociations() {
+ Object model = Model.getModelManagementFactory().createModel();
+ Object class1 = Model.getCoreFactory().buildClass(model);
+ Object assoc1 = Model.getCoreFactory().buildAssociation(class1, class1);
+ Object assoc2 = Model.getCoreFactory().buildAssociation(class1, class1);
+ Model.getUmlFactory().delete(class1);
+ Model.getPump().flushModelEvents();
+
+ assertTrue("class not removed",
+ Model.getUmlFactory().isRemoved(class1));
+ assertTrue("assoc1 not removed",
+ Model.getUmlFactory().isRemoved(assoc1));
+ assertTrue("assoc2 not removed",
+ Model.getUmlFactory().isRemoved(assoc2));
+ }
+
+ /**
+ * Test buildConstraint().
+ */
+ public void testBuildConstraint() {
+ try {
+ Model.getCoreFactory().buildConstraint(null);
+ fail("IllegalArgumentException should be thrown");
+ } catch (IllegalArgumentException i) {
+ // Expected IllegalArgumentException seen
+ }
+ Object elem = Model.getModelManagementFactory().createModel();
+ Object con = Model.getCoreFactory().buildConstraint(elem);
+ Model.getPump().flushModelEvents();
+ assertNull("Namespace is unexpectly set", Model.getFacade()
+ .getNamespace(con));
+ assertTrue(
+ "Constrained element is not set",
+ !Model.getFacade().getConstrainedElements(con).isEmpty());
+ assertTrue("Constraint is not set", !Model.getFacade().getConstraints(
+ elem).isEmpty());
+ Model.getCoreHelper().setNamespace(elem,
+ Model.getModelManagementFactory().createPackage());
+ con = Model.getCoreFactory().buildConstraint(elem);
+ Model.getPump().flushModelEvents();
+ assertNotNull("Namespace is not set", Model.getFacade().getNamespace(
+ con));
+ }
+
+ /**
+ * Test building a template ModelElement.
+ */
+ public void testBuildTemplate() {
+ Object model = Model.getModelManagementFactory().createModel();
+ Object templatedClass =
+ Model.getCoreFactory().buildClass("Template", model);
+
+ Object parameterizedClass = Model.getCoreFactory().buildClass(
+ "ParameterizedClass", model);
+ assertNotNull("Failed to create Class", parameterizedClass);
+ Object binding = Model.getCoreFactory().buildBinding(
+ parameterizedClass, templatedClass, null);
+ assertNotNull("Failed to create build Binding with null arg list",
+ binding);
+
+ Object paramType1 = Model.getCoreFactory().buildClass("ParamType1");
+ Object paramType2 = Model.getCoreFactory().buildInterface("ParamType2");
+ Object paramType3 = Model.getCoreFactory().buildClass("ParamType3");
+
+ Object param1 = Model.getCoreFactory().createTemplateParameter();
+ assertNotNull("Failed to create Template Parameter", param1);
+ Object param2 = Model.getCoreFactory().createTemplateParameter();
+ Object param3 = Model.getCoreFactory().createTemplateParameter();
+
+ Model.getCoreHelper().setParameter(param1, paramType1);
+ assertEquals("Parameters don't match", paramType1,
+ Model.getFacade().getParameter(param1));
+ Model.getCoreHelper().setParameter(param2, paramType2);
+ Model.getCoreHelper().setParameter(param3, paramType3);
+
+ Object default1 = Model.getCoreFactory().buildClass("Default1");
+ Object default2 = Model.getCoreFactory().buildInterface("Default2");
+ Object default3 = Model.getCoreFactory().buildClass("Default3");
+
+ Model.getCoreHelper().setDefaultElement(param1, default1);
+ assertEquals("Default element doesn't match", default1,
+ Model.getFacade().getDefaultElement(param1));
+ Model.getCoreHelper().setDefaultElement(param2, default2);
+ Model.getCoreHelper().setDefaultElement(param3, default3);
+
+ Model.getCoreHelper().addTemplateParameter(templatedClass, param2);
+ Model.getCoreHelper().addTemplateParameter(templatedClass, param3);
+ Model.getCoreHelper().addTemplateParameter(templatedClass, 0, param1);
+
+ List params = new ArrayList();
+ params.add(param1);
+ params.add(param2);
+ params.add(param3);
+
+ assertEquals("TemplateParameter list is wrong", params,
+ Model.getFacade().getTemplateParameters(templatedClass));
+
+ Model.getCoreHelper().removeTemplateParameter(templatedClass, param2);
+ params.remove(1);
+ assertEquals("removeTemplateParameter gave wrong result", params,
+ Model.getFacade().getTemplateParameters(templatedClass));
+
+ Model.getCoreHelper().addTemplateParameter(templatedClass, 1, param2);
+ params.add(1, param2);
+ assertEquals("addTemplateParameter in middle gave wrong result",
+ params, Model.getFacade().getTemplateParameters(templatedClass));
+
+ Object arg1 = Model.getCoreFactory().buildClass("Arg1");
+ Object arg2 = Model.getCoreFactory().buildInterface("Arg2");
+ Object arg3 = Model.getCoreFactory().buildClass("Arg3");
+
+ Object ta1 = Model.getCoreFactory().buildTemplateArgument(arg1);
+ assertNotNull("buildTemplateArgument produced null result", ta1);
+ assertEquals("model element of template argument doesn't match",
+ arg1, Model.getFacade().getModelElement(ta1));
+ Object ta2 = Model.getCoreFactory().buildTemplateArgument(arg2);
+ Object ta3 = Model.getCoreFactory().buildTemplateArgument(arg3);
+
+ Model.getCoreHelper().addTemplateArgument(binding, ta2);
+ Model.getCoreHelper().addTemplateArgument(binding, ta3);
+ Model.getCoreHelper().addTemplateArgument(binding, 0, ta1);
+
+ List args = new ArrayList();
+ args.add(ta1);
+ args.add(ta2);
+ args.add(ta3);
+ assertEquals("Binding arguments don't match", args,
+ Model.getFacade().getArguments(binding));
+
+ Model.getCoreHelper().removeTemplateArgument(binding, ta2);
+ args.remove(ta2);
+ assertEquals("Binding arguments don't match", args,
+ Model.getFacade().getArguments(binding));
+
+ Model.getCoreHelper().addTemplateArgument(binding, 1, ta2);
+ args.add(1, ta2);
+ assertEquals("Binding arguments don't match", args,
+ Model.getFacade().getArguments(binding));
+
+ // A parameterized class can only be the client of a single binding
+ try {
+ Model.getCoreFactory()
+ .buildBinding(
+ parameterizedClass,
+ Model.getCoreFactory().buildClass(
+ "Template2", model), null);
+ fail("Attempt to create 2nd binding for a client didn't fail "
+ + "as expected.");
+ } catch (IllegalArgumentException e) {
+ // exception expected - test success
+ }
+
+ // Create a different client to bind to the same supplier
+ Object parameterizedClass2 = Model.getCoreFactory().buildClass(
+ "ParameterizedClass2", model);
+
+ args.remove(0);
+ try {
+ Model.getCoreFactory().buildBinding(
+ parameterizedClass2, templatedClass, args);
+ fail("Expected exception for mismatched number of args & params");
+ } catch (IllegalArgumentException e) {
+ // expected - test success
+ }
+
+ args.add(arg1);
+ try {
+ Model.getCoreFactory().buildBinding(
+ parameterizedClass2, templatedClass, args);
+ fail("Expected exception for mismatched type/order of args "
+ + "& params");
+ } catch (IllegalArgumentException e) {
+ // expected - test success
+ }
+
+ // Create a new arg list with a different set of args (but same types)
+ args.clear();
+ // NOTE: Although it's not shown in the UML 1.4 spec, a TemplateArgument
+ // appears to be a datavalue (like MultiplicityRange) and can not be
+ // reused in multiple instances. The UML diagrams don't show it as a
+ // composition, but it effectively is.
+ ta1 = Model.getCoreFactory().buildTemplateArgument(
+ Model.getCoreFactory().buildClass("ta1a"));
+ ta2 = Model.getCoreFactory().buildTemplateArgument(
+ Model.getCoreFactory().buildInterface("ta2a"));
+ ta3 = Model.getCoreFactory().buildTemplateArgument(
+ Model.getCoreFactory().buildClass("ta3a"));
+ args.add(ta1);
+ args.add(ta2);
+ args.add(ta3);
+ Object binding2 = Model.getCoreFactory().buildBinding(
+ parameterizedClass2, templatedClass, args);
+ assertNotNull("Failed to create 2nd binding to same template",
+ binding2);
+ assertEquals("Binding arguments don't match", args,
+ Model.getFacade().getArguments(binding2));
+
+ Collection deps =
+ Model.getFacade().getClientDependencies(parameterizedClass2);
+ assertEquals(1, deps.size());
+ Object dep = deps.iterator().next();
+ assertEquals(binding2, dep);
+ Collection suppliers = Model.getFacade().getSuppliers(dep);
+ assertEquals(1, suppliers.size());
+ Collection clients = Model.getFacade().getClients(dep);
+ assertEquals(1, clients.size());
+ assertEquals(templatedClass, suppliers.iterator().next());
+ }
+
+
+ /**
+ * Test building an association between classes in two different packages
+ * and verify that the
+ */
+ public void testBuildAssociation() {
+ Object model = Model.getModelManagementFactory().createModel();
+ Object packA = Model.getModelManagementFactory().buildPackage("package-a", "111");
+ Object packB = Model.getModelManagementFactory().buildPackage("package-b", "222");
+ Object packC = Model.getModelManagementFactory().buildPackage("package-c", "222");
+
+ Model.getCoreHelper().setNamespace(packA, model);
+ Model.getCoreHelper().setNamespace(packB, packA);
+ Model.getCoreHelper().setNamespace(packC, packA);
+ Object class1 = Model.getCoreFactory().buildClass(packB);
+ Object class2 = Model.getCoreFactory().buildClass(packC);
+ Model.getModelManagementFactory().buildElementImport(packB, class2);
+
+ Object assoc = Model.getCoreFactory().buildAssociation(class1, class2);
+ assertTrue("buildAssociation() and isValidNamespace() don't agree on " +
+ "namespace for an Association",
+ Model.getCoreHelper().isValidNamespace(assoc,
+ Model.getFacade().getNamespace(assoc)));
+
+ }
+
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestCoreHelper.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestCoreHelper.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestCoreHelper.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,256 @@
+// $Id:TestCoreHelper.java 12576 2007-05-09 14:19:16Z tfmorris $
+// Copyright (c) 1996-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.model;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+/**
+ * @since Oct 10, 2002
+ * @author [email protected]
+ */
+public class TestCoreHelper extends TestCase {
+
+ // Flag to enable performance testing - off by default
+ private static final boolean PERFORMANCE_TEST = false;
+
+ // Performance testing parameters
+ private static final int CHILDREN_PER_NAMESPACE = 5;
+ private static final int NAMESPACE_LEVELS = 5;
+ private static final long TIME_LIMIT = 20L * 1000; // 20 sec.
+
+ /**
+ * Constructor for TestCoreHelper.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestCoreHelper(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() {
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test getting the metamodel name.
+ */
+ public void testGetMetaModelName() {
+ CheckUMLModelHelper.metaModelNameCorrect(
+ Model.getCoreFactory(),
+ TestCoreFactory.getTestableModelElements());
+ }
+
+ /**
+ * Test stereotypes.
+ */
+ public void testIsValidStereoType() {
+ CheckUMLModelHelper.isValidStereoType(
+ Model.getCoreFactory(),
+ TestCoreFactory.getTestableModelElements());
+ }
+
+
+ /**
+ * Test subtype check.
+ */
+ public void testIsSubType() {
+ assertTrue("Is not a subtype",
+ Model.getCoreHelper().
+ isSubType(
+ Model.getMetaTypes().getClassifier(),
+ Model.getMetaTypes().getUMLClass()));
+ assertTrue("Is not a parent type",
+ !Model.getCoreHelper().
+ isSubType(
+ Model.getMetaTypes().getUMLClass(),
+ Model.getMetaTypes().getClassifier()));
+ assertTrue("Is not a parent type",
+ !Model.getCoreHelper().
+ isSubType(Model.getMetaTypes().getUMLClass(),
+ Model.getMetaTypes().getAggregationKind()));
+ }
+
+ /**
+ * Test getting children.
+ */
+ public void testGetChildren() {
+ CoreFactory coreFactory = Model.getCoreFactory();
+ // Create a generalizable element with an element without children.
+ Object ge = coreFactory.createClass();
+
+ assertTrue(Model.getCoreHelper().getChildren(ge).size() == 0);
+
+ // Add one child.
+ Object g1 = coreFactory.createGeneralization();
+ Model.getCoreHelper().setParent(g1, ge);
+ Model.getCoreHelper().setChild(g1, coreFactory.createClass());
+
+ assertTrue(Model.getCoreHelper().getChildren(ge).size() == 1);
+
+ // Add another child.
+ Object g2 = coreFactory.createGeneralization();
+ Model.getCoreHelper().setParent(g2, ge);
+ Object ge2 = coreFactory.createClass();
+ Model.getCoreHelper().setChild(g2, ge2);
+
+ assertTrue(Model.getCoreHelper().getChildren(ge).size() == 2);
+
+ // Add grandchild.
+ Object g3 = coreFactory.createGeneralization();
+ Model.getCoreHelper().setParent(g3, ge2);
+ Model.getCoreHelper().setChild(g3, coreFactory.createClass());
+
+ assertTrue(Model.getCoreHelper().getChildren(ge).size() == 3);
+ }
+
+ /**
+ * Test if adding a client to a binary dependency
+ * actually increases the client count.
+ */
+ public void testAddClient() {
+ Object model = Model.getModelManagementFactory().createModel();
+ Object class1 = Model.getCoreFactory().buildClass(model);
+ Object class2 = Model.getCoreFactory().buildClass(model);
+ Object dep = Model.getCoreFactory().buildDependency(class1, class2);
+ Object class3 = Model.getCoreFactory().buildClass(model);
+ Model.getCoreHelper().addClient(dep, class3);
+ Collection clients = Model.getFacade().getClients(dep);
+ assertEquals(2, Model.getFacade().getClients(dep).size());
+ Iterator it = clients.iterator();
+ assertEquals(class1, it.next());
+ assertEquals(class3, it.next());
+ }
+
+ /**
+ * Test the getFirstSharedNamespace method for correctness
+ * and, optionally, performance.
+ */
+ public void testGetFirstSharedNamespace() {
+ Object model = Model.getModelManagementFactory().createModel();
+ CoreFactory cf = Model.getCoreFactory();
+
+ // Build namespace hierarchy like this:
+ // g a
+ // /\
+ // b c
+ // /\
+ // d e f
+
+ Object a = cf.buildClass("a", model);
+ Object b = cf.buildClass("b", a);
+ Object c = cf.buildClass("c", a);
+ Object d = cf.buildClass("d", c);
+ Object e = cf.buildClass("e", c);
+ Object f = cf.buildClass("f", c);
+ Object g = cf.buildClass();
+
+ CoreHelper ch = Model.getCoreHelper();
+
+ assertEquals("Got wrong namespace for first shared", a,
+ ch.getFirstSharedNamespace(b, e));
+ assertEquals("Got wrong namespace for first shared", c,
+ ch.getFirstSharedNamespace(d, e));
+ assertEquals("Got wrong namespace for first shared", a,
+ ch.getFirstSharedNamespace(a, e));
+ assertEquals("Got wrong namespace for first shared", a,
+ ch.getFirstSharedNamespace(a, c));
+ assertEquals("Got wrong namespace for first shared", a,
+ ch.getFirstSharedNamespace(b, c));
+ // The following test fails with the current implementation
+// assertNull("getFirstSharedNamespace didn't return null"
+// + " when none shared",
+// ch.getFirstSharedNamespace(g, a));
+
+ // Try changing namespace of element and make sure results track
+ assertEquals("Got wrong namespace for first shared", c,
+ ch.getFirstSharedNamespace(d, f));
+ ch.setNamespace(f, b);
+ ch.setNamespace(g, f);
+ assertEquals("Got wrong namespace after setNamespace", a,
+ ch.getFirstSharedNamespace(d, f));
+ assertEquals("Got wrong namespace after setNamespace", a,
+ ch.getFirstSharedNamespace(g, e));
+
+ if (PERFORMANCE_TEST) {
+ List children = new ArrayList();
+ Object root = cf.buildClass();
+ children.add(root);
+ createChildren(children, root, 0, NAMESPACE_LEVELS,
+ CHILDREN_PER_NAMESPACE);
+ // Tree is created depth first, so this should be at the bottom
+ Object base = children.get(NAMESPACE_LEVELS);
+ long startTime = System.currentTimeMillis();
+ int i;
+ for (i = 0; i < children.size(); i++) {
+ Object o = ch.getFirstSharedNamespace(base, children.get(i));
+ if ( i % 100 == 0) {
+ // Check periodically to see if we've exceeded time limit
+ if ((System.currentTimeMillis() - startTime) > TIME_LIMIT) {
+ break;
+ }
+ }
+ }
+ long endTime = System.currentTimeMillis();
+ System.out.println("Iterations: " + i + ", time: "
+ + (endTime - startTime) / 1.0e3 + " seconds.");
+ System.out.println("Average time for getFirstSharedNameSpace = "
+ + (endTime - startTime) * 1.0 / i
+ + " millisecs searching in "
+ + children.size() + " total elements.");
+ }
+ }
+
+ /*
+ * Populate our namespace hierarchy to the requested depth. Total number
+ * of created elements is children^maxLevel, so be careful not to increase
+ * parameters too much.
+ */
+ private List createChildren(List children, Object parent, int currentLevel,
+ int maxLevel, int numChildren) {
+ currentLevel++;
+ if (currentLevel > maxLevel) {
+ return children;
+ }
+ Object child;
+ for (int i = 0; i < numChildren; i++) {
+ child = Model.getCoreFactory().buildClass(
+ "l" + currentLevel + "n" + i);
+ children.add(child);
+ Model.getCoreHelper().setNamespace(child, parent);
+ createChildren(children, child, currentLevel, maxLevel,
+ numChildren);
+ }
+ return children;
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestCoreHelperWithMock.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestCoreHelperWithMock.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestCoreHelperWithMock.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,114 @@
+// $Id:TestCoreHelperWithMock.java 12485 2007-05-03 05:59:35Z linus $
+// Copyright (c) 2006-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.model;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for the Undo stuff in the org.argouml.model.
+ *
+ * @author Linus Tolke
+ */
+public class TestCoreHelperWithMock extends TestCase {
+ /**
+ * The Mock ModelImplementation.
+ */
+ private MockModelImplementation mockMI;
+
+ /**
+ * The ModelMemento that we got from the Model.
+ */
+ private ModelMemento memo;
+
+ /**
+ * Constructor.
+ *
+ * @param arg0 Name of the test case.
+ */
+ public TestCoreHelperWithMock(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() {
+ mockMI = InitializeModel.initializeMock();
+
+ // Must be called after setImplementation.
+ mockMI.reset();
+
+ // Registering memento.
+ Model.setMementoCreationObserver(new MementoCreationObserver() {
+ /*
+ * @see org.argouml.model.MementoCreationObserver#mementoCreated(org.argouml.model.ModelMemento)
+ */
+ public void mementoCreated(ModelMemento memento) {
+ memo = memento;
+ }
+ });
+ }
+
+ /*
+ * @see junit.framework.TestCase#tearDown()
+ */
+ public void tearDown() {
+ mockMI.verify();
+ }
+
+ /**
+ * Test {@link org.argouml.model.CoreHelper#setAbstract(Object, boolean)}.
+ */
+ public void testSetAbstract() {
+ final Object o = new Object();
+
+ // Record for doing it.
+ mockMI.getFacade().isAbstract(o);
+ mockMI.getFacadeControl().setReturnValue(false);
+ mockMI.getCoreHelper().setAbstract(o, true);
+ mockMI.replay();
+
+ // Doing it.
+ Model.getCoreHelper().setAbstract(o, true);
+
+ mockMI.verify();
+
+ // Record for undoing it.
+ mockMI.reset();
+ mockMI.getCoreHelper().setAbstract(o, false);
+ mockMI.replay();
+
+ // Undoing it.
+ memo.undo();
+
+ // Record for redoing it.
+ mockMI.reset();
+ mockMI.getCoreHelper().setAbstract(o, true);
+ mockMI.replay();
+
+ // Redoing it.
+ memo.redo();
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestDataTypesFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestDataTypesFactory.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestDataTypesFactory.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,119 @@
+// $Id:TestDataTypesFactory.java 12485 2007-05-03 05:59:35Z linus $
+// Copyright (c) 2002-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.model;
+
+import java.util.LinkedList;
+
+import junit.framework.TestCase;
+
+/**
+ * Test the DataTypesFactory class.
+ *
+ */
+public class TestDataTypesFactory extends TestCase {
+
+ /**
+ * The constructor.
+ *
+ * @param n the name
+ */
+ public TestDataTypesFactory(String n) {
+ super(n);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() {
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test if this class is really a singleton.
+ */
+ public void testSingleton() {
+
+ Object o1 = Model.getDataTypesFactory();
+
+ Object o2 = Model.getDataTypesFactory();
+
+ assertTrue("Different singletons", o1 == o2);
+
+ }
+
+ /**
+ * Test creation.
+ */
+ public void testCreates() {
+
+ Object[] args = {
+ "language",
+ "body",
+ };
+
+ String[] objs = {
+ "ActionExpression",
+ "ArgListsExpression",
+ "BooleanExpression",
+ "Expression",
+ "IterationExpression",
+ "MappingExpression",
+ "ObjectSetExpression",
+ "ProcedureExpression",
+ "TimeExpression",
+ "TypeExpression",
+ null,
+ };
+
+ DataTypesFactory dtf = Model.getDataTypesFactory();
+
+ CheckUMLModelHelper.createAndRelease(
+ dtf,
+ objs,
+ args);
+
+ // Multiplicity
+
+ CheckUMLModelHelper.deleteAndRelease(dtf.createMultiplicity(1, 10));
+
+ CheckUMLModelHelper.deleteAndRelease(
+ dtf.createMultiplicity(new LinkedList()));
+
+ CheckUMLModelHelper.deleteAndRelease(dtf.createMultiplicity("1..10"));
+
+ // Do we need to add tests for the following?
+ //
+ // AggregationKind
+ // ChangeableKind
+ // MessageDirectionKind
+ // OrderingKind
+ // ParameterDirectionKind
+ // PseudostateKind
+ // ScopeKind
+ // VisibilityKind
+ //
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestExtensionMechanismsFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestExtensionMechanismsFactory.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestExtensionMechanismsFactory.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,152 @@
+// $Id:TestExtensionMechanismsFactory.java 12576 2007-05-09 14:19:16Z tfmorris $
+// Copyright (c) 2002-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.model;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+/**
+ * Test the ExtensionMechanismsFactory class.
+ *
+ */
+public class TestExtensionMechanismsFactory extends TestCase {
+ /**
+ * List of model elements to test.
+ */
+ private static String[] allModelElements = {
+ "Stereotype",
+ "TagDefinition",
+ "TaggedValue",
+ };
+
+ /**
+ * The constructor.
+ *
+ * @param n the name of the test
+ */
+ public TestExtensionMechanismsFactory(String n) {
+ super(n);
+ }
+
+ /**
+ * @return Returns the allModelElements.
+ */
+ static String[] getAllModelElements() {
+ return allModelElements;
+ }
+
+ /**
+ * @return the concrete ModelElements which are testable
+ */
+ static List<String> getTestableModelElements() {
+ List<String> c = new ArrayList<String>(Arrays.asList(allModelElements));
+ // TODO: Stereotype was untested before, but I'm not sure if it was
+ // intentional. Seems more like an oversight. - tfm
+// c.remove("Stereotype");
+ return c;
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() {
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test if the ExtensionMechanismsFactory is really a singleton.
+ */
+ public void testSingleton() {
+ Object o1 = Model.getExtensionMechanismsFactory();
+ Object o2 = Model.getExtensionMechanismsFactory();
+ assertTrue("Different singletons", o1 == o2);
+ }
+
+ /**
+ * Test creation.
+ */
+ public void testCreates() {
+ CheckUMLModelHelper.createAndRelease(
+ Model.getExtensionMechanismsFactory(),
+ getTestableModelElements());
+
+ ExtensionMechanismsFactory emFactory =
+ Model.getExtensionMechanismsFactory();
+ Object model = Model.getModelManagementFactory().createModel();
+ Object stereo = emFactory.buildStereotype("mystereo", model);
+ try {
+ emFactory.buildTagDefinition("myTD", stereo, model);
+ fail("Illegal buildTagDefinition with both sterotype"
+ + " and model didn't throw exception.");
+ } catch (IllegalArgumentException e) {
+ // Expected
+ }
+ }
+
+ /**
+ * Test cascading delete to make sure dependent
+ * elements disappear.
+ */
+ public void testDelete() {
+ ExtensionMechanismsFactory emFactory =
+ Model.getExtensionMechanismsFactory();
+ ExtensionMechanismsHelper emHelper =
+ Model.getExtensionMechanismsHelper();
+ Object model = Model.getModelManagementFactory().createModel();
+ Model.getModelManagementFactory().setRootModel(model);
+ Object stereo = emFactory.buildStereotype("mystereo", model);
+ emFactory.buildTagDefinition("myTD", stereo, null);
+ Object tv = emFactory.buildTaggedValue("myTD", "the tag value");
+ Object clazz = Model.getCoreFactory().buildClass("MyClass", model);
+ emHelper.addTaggedValue(clazz, tv);
+
+ Collection tvs = Model.getFacade().getTaggedValuesCollection(clazz);
+ assertEquals("Wrong number of TaggedValues returned", 1, tvs.size());
+ assertTrue("TaggedValue not found", tvs.contains(tv));
+ Collection tds =
+ Model.getModelManagementHelper()
+ .getAllModelElementsOfKind(model,
+ Model.getMetaTypes().getTagDefinition());
+ assertEquals("TagDefinition not found", 1, tds.size());
+
+ // Deleting the stereotype should cascade to the TagDefinition,
+ // then the TaggedValue
+ Model.getUmlFactory().delete(stereo);
+ Model.getPump().flushModelEvents();
+
+ tvs = Model.getFacade().getTaggedValuesCollection(clazz);
+ assertEquals("TaggedValue not deleted", 0, tvs.size());
+ tds =
+ Model.getModelManagementHelper()
+ .getAllModelElementsOfKind(model,
+ Model.getMetaTypes().getTagDefinition());
+ assertEquals("TagDefinition not deleted", 0, tds.size());
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestExtensionMechanismsHelper.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestExtensionMechanismsHelper.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestExtensionMechanismsHelper.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,171 @@
+// $Id:TestExtensionMechanismsHelper.java 12485 2007-05-03 05:59:35Z linus $
+// Copyright (c) 1996-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.model;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import junit.framework.TestCase;
+
+/**
+ * TODO: This is currently just a mechanical merge of the tests in
+ * from the generic Model test and the NSUML tests. They need to be
+ * reviewed & merged.
+ *
+ * @author euluis
+ * @since 0.19.2
+ * @version 0.00
+ */
+public class TestExtensionMechanismsHelper extends TestCase {
+
+ private Object model;
+
+ private Object pack;
+
+ private Object theClass;
+
+ private Object theStereotype;
+
+ private Collection models;
+
+ /**
+ * The constructor.
+ *
+ * @param n the name
+ */
+ public TestExtensionMechanismsHelper(String n) {
+ super(n);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ InitializeModel.initializeDefault();
+
+ model = Model.getModelManagementFactory().createModel();
+ pack =
+ Model.getModelManagementFactory().buildPackage("pack",
+ UUIDManager.getInstance().getNewUUID());
+ Model.getCoreHelper().setNamespace(pack, model);
+
+ theClass = Model.getCoreFactory().buildClass("TheClass", pack);
+ theStereotype =
+ Model.getExtensionMechanismsFactory().buildStereotype(
+ theClass, "containedStereotype", pack);
+ models = new ArrayList();
+ models.add(model);
+ }
+
+ /**
+ * This method tests the working of getAllPossibleStereotypes when the
+ * stereotype is contained within the same package as the model element.
+ */
+ public void
+ testGetAllPossibleStereotypesStereotypeAndMEContainedInSubPackage() {
+ Collection stereotypes =
+ Model.getExtensionMechanismsHelper()
+ .getAllPossibleStereotypes(models, theClass);
+ assertTrue("The \"" + theStereotype
+ + "\" isn't returned, but is possible.", stereotypes
+ .contains(theStereotype));
+ }
+
+ /**
+ * Test that a stereotype contained in a containing package of the package
+ * where the model element is, is applicable to the model element.
+ */
+ public void testGetAllPossibleStereotypesStereotypeInContainingPackage() {
+ Object subpack =
+ Model.getModelManagementFactory().buildPackage(
+ "subpack", UUIDManager.getInstance().getNewUUID());
+ Model.getCoreHelper().setNamespace(subpack, pack);
+ theClass =
+ Model.getCoreFactory().buildClass("TheClassInSubpack", subpack);
+ Collection stereotypes =
+ Model.getExtensionMechanismsHelper()
+ .getAllPossibleStereotypes(models, theClass);
+ assertTrue("The \"" + theStereotype
+ + "\" isn't returned, but is possible.", stereotypes
+ .contains(theStereotype));
+ }
+
+
+ /**
+ * Test if we can create modelelements with the names given.
+ */
+ public void testGetMetaModelName() {
+ CheckUMLModelHelper.metaModelNameCorrect(
+ Model.getExtensionMechanismsFactory(),
+ TestExtensionMechanismsFactory.getAllModelElements());
+ }
+
+ /**
+ * Test if we can create a valid stereotype for all the modelelements.
+ */
+ public void testIsValidStereoType() {
+ CheckUMLModelHelper.isValidStereoType(
+ Model.getExtensionMechanismsFactory(),
+ TestExtensionMechanismsFactory.getAllModelElements());
+ }
+
+ /**
+ * Test multiple base class support.
+ */
+ public void testMultipleBaseClasses() {
+ String classType = Model.getMetaTypes().getName(theClass);
+ Collection baseClasses =
+ Model.getFacade().getBaseClasses(theStereotype);
+ assertNotNull("There are no base classes", baseClasses);
+ assertEquals("Wrong number of base classes", 1, baseClasses.size());
+ assertEquals("Base class doesn't match type of model element",
+ classType,
+ baseClasses.iterator().next());
+ Model.getExtensionMechanismsHelper().removeBaseClass(theStereotype,
+ theClass);
+ assertEquals("Wrong number of base classes",
+ 0,
+ Model.getFacade().getBaseClasses(theStereotype).size());
+ // Test both forms of addBaseClass
+ Model.getExtensionMechanismsHelper().addBaseClass(theStereotype,
+ theClass);
+ Model.getExtensionMechanismsHelper().addBaseClass(theStereotype,
+ "myOtherClass");
+ assertEquals("Wrong number of base classes",
+ 2,
+ Model.getFacade().getBaseClasses(theStereotype).size());
+ assertTrue("Base class not found", Model.getFacade().getBaseClasses(
+ theStereotype).contains(classType));
+ assertTrue("Base class not found", Model.getFacade().getBaseClasses(
+ theStereotype).contains("myOtherClass"));
+ // Test remaining form of removeBaseClass
+ Model.getExtensionMechanismsHelper().removeBaseClass(theStereotype,
+ Model.getMetaTypes().getName(theClass));
+ assertEquals("Wrong number of base classes",
+ 1,
+ Model.getFacade().getBaseClasses(theStereotype).size());
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,185 @@
+// $Id:TestModel.java 12905 2007-06-24 12:54:39Z mvw $
+// Copyright (c) 2004-2006 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.model;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Test that the Model class returns only
+ * model implementation independent interfaces.
+ */
+public class TestModel extends TestCase {
+ /**
+ * The method to test.
+ */
+ private Method savedMethod;
+
+ /**
+ * @param arg0 The name of the test case.
+ */
+ public TestModel(String arg0) {
+ super(arg0);
+ }
+
+ /**
+ * Create a test for one of the methods in Model.
+ *
+ * @param modelMethod The method to test.
+ */
+ public TestModel(Method modelMethod) {
+ this(modelMethod.getName());
+ savedMethod = modelMethod;
+ }
+
+ /**
+ * @return the test suite
+ */
+ public static Test suite() {
+ TestSuite suite =
+ new TestSuite("Tests for "
+ + TestModel.class.getPackage().getName());
+
+ Method[] modelMethods = Model.class.getDeclaredMethods();
+
+ for (int i = 0; i < modelMethods.length; i++) {
+ Method modelMethod = modelMethods[i];
+
+ if (!Modifier.isPublic(modelMethod.getModifiers())) {
+ // This is a private method in Model.
+ continue;
+ }
+
+ suite.addTest(new TestModel(modelMethod));
+ }
+
+ return suite;
+ }
+
+ /**
+ * Test each of the interfaces returned so that they don't contain any
+ * model implementation artifacts in any of their signatures.
+ */
+ public void testInterfaces() {
+ }
+
+
+ /**
+ * Run the test for one method.
+ *
+ * @see junit.framework.TestCase#runTest()
+ */
+ public void runTest() {
+ assertTrue("The method " + savedMethod + "is not static",
+ Modifier.isStatic(savedMethod.getModifiers()));
+
+ Class factoryIF = savedMethod.getReturnType();
+
+ // Handling methods that doesn't return
+ if (factoryIF.isPrimitive() && factoryIF.getName().equals("void")) {
+ return;
+ }
+
+ // Handling the isInitiated method
+ if (factoryIF.isPrimitive() && factoryIF.getName().equals("boolean")) {
+ return;
+ }
+
+ // Handling the initialise method
+ if (factoryIF.getName().equals("java.lang.Throwable")) {
+ return;
+ }
+
+ assertTrue("The return type from " + savedMethod
+ + " must be an interface.",
+ factoryIF.isInterface());
+
+ checkInterface(factoryIF);
+ }
+
+ /**
+ * Check that an interface obeys the rules.<p>
+ *
+ * This checks all extended interfaces recursively.<p>
+ *
+ * @param theInterface The interface to check.
+ */
+ private void checkInterface(Class theInterface) {
+ Method[] methods = theInterface.getDeclaredMethods();
+
+ for (int i = 0; i < methods.length; i++) {
+ Method method = methods[i];
+
+ assertTrue("The method " + method + " has invalid return type "
+ + method.getReturnType(),
+ isValid(method.getReturnType()));
+
+ Class[] parameters = method.getParameterTypes();
+
+ for (int k = 0; k < parameters.length; k++) {
+ assertTrue("The method " + method
+ + " has invalid parameter type "
+ + parameters[k],
+ isValid(parameters[k]));
+ }
+ }
+
+ Class[] inherited = theInterface.getInterfaces();
+ for (int i = 0; i < inherited.length; i++) {
+ checkInterface(inherited[i]);
+ }
+ }
+
+ /**
+ * Prefix identified as an implementation specific class.
+ * TODO: This should be generalized so it doesn't have to be changed
+ * each time a new implementation is created - tfm 20051109
+ */
+ private static final String UML_PATH_PREFIX;
+
+ static {
+ UML_PATH_PREFIX = "org.omg.uml.";
+ }
+
+ /**
+ * Tells if a type is valid or not.
+ *
+ * @param cls The class to test.
+ * @return <code>true</code> if it is.
+ */
+ private boolean isValid(Class cls) {
+ int length = UML_PATH_PREFIX.length();
+ if (cls.getName().length() > length
+ && cls.getName().substring(0, length).equals(UML_PATH_PREFIX)) {
+ return false;
+ }
+
+ return true;
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestModel2.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestModel2.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestModel2.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,75 @@
+// $Id:TestModel2.java 12485 2007-05-03 05:59:35Z linus $
+// Copyright (c) 2005-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.model;
+
+import junit.framework.TestCase;
+
+/**
+ * Split out the manual tests.
+ */
+public class TestModel2 extends TestCase {
+ /**
+ * @param arg0 The name of the test case.
+ */
+ public TestModel2(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() {
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test if the CollaborationsFactory is really a singleton.
+ */
+ public void testCollaborationsFactoryInstance() {
+ Object o1 = Model.getCollaborationsFactory();
+ Object o2 = Model.getCollaborationsFactory();
+
+ assertTrue("Different singletons", o1 == o2);
+ }
+
+ /**
+ * Test if the factory is really a singleton.
+ */
+ public void testCommonBehaviorFactoryInstance() {
+ Object o1 = Model.getCommonBehaviorFactory();
+ Object o2 = Model.getCommonBehaviorFactory();
+ assertTrue("Different singletons", o1 == o2);
+ }
+
+ /**
+ * Test if the CoreFactory is really a singleton.
+ */
+ public void testCoreFactoryInstance() {
+ Object o1 = Model.getCoreFactory();
+ Object o2 = Model.getCoreFactory();
+ assertTrue("Different singletons", o1 == o2);
+ }
+}
+
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestModelEventPump.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestModelEventPump.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestModelEventPump.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,282 @@
+// $Id:TestModelEventPump.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 2004-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.model;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import junit.framework.TestCase;
+
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
+
+/**
+ * This test case is initially very much a copy of the applicable parts
+ * of the TestUmlModelEventPump test case.
+ *
+ * TODO: We have not documented exactly what events arrive and when.
+ *
+ * @author Linus Tolke
+ */
+public class TestModelEventPump extends TestCase {
+ private Object elem;
+ private boolean eventcalled;
+ private TestListener listener;
+
+ /**
+ * A mock listener used for the tests.
+ */
+ private class TestListener implements PropertyChangeListener {
+ /*
+ * @see PropertyChangeListener#propertyChange(PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent e) {
+ // TODO: This log entry tells us what events actually arrive
+ // to the listener. I (Linus) suggest we let it in there until
+ // all event types and contents are fully documented.
+ System.out.println("Received event " + e.getSource()
+ + "[" + e.getSource().getClass() + "], "
+ + e.getPropertyName() + ", "
+ + e.getOldValue() + ", "
+ + e.getNewValue());
+ eventcalled = true;
+ }
+ }
+
+ /**
+ * Constructor for TestUmlModelEventPump.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestModelEventPump(String arg0) {
+ super(arg0);
+ InitializeModel.initializeDefault();
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ elem = Model.getCoreFactory().createClass();
+ Project project = ProjectManager.getManager().getCurrentProject();
+ Object model = project.getRoot();
+ Model.getCoreHelper().addOwnedElement(model, elem);
+ eventcalled = false;
+ listener = new TestListener();
+ Model.getPump().flushModelEvents();
+ }
+
+ /*
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ if (elem != null) {
+ Model.getUmlFactory().delete(elem);
+ }
+ listener = null;
+ }
+
+ /**
+ * Tests if a listener that registred for a PropertySet event on
+ * the class level really receive the event.
+ */
+ public void testPropertySetClass() {
+ Model.getPump().addClassModelEventListener(listener,
+ elem.getClass(),
+ new String[] {
+ "isRoot",
+ });
+ Model.getCoreHelper().setRoot(elem, true);
+ Model.getPump().flushModelEvents();
+ assertTrue(eventcalled);
+ }
+
+ /**
+ * Tests if a listener that registred for a Removed event on the
+ * class level really receive the event.
+ */
+ public void testRemovedClass() {
+ Model.getPump().addClassModelEventListener(listener,
+ elem.getClass(),
+ new String[] {
+ "remove",
+ });
+ Model.getUmlFactory().delete(elem);
+ Model.getPump().flushModelEvents();
+ assertTrue(eventcalled);
+ }
+
+ /**
+ * Tests if a listener that registred for a RoleAdded event on the
+ * class level really receive the event.
+ */
+ public void testRoleAddedSetClass() {
+ Model.getPump().addClassModelEventListener(listener,
+ elem.getClass(),
+ new String[] {
+ "parameter",
+ });
+ Model.getCoreHelper().addParameter(
+ elem,
+ Model.getCoreFactory().createParameter());
+ Model.getPump().flushModelEvents();
+ assertTrue(eventcalled);
+ }
+
+ /**
+ * Tests if a listener that registred for a RoleRemoved event on
+ * the class level really receive the event.
+ */
+ public void testRoleRemovedSetClass() {
+ Object param = Model.getCoreFactory().createParameter();
+ Model.getCoreHelper().addParameter(elem, param);
+ Model.getPump().addClassModelEventListener(listener,
+ elem.getClass(),
+ new String[] {
+ "parameter",
+ });
+ Model.getCoreHelper().removeParameter(elem, param);
+ Model.getPump().flushModelEvents();
+ assertTrue(eventcalled);
+ }
+
+ /**
+ * Tests if a non registred listener does not receive any events.
+ */
+ public void testFireNonRegistredListener() {
+ Model.getCoreFactory().createClass();
+ Model.getCoreHelper().addParameter(
+ elem,
+ Model.getCoreFactory().createParameter());
+ Model.getPump().flushModelEvents();
+ assertTrue(!eventcalled);
+ }
+
+ /**
+ * Tests if a listener that registred for a PropertySet event really
+ * receive the event.
+ */
+ public void testPropertySet() {
+ Model.getPump().addModelEventListener(listener,
+ elem,
+ new String[] {
+ "isRoot",
+ });
+ Model.getCoreHelper().setRoot(elem, true);
+ Model.getPump().flushModelEvents();
+ assertTrue(eventcalled);
+ }
+
+ /**
+ * Tests if a listener that registred for a Removed event really
+ * receive the event.
+ */
+ public void testRemoved() {
+ Model.getPump().addModelEventListener(listener,
+ elem,
+ new String[] {
+ "remove",
+ });
+ Model.getUmlFactory().delete(elem);
+ Model.getPump().flushModelEvents();
+ assertTrue(eventcalled);
+ }
+
+ /**
+ * Tests if a listener that registred for a RoleAddedSet event really
+ * receive the event.
+ */
+ public void testRoleAddedSet() {
+ Model.getPump().addModelEventListener(listener,
+ elem,
+ new String[] {
+ "parameter",
+ });
+ Model.getCoreHelper().addParameter(
+ elem,
+ Model.getCoreFactory().createParameter());
+ Model.getPump().flushModelEvents();
+ assertTrue(eventcalled);
+ }
+
+ /**
+ * Tests if a listener that registred for a RoleRemovedSet event really
+ * receive the event.
+ */
+ public void testRoleRemovedSet() {
+ Object param = Model.getCoreFactory().createParameter();
+ Model.getCoreHelper().addParameter(elem, param);
+ Model.getPump().addModelEventListener(listener,
+ elem,
+ new String[] {
+ "parameter",
+ });
+ Model.getCoreHelper().removeParameter(elem, param);
+ Model.getPump().flushModelEvents();
+ assertTrue(eventcalled);
+ }
+
+ /**
+ * Tests if a listener to a class that is legally added and then
+ * removed, really is removed.
+ */
+ public void testRemoveLegalClassListener() {
+ Model.getPump().addClassModelEventListener(listener,
+ elem.getClass(),
+ new String[] {
+ "isRoot",
+ });
+ Model.getPump().removeClassModelEventListener(listener,
+ elem.getClass(),
+ new String[] {
+ "isRoot",
+ });
+ Model.getCoreHelper().addParameter(
+ elem,
+ Model.getCoreFactory().createParameter());
+ Model.getPump().flushModelEvents();
+ assertTrue(!eventcalled);
+ }
+
+ /**
+ * Tests if a listener that is legally added and then removed,
+ * really is removed.
+ */
+ public void testRemoveLegalListener() {
+ String[] map = new String[] {
+ "isRoot",
+ };
+ Model.getPump().addModelEventListener(listener, elem, map);
+ Model.getPump().removeModelEventListener(listener, elem, map);
+ Model.getCoreHelper().addParameter(
+ elem,
+ Model.getCoreFactory().createParameter());
+ Model.getPump().flushModelEvents();
+ assertTrue(!eventcalled);
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestModelFacade2.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestModelFacade2.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestModelFacade2.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,175 @@
+// $Id:TestModelFacade2.java 12794 2007-06-08 19:29:23Z tfmorris $
+// Copyright (c) 2003-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.model;
+
+import java.util.Collection;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests some specific methods in Facade.<p>
+ *
+ * This is a complement to the tests in
+ * {@link TestModelFacade3} that makes a lot more general tests.<p>
+ *
+ * As opposed to the tests in
+ * {@link TestModelFacade3} that are run on a whole set of objects,
+ * these tests are maintained manually.
+ *
+ * @author Linus Tolke
+ */
+public class TestModelFacade2 extends TestCase {
+
+ /**
+ * Constructor for TestModelFacade2.
+ *
+ * @param arg0 name of test case
+ */
+ public TestModelFacade2(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() {
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test that the correct error is thrown for isAsynchronous.
+ */
+ public void testErrorThrownInIsAsynchronous() {
+ try {
+ Model.getFacade().isAsynchronous(new Object());
+ assertTrue("Error was not thrown", false);
+ } catch (Throwable e) {
+ if (e instanceof IllegalArgumentException
+ || e instanceof ClassCastException) {
+ // one of the expected errors, just ignore
+ } else {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ /**
+ * Test that the correct error is thrown for a setName with illegal name.
+ */
+ public void testSetName() {
+ Object ob = Model.getCoreFactory().buildClass("initial");
+ final String correctValue = "correct";
+ Model.getCoreHelper().setName(ob, correctValue);
+ assertEquals(correctValue, Model.getFacade().getName(ob));
+ }
+
+
+ /**
+ * Test for setModelElementContainer.
+ */
+ public void testSetModelElementContainer() {
+ Object container =
+ Model.getActivityGraphsFactory().createActivityGraph();
+ Object partition = Model.getActivityGraphsFactory().createPartition();
+
+ Model.getCoreHelper().setModelElementContainer(partition, container);
+
+ Collection collection = Model.getFacade().getPartitions(container);
+ assertTrue(collection.contains(partition));
+ assertTrue(container.equals(Model.getFacade().getModelElementContainer(
+ partition)));
+ }
+
+ /**
+ * Test getModelElementContainer.
+ */
+ public void testGetModelElementContainer() {
+ StateMachinesFactory factory = Model.getStateMachinesFactory();
+ StateMachinesHelper helper = Model.getStateMachinesHelper();
+
+ Object stateMachine = factory.createStateMachine();
+ Object state = factory.createSimpleState();
+ Object action = Model.getCommonBehaviorFactory().createCallAction();
+ helper.setStateMachine(state, stateMachine);
+ helper.setEntry(state, action);
+
+ Object parentComposite =
+ Model.getFacade().getModelElementContainer(action);
+ assertTrue(state.equals(parentComposite));
+ assertTrue(stateMachine.equals(Model.getFacade()
+ .getModelElementContainer(parentComposite)));
+ }
+
+
+ /**
+ * Test some Tagged Value functions.
+ */
+ private static final String TAG_TYPE = "fooTagType";
+ private static final String TAG_VALUE = "fooTagValue";
+
+ public void testTaggedValue() {
+ Model.getModelManagementFactory().setRootModel(
+ Model.getModelManagementFactory().createModel());
+ Object cls = Model.getCoreFactory().buildClass();
+
+ assertNull(Model.getFacade().getTaggedValue(cls, TAG_TYPE));
+ Model.getExtensionMechanismsHelper().addTaggedValue(
+ cls,
+ Model.getExtensionMechanismsFactory().buildTaggedValue(
+ TAG_TYPE, TAG_VALUE));
+ Object taggedValue = Model.getFacade().getTaggedValue(cls, TAG_TYPE);
+ assertEquals(Model.getFacade().getValueOfTag(taggedValue), TAG_VALUE);
+ Model.getExtensionMechanismsHelper()
+ .removeTaggedValue(cls, taggedValue);
+ Object unusedTaggedValue = Model.getExtensionMechanismsFactory()
+ .buildTaggedValue("xxx", "yyy");
+ Model.getExtensionMechanismsHelper().removeTaggedValue(cls,
+ unusedTaggedValue);
+ assertNull(Model.getFacade().getTaggedValue(cls, TAG_TYPE));
+ }
+
+ /**
+ * Test the stereotypes.
+ */
+ public void testGetStereotypes() {
+ Object cls = Model.getCoreFactory().buildClass();
+ Model.getCoreHelper().setNamespace(cls,
+ Model.getModelManagementFactory().createPackage());
+ Collection coll1 = Model.getFacade().getStereotypes(cls);
+ assertEquals(0, coll1.size());
+
+ Object stereotype =
+ Model.getExtensionMechanismsFactory().buildStereotype(
+ "TestStereotype",
+ Model.getFacade().getNamespace(cls));
+
+ Model.getCoreHelper().addStereotype(cls, stereotype);
+
+ Collection coll2 = Model.getFacade().getStereotypes(cls);
+
+ assertEquals(1, coll2.size());
+ assertTrue(coll2.contains(stereotype));
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestModelFacade3.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestModelFacade3.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestModelFacade3.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,183 @@
+// $Id:TestModelFacade3.java 12794 2007-06-08 19:29:23Z tfmorris $
+// Copyright (c) 2003-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.model;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * This TestCase dynamically generates a suite of tests to throw arguments at
+ * each method in the Model subsystem Facade to check whether they throw an
+ * IllegalArgumentException.
+ */
+public class TestModelFacade3 extends TestCase {
+
+ private Method methodToTest = null;
+
+ private Facade facade = null;
+
+ /**
+ * Creates one of the test cases.
+ *
+ * @param method
+ * to be tested.
+ */
+ public TestModelFacade3(Method method) {
+ super(method.toString());
+ methodToTest = method;
+ }
+
+ /**
+ * @return the test suite
+ */
+ public static Test suite() {
+ TestSuite suite = new TestSuite("Tests for "
+ + TestModelFacade3.class.getPackage().getName());
+
+ Method methods[] = Facade.class.getDeclaredMethods();
+
+ for (int i = 0; i < methods.length; i++) {
+ suite.addTest(new TestModelFacade3(methods[i]));
+ }
+
+ return suite;
+ }
+
+ /**
+ * This method checks whether a test should be executed for a given
+ * method.
+ *
+ * @return true if method is not eligible for testing (e.g. helper
+ * methods)
+ */
+ protected boolean methodForbidden() {
+ return methodToTest.getName().equals("getClassNull")
+ || methodToTest.getName().startsWith("isA")
+ || methodToTest.getName().equals("create")
+ || methodToTest.getName().equals("getTipString")
+ || methodToTest.getName().equals("toString");
+ }
+
+ /*
+ * @see junit.framework.TestCase#runTest()
+ */
+ protected void runTest() throws Throwable {
+ if (!methodForbidden()) {
+ if (methodToTest.getParameterTypes() != null
+ && methodToTest.getParameterTypes().length >= 1
+ && Modifier.isPublic(methodToTest
+ .getModifiers())) {
+ testOneOrMoreParameters();
+ }
+ }
+ }
+
+ /**
+ * testOneOrMoreParameters checks whether a public method in the Model
+ * subsystem Facade throws an IllegalArgumentException when invoked with
+ * stupid arguments. Stupid arguments are arguments which are not from
+ * the UML domain, such as a plain Object.
+ */
+ public void testOneOrMoreParameters() {
+ int nrParameters = methodToTest.getParameterTypes().length;
+ Class[] params = methodToTest.getParameterTypes();
+ Object[] foo = new Object[nrParameters];
+
+ // set up all parameters. Some methods are invoked with
+ // primitives or collections, so we need to create them
+ // accordingly
+ for (int i = 0; i < nrParameters; i++) {
+ try {
+ if (params[i].isPrimitive()) {
+ String primitiveName = params[i]
+ .getName();
+ if (primitiveName.equals("int")) {
+ foo[i] = new Integer(0);
+ }
+ if (primitiveName.equals("boolean")) {
+ foo[i] = new Boolean(true);
+ }
+ if (primitiveName.equals("short")) {
+ foo[i] = new Short("0");
+ }
+ } else if (params[i].getName().equals("java.util.Collection")) {
+ foo[i] = new ArrayList();
+ } else {
+ /*
+ * this call could easily fall if there is e.g. no public
+ * default constructor. If it fails tweak the if/else tree
+ * above to accomodate the parameter or check if we need to
+ * test the particular method at all.
+ */
+ foo[i] = params[i].newInstance();
+ }
+ } catch (InstantiationException e) {
+ fail("Cannot create an instance of : "
+ + params[i].getName()
+ + ", required for "
+ + methodToTest.getName()
+ + ". Check if "
+ + "test needs reworking.");
+ } catch (IllegalAccessException il) {
+ fail("Illegal Access to : "
+ + params[i].getName());
+ }
+ }
+
+ try {
+ methodToTest.invoke(facade, foo);
+ fail(methodToTest.getName()
+ + " does not deliver an IllegalArgumentException");
+ } catch (InvocationTargetException e) {
+ if (e.getTargetException() instanceof IllegalArgumentException
+ || e.getTargetException() instanceof ClassCastException) {
+ return;
+ }
+ fail("Test failed for " + methodToTest.toString()
+ + " because of: "
+ + e.getTargetException());
+ } catch (Exception e) {
+ fail("Test failed for " + methodToTest.toString()
+ + " because of: " + e.toString());
+ }
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+
+ facade = Model.getFacade();
+ assertNotNull("Cound not get Facade", facade);
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestModelManagementFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestModelManagementFactory.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestModelManagementFactory.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,93 @@
+// $Id:TestModelManagementFactory.java 12576 2007-05-09 14:19:16Z tfmorris $
+// Copyright (c) 2002-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.model;
+
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+/**
+ * Test the ModelManagementFactory class.
+ *
+ */
+public class TestModelManagementFactory extends TestCase {
+ /**
+ * The model elements to test.
+ */
+ private static String[] allModelElements = {
+ "ElementImport", "Model", "Package", "Subsystem",
+ };
+
+ /**
+ * The constructor.
+ *
+ * @param n
+ * the name
+ */
+ public TestModelManagementFactory(String n) {
+ super(n);
+ }
+
+ /**
+ * @return Returns the allModelElements.
+ */
+ protected static String[] getAllModelElements() {
+ return allModelElements;
+ }
+
+ /**
+ * @return all testable model elements
+ */
+ static List<String> getTestableModelElements() {
+ return Arrays.asList(allModelElements);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() {
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test if this class is really a singleton.
+ */
+ public void testSingleton() {
+ Object o1 = Model.getModelManagementFactory();
+ Object o2 = Model.getModelManagementFactory();
+ assertTrue("Different singletons", o1 == o2);
+ }
+
+ /**
+ * Test creation.
+ */
+ public void testCreates() {
+ CheckUMLModelHelper.createAndRelease(
+ Model.getModelManagementFactory(),
+ getTestableModelElements());
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestModelManagementHelper.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestModelManagementHelper.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestModelManagementHelper.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,161 @@
+// $Id:TestModelManagementHelper.java 12485 2007-05-03 05:59:35Z linus $
+// Copyright (c) 1996-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.model;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import junit.framework.TestCase;
+
+/**
+ * @since Oct 10, 2002
+ * @author [email protected]
+ */
+public class TestModelManagementHelper extends TestCase {
+
+ private Object theModel;
+ private Object theGoodPackage;
+ private Object theBadPackage;
+ private Object theStereotype;
+ private Object theTagDefinition;
+ private Object theClass;
+ private Collection tdPath = new ArrayList();
+
+ /**
+ * Constructor for TestModelManagementHelper.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestModelManagementHelper(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() {
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test getting the metamodel name.
+ */
+ public void testGetMetaModelName() {
+ CheckUMLModelHelper.metaModelNameCorrect(
+ Model.getModelManagementFactory(),
+ TestModelManagementFactory.getAllModelElements());
+ }
+
+ /**
+ * Test stereotypes.
+ */
+ public void testIsValidStereoType() {
+ CheckUMLModelHelper.isValidStereoType(
+ Model.getModelManagementFactory(),
+ TestModelManagementFactory.getAllModelElements());
+ }
+
+ private void setUpTestsOfTagDefinitionContainedInStereotype() {
+ theModel = Model.getModelManagementFactory().createModel();
+ Model.getCoreHelper().setName(theModel, "TheModel");
+ Model.getModelManagementFactory().setRootModel(theModel);
+
+ theGoodPackage = Model.getModelManagementFactory().createPackage();
+ Model.getCoreHelper().setName(theGoodPackage, "TheGoodPackage");
+ Model.getCoreHelper().setNamespace(theGoodPackage, theModel);
+
+ theBadPackage = Model.getModelManagementFactory().createPackage();
+ Model.getCoreHelper().setName(theBadPackage, "TheBadPackage");
+ Model.getCoreHelper().setNamespace(theBadPackage, theModel);
+
+ theClass = Model.getCoreFactory().buildClass("TheClass",
+ theGoodPackage);
+ theStereotype = Model.getExtensionMechanismsFactory().buildStereotype(
+ theClass, "containedStereotype", theGoodPackage);
+ theTagDefinition = Model.getExtensionMechanismsFactory()
+ .buildTagDefinition("TagDefinition", theStereotype, null);
+
+ // Note: the containing model is not included in the returned path
+ tdPath.add("TheGoodPackage");
+ tdPath.add("containedStereotype");
+ tdPath.add("TagDefinition");
+ }
+
+ /**
+ * Test getAllModelElementsOfKind() for tag definitions contained in
+ * stereotypes. Issue #3829.
+ */
+ public void testGetAllModelElementsOfKindForTagDefinitionInStereotype() {
+ setUpTestsOfTagDefinitionContainedInStereotype();
+ Model.getCoreHelper().addStereotype(theClass, theStereotype);
+ assertTrue(Model.getFacade().getStereotypes(theClass).
+ contains(theStereotype));
+ Collection col = Model.getModelManagementHelper().
+ getAllModelElementsOfKind(
+ theGoodPackage, Model.getMetaTypes().getTagDefinition());
+ assertTrue("Tag definition should be contained in the model!",
+ col.contains(theTagDefinition));
+ }
+
+ /**
+ * Test getAllModelElementsOfKind() to make sure that it doesn't
+ * return elements which are not in the requested namespace.
+ */
+ public void testGetAllModelElementsOfKindNamespaceContraint() {
+ setUpTestsOfTagDefinitionContainedInStereotype();
+ Model.getCoreHelper().addStereotype(theClass, theStereotype);
+ Collection elements = Model.getModelManagementHelper()
+ .getAllModelElementsOfKind(theBadPackage,
+ Model.getMetaTypes().getTagDefinition());
+ assertTrue("Elements not in namespace returned", elements.isEmpty());
+ elements = Model.getModelManagementHelper().getAllModelElementsOfKind(
+ theBadPackage, Model.getMetaTypes().getUMLClass());
+ assertTrue("Elements not in namespace returned", elements.isEmpty());
+ }
+
+ /**
+ * Test to make sure that we can get UmlClass since its name is different
+ */
+ public void testGetUmlClassModelElements() {
+ setUpTestsOfTagDefinitionContainedInStereotype();
+ Collection col = Model.getModelManagementHelper()
+ .getAllModelElementsOfKind(theGoodPackage,
+ Model.getMetaTypes().getUMLClass());
+ assertTrue("Failed to get UmlClass ModelElement", col
+ .contains(theClass));
+ }
+
+ /**
+ * Test the getPath method with a tag definition contained in a stereotype.
+ */
+ public void testGetPathForTagDefinitionInStereotype() {
+ setUpTestsOfTagDefinitionContainedInStereotype();
+
+ Collection path = Model.getModelManagementHelper().getPath(
+ theTagDefinition);
+ assertTrue("Wrong path returned for TagDefinition",
+ tdPath.equals(path));
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestStateMachinesFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestStateMachinesFactory.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestStateMachinesFactory.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,114 @@
+// $Id:TestStateMachinesFactory.java 12576 2007-05-09 14:19:16Z tfmorris $
+// Copyright (c) 2002-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.model;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+/**
+ * Test the StateMachinesFactory class.
+ *
+ */
+public class TestStateMachinesFactory extends TestCase {
+ /**
+ * Model elements to test.
+ */
+ private static String[] allModelElements =
+ {
+ "CallEvent",
+ "ChangeEvent",
+ "CompositeState",
+ "Event", // abstract
+ "FinalState",
+ "Guard",
+ "Pseudostate",
+ "SignalEvent",
+ "SimpleState",
+ "State", // abstract
+ "StateMachine",
+ "StateVertex", // abstract
+ "StubState",
+ "SubmachineState",
+ "SynchState",
+ "TimeEvent",
+ "Transition",
+ };
+
+ /**
+ * The constructor.
+ *
+ * @param n the name of the test
+ */
+ public TestStateMachinesFactory(String n) {
+ super(n);
+ }
+
+ /**
+ * @return the concrete ModelElements which are testable
+ */
+ static List<String> getTestableModelElements() {
+ List<String> c = new ArrayList<String>(Arrays.asList(allModelElements));
+ c.remove("Event");
+ c.remove("State");
+ c.remove("StateVertex");
+ return c;
+ }
+
+ /**
+ * @return Returns the allModelElements.
+ */
+ static String[] getAllModelElements() {
+ return allModelElements;
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() {
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test if this class is really a singleton.
+ */
+ public void testSingleton() {
+ Object o1 = Model.getStateMachinesFactory();
+ Object o2 = Model.getStateMachinesFactory();
+ assertTrue("Different singletons", o1 == o2);
+ }
+
+ /**
+ * Test creation.
+ */
+ public void testCreates() {
+ CheckUMLModelHelper.createAndRelease(
+ Model.getStateMachinesFactory(), getTestableModelElements());
+ }
+
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestStateMachinesHelper.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestStateMachinesHelper.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestStateMachinesHelper.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,68 @@
+// $Id:TestStateMachinesHelper.java 12576 2007-05-09 14:19:16Z tfmorris $
+// Copyright (c) 1996-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.model;
+
+import junit.framework.TestCase;
+
+/**
+ * @since Oct 10, 2002
+ * @author [email protected]
+ */
+public class TestStateMachinesHelper extends TestCase {
+
+ /**
+ * Constructor for TestStateMachinesHelper.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestStateMachinesHelper(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() {
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Check if the metamodel name is correct.
+ */
+ public void testGetMetaModelName() {
+ CheckUMLModelHelper.metaModelNameCorrect(
+ Model.getStateMachinesFactory(),
+ TestStateMachinesFactory.getTestableModelElements());
+ }
+
+ /**
+ * Test creating a stereotype.
+ */
+ public void testIsValidStereoType() {
+ CheckUMLModelHelper.isValidStereoType(
+ Model.getStateMachinesFactory(),
+ TestStateMachinesFactory.getTestableModelElements());
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestUml.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestUml.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestUml.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,67 @@
+// $Id:TestUml.java 10734 2006-06-11 15:43:58Z mvw $
+// Copyright (c) 2003-2006 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.model;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Thierry
+ */
+public class TestUml extends TestCase
+{
+
+ /**
+ * Constructor for Uml.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestUml(String arg0)
+ {
+ super(arg0);
+ }
+
+
+ /**
+ * TODO: Rewrite this test using reflection against Uml class.
+ *
+ * This code has been commented out since September 2003
+ */
+ public void testUmlClassList() {
+// for (Iterator i = Uml.getUmlClassList().iterator(); i.hasNext();) {
+// UmlModelEntity type = (UmlModelEntity) i.next();
+// String typeName = type.getClass().getName().toUpperCase();
+// String expected = type.getName().toUpperCase();
+// // System.out.println(type.getClass().getName().toUpperCase());
+// // System.out.println("ORG.ARGOUML.MODEL.UML.UML$TYPE"
+// // + key.toString().toUpperCase());
+// assertEquals(
+// "Not the correct class",
+// type.getClass().getName().toUpperCase(),
+// "ORG.ARGOUML.MODEL.UML.UML$TYPE"
+// + type.getName().toUpperCase());
+// }
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlActor.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlActor.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlActor.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,67 @@
+// $Id:TestUmlActor.java 12778 2007-06-08 07:46:32Z tfmorris $
+// Copyright (c) 2003-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.model;
+
+/**
+ * @author Thierry Lach
+ */
+public class TestUmlActor extends GenericUmlObjectTestFixture {
+ /**
+ * Constructor.
+ *
+ * @param arg0 test name
+ */
+ public TestUmlActor(String arg0) {
+ super(arg0);
+ setEntity(Model.getMetaTypes().getActor());
+ validateTestClassIsGeneric(this);
+ }
+
+ /**
+ * Test the creation of an actor.
+ */
+ public void testActor() {
+ Object o =
+ Model.getUmlFactory().buildNode(Model.getMetaTypes().getActor());
+ assertNotNull("Didn't create object", o);
+ assertTrue("Should be a model element", Model.getFacade()
+ .isAUMLElement(o));
+ assertTrue("Should be a actor", Model.getFacade().isAActor(o));
+ runTruthTests(o);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ setTruth(Model.getMetaTypes().getModelElement(), true);
+ setTruth(Model.getMetaTypes().getGeneralizableElement(), true);
+ setTruth(Model.getMetaTypes().getClassifier(), true);
+ setTruth(Model.getMetaTypes().getNamespace(), true);
+ setTruth(Model.getMetaTypes().getActor(), true);
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlExtend.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlExtend.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlExtend.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,118 @@
+// $Id:TestUmlExtend.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 2003-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.model;
+
+import java.util.Collection;
+
+
+
+/**
+ * Test to check various aspects of extend relationships
+ *
+ * @author Markus Klink
+ */
+public class TestUmlExtend extends GenericUmlObjectTestFixture {
+
+ private Object uc1, uc2;
+ private Object ep1, ep2;
+ private Object extend;
+ private UseCasesHelper helper = Model.getUseCasesHelper();
+
+ /**
+ * Constructor.
+ *
+ * @param arg0 test name
+ */
+ public TestUmlExtend(String arg0) {
+ super(arg0);
+ setEntity(Model.getMetaTypes().getExtend());
+ validateTestClassIsGeneric(this);
+ }
+
+ /**
+ * Check that Usecases have Extends
+ */
+ public void testUsecasesHaveExtend() {
+ Object myextend = helper.getExtends(uc1, uc2);
+ assertNotNull(myextend);
+ assertSame(extend, myextend);
+ }
+
+ /**
+ * Check that the Extends are correct
+ */
+ public void testExtendIsCorrect() {
+ Object base =
+ Model.getFacade().getBase(extend);
+ Object included =
+ Model.getFacade().getExtension(extend);
+ assertSame(uc1, base);
+ assertSame(uc2, included);
+ }
+
+ /**
+ * Test that ExtensionPoints got created correctly during setup
+ */
+ public void testUsecaseHasExtensionPoints() {
+ Collection eps = Model.getFacade().getExtensionPoints(uc1);
+ assertTrue(eps.size() == 3);
+ assertTrue(eps.contains(ep1));
+ assertTrue(eps.contains(ep2));
+ Collection eps2 = Model.getFacade().getExtensionPoints(uc2);
+ assertNotNull(eps2);
+ assertTrue(eps2.size() == 0);
+ }
+
+ /**
+ * Test setting ExtensionPoints
+ */
+ public void testSetExtensionPoints() {
+ Collection eps = Model.getFacade().getExtensionPoints(uc1);
+ helper.setExtensionPoints(extend, eps);
+ Collection eps2 = Model.getFacade().getExtensionPoints(extend);
+ assertTrue(eps2.containsAll(eps));
+ assertTrue(eps.size() == eps2.size());
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ uc1 =
+ Model.getUmlFactory().buildNode(Model.getMetaTypes().getUseCase());
+ uc2 =
+ Model.getUmlFactory().buildNode(Model.getMetaTypes().getUseCase());
+ // by default the build already builds one default EP
+ extend =
+ Model.getUseCasesFactory().buildExtend(uc1, uc2);
+ ep1 =
+ Model.getUseCasesFactory().buildExtensionPoint(uc1);
+ ep2 =
+ Model.getUseCasesFactory().buildExtensionPoint(uc1);
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlFactoryBuildNode.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlFactoryBuildNode.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlFactoryBuildNode.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,133 @@
+// $Id:TestUmlFactoryBuildNode.java 12485 2007-05-03 05:59:35Z linus $
+// Copyright (c) 2005-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.model;
+
+import junit.framework.TestCase;
+
+/**
+ * Checks that the {@link UmlFactory#buildNode(Object)} method works with
+ * all conceivable alternatives.
+ */
+public class TestUmlFactoryBuildNode extends TestCase {
+ /**
+ * Constructor.
+ *
+ * @param arg0 name of the test case
+ */
+ public TestUmlFactoryBuildNode(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() {
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Testing Core elements.
+ */
+ public void testBuildCoreNodes() {
+ assertNotNull(Model.getUmlFactory().buildNode(
+ Model.getMetaTypes().getUMLClass()));
+ assertNotNull(Model.getUmlFactory().buildNode(
+ Model.getMetaTypes().getModel()));
+ assertNotNull(Model.getUmlFactory().buildNode(
+ Model.getMetaTypes().getPackage()));
+ // ...
+ }
+
+ // ActivityGraphs
+
+ /**
+ * Testing Use Cases elements.
+ */
+ public void testBuildUseCasesNodes() {
+ assertNotNull(Model.getUmlFactory().buildNode(
+ Model.getMetaTypes().getActor()));
+ assertNotNull(Model.getUmlFactory().buildNode(
+ Model.getMetaTypes().getUseCase()));
+ assertNotNull(Model.getUmlFactory().buildNode(
+ Model.getMetaTypes().getPackage()));
+
+ // Instance (in UML 1.4) and Classifier are abstract and not tested
+
+ /*
+ * Extend, Include, UseCaseInstance & ExtensionPoint not implemented
+ */
+// assertNotNull(Model.getUmlFactory().buildNode(
+// Model.getMetaTypes().getExtend()));
+// assertNotNull(Model.getUmlFactory().buildNode(
+// Model.getMetaTypes().getInclude()));
+// assertNotNull(Model.getUmlFactory().buildNode(
+// Model.getMetaTypes().getUseCaseInstance()));
+// assertNotNull(Model.getUmlFactory().buildNode(
+// Model.getMetaTypes().getExtensionPoint()));
+ // ...
+ }
+
+ /**
+ * Tests for StateMachines elements.
+ */
+ public void testBuildStateMachineNodes() {
+ assertNotNull(Model.getUmlFactory().buildNode(
+ Model.getMetaTypes().getCompositeState()));
+ assertNotNull(Model.getUmlFactory().buildNode(
+ Model.getMetaTypes().getFinalState()));
+ assertNotNull(Model.getUmlFactory().buildNode(
+ Model.getMetaTypes().getSimpleState()));
+
+ /*
+ * State is concrete in UML 1.3, but becomes abstract in UML 1.4, so we
+ * never allow it to be created (and don't test creation)
+ */
+// assertNotNull(Model.getUmlFactory().buildNode(
+// Model.getMetaTypes().getState()));
+ assertNotNull(Model.getUmlFactory().buildNode(
+ Model.getMetaTypes().getPseudostate()));
+ assertNotNull(Model.getUmlFactory().buildNode(
+ Model.getMetaTypes().getSynchState()));
+ assertNotNull(Model.getUmlFactory().buildNode(
+ Model.getMetaTypes().getStubState()));
+ assertNotNull(Model.getUmlFactory().buildNode(
+ Model.getMetaTypes().getSubmachineState()));
+ // ...
+ }
+
+ /**
+ * Tests for Collaborations elements.
+ */
+ public void testBuildCollaborationsNodes() {
+ assertNotNull(Model.getUmlFactory().buildNode(
+ Model.getMetaTypes().getUMLClass()));
+ // ...
+ }
+
+ // CommonBehaviorFactory
+ // DataTypesFactory
+ // ExtensionMechanismsFactory
+ // ModelManagementFactory
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlGeneralization.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlGeneralization.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlGeneralization.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,114 @@
+// $Id:TestUmlGeneralization.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 2003-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.model;
+
+import java.util.Collection;
+
+/**
+ * Test to check various aspects of generalization relationships
+ *
+ * @author Markus Klink
+ */
+public class TestUmlGeneralization extends GenericUmlObjectTestFixture {
+
+ private Object class1, class2, class3;
+ private Object gen1, gen2;
+ private Object namespace;
+
+ /**
+ * Constructor.
+ *
+ * @param arg0
+ * test name
+ */
+ public TestUmlGeneralization(String arg0) {
+ super(arg0);
+ setEntity(Model.getMetaTypes().getClass());
+ validateTestClassIsGeneric(this);
+ }
+
+
+ /**
+ * Make sure that the generalization can be retrieved and followed to the
+ * correct parent.
+ */
+ public void testClasshasGeneralizations() {
+ Collection gen = Model.getFacade().getGeneralizations(class2);
+ assertNotNull(gen);
+ assertTrue(gen.size() == 1);
+ assertTrue(gen.contains(gen2));
+ assertTrue(Model.getFacade().getParent(gen2) == class3);
+ }
+
+ /**
+ * Make sure that the specialization can be retrieved and followed to the
+ * correct child.
+ */
+ public void testClasshasSpecializations() {
+ Collection gen = Model.getFacade().getSpecializations(class2);
+ assertNotNull(gen);
+ assertTrue(gen.size() == 1);
+ assertTrue(gen.contains(gen1));
+ assertTrue(Model.getFacade().getChild(gen1) == class1);
+ }
+
+ /**
+ * Delete the middle class in a 3 level hierarchy and make sure the
+ * generalizations and specializations on both sides get deleted as well.
+ */
+ public void testDeleteClass() {
+ Model.getUmlFactory().delete(class2);
+ Collection gens1 = Model.getFacade().getGeneralizations(class1);
+ Collection specs1 = Model.getFacade().getSpecializations(class1);
+ assertTrue(gens1.isEmpty());
+ assertTrue(specs1.isEmpty());
+ Collection gens2 = Model.getFacade().getGeneralizations(class3);
+ Collection specs2 = Model.getFacade().getSpecializations(class3);
+ assertTrue(gens2.isEmpty());
+ assertTrue(specs2.isEmpty());
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ Object mmodel =
+ Model.getModelManagementFactory().createModel();
+ Model.getCoreHelper().setName(mmodel, "untitledModel");
+ Model.getModelManagementFactory().setRootModel(mmodel);
+ namespace = Model.getModelManagementFactory().createPackage();
+ class1 = Model.getCoreFactory().buildClass("Class1", namespace);
+ class2 = Model.getCoreFactory().buildClass("Class2", namespace);
+ class3 = Model.getCoreFactory().buildClass("Class3", namespace);
+
+ gen1 =
+ Model.getCoreFactory().buildGeneralization(class1, class2);
+ gen2 =
+ Model.getCoreFactory().buildGeneralization(class2, class3);
+
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,65 @@
+// $Id:TestUmlModel.java 12778 2007-06-08 07:46:32Z tfmorris $
+// Copyright (c) 2003-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.model;
+
+/**
+ * @author Thierry Lach
+ */
+public class TestUmlModel extends GenericUmlObjectTestFixture {
+ /**
+ * Constructor.
+ *
+ * @param arg0 test name
+ */
+ public TestUmlModel(String arg0) {
+ super(arg0);
+ setEntity(Model.getMetaTypes().getModel());
+ validateTestClassIsGeneric(this);
+ }
+
+ /**
+ * Test the creation of a namespace.
+ */
+ public void testNamespace() {
+ Object o =
+ Model.getUmlFactory().buildNode(Model.getMetaTypes().getModel());
+ assertNotNull("Didn't create object", o);
+ assertTrue("Should be a base", Model.getFacade().isAUMLElement(o));
+ assertTrue("Should be a model", Model.getFacade().isAModel(o));
+ runTruthTests(o);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ setTruth(Model.getMetaTypes().getModelElement(), true);
+ setTruth(Model.getMetaTypes().getGeneralizableElement(), true);
+ setTruth(Model.getMetaTypes().getNamespace(), true);
+ setTruth(Model.getMetaTypes().getPackage(), true);
+ setTruth(Model.getMetaTypes().getModel(), true);
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlModelElement.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlModelElement.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlModelElement.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,58 @@
+// $Id:TestUmlModelElement.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 2003-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.model;
+
+/**
+ * @author Thierry Lach
+ */
+public class TestUmlModelElement extends GenericUmlObjectTestFixture {
+ /**
+ * Constructor.
+ *
+ * @param arg0 test name
+ */
+ public TestUmlModelElement(String arg0) {
+ super(arg0);
+ setEntity(Model.getMetaTypes().getModelElement());
+ validateTestClassIsGeneric(this);
+ }
+
+ /**
+ * Test Model Element
+ */
+ public void testModelElement() {
+ // ModelElement is abstract, so no create tests
+ // TODO: Add any other relevant tests
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ setTruth(Model.getMetaTypes().getModelElement(), true);
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlUseCase.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlUseCase.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestUmlUseCase.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,67 @@
+// $Id:TestUmlUseCase.java 12778 2007-06-08 07:46:32Z tfmorris $
+// Copyright (c) 2003-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.model;
+
+/**
+ * @author Thierry Lach
+ */
+public class TestUmlUseCase extends GenericUmlObjectTestFixture {
+ /**
+ * Constructor.
+ *
+ * @param arg0 test name
+ */
+ public TestUmlUseCase(String arg0) {
+ super(arg0);
+ setEntity(Model.getMetaTypes().getUseCase());
+ validateTestClassIsGeneric(this);
+ }
+
+ /**
+ * Test creating a usecase.
+ */
+ public void testUseCase() {
+ Object o =
+ Model.getUmlFactory().buildNode(Model.getMetaTypes().getUseCase());
+ assertNotNull("Didn't create object", o);
+ assertTrue("Should be a model element",
+ Model.getFacade().isAUMLElement(o));
+ assertTrue("Should be a use case", Model.getFacade().isAUseCase(o));
+ runTruthTests(o);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ setTruth(Model.getMetaTypes().getModelElement(), true);
+ setTruth(Model.getMetaTypes().getGeneralizableElement(), true);
+ setTruth(Model.getMetaTypes().getNamespace(), true);
+ setTruth(Model.getMetaTypes().getClassifier(), true);
+ setTruth(Model.getMetaTypes().getUseCase(), true);
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestUseCasesFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestUseCasesFactory.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestUseCasesFactory.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,157 @@
+// $Id:TestUseCasesFactory.java 12793 2007-06-08 19:28:22Z tfmorris $
+// Copyright (c) 2002-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.model;
+
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+
+
+/**
+ * Test the UseCasesFactory class.
+ *
+ */
+public class TestUseCasesFactory extends TestCase {
+ /**
+ * List of elements to test.
+ */
+ private static String[] allModelElements = {
+ "Actor",
+ "Extend",
+ "ExtensionPoint",
+ "Include",
+ "UseCase",
+// "UseCaseInstance", // Gone in UML 2.x & unused by ArgoUML
+ };
+
+ /**
+ * The constructor.
+ *
+ * @param n the name of the test
+ */
+ public TestUseCasesFactory(String n) {
+ super(n);
+ }
+
+ /**
+ * @return Returns the allModelElements.
+ */
+ static String[] getAllModelElements() {
+ return allModelElements;
+ }
+
+ /**
+ * @return all testable model elements
+ */
+ static List<String> getTestableModelElements() {
+ return Arrays.asList(allModelElements);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() {
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test if the UseCasesFactory is really a singleton.
+ */
+ public void testSingleton() {
+ Object o1 = Model.getUseCasesFactory();
+ Object o2 = Model.getUseCasesFactory();
+ assertTrue("Different singletons", o1 == o2);
+ }
+
+ /**
+ * Test creation.
+ */
+ public void testCreates() {
+ CheckUMLModelHelper.createAndRelease(
+ Model.getUseCasesFactory(), getTestableModelElements());
+ }
+
+ /**
+ * Test building extensions.
+ */
+ public void testBuildExtend1() {
+ Object base = Model.getUseCasesFactory().createUseCase();
+ Object extension = Model.getUseCasesFactory().createUseCase();
+ Object point = Model.getUseCasesFactory()
+ .buildExtensionPoint(base);
+ assertTrue("extensionpoint not added to base",
+ Model.getFacade().getExtensionPoints(base).contains(point));
+ Object extend = Model.getUseCasesFactory()
+ .buildExtend(base, extension, point);
+ // The following method is unused by ArgoUML and has been
+ // deprecated.
+// assertTrue("extend not added to base",
+// Model.getUseCasesHelper()
+// .getExtendingUseCases(base).contains(extend));
+ assertTrue("extend not added to extension",
+ Model.getFacade().getExtends(extension).contains(extend));
+ assertTrue("extend not added to correct extensionpoint",
+ (Model.getFacade().getExtensionPoints(extend).contains(point)
+ && Model.getFacade().getExtensionPoints(extend).size() == 1));
+ }
+
+ public void testGetAll() {
+ Object model = Model.getModelManagementFactory().createModel();
+ Object pkg = Model.getModelManagementFactory().createPackage();
+ Model.getCoreHelper().addOwnedElement(model, pkg);
+
+ Object uc = Model.getUseCasesFactory().createUseCase();
+ Model.getCoreHelper().setName(uc, "UseCase1");
+ Model.getCoreHelper().addOwnedElement(model, uc);
+
+ uc = Model.getUseCasesFactory().createUseCase();
+ Model.getCoreHelper().setName(uc, "UseCase2");
+ Model.getCoreHelper().addOwnedElement(pkg, uc);
+
+ assertEquals("Failed to get two UseCases", 2,
+ Model.getUseCasesHelper().getAllUseCases(model).size());
+
+ Object actor = Model.getUseCasesFactory().createActor();
+ Model.getCoreHelper().setName(actor, "Actor1");
+ Model.getCoreHelper().addOwnedElement(model, actor);
+
+ actor = Model.getUseCasesFactory().createActor();
+ Model.getCoreHelper().setName(actor, "Actor2");
+ Model.getCoreHelper().addOwnedElement(pkg, actor);
+
+
+ actor = Model.getUseCasesFactory().createActor();
+ Model.getCoreHelper().setName(actor, "Actor3");
+ Model.getCoreHelper().addOwnedElement(pkg, actor);
+
+ assertEquals("Failed to get three Actors", 3,
+ Model.getUseCasesHelper().getAllActors(model).size());
+
+ }
+
+}
+
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/TestUseCasesHelper.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/TestUseCasesHelper.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/TestUseCasesHelper.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,68 @@
+// $Id:TestUseCasesHelper.java 12485 2007-05-03 05:59:35Z linus $
+// Copyright (c) 1996-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.model;
+
+import junit.framework.TestCase;
+
+/**
+ * @since Oct 10, 2002
+ * @author [email protected]
+ */
+public class TestUseCasesHelper extends TestCase {
+
+ /**
+ * Constructor for TestUseCasesHelper.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestUseCasesHelper(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() {
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test getting the meta model name.
+ */
+ public void testGetMetaModelName() {
+ CheckUMLModelHelper.metaModelNameCorrect(
+ Model.getUseCasesFactory(),
+ TestUseCasesFactory.getAllModelElements());
+ }
+
+ /**
+ * Test stereotypes.
+ */
+ public void testIsValidStereoType() {
+ CheckUMLModelHelper.isValidStereoType(
+ Model.getUseCasesFactory(),
+ TestUseCasesFactory.getAllModelElements());
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/model/package.html
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/model/package.html?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/model/package.html 2007-08-13 09:07:56-0700
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+ Copyright (c) 1996-2005 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.
+-->
+</head>
+<body bgcolor="white">
+Provides for testing the Model subsystem interfaces.
+<p>
+Don't use any NSUML-things (ru.novosoft) and
+NSUML implementation (org.argouml.model.uml)
+(and other future implementations)
+in these classes.
+</body>
+</html>
Added: branches/gsoc2007/b00__1/tests/org/argouml/moduleloader/GUITestModuleLoader2.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/moduleloader/GUITestModuleLoader2.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/moduleloader/GUITestModuleLoader2.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,203 @@
+// $Id:GUITestModuleLoader2.java 12983 2007-07-05 04:59:26Z tfmorris $
+// Copyright (c) 2006-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.moduleloader;
+
+import java.util.Collection;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.argouml.model.InitializeModel;
+
+/**
+ * Tests for the new module loader.
+ */
+public class GUITestModuleLoader2 extends TestCase {
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ public void testGetInstance() {
+ assertNotNull(ModuleLoader2.getInstance());
+ }
+
+ public void testDoLoad() {
+ ModuleLoader2.doLoad(false);
+ ModuleLoader2.doLoad(true);
+ }
+
+ public void testIsEnabled() {
+ assertFalse(ModuleLoader2.isEnabled("some-nonexisting-module"));
+ }
+
+ public void testAllModules() {
+ Collection<String> all = ModuleLoader2.allModules();
+ assertNotNull(all);
+
+ for (String module : all) {
+ assertNotNull(module);
+ }
+ }
+
+ public void testIsSelected() {
+ assertFalse(ModuleLoader2.isSelected("some-module-that-do-not-exist"));
+ }
+
+ public void testSetSelected() {
+ ModuleLoader2.setSelected("nonexisting-module", true);
+ ModuleLoader2.setSelected("nonexisting-module", false);
+ }
+
+ public void testGetDescription() {
+ try {
+ ModuleLoader2.getDescription("nonexisting-module");
+ fail("No exception was thrown.");
+ } catch (IllegalArgumentException e) {
+ // Fine!
+ }
+ }
+
+ public void testGetExtensionLocations() {
+ List<String> extensionLocations =
+ ModuleLoader2.getInstance().getExtensionLocations();
+ assertNotNull(extensionLocations);
+
+ for (String extensionLocation : extensionLocations) {
+ assertNotNull(extensionLocation);
+ }
+ }
+
+ public void testAddClassNegative() {
+ try {
+ ModuleLoader2.addClass("a.class.that.do.not.exist");
+ fail("No exception was thrown!");
+ } catch (ClassNotFoundException e) {
+ // Fine!
+ }
+
+ try {
+ ModuleLoader2.addClass(this.getClass().getName());
+ } catch (ClassNotFoundException e) {
+ fail("Exception thrown unexpectedly.");
+ }
+ }
+
+
+ private static Object created;
+ public static void interfaceCreatedForTesting(Object testing1) {
+ created = testing1;
+ }
+
+ public void testAddClass() {
+ created = null;
+
+ try {
+ ModuleLoader2.addClass(ModuleInterfaceForTesting1.class.getName());
+ } catch (ClassNotFoundException e) {
+ fail("Exception thrown unexpectedly.");
+ }
+
+ assertNotNull(created);
+
+ ModuleInterfaceForTesting1.setReadyToBeEnabled(false);
+
+ ModuleLoader2.setSelected(
+ ModuleInterfaceForTesting1.TEST_MODULE_NAME, false);
+
+ assertNotNull(
+ ModuleLoader2.getDescription(
+ ModuleInterfaceForTesting1.TEST_MODULE_NAME));
+ assertFalse(
+ ModuleLoader2.isEnabled(
+ ModuleInterfaceForTesting1.TEST_MODULE_NAME));
+ assertFalse(
+ ModuleLoader2.isSelected(
+ ModuleInterfaceForTesting1.TEST_MODULE_NAME));
+
+ ModuleLoader2.doLoad(false);
+
+ assertFalse(
+ ModuleLoader2.isEnabled(
+ ModuleInterfaceForTesting1.TEST_MODULE_NAME));
+ assertFalse(
+ ModuleLoader2.isSelected(
+ ModuleInterfaceForTesting1.TEST_MODULE_NAME));
+
+ ModuleLoader2.setSelected(
+ ModuleInterfaceForTesting1.TEST_MODULE_NAME, true);
+
+ assertFalse(
+ ModuleLoader2.isEnabled(
+ ModuleInterfaceForTesting1.TEST_MODULE_NAME));
+ assertTrue(
+ ModuleLoader2.isSelected(
+ ModuleInterfaceForTesting1.TEST_MODULE_NAME));
+
+ ModuleLoader2.setSelected(
+ ModuleInterfaceForTesting1.TEST_MODULE_NAME, false);
+
+ assertFalse(
+ ModuleLoader2.isEnabled(
+ ModuleInterfaceForTesting1.TEST_MODULE_NAME));
+ assertFalse(
+ ModuleLoader2.isSelected(
+ ModuleInterfaceForTesting1.TEST_MODULE_NAME));
+
+ ModuleLoader2.setSelected(
+ ModuleInterfaceForTesting1.TEST_MODULE_NAME, true);
+
+ assertFalse(
+ ModuleLoader2.isEnabled(
+ ModuleInterfaceForTesting1.TEST_MODULE_NAME));
+ assertTrue(
+ ModuleLoader2.isSelected(
+ ModuleInterfaceForTesting1.TEST_MODULE_NAME));
+
+ ModuleLoader2.doLoad(false);
+
+ assertFalse(
+ ModuleLoader2.isEnabled(
+ ModuleInterfaceForTesting1.TEST_MODULE_NAME));
+ assertTrue(
+ ModuleLoader2.isSelected(
+ ModuleInterfaceForTesting1.TEST_MODULE_NAME));
+
+ ModuleInterfaceForTesting1.setReadyToBeEnabled(true);
+
+ ModuleLoader2.doLoad(false);
+
+ assertTrue(
+ ModuleLoader2.isEnabled(
+ ModuleInterfaceForTesting1.TEST_MODULE_NAME));
+ assertTrue(
+ ModuleLoader2.isSelected(
+ ModuleInterfaceForTesting1.TEST_MODULE_NAME));
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/moduleloader/ModuleInterfaceForTesting1.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/moduleloader/ModuleInterfaceForTesting1.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/moduleloader/ModuleInterfaceForTesting1.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,69 @@
+// $Id:ModuleInterfaceForTesting1.java 11584 2006-12-10 21:03:05Z linus $
+// Copyright (c) 2006 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.moduleloader;
+
+
+/**
+ * A module for testing.
+ */
+public class ModuleInterfaceForTesting1 implements ModuleInterface {
+
+ static final String TEST_MODULE_NAME = "test-module-153";
+ private static boolean readyToBeEnabled;
+
+ /**
+ * Constructor.
+ */
+ public ModuleInterfaceForTesting1() {
+ GUITestModuleLoader2.interfaceCreatedForTesting(this);
+ }
+
+ public static boolean isReadyToBeEnabled() {
+ return readyToBeEnabled;
+ }
+
+ public static void setReadyToBeEnabled(boolean r) {
+ readyToBeEnabled = r;
+ }
+
+ public boolean disable() {
+ // TODO: Auto-generated method stub
+ return false;
+ }
+
+ public boolean enable() {
+ return readyToBeEnabled;
+ }
+
+ public String getInfo(int type) {
+ // TODO: Auto-generated method stub
+ return null;
+ }
+
+ public String getName() {
+ return ModuleInterfaceForTesting1.TEST_MODULE_NAME;
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/notation/TestNotationProvider.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/notation/TestNotationProvider.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/notation/TestNotationProvider.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,142 @@
+// $Id$
+// Copyright (c) 2006-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.notation;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.HashMap;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.Model;
+import org.argouml.notation.NotationProvider;
+
+/**
+ * @author Michiel
+ */
+public class TestNotationProvider extends TestCase
+ implements PropertyChangeListener {
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ private Object aClass;
+ private boolean propChanged = false;
+
+ /**
+ * Test the existence of the
+ * toString(Object modelElement, HashMap args) method.
+ * TODO: Need to find a more usefull test.
+ */
+ public void testToString() {
+ NotationProvider np = new NPImpl();
+ HashMap<String, String> args = new HashMap<String, String>();
+ args.put("b", "c");
+ assertTrue("Test toString()", "a1".equals(np.toString("a", args)));
+ args.put("d", "e");
+ assertTrue("Test toString()", "f2".equals(np.toString("f", args)));
+ }
+
+ /**
+ * Test the isValue utility function.
+ */
+ public void testIsValue() {
+ HashMap<String, Object> args = new HashMap<String, Object>();
+ args.put("not a boolean", "c");
+ args.put("true", Boolean.TRUE);
+ args.put("false", Boolean.FALSE);
+ args.put("null", null);
+ assertTrue("Not a boolean",
+ !NotationProvider.isValue("not a boolean", args));
+ assertTrue("Finding true",
+ NotationProvider.isValue("true", args));
+ assertTrue("Finding false",
+ !NotationProvider.isValue("false", args));
+ assertTrue("Finding null",
+ !NotationProvider.isValue("null", args));
+ assertTrue("Not encountered",
+ !NotationProvider.isValue("xyz", args));
+ }
+
+ private class NPImpl extends NotationProvider {
+
+ /*
+ * @see org.argouml.notation.providers.NotationProvider#getParsingHelp()
+ */
+ public String getParsingHelp() {
+ return null;
+ }
+
+ /*
+ * @see org.argouml.notation.providers.NotationProvider#toString(java.lang.Object, java.util.HashMap)
+ */
+ public String toString(Object modelElement, HashMap args) {
+ return modelElement.toString() + args.size();
+ }
+
+ /*
+ * @see org.argouml.notation.providers.NotationProvider#parse(java.lang.Object, java.lang.String)
+ */
+ public void parse(Object modelElement, String text) {
+
+ }
+ }
+
+ public void testListener() {
+ Object model =
+ Model.getModelManagementFactory().createModel();
+ Project p = ProjectManager.getManager().getCurrentProject();
+ p.setRoot(model);
+ aClass = Model.getCoreFactory().buildClass(model);
+
+ NotationProvider np = new NPImpl();
+ np.initialiseListener(this, aClass);
+
+ propChanged = false;
+ Model.getCoreHelper().setName(aClass, "ClassA1");
+ Model.getPump().flushModelEvents();
+ assertTrue("No event received", propChanged);
+
+ np.cleanListener(this, aClass);
+ propChanged = false;
+ Model.getCoreHelper().setName(aClass, "ClassA2");
+ Model.getPump().flushModelEvents();
+ assertTrue("Event received, despite not listening", !propChanged);
+
+ np.updateListener(this, aClass, null);
+ }
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ propChanged = true;
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/TestNotation.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/TestNotation.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/TestNotation.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,96 @@
+// $Id:TestNotation.java 12433 2007-04-23 18:19:31Z mvw $
+// 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.notation.providers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.swing.ImageIcon;
+
+import junit.framework.TestCase;
+
+import org.argouml.application.helpers.ResourceLoaderWrapper;
+import org.argouml.notation.Notation;
+import org.argouml.notation.NotationName;
+
+/**
+ * Test the Notation class.
+ *
+ * @author Michiel
+ */
+public class TestNotation extends TestCase {
+
+ public void testConfiguredNotation() {
+ NotationName name = Notation.getConfiguredNotation();
+ assertTrue("No configured notation available or generated",
+ name != null);
+ NotationName nn = Notation.makeNotation("Test", null,
+ ResourceLoaderWrapper.lookupIconResource("JavaNotation"));
+ Notation.setDefaultNotation(nn);
+ assertTrue("Default notation not changed",
+ nn.sameNotationAs(Notation.getConfiguredNotation()));
+ }
+
+ public void testAddingAndRemovingNotations() {
+ int oldSize = Notation.getAvailableNotations().size();
+ NotationName name = Notation.makeNotation("TestNotation",
+ null, ResourceLoaderWrapper
+ .lookupIconResource("JavaNotation"));
+ int newSize = Notation.getAvailableNotations().size();
+ assertTrue("Adding a notation failed", newSize == oldSize + 1);
+ assertTrue("Not able to remove notation",
+ Notation.removeNotation(name));
+ int originalSize = Notation.getAvailableNotations().size();
+ assertTrue("Adding then removing a notation failed",
+ oldSize == originalSize);
+ }
+
+ public void testNoDefaultNotation() {
+ List nots = new ArrayList(Notation.getAvailableNotations());
+ Iterator i = nots.iterator();
+ while (i.hasNext()) {
+ NotationName nn = (NotationName) i.next();
+ assertTrue("Not able to remove notation",
+ Notation.removeNotation(nn));
+ }
+ assertTrue("Notations list not empty",
+ Notation.getAvailableNotations().size() == 0);
+ Notation.makeNotation("UML 1.4", null,
+ ResourceLoaderWrapper.lookupIconResource("UmlNotation"));
+ NotationName name = Notation.getConfiguredNotation();
+ assertTrue("No configured notation generated",
+ name != null);
+ }
+
+ public void testNotationIcons() {
+ ImageIcon uml =
+ ResourceLoaderWrapper.lookupIconResource("UmlNotation");
+ assertTrue("No UML icon found", uml != null);
+ ImageIcon java =
+ ResourceLoaderWrapper.lookupIconResource("JavaNotation");
+ assertTrue("No Java icon found", java != null);
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/TestNotationProviderFactory2.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/TestNotationProviderFactory2.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/TestNotationProviderFactory2.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,129 @@
+// $Id:TestNotationProviderFactory2.java 12987 2007-07-05 14:28:59Z mvw $
+// 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.notation.providers;
+
+import java.util.HashMap;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.application.helpers.ResourceLoaderWrapper;
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
+import org.argouml.notation.Notation;
+import org.argouml.notation.NotationName;
+import org.argouml.notation.NotationProvider;
+
+
+
+/**
+ * Test the NotationProviderFactory.
+ *
+ * @author Michiel
+ */
+public class TestNotationProviderFactory2 extends TestCase {
+
+ private NotationName name;
+ private Project proj;
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ InitializeModel.initializeDefault();
+ name = Notation.makeNotation(
+ "Test",
+ null,
+ ResourceLoaderWrapper.lookupIconResource("JavaNotation"));
+ Notation.setDefaultNotation(name);
+ proj = ProjectManager.getManager().getCurrentProject();
+ proj.getProjectSettings().setNotationLanguage(name);
+ }
+
+ public void testFactory() {
+ assertTrue("Test notation not found",
+ Notation.findNotation("Test") != null);
+ assertTrue("Default notation is not as expected",
+ Notation.getConfiguredNotation().getName().equals("Test"));
+ assertTrue("Project notation is not as expected",
+ proj.getProjectSettings().getNotationName()
+ .sameNotationAs(name));
+
+ /* TODO: Why does the next part not work? */
+// NotationProviderFactory2.getInstance().addNotationProvider(1234,
+// name, MyNP.class);
+// NotationProvider notationProvider =
+// NotationProviderFactory2.getInstance().getNotationProvider(
+// 1234, new Object());
+// assertTrue("Test notation provider for 1234 not found",
+// notationProvider != null);
+ }
+
+ class MyNP extends NotationProvider {
+
+ /*
+ * Constructor.
+ */
+ public MyNP() {
+ }
+
+ /*
+ * Constructor.
+ *
+ * @param me an Object
+ */
+ public MyNP(Object me) {
+ if (me == null) {
+ throw new IllegalArgumentException("This is not an Object.");
+ }
+ }
+
+ public MyNP getInstance() {
+ return new MyNP();
+ }
+
+ /*
+ * @see org.argouml.notation.providers.NotationProvider#getParsingHelp()
+ */
+ public String getParsingHelp() {
+ return null;
+ }
+
+ /*
+ * @see org.argouml.notation.providers.NotationProvider#toString(java.lang.Object, java.util.HashMap)
+ */
+ public String toString(Object modelElement, HashMap args) {
+ return modelElement.toString() + args.size();
+ }
+
+ /*
+ * @see org.argouml.notation.providers.NotationProvider#parse(java.lang.Object, java.lang.String)
+ */
+ public void parse(Object modelElement, String text) {
+
+ }
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/java/TestModelElementNameNotationJava.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/java/TestModelElementNameNotationJava.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/java/TestModelElementNameNotationJava.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,87 @@
+// $Id:TestModelElementNameNotationJava.java 12483 2007-05-02 20:20:37Z linus $
+// 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.notation.providers.java;
+
+import java.util.HashMap;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.Model;
+import org.argouml.notation.providers.ModelElementNameNotation;
+
+/**
+ * Tests the ModelElementNameNotationJava class.
+ *
+ * @author Luis Sergio Oliveira (euluis)
+ */
+public class TestModelElementNameNotationJava extends TestCase {
+ private Object theClass;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ theClass = Model.getCoreFactory().buildClass("TheClass", getModel());
+ }
+
+ public void testToStringForRealization() {
+ Object theInterface = Model.getCoreFactory().buildInterface(
+ "TheInterface", getModel());
+ Object realization = Model.getCoreFactory().buildRealization(theClass,
+ theInterface, getModel());
+ assertToStringForUnnamedRelationshipIsEmpty(realization);
+ assertToStringForNamedRelationshipEqualsItsName(realization);
+ }
+
+ private void assertToStringForUnnamedRelationshipIsEmpty(
+ Object relationship) {
+ ModelElementNameNotation notation = new ModelElementNameNotationJava(
+ relationship);
+ assertEquals("", notation.toString(relationship, new HashMap()));
+ }
+
+ private void assertToStringForNamedRelationshipEqualsItsName(
+ Object relationship) {
+ ModelElementNameNotation notation = new ModelElementNameNotationJava(
+ relationship);
+ Model.getCoreHelper().setName(relationship, "relationshipName");
+ assertEquals(Model.getFacade().getName(relationship), notation.toString(
+ relationship, new HashMap()));
+ }
+
+ public void testToStringForGeneralization() {
+ Object theBaseClass = Model.getCoreFactory().buildClass("TheBaseClass",
+ getModel());
+ Object generalization = Model.getCoreFactory().buildGeneralization(
+ theClass, theBaseClass);
+ assertToStringForUnnamedRelationshipIsEmpty(generalization);
+ assertToStringForNamedRelationshipEqualsItsName(generalization);
+ }
+
+ private Object getModel() {
+ return ProjectManager.getManager().getCurrentProject().getModel();
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestAttributeAndOperationNotationUml.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestAttributeAndOperationNotationUml.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestAttributeAndOperationNotationUml.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,1036 @@
+// $Id:TestAttributeAndOperationNotationUml.java 12987 2007-07-05 14:28:59Z mvw $
+// Copyright (c) 2006-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.notation.providers.uml;
+
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.InitializeModel;
+import org.argouml.model.Model;
+import org.argouml.notation.InitNotation;
+import org.argouml.notation.NotationProvider;
+import org.argouml.notation.providers.java.InitNotationJava;
+
+/**
+ * @author michiel
+ */
+public class TestAttributeAndOperationNotationUml extends TestCase {
+
+
+ private static final String ATTR01 = "name";
+ private static final String ATTR02 = "+name";
+ private static final String ATTR03 = "-name : void";
+ private static final String ATTR04 = "#name [1..1] : int {a=b}";
+ private static final String ATTR05 =
+ "public name {a=b, c = d } : [1..*] int = 0";
+ private static final String ATTR06 =
+ "private name {a=b, c = d } [*..*] : int = 15 {frozen}";
+ private static final String ATTR07 = "+name : String = \'val[15] \'";
+ private static final String ATTR08 =
+ " + name : String = \"a <<string>>\"";
+ private static final String ATTR09 = "+name : String = (a * (b+c) - d)";
+ private static final String ATTR10 =
+ "+name << attrstereo1 >> : String = 2 * (b+c) - 10";
+ private static final String ATTR11 =
+ "<<attrstereo2>> +name : String = a[15]";
+ private static final String ATTR12 = "+ name : String = a << 5";
+ private static final String ATTR13 =
+ "<<attrstereo1,attrstereo2>> +name : String = a[15]";
+
+ private static final String NATTR01 = "too many string in an attribute";
+ private static final String NATTR02 = "+vis name";
+ private static final String NATTR03 = "vis name : type : type";
+ private static final String NATTR04 = "vis name = 0 = 1";
+ private static final String NATTR05 = "vis name [1..1] [1..1]";
+ private static final String NATTR06 = "vis name [1..1";
+ private static final String NATTR07 = "vis name { a = b, cv = ";
+ private static final String NATTR08 = "vis \"name\"";
+ private static final String NATTR09 = "\"vis\" name";
+ private static final String NATTR10 = "vis (name)";
+ private static final String NATTR11 = "(vis) name";
+ private static final String NATTR12 = "vis name : \"type\"";
+ private static final String NATTR13 = "vis name : (type)";
+
+ private static final String OPER01 = "name()";
+ private static final String OPER02 =
+ "<<opstereo1>> -name(in foo: float = 0) "
+ + "{root, abstract = false} : int";
+ private static final String OPER03 =
+ "<< opstereo2 >> protected name2("
+ + "out foo: double = 0., inout bar = \"\"some\"\":String) "
+ + "{leaf,query} : String";
+ private static final String OPER04 = "<<>> # name2()";
+ private static final String OPER05 = "<< opstereo1, opstereo2 >> name5()";
+
+ private static final String NOPER01 = "name(";
+ private static final String NOPER02 = "\"name\"()";
+ private static final String NOPER03 = "\"vis\" name()";
+ private static final String NOPER04 = "\'name\'()";
+ private static final String NOPER05 = "\'vis\' name()";
+ private static final String NOPER06 = "(name)()";
+ private static final String NOPER07 = "(vis) name()";
+ private static final String NOPER08 = "name() : \"type\"";
+ private static final String NOPER09 = "name() : \'type\'";
+ private static final String NOPER10 = "name() : (type)";
+
+ /**
+ * The constructor.
+ *
+ * @param str the name of the test
+ */
+ public TestAttributeAndOperationNotationUml(String str) {
+ super(str);
+ InitializeModel.initializeDefault();
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() {
+ (new InitNotation()).init();
+ (new InitNotationUml()).init();
+ (new InitNotationJava()).init();
+ }
+
+ /**
+ * Test the parsing of an attribute name.
+ *
+ * @throws ParseException if the parsing fails.
+ */
+ public void testAttributeName()
+ throws ParseException {
+ Object attr;
+
+ Project p = ProjectManager.getManager().getCurrentProject();
+ Object model = p.getModel();
+ Object attrType = p.getDefaultAttributeType();
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, model);
+
+ checkName(attr, ATTR01, "name");
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, model);
+
+ checkName(attr, ATTR02, "name");
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, model);
+
+ checkName(attr, ATTR03, "name");
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, model);
+
+ checkName(attr, ATTR04, "name");
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, model);
+
+ checkName(attr, ATTR05, "name");
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, model);
+
+ checkName(attr, ATTR06, "name");
+ }
+
+
+ /**
+ * Test the parsing of an attribute's type.
+ *
+ * @throws ParseException if the parsing fails.
+ */
+ public void testAttributeType() throws ParseException {
+ Object attr;
+
+ Project project = ProjectManager.getManager().getCurrentProject();
+ Object ns = project.getModel();
+ Object attrType = project.getDefaultAttributeType();
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkType(attr, ATTR03, "void");
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkType(attr, ATTR04, "int");
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkType(attr, ATTR05, "int");
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkType(attr, ATTR06, "int");
+ }
+
+ /**
+ * Test the parsing of the attribute's visibility.
+ *
+ * @throws ParseException if the parsing fails.
+ */
+ public void testAttributeVisibility() throws ParseException {
+ Object attr;
+
+ Project project = ProjectManager.getManager().getCurrentProject();
+ Object ns = project.getModel();
+ Object attrType = project.getDefaultAttributeType();
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkVisibility(attr, ATTR02, "public");
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkVisibility(attr, ATTR03, "private");
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkVisibility(attr, ATTR04, "protected");
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkVisibility(attr, ATTR05, "public");
+ checkVisibility(attr, ATTR01, "public");
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkVisibility(attr, ATTR06, "private");
+ checkVisibility(attr, ATTR01, "private");
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkVisibility(attr, ATTR08, "public");
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkVisibility(attr, ATTR11, "public");
+ }
+
+ /**
+ * Test the parsing of an attribute's property.
+ *
+ * @throws ParseException if the parsing fails.
+ */
+ public void testAttributeProperty() throws ParseException {
+ Object attr;
+ String[] res1 = {
+ "a", "b",
+ };
+ String[] res2 = {
+ "a", "b", "c", "d",
+ };
+ String[] res3 = {
+ "a", "b", "c", "d", "frozen",
+ null,
+ };
+
+ Object ns =
+ ProjectManager.getManager().getCurrentProject().getModel();
+ Object attrType = ProjectManager.getManager().getCurrentProject()
+ .getDefaultAttributeType();
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkProperties(attr, ATTR04, res1);
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkProperties(attr, ATTR05, res2);
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkProperties(attr, ATTR06, res3);
+ }
+
+ /**
+ * Test parsing an attribute's multiplicity.
+ *
+ * @throws ParseException if the parsing fails.
+ */
+ public void testAttributeMultiplicity() throws ParseException {
+ Object attr;
+
+ Object ns =
+ ProjectManager.getManager().getCurrentProject().getModel();
+ Object attrType = ProjectManager.getManager().getCurrentProject()
+ .getDefaultAttributeType();
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkMultiplicity(attr, ATTR04,
+ Model.getDataTypesFactory().createMultiplicity("1..1"));
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkMultiplicity(attr, ATTR05,
+ Model.getDataTypesFactory().createMultiplicity("1..*"));
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkMultiplicity(attr, ATTR06,
+ Model.getDataTypesFactory().createMultiplicity("*..*"));
+ }
+
+ /**
+ * Test that the parser throws the correct exceptions.
+ */
+ public void testAttributeParseExceptions() {
+ Object attr;
+
+ Object ns =
+ ProjectManager.getManager().getCurrentProject().getModel();
+ Object attrType = ProjectManager.getManager().getCurrentProject()
+ .getDefaultAttributeType();
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkThrows(attr, NATTR01, true, false, false);
+ checkThrows(attr, NATTR02, true, false, false);
+ checkThrows(attr, NATTR03, true, false, false);
+ checkThrows(attr, NATTR04, true, false, false);
+ checkThrows(attr, NATTR05, true, false, false);
+ checkThrows(attr, NATTR06, true, false, false);
+ checkThrows(attr, NATTR07, true, false, false);
+ checkThrows(attr, NATTR08, true, false, false);
+ checkThrows(attr, NATTR09, true, false, false);
+ checkThrows(attr, NATTR10, true, false, false);
+ checkThrows(attr, NATTR11, true, false, false);
+ checkThrows(attr, NATTR12, true, false, false);
+ checkThrows(attr, NATTR13, true, false, false);
+ }
+
+ /**
+ * Test the parsing of an attribute's value.
+ *
+ * @throws ParseException if the parsing fails.
+ */
+ public void testAttributeValue() throws ParseException {
+ Object attr;
+
+ Object ns =
+ ProjectManager.getManager().getCurrentProject().getModel();
+ Object attrType = ProjectManager.getManager().getCurrentProject()
+ .getDefaultAttributeType();
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkValue(attr, ATTR05, "0");
+ checkValue(attr, ATTR01, "0");
+ checkValue(attr, ATTR06, "15");
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkValue(attr, ATTR07, "\'val[15] \'");
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkValue(attr, ATTR08, "\"a <<string>>\"");
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkValue(attr, ATTR09, "(a * (b+c) - d)");
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkValue(attr, ATTR10, "2 * (b+c) - 10");
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkValue(attr, ATTR11, "a[15]");
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkValue(attr, ATTR12, "a << 5");
+ }
+
+ /**
+ * Add stereotype to a model element if it doesn't already have it.
+ */
+ private void softAddStereotype(String name, Object elem) {
+ Object ns =
+ ProjectManager.getManager().getCurrentProject().getModel();
+
+ Iterator it =
+ Model.getExtensionMechanismsHelper()
+ .getStereotypes(ns).iterator();
+ while (it.hasNext()) {
+ Object s = it.next();
+ if (name.equals(Model.getFacade().getName(s))) {
+ return;
+ }
+ }
+ Model.getExtensionMechanismsFactory().buildStereotype(
+ elem,
+ name,
+ ns);
+ }
+
+
+ /**
+ * Test the parsing of an attribute's stereotype.
+ *
+ * @throws ParseException if the parsing fails.
+ */
+ public void testAttributeStereotype() throws ParseException {
+ Object attr;
+
+ Object ns =
+ ProjectManager.getManager().getCurrentProject().getModel();
+ Object attrType = ProjectManager.getManager().getCurrentProject()
+ .getDefaultAttributeType();
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ softAddStereotype("attrstereo1", attr);
+ softAddStereotype("attrstereo2", attr);
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkStereotype(attr, ATTR01, new String[] {});
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkStereotype(attr, ATTR10, new String[] {"attrstereo1"});
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkStereotype(attr, ATTR11, new String[] {"attrstereo2"});
+
+ attr = Model.getCoreFactory().buildAttribute2(attrType);
+ Model.getCoreHelper().setNamespace(attr, ns);
+
+ checkStereotype(attr, ATTR13, new String[] {"attrstereo1",
+ "attrstereo2", });
+ }
+
+
+ /**
+ * Test the parsing of an operation's name.
+ *
+ * @throws ParseException if the parsing fails.
+ */
+ public void testOperationName() throws ParseException {
+ Object op;
+ Object cl = Model.getCoreFactory().buildClass();
+
+ Object ns =
+ ProjectManager.getManager().getCurrentProject().getModel();
+
+ Model.getCoreHelper().setNamespace(cl, ns);
+ Object returnType = ProjectManager.getManager().getCurrentProject()
+ .getDefaultReturnType();
+
+ op = Model.getCoreFactory().buildOperation(cl, returnType);
+ checkName(op, OPER01, "name");
+
+ op = Model.getCoreFactory().buildOperation(cl, returnType);
+ checkName(op, OPER02, "name");
+
+ op = Model.getCoreFactory().buildOperation(cl, returnType);
+ checkName(op, OPER03, "name2");
+ }
+
+ /**
+ * Test the parsing of an operation's type.
+ *
+ * @throws ParseException
+ * if the parsing fails.
+ */
+ public void testOperationType() throws ParseException {
+ Object op;
+ Object cl = Model.getCoreFactory().buildClass();
+ Object ns = ProjectManager.getManager().getCurrentProject().getModel();
+
+ Model.getCoreHelper().setNamespace(cl, ns);
+ Object returnType =
+ ProjectManager.getManager().getCurrentProject().findType("void");
+
+ op = Model.getCoreFactory().buildOperation(cl, returnType);
+ checkType(op, OPER01, "void");
+
+ op = Model.getCoreFactory().buildOperation(cl, returnType);
+ checkType(op, OPER02, "int");
+ checkType(op, OPER01, "int");
+
+ op = Model.getCoreFactory().buildOperation(cl, returnType);
+ checkType(op, OPER03, "String");
+ }
+
+ /**
+ * Test the parsing of an operation's visibility.
+ *
+ * @throws ParseException
+ * if the parsing fails.
+ */
+ public void testOperationVisibility() throws ParseException {
+ Object op;
+ Object cl = Model.getCoreFactory().buildClass();
+ Object ns = ProjectManager.getManager().getCurrentProject().getModel();
+
+ Model.getCoreHelper().setNamespace(cl, ns);
+ Object returnType = ProjectManager.getManager().getCurrentProject()
+ .getDefaultReturnType();
+
+ op = Model.getCoreFactory().buildOperation(cl, returnType);
+ checkVisibility(op, OPER01, "public");
+
+ op = Model.getCoreFactory().buildOperation(cl, returnType);
+ checkVisibility(op, OPER02, "private");
+
+ op = Model.getCoreFactory().buildOperation(cl, returnType);
+ checkVisibility(op, OPER03, "protected");
+ checkVisibility(op, OPER01, "protected");
+ checkVisibility(op, OPER02, "private");
+
+ op = Model.getCoreFactory().buildOperation(cl, returnType);
+ checkVisibility(op, OPER04, "protected");
+ }
+
+ /**
+ * Test the parsing of an operation's parameters.
+ *
+ * @throws ParseException if the parsing fails.
+ */
+ public void testOperationParameters() throws ParseException {
+ Object op;
+ Object cl = Model.getCoreFactory().buildClass();
+ Object ns =
+ ProjectManager.getManager().getCurrentProject().getModel();
+ Object returnType = ProjectManager.getManager().getCurrentProject()
+ .getDefaultReturnType();
+
+ Model.getCoreHelper().setNamespace(cl, ns);
+
+ String[] res1 = {
+ };
+ String[] res2 = {
+ "in", "foo", "float", "0",
+ };
+ String[] res3 = {
+ "out",
+ "foo",
+ "double",
+ "0.",
+ "inout",
+ "bar",
+ "String",
+ "\"\"some\"\"",
+ };
+
+ op = Model.getCoreFactory().buildOperation(cl, returnType);
+ checkParameters(op, OPER01, res1);
+
+ op = Model.getCoreFactory().buildOperation(cl, returnType);
+ checkParameters(op, OPER02, res2);
+
+ op = Model.getCoreFactory().buildOperation(cl, returnType);
+ checkParameters(op, OPER03, res3);
+ checkParameters(op, OPER01, res1);
+ checkParameters(op, OPER02, res2);
+ }
+
+ /**
+ * Test the parsing of an operation's properties.
+ *
+ * @throws ParseException if the parsing fails.
+ */
+ public void testOperationProperties() throws ParseException {
+ Object op;
+ Object cl = Model.getCoreFactory().buildClass();
+ Object ns = ProjectManager.getManager().getCurrentProject().getModel();
+ Object returnType = ProjectManager.getManager().getCurrentProject()
+ .getDefaultReturnType();
+
+ Model.getCoreHelper().setNamespace(cl, ns);
+
+ String[] res1 = {
+ "abstract", null,
+ "concurrency", null,
+ "concurrent", null,
+ "guarded", null,
+ "leaf", null,
+ "query", null,
+ "root", null,
+ "sequential", null,
+ };
+
+ op = Model.getCoreFactory().buildOperation(cl, returnType);
+ checkProperties(op, OPER01, res1);
+
+ op = Model.getCoreFactory().buildOperation(cl, returnType);
+ checkProperties(op, OPER02, res1);
+
+ op = Model.getCoreFactory().buildOperation(cl, returnType);
+ checkProperties(op, OPER03, res1);
+ }
+
+ /**
+ * Test the parsing of an operation's stereotype.
+ *
+ * @throws ParseException
+ * if the parsing fails.
+ */
+ public void testOperationStereotype()
+ throws ParseException {
+
+ Object op;
+ Object cl = Model.getCoreFactory().buildClass();
+ Object ns =
+ ProjectManager.getManager().getCurrentProject().getModel();
+
+ Model.getCoreHelper().setNamespace(cl, ns);
+ Object returnType = ProjectManager.getManager().getCurrentProject()
+ .getDefaultReturnType();
+
+ op = Model.getCoreFactory().buildOperation(cl, returnType);
+ softAddStereotype("opstereo1", op);
+ softAddStereotype("opstereo2", op);
+
+ op = Model.getCoreFactory().buildOperation(cl, returnType);
+ checkStereotype(op, OPER01, new String[] {});
+
+ op = Model.getCoreFactory().buildOperation(cl, returnType);
+ checkStereotype(op, OPER02, new String[] {"opstereo1"});
+
+ op = Model.getCoreFactory().buildOperation(cl, returnType);
+ checkStereotype(op, OPER03, new String [] {"opstereo2"});
+ checkStereotype(op, OPER04, new String[] {});
+ checkStereotype(op, OPER05, new String [] {"opstereo1", "opstereo2"});
+ }
+
+ /**
+ * Test the parsing of an operation's parse exceptions.
+ */
+ public void testOperationParseExceptions() {
+ Object op;
+ Object cl = Model.getCoreFactory().buildClass();
+ Object ns =
+ ProjectManager.getManager().getCurrentProject().getModel();
+
+ Model.getCoreHelper().setNamespace(cl, ns);
+ Object returnType = ProjectManager.getManager().getCurrentProject()
+ .getDefaultReturnType();
+
+ op = Model.getCoreFactory().buildOperation(cl, returnType);
+ checkThrows(op, NOPER01, true, false, false);
+ checkThrows(op, NOPER02, true, false, false);
+ checkThrows(op, NOPER03, true, false, false);
+ checkThrows(op, NOPER04, true, false, false);
+ checkThrows(op, NOPER05, true, false, false);
+ checkThrows(op, NOPER06, true, false, false);
+ checkThrows(op, NOPER07, true, false, false);
+ checkThrows(op, NOPER08, true, false, false);
+ checkThrows(op, NOPER09, true, false, false);
+ checkThrows(op, NOPER10, true, false, false);
+ }
+
+ private void checkName(Object element, String text, String name)
+ throws ParseException {
+
+ if (Model.getFacade().isAAttribute(element)) {
+ AttributeNotationUml anu = new AttributeNotationUml();
+ anu.parseAttribute(text, element);
+ assertTrue(text
+ + " gave wrong name: "
+ + Model.getFacade().getName(element),
+ name.equals(Model.getFacade().getName(element)));
+ } else if (Model.getFacade().isAOperation(element)) {
+ OperationNotationUml onu = new OperationNotationUml(element);
+ onu.parseOperation(text, element);
+ assertTrue(text
+ + " gave wrong name: "
+ + Model.getFacade().getName(element)
+ + " != " + name,
+ name.equals(Model.getFacade().getName(element)));
+ } else {
+ fail("Can only check name of a feature or classifier role");
+ }
+ }
+
+ private void checkType(Object feature, String text, String type)
+ throws ParseException {
+ if (Model.getFacade().isAAttribute(feature)) {
+ AttributeNotationUml anu = new AttributeNotationUml();
+ anu.parseAttribute(text, feature);
+ assertTrue(text + " gave wrong type: (null)",
+ Model.getFacade().getType(feature) != null);
+ assertTrue(text + " gave wrong type: "
+ + Model.getFacade().getName(
+ Model.getFacade().getType(feature)),
+ type.equals(Model.getFacade().getName(
+ Model.getFacade().getType(feature))));
+ } else if (Model.getFacade().isAOperation(feature)) {
+ OperationNotationUml onu = new OperationNotationUml(feature);
+ onu.parseOperation(text, feature);
+ Collection ret =
+ Model.getCoreHelper().getReturnParameters(feature);
+ Iterator it = ret.iterator();
+ assertTrue(
+ text + " gave extra return value",
+ !(type == null && it.hasNext()));
+ assertTrue(
+ text + " lacks return value",
+ !(type != null && !it.hasNext()));
+ if (it.hasNext()) {
+ Object p = it.next();
+ Object pType = Model.getFacade().getType(p);
+ assertTrue(
+ text + " gave wrong return",
+ (type == null && pType == null)
+ || (type != null
+ && type.equals(Model.getFacade().getName(pType))));
+ }
+ assertTrue(text + " gave extra return value", !it.hasNext());
+ } else {
+ fail("Can only check type of a feature");
+ }
+ }
+
+
+ private void checkParameters(Object op, String text, String[] params)
+ throws ParseException {
+ int i;
+
+ OperationNotationUml onu = new OperationNotationUml(op);
+ onu.parseOperation(text, op);
+ Collection prm = Model.getFacade().getParameters(op);
+ Iterator it = prm.iterator();
+ assertTrue(
+ text + " lacks parameters",
+ !(params.length > 0 && !it.hasNext()));
+ for (i = 0; i + 3 < params.length; i += 4) {
+ Object p;
+ do {
+ assertTrue(text + " lacks parameters", it.hasNext());
+ p = it.next();
+ } while (Model.getFacade().getKind(p).equals(
+ Model.getDirectionKind().getReturnParameter()));
+ assertTrue(text + "gave wrong inout in parameter " + (i / 4),
+ params[i].equals(Model.getFacade()
+ .getName(Model.getFacade().getKind(p))));
+ assertTrue(text + "gave wrong name in parameter " + (i / 4),
+ params[i + 1].equals(Model.getFacade().getName(p)));
+ Object pType = Model.getFacade().getType(p);
+ assertTrue(text + "gave wrong type in parameter " + (i / 4),
+ params[i + 2].equals(Model.getFacade().getName(pType)));
+ Object defaultValue = Model.getFacade().getDefaultValue(p);
+ assertTrue(text + "gave wrong default value in parameter "
+ + (i / 4),
+ (params[i + 3] == null && defaultValue == null)
+ || ((params[i + 3] != null
+ && defaultValue != null)
+ && params[i + 3].equals(
+ Model.getFacade().getBody(defaultValue))));
+ }
+ while (it.hasNext()) {
+ Object p = it.next();
+ assertTrue(
+ text + " gave extra parameters",
+ Model.getFacade().getKind(p).equals(
+ Model.getDirectionKind().getReturnParameter()));
+ }
+ }
+
+ private void checkVisibility(Object feature, String text, String vis)
+ throws ParseException {
+ if (Model.getFacade().isAAttribute(feature)) {
+ AttributeNotationUml anu = new AttributeNotationUml();
+ anu.parseAttribute(text, feature);
+ assertTrue(text + " gave wrong visibility: (null)",
+ Model.getFacade().getVisibility(feature) != null);
+ assertTrue(text + " gave wrong visibility: "
+ + Model.getFacade().getName(
+ Model.getFacade().getVisibility(feature)),
+ vis.equals(Model.getFacade().getName(
+ Model.getFacade().getVisibility(feature))));
+ } else if (Model.getFacade().isAOperation(feature)) {
+ OperationNotationUml onu = new OperationNotationUml(feature);
+ onu.parseOperation(text, feature);
+ assertTrue(text + " gave wrong visibility: (null)",
+ Model.getFacade().getVisibility(feature) != null);
+ assertTrue(text + " gave wrong visibility: "
+ + Model.getFacade().getName(
+ Model.getFacade().getVisibility(feature)),
+ vis.equals(Model.getFacade().getName(
+ Model.getFacade().getVisibility(feature))));
+ } else {
+ fail("Can only check visibility of a feature");
+ }
+ }
+
+ private void checkProperties(
+ Object feature,
+ String text,
+ String[] props)
+ throws ParseException {
+
+ if (Model.getFacade().isAAttribute(feature)) {
+ int i;
+ AttributeNotationUml anu = new AttributeNotationUml();
+ anu.parseAttribute(text, feature);
+ for (i = 0; i + 1 < props.length; i += 2) {
+ if (props[i + 1] == null) {
+ assertTrue(
+ "TaggedValue " + props[i] + " exists!",
+ Model.getFacade().getTaggedValue(feature, props[i])
+ == null);
+ } else {
+ Object tv =
+ Model.getFacade().getTaggedValue(feature, props[i]);
+ Object tvValue = Model.getFacade().getValueOfTag(tv);
+
+ assertTrue(
+ "TaggedValue " + props[i] + " wrong!",
+ props[i + 1].equals(tvValue)
+ );
+ }
+ }
+ } else if (Model.getFacade().isAOperation(feature)) {
+ int i;
+
+ OperationNotationUml onu = new OperationNotationUml(feature);
+ onu.parseOperation(text, feature);
+ for (i = 0; i + 1 < props.length; i += 2) {
+ if (props[i + 1] == null) {
+ assertTrue(
+ "TaggedValue " + props[i] + " exists!",
+ Model.getFacade().getTaggedValue(feature, props[i])
+ == null);
+ } else {
+ Object tv =
+ Model.getFacade().getTaggedValue(feature, props[i]);
+ Object tvValue = Model.getFacade().getValueOfTag(tv);
+ assertTrue(
+ "TaggedValue " + props[i] + " wrong!",
+ props[i + 1].equals(tvValue));
+ }
+ }
+ }
+ }
+
+ private void checkMultiplicity(
+ Object attr,
+ String text,
+ Object mult)
+ throws ParseException {
+
+ AttributeNotationUml anu = new AttributeNotationUml();
+ anu.parseAttribute(text, attr);
+ if (mult == null) {
+ assertTrue(
+ text
+ + " gave wrong multiplicity: "
+ + (Model.getFacade().getMultiplicity(attr) == null
+ ? "(null)"
+ : Model.getFacade().toString(Model.getFacade().
+ getMultiplicity(attr))),
+ Model.getFacade().getMultiplicity(attr) == null);
+ } else {
+ assertTrue(
+ text
+ + " gave wrong multiplicity: "
+ + (Model.getFacade().getMultiplicity(attr) == null
+ ? "(null)"
+ : Model.getFacade().toString(Model.getFacade().
+ getMultiplicity(attr))),
+ Model.getFacade().toString(mult).equals(
+ Model.getFacade().toString(
+ Model.getFacade().getMultiplicity(attr))));
+ }
+ }
+
+ private void checkThrows(
+ Object element,
+ String text,
+ boolean prsEx,
+ boolean ex2,
+ boolean ex3) {
+ if (Model.getFacade().isAAttribute(element)) {
+ try {
+ AttributeNotationUml anu = new AttributeNotationUml();
+ anu.parseAttribute(text, element);
+ fail("didn't throw for " + text);
+ } catch (ParseException pe) {
+ assertTrue(text + " threw ParseException " + pe, prsEx);
+ }
+ } else if (Model.getFacade().isAOperation(element)) {
+ try {
+ OperationNotationUml onu = new OperationNotationUml(element);
+ onu.parseOperation(text, element);
+ fail("didn't throw for " + text);
+ } catch (ParseException pe) {
+ assertTrue(text + " threw ParseException " + pe, prsEx);
+ }
+ }
+ }
+
+ private void checkValue(Object attr, String text, String val)
+ throws ParseException {
+
+ AttributeNotationUml anu = new AttributeNotationUml();
+ anu.parseAttribute(text, attr);
+ if (val == null) {
+ assertTrue(
+ text
+ + " gave wrong visibility: "
+ + (Model.getFacade().getInitialValue(attr) == null
+ ? "(null)"
+ : Model.getFacade().getBody(
+ Model.getFacade().getInitialValue(attr))),
+ Model.getFacade().getInitialValue(attr) == null
+ || "".equals(Model.getFacade().getBody(
+ Model.getFacade().getInitialValue(attr))));
+ } else {
+ assertTrue(
+ text
+ + " gave wrong visibility: "
+ + (Model.getFacade().getInitialValue(attr) == null
+ ? "(null)"
+ : Model.getFacade().getBody(
+ Model.getFacade().getInitialValue(attr))),
+ Model.getFacade().getInitialValue(attr) != null
+ && val.equals(Model.getFacade().getBody(
+ Model.getFacade().getInitialValue(attr))));
+ }
+ }
+
+ /**
+ * Parses the text into the feature and checks that the feature gets
+ * the stereotype with the name val.
+ *
+ * @param feature The feature.
+ * @param text The text to parse.
+ * @param val The name of the stereotype(s).
+ * @throws ParseException if we cannot parse the text.
+ */
+ private void checkStereotype(Object feature, String text, String[] val)
+ throws ParseException {
+
+ NotationProvider np = null;
+ if (Model.getFacade().isAAttribute(feature)) {
+ AttributeNotationUml anu = new AttributeNotationUml();
+ anu.parseAttribute(text, feature);
+ np = anu;
+ } else if (Model.getFacade().isAOperation(feature)) {
+ OperationNotationUml onu = new OperationNotationUml(feature);
+ onu.parseOperation(text, feature);
+ np = onu;
+ } else {
+ fail("Unknown feature type " + feature);
+ }
+
+ Collection stereos = Model.getFacade().getStereotypes(feature);
+ List<Object> stereoNames = new ArrayList<Object>();
+ for (Iterator i = stereos.iterator(); i.hasNext();) {
+ stereoNames.add(Model.getFacade().getName(i.next()));
+ }
+ boolean stereosMatch = true;
+ for (int i = 0; i < val.length; i++) {
+ if (!stereoNames.contains(val[i])) {
+ stereosMatch = false;
+ }
+ }
+ assertTrue(
+ text + " gave wrong stereotype " + stereos.toArray(),
+ val.length == stereos.size()
+ && stereosMatch);
+
+ String str = np.toString(feature, null);
+ assertTrue("Empty string", str.length() > 0);
+ // TODO: Test if the generated string is correct.
+ }
+
+ /**
+ * Test if help is correctly provided.
+ */
+ public void testGetHelpAttribute() {
+ AttributeNotationUml notation = new AttributeNotationUml();
+ String help = notation.getParsingHelp();
+ assertTrue("No help at all given", help.length() > 0);
+ assertTrue("Parsing help not conform for translation",
+ help.startsWith("parsing."));
+ }
+
+ /**
+ * Test if help is correctly provided.
+ */
+ public void testGetHelpOperation() {
+ Object op;
+ Object cl = Model.getCoreFactory().buildClass();
+
+ Object ns = ProjectManager.getManager().getCurrentProject().getModel();
+
+ Model.getCoreHelper().setNamespace(cl, ns);
+ Object returnType = ProjectManager.getManager().getCurrentProject()
+ .getDefaultReturnType();
+
+ op = Model.getCoreFactory().buildOperation(cl, returnType);
+
+ OperationNotationUml notation = new OperationNotationUml(op);
+ String help = notation.getParsingHelp();
+ assertTrue("No help at all given", help.length() > 0);
+ assertTrue("Parsing help not conform for translation",
+ help.startsWith("parsing."));
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestCallStateNotationUml.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestCallStateNotationUml.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestCallStateNotationUml.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,282 @@
+// $Id:TestCallStateNotationUml.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 2006-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.notation.providers.uml;
+
+import java.text.ParseException;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.Model;
+
+/**
+ * Test the notation for a CallState.
+ *
+ * @author Michiel
+ */
+public class TestCallStateNotationUml extends TestCase {
+ private Object aClass, aClass2;
+ private Object aStateMachine;
+ private Object aOper, aOper2, aOperB;
+ private Object aState;
+ private Object aCallState;
+ private Object aCallAction;
+
+ /**
+ * The constructor.
+ *
+ * @param arg0 the name
+ */
+ public TestCallStateNotationUml(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() {
+ InitializeModel.initializeDefault();
+ Object model =
+ Model.getModelManagementFactory().createModel();
+ Project p = ProjectManager.getManager().getCurrentProject();
+ p.setRoot(model);
+ aClass = Model.getCoreFactory().buildClass(model);
+ aClass2 = Model.getCoreFactory().buildClass(model);
+ Object returnType = p.getDefaultReturnType();
+ aOper = Model.getCoreFactory().buildOperation2(aClass, returnType,
+ "myOper");
+ aOper2 = Model.getCoreFactory().buildOperation2(aClass, returnType,
+ "myOper2");
+ aOperB = Model.getCoreFactory().buildOperation2(aClass2, returnType,
+ "myOperB");
+ aStateMachine =
+ Model.getStateMachinesFactory().buildStateMachine(aClass);
+ Object top = Model.getFacade().getTop(aStateMachine);
+ aState =
+ Model.getStateMachinesFactory().buildCompositeState(top);
+ aCallState =
+ Model.getActivityGraphsFactory().createCallState();
+ Model.getStateMachinesHelper().setContainer(aCallState, top);
+ }
+
+ /**
+ * An extra setup fiunction.
+ */
+ protected void setUp2() {
+ aCallAction =
+ Model.getCommonBehaviorFactory().buildCallAction(aOper, "myAction");
+ Model.getStateMachinesHelper().setEntry(aCallState, aCallAction);
+ }
+
+ /**
+ * Test if the string for an un-named class is correct.
+ */
+ public void testStringGenerationNoClassName() {
+ setUp2();
+ CallStateNotationUml notation = new CallStateNotationUml(aCallState);
+ String notationStr = notation.toString(aCallState, null);
+ assertTrue("Notation not correctly generated - "
+ + "Resulted in: '" + notationStr + "'",
+ notationStr.equals("myOper"));
+ }
+
+ /**
+ * Test if the string generated for a named class and operation is correct.
+ */
+ public void testStringGenerationClassName() {
+ setUp2();
+ CallStateNotationUml notation = new CallStateNotationUml(aCallState);
+ Model.getCoreHelper().setName(aClass, "ClassA");
+ String notationStr = notation.toString(aCallState, null);
+ assertTrue("Notation not correctly generated - "
+ + "Resulted in: '" + notationStr + "'",
+ notationStr.equals("myOper\n(ClassA)"));
+ }
+
+ /**
+ * Test generating the modelelements from a string, and then
+ * re-creating the string from the modelelements.
+ * The resulting string should be equal to the original.
+ */
+ public void testGenerateRoundTrip() {
+ CallStateNotationUml notation = new CallStateNotationUml(aCallState);
+ Model.getCoreHelper().setName(aClass, "ClassA");
+ try {
+ notation.parseCallState(aCallState, "myOper\n(ClassA)");
+ } catch (ParseException e) {
+ assertTrue("Unexpected exception: " + e.getMessage(), true);
+ }
+ Object entry = Model.getFacade().getEntry(aCallState);
+ assertTrue("No entry action generated", entry != null);
+ Object op = Model.getFacade().getOperation(entry);
+ assertTrue("Operation not linked to entry action", op != null);
+ String notationStr = notation.toString(aCallState, null);
+ assertTrue("Notation not correctly generated - "
+ + "Resulted in: '" + notationStr + "'",
+ notationStr.equals("myOper\n(ClassA)"));
+ }
+
+ /**
+ * Test changing the operation.
+ */
+ public void testChangeOperation() {
+ CallStateNotationUml notation = new CallStateNotationUml(aCallState);
+ Model.getCoreHelper().setName(aClass, "ClassA");
+ setUp2();
+ try {
+ notation.parseCallState(aCallState, "myOper2\n(ClassA)");
+ } catch (ParseException e) {
+ assertTrue("Unexpected exception: " + e.getMessage(), true);
+ }
+ Object entry = Model.getFacade().getEntry(aCallState);
+ assertTrue("No entry action generated", entry != null);
+ Object op = Model.getFacade().getOperation(entry);
+ assertTrue("Operation not linked to entry action", op != null);
+ String name = Model.getFacade().getName(op);
+ assertTrue("Operation name incorrect - resulted in: '" + name + "'",
+ "myOper2".equals(name));
+ String notationStr = notation.toString(aCallState, null);
+ assertTrue("Notation not correctly generated - "
+ + "Resulted in: '" + notationStr + "'",
+ notationStr.equals("myOper2\n(ClassA)"));
+ }
+
+ /**
+ * Test changing the Class and Operation.
+ */
+ public void testChangeOperationAndClass() {
+ CallStateNotationUml notation = new CallStateNotationUml(aCallState);
+ Model.getCoreHelper().setName(aClass, "ClassA");
+ Model.getCoreHelper().setName(aClass2, "ClassB");
+ setUp2();
+ try {
+ notation.parseCallState(aCallState, "myOperB\n(ClassB)");
+ } catch (ParseException e) {
+ assertTrue("Unexpected exception: " + e.getMessage(), true);
+ }
+ Object entry = Model.getFacade().getEntry(aCallState);
+ assertTrue("No entry action generated", entry != null);
+ Object op = Model.getFacade().getOperation(entry);
+ assertTrue("Operation not linked to entry action", op != null);
+ String name = Model.getFacade().getName(op);
+ assertTrue("Operation name incorrect - resulted in: '" + name + "'",
+ "myOperB".equals(name));
+ String notationStr = notation.toString(aCallState, null);
+ assertTrue("Notation not correctly generated - "
+ + "Resulted in: '" + notationStr + "'",
+ notationStr.equals("myOperB\n(ClassB)"));
+ }
+
+ /**
+ * Test is some mistakes in the string do generate
+ * exceptions as they should.
+ */
+ public void testExceptionalCases() {
+ CallStateNotationUml notation = new CallStateNotationUml(aCallState);
+ Model.getCoreHelper().setName(aClass, "ClassA");
+ try {
+ notation.parseCallState(aCallState, "myOper\n(ClassA");
+ assertTrue("Expected 'wrong brackets' exception did not happen",
+ true);
+ } catch (ParseException e) {
+ //ok
+ }
+ try {
+ notation.parseCallState(aCallState, "myOper\nClassA)");
+ assertTrue("Expected 'wrong brackets' exception did not happen",
+ true);
+ } catch (ParseException e) {
+ //ok
+ }
+ try {
+ notation.parseCallState(aCallState, "myOper\n)ClassA(");
+ assertTrue("Expected 'wrong brackets' exception did not happen",
+ true);
+ } catch (ParseException e) {
+ //ok
+ }
+ try {
+ notation.parseCallState(aCallState, "myOperX\n(ClassA)");
+ assertTrue("Expected 'Operation not found' exception "
+ + "did not happen", true);
+ } catch (ParseException e) {
+ //ok
+ }
+ try {
+ notation.parseCallState(aCallState, "myOper\n(ClassB)");
+ assertTrue("Expected 'Operation not found' exception "
+ + "did not happen", true);
+ } catch (ParseException e) {
+ //ok
+ }
+ try {
+ notation.parseCallState(aCallState, "myOper\n(ClassX)");
+ assertTrue("Expected 'Classifier not found' exception "
+ + "did not happen", true);
+ } catch (ParseException e) {
+ //ok
+ }
+ try {
+ notation.parseCallState(aCallState, "X");
+ assertTrue("Expected exception did not happen", true);
+ } catch (ParseException e) {
+ //ok
+ }
+ }
+
+ /**
+ * The entered string does not have a linefeed.
+ */
+ public void testGenerateNoLineFeed() {
+ CallStateNotationUml notation = new CallStateNotationUml(aCallState);
+ Model.getCoreHelper().setName(aClass, "ClassA");
+ try {
+ notation.parseCallState(aCallState, "myOper(ClassA)");
+ } catch (ParseException e) {
+ assertTrue("Unexpected exception: " + e.getMessage(), true);
+ }
+ Object entry = Model.getFacade().getEntry(aCallState);
+ assertTrue("No entry action generated", entry != null);
+ Object op = Model.getFacade().getOperation(entry);
+ assertTrue("Operation not linked to entry action", op != null);
+ String notationStr = notation.toString(aCallState, null);
+ assertTrue("Notation not correctly generated - "
+ + "Resulted in: '" + notationStr + "'",
+ notationStr.equals("myOper\n(ClassA)"));
+ }
+
+ /**
+ * Test if help is correctly provided.
+ */
+ public void testGetHelp() {
+ CallStateNotationUml notation = new CallStateNotationUml(aCallState);
+ String help = notation.getParsingHelp();
+ assertTrue("No help at all given", help.length() > 0);
+ assertTrue("Parsing help not conform for translation",
+ help.startsWith("parsing."));
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestClassifierRoleNotationUml.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestClassifierRoleNotationUml.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestClassifierRoleNotationUml.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,206 @@
+// $Id:TestClassifierRoleNotationUml.java 12485 2007-05-03 05:59:35Z linus $
+// Copyright (c) 2006-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.notation.providers.uml;
+
+import java.text.ParseException;
+import java.util.Collection;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.model.Model;
+
+/**
+ * Test ClassifierRoleNotationUml (formerly ParserDisplay):
+ * parsing classifier-role.
+ *
+ * @author Michiel
+ */
+public class TestClassifierRoleNotationUml extends TestCase {
+ private final String clro01 = "/ roname : int";
+ private final String clro02 = " : int , double / roname2 ";
+ private final String clro03 = ":float,long/roname";
+
+ private final String nclro01 = "/ roname : int / roname2 ";
+ private final String nclro02 = "oname1 oname2 / roname : int , double";
+ private final String nclro03 = "/ roname roname2 : int ";
+ private final String nclro04 = "/ roname : int double ";
+
+ /**
+ * The constructor.
+ *
+ * @param str the name
+ */
+ public TestClassifierRoleNotationUml(String str) {
+ super(str);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test the name of the ClassifierRole.
+ */
+ public void testClassifierRoleName() {
+ Object cr;
+
+ cr = Model.getCollaborationsFactory().createClassifierRole();
+ checkNameClassifierRole(cr, clro01, "roname");
+ checkNameClassifierRole(cr, clro02, "roname2");
+
+ cr = Model.getCollaborationsFactory().createClassifierRole();
+ checkNameClassifierRole(cr, clro03, "roname");
+ }
+
+ /**
+ * Test the Base of the ClassifierRole.
+ */
+ public void testClassifierRoleBases() {
+ Object cr;
+ String[] res1 = {
+ "int",
+ };
+ String[] res2 = {
+ "int", "double",
+ };
+ String[] res3 = {
+ "float", "long",
+ };
+
+ cr = Model.getCollaborationsFactory().createClassifierRole();
+ checkBases(cr, clro01, res1);
+ checkBases(cr, clro02, res2);
+ checkBases(cr, clro03, res3);
+
+ cr = Model.getCollaborationsFactory().createClassifierRole();
+ checkBases(cr, clro03, res3);
+ }
+
+ /**
+ * Test if parsing a ClassifierRole throws exceptions.
+ */
+ public void testClassifierRoleThrows() {
+ Object cr;
+
+ cr = Model.getCollaborationsFactory().createClassifierRole();
+ checkThrowsClassifierRole(cr, nclro01, true, false, false);
+ checkThrowsClassifierRole(cr, nclro02, true, false, false);
+ checkThrowsClassifierRole(cr, nclro03, true, false, false);
+ checkThrowsClassifierRole(cr, nclro04, true, false, false);
+ }
+
+ private void checkNameClassifierRole(Object ro, String text, String name) {
+ try {
+ ClassifierRoleNotationUml crn = new ClassifierRoleNotationUml(ro);
+ crn.parseClassifierRole(ro, text);
+ } catch (ParseException e) {
+ fail("Could not parse expression " + text);
+ }
+ assertEquals(name, Model.getFacade().getName(ro));
+ }
+
+ private void checkThrowsClassifierRole(
+ Object ro,
+ String text,
+ boolean prsEx,
+ boolean ex2,
+ boolean ex3) {
+ try {
+ ClassifierRoleNotationUml crn = new ClassifierRoleNotationUml(ro);
+ crn.parseClassifierRole(ro, text);
+ fail("didn't throw for " + text);
+ } catch (ParseException pe) {
+ assertTrue(text + " threw ParseException " + pe, prsEx);
+ } catch (Exception e) {
+ assertTrue(text + " threw Exception " + e, !prsEx);
+ }
+ }
+
+ private void checkBases(Object cr, String text, String[] bases) {
+ int i;
+ Collection c;
+ Iterator it;
+ Object cls;
+
+ try {
+ ClassifierRoleNotationUml crn = new ClassifierRoleNotationUml(cr);
+ crn.parseClassifierRole(cr, text);
+ c = Model.getFacade().getBases(cr);
+ it = c.iterator();
+ checkAllValid :
+ while (it.hasNext()) {
+ cls = it.next();
+ for (i = 0; i < bases.length; i++) {
+ if (bases[i].equals(Model.getFacade().getName(cls))) {
+ continue checkAllValid;
+ }
+ }
+ assertTrue(
+ "Base "
+ + Model.getFacade().getName(cls)
+ + " falsely "
+ + "generated by "
+ + text,
+ false);
+ }
+
+ checkAllExist :
+ for (i = 0; i < bases.length; i++) {
+ it = c.iterator();
+ while (it.hasNext()) {
+ cls = it.next();
+ if (bases[i].equals(Model.getFacade().getName(cls))) {
+ continue checkAllExist;
+ }
+ }
+ assertTrue("Base " + bases[i]
+ + " was not generated by " + text,
+ false);
+ }
+ } catch (Exception e) {
+ assertTrue(text + " threw unexpectedly: " + e, false);
+ }
+ }
+
+ /**
+ * Test if help is correctly provided.
+ */
+ public void testGetHelp() {
+ Object cr;
+ cr = Model.getCollaborationsFactory().createClassifierRole();
+
+ ClassifierRoleNotationUml notation = new ClassifierRoleNotationUml(cr);
+ String help = notation.getParsingHelp();
+ assertTrue("No help at all given", help.length() > 0);
+ assertTrue("Parsing help not conform for translation",
+ help.startsWith("parsing."));
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestMessageNotationUml.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestMessageNotationUml.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestMessageNotationUml.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,478 @@
+// $Id:TestMessageNotationUml.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 1996-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.notation.providers.uml;
+
+import java.text.ParseException;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.model.Model;
+
+/**
+ * Test class to test the parsing of a message.<p>
+ *
+ * Formerly called TestParseMessage. <p>
+ *
+ * For some reason these tests require the ProjectBrowser loaded when running.
+ * For that reason they cannot be run in Headless mode.
+ */
+public class TestMessageNotationUml extends TestCase {
+
+ /*
+ * @see junit.framework.TestCase#TestCase(String)
+ */
+ public TestMessageNotationUml(String str) {
+ super(str);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Static test of the signature.
+ *
+ * @throws ParseException if the parsing fails.
+ */
+ public void compileTestParseMessage() throws ParseException {
+ Object m = Model.getCollaborationsFactory().createMessage();
+ MessageNotationUml mnu = new MessageNotationUml(m);
+ mnu.parseMessage(m, "hej");
+ }
+
+ /**
+ * Dummy test.
+ */
+ public void testDummy() { }
+
+ /**
+ * Test the parsing of a message.
+ *
+ * @throws ParseException if the parsing was in error.
+ */
+ public void testParseMessage() throws ParseException {
+ Object coll = Model.getCollaborationsFactory().createCollaboration();
+ Object inter = Model.getCollaborationsFactory().buildInteraction(coll);
+
+ Object cl1 = Model.getCollaborationsFactory().createClassifierRole();
+ Object cl2 = Model.getCollaborationsFactory().createClassifierRole();
+ Object cl3 = Model.getCollaborationsFactory().createClassifierRole();
+ Object cl4 = Model.getCollaborationsFactory().createClassifierRole();
+ Object cl5 = Model.getCollaborationsFactory().createClassifierRole();
+ Model.getCoreHelper().setNamespace(cl1, coll);
+ Model.getCoreHelper().setNamespace(cl2, coll);
+ Model.getCoreHelper().setNamespace(cl3, coll);
+ Model.getCoreHelper().setNamespace(cl4, coll);
+ Model.getCoreHelper().setNamespace(cl5, coll);
+
+ Object r1to2 =
+ Model.getCollaborationsFactory().buildAssociationRole(cl1, cl2);
+ Object r2to3 =
+ Model.getCollaborationsFactory().buildAssociationRole(cl2, cl3);
+ Object r3to4 =
+ Model.getCollaborationsFactory().buildAssociationRole(cl3, cl4);
+ Object r4to5 =
+ Model.getCollaborationsFactory().buildAssociationRole(cl4, cl5);
+ Object r3to1 =
+ Model.getCollaborationsFactory().buildAssociationRole(cl3, cl1);
+ Object r5to3 =
+ Model.getCollaborationsFactory().buildAssociationRole(cl5, cl3);
+
+ /* START TESTING STUFF */
+
+ Object m1 =
+ Model.getCollaborationsFactory()
+ .buildMessage(inter, r1to2);
+ assertTrue(Model.getFacade().getSender(m1) == cl1);
+ assertTrue(Model.getFacade().getReceiver(m1) == cl2);
+ assertTrue(Model.getFacade().getInteraction(m1) == inter);
+ assertNull(Model.getFacade().getActivator(m1));
+ Object action = Model.getFacade().getAction(m1);
+ assertTrue(
+ action == null || Model.getFacade().getRecurrence(action) == null);
+ assertTrue(Model.getFacade().getPredecessors(m1).size() == 0);
+ Model.getCoreHelper().setName(m1, "m1");
+
+ Object m2 =
+ Model.getCollaborationsFactory()
+ .buildMessage(inter, r2to3);
+ assertTrue(Model.getFacade().getSender(m2) == cl2);
+ assertTrue(Model.getFacade().getReceiver(m2) == cl3);
+ assertTrue(Model.getFacade().getActivator(m2) == m1);
+ action = Model.getFacade().getAction(m2);
+ assertTrue(
+ action == null || Model.getFacade().getRecurrence(action) == null);
+ assertTrue(Model.getFacade().getPredecessors(m2).size() == 0);
+ Model.getCoreHelper().setName(m2, "m2");
+
+ Object m3 =
+ Model.getCollaborationsFactory()
+ .buildMessage(inter, r2to3);
+ assertTrue(Model.getFacade().getActivator(m3) == m1);
+ assertTrue(
+ Model.getFacade().getPredecessors(m3).iterator().next() == m2
+ && Model.getFacade().getPredecessors(m3).size() == 1);
+ Model.getCoreHelper().setName(m3, "m3");
+
+ /* TRY MOVING IN A SIMPLE MANER */
+
+ trySimpleMoving(m1, m2, m3);
+
+ /* TRY SOME ERRORS */
+
+ trySomeErrors(m3);
+
+ /* TRY SOME MORE COMPLEX MOVING */
+
+ trySomeMoreComplexMoving(m1, m2, m3);
+
+ /* TRY SOME MORE ERRORS */
+
+ checkParseException(m1, " 1.1 : ");
+ checkParseException(m2, " 1.1.1 : ");
+
+ /* TRY GUARD/ITERATOR SYNTAX */
+
+ tryGuardAndIteratorSyntax(m3);
+
+ /* TRY SOME GUARD/ITERATOR ERRORS */
+
+ trySomeGuardAndIteratorErrors(m3);
+
+ /* TRY THE ACTIONS */
+
+ tryTheActions(m3);
+
+ /* TRY SOME ACTION ERRORS */
+
+ trySomeActionErrors(m3);
+
+ /* TRY THE PREDECESSORS */
+
+ checkParseException(m3, "1.2.1 / 1.2 :");
+
+ Object m4 =
+ Model.getCollaborationsFactory()
+ .buildMessage(inter, r3to4);
+ Object m5 =
+ Model.getCollaborationsFactory()
+ .buildMessage(inter, r4to5);
+ Object m6 =
+ Model.getCollaborationsFactory()
+ .buildMessage(inter, r5to3);
+ Object m7 =
+ Model.getCollaborationsFactory()
+ .buildMessage(inter, r3to1);
+
+ checkParseException(m6, "1.2.2 :");
+
+ parseMessage(m7, "2:");
+ assertTrue(Model.getFacade().getSender(m7) == cl1);
+ assertTrue(Model.getFacade().getReceiver(m7) == cl3);
+ assertNull(Model.getFacade().getActivator(m7));
+ assertTrue(Model.getFacade().getPredecessors(m7).iterator().next()
+ == m1);
+ assertTrue(Model.getFacade().getPredecessors(m7).size() == 1);
+
+ parseMessage(m7, "1.2.1.1.1.1:");
+ assertTrue(Model.getFacade().getSender(m7) == cl3);
+ assertTrue(Model.getFacade().getReceiver(m7) == cl1);
+ assertTrue(Model.getFacade().getActivator(m7) == m6);
+ assertTrue(Model.getFacade().getPredecessors(m7).size() == 0);
+
+ /* TRY PREDECESSORS */
+ tryPredecessors(m1, m3, m4, m5, m7);
+
+ /* TRY SOME PREDECESSOR ERRORS */
+ trySomePredecessorErrors(m2, m3);
+ }
+
+ /**
+ * @param m1 message to be tested
+ * @param m3 message to be tested
+ * @param m4 message to be tested
+ * @param m5 message to be tested
+ * @param m7 message to be tested
+ * @throws ParseException if the parser found a syntax error
+ */
+ private void tryPredecessors(Object m1, Object m3, Object m4,
+ Object m5, Object m7) throws ParseException {
+ Object m;
+ Iterator it;
+ assertNull(Model.getFacade().getActivator(m1));
+ assertTrue(Model.getFacade().getPredecessors(m1).size() == 0);
+ assertTrue(Model.getFacade().getActivator(m4) == m3);
+ assertTrue(Model.getFacade().getPredecessors(m4).size() == 0);
+ assertTrue(Model.getFacade().getActivator(m3) == m1);
+ assertTrue(Model.getFacade().getPredecessors(m3).size() == 1);
+
+ parseMessage(m7, "1.2.1 / 1.2.1.1.1.1:");
+ assertTrue(Model.getFacade().getPredecessors(m7).iterator().next()
+ == m4);
+ assertTrue(Model.getFacade().getPredecessors(m7).size() == 1);
+
+ parseMessage(m7, "1.2.1, 1.2.1.1 / 1.2.1.1.1.1:");
+ boolean pre1 = false;
+ boolean pre2 = false;
+ it = Model.getFacade().getPredecessors(m7).iterator();
+ m = it.next();
+ if (m == m4) {
+ pre1 = true;
+ } else if (m == m5) {
+ pre2 = true;
+ } else {
+ assertTrue("Strange message found", false);
+ }
+ m = it.next();
+ if (m == m4) {
+ pre1 = true;
+ } else if (m == m5) {
+ pre2 = true;
+ } else {
+ assertTrue("Strange message found", false);
+ }
+ assertTrue(pre1);
+ assertTrue(pre2);
+ assertTrue(!it.hasNext());
+ }
+
+ /**
+ * @param m2 message to be tested
+ * @param m3 message to be tested
+ */
+ private void trySomePredecessorErrors(Object m2, Object m3) {
+ checkParseException(m2, "1.2 / 1.1 :");
+ checkParseException(m2, "1.2.1 / 1.1 :");
+ checkParseException(m3, "1.2.1 / 1.2 :");
+ }
+
+ /**
+ * @param m3 message to be tested
+ */
+ private void trySomeActionErrors(Object m3) {
+ checkParseException(m3, "1.2 : func() ()");
+ checkParseException(m3, "1.2 : func() foo()");
+ checkParseException(m3, "1.2 : func(), foo()");
+ checkParseException(m3, "1.2 : var() = func()");
+ checkParseException(m3, "1.2 : var = func(), foo()");
+ checkParseException(m3, "1.2 : func() foo()");
+ checkParseException(m3, "1.2 : var = ()");
+ checkParseException(m3, "1.2 : var = () foo");
+ checkParseException(m3, "1.2 : var = (foo(), bar())");
+ checkParseException(m3, "1.2 : func(");
+ checkParseException(m3, "1.2 : func(a, b");
+ }
+
+ /**
+ * @param m3 message to be tested
+ * @throws ParseException if the parser found a syntax error
+ */
+ private void tryTheActions(Object m3) throws ParseException {
+
+ parseMessage(m3, " 1.2 : func() ");
+ Object script =
+ Model.getFacade().getScript(Model.getFacade().getAction(m3));
+ Object body = Model.getFacade().getBody(script);
+ assertEquals("func", body);
+
+ parseMessage(m3, " 1.2 ");
+ script = Model.getFacade().getScript(Model.getFacade().getAction(m3));
+ body = Model.getFacade().getBody(script);
+ assertEquals("func", body);
+
+ parseMessage(m3, " 1.2 : ");
+ script = Model.getFacade().getScript(Model.getFacade().getAction(m3));
+ body = Model.getFacade().getBody(script);
+ assertEquals("", body);
+
+ parseMessage(m3, " 1.2 : var := func() ");
+ script = Model.getFacade().getScript(Model.getFacade().getAction(m3));
+ body = Model.getFacade().getBody(script);
+ assertEquals("var := func", body);
+
+ parseMessage(m3, " 1.2 : var = func() ");
+ script = Model.getFacade().getScript(Model.getFacade().getAction(m3));
+ body = Model.getFacade().getBody(script);
+ assertEquals("var := func", body);
+
+ parseMessage(m3, "1.2:var2:=func2()");
+ script = Model.getFacade().getScript(Model.getFacade().getAction(m3));
+ body = Model.getFacade().getBody(script);
+ assertEquals("var2 := func2", body);
+
+ parseMessage(m3, " 1.2 : var, var2, var3 := func() ");
+ script = Model.getFacade().getScript(Model.getFacade().getAction(m3));
+ body = Model.getFacade().getBody(script);
+ assertEquals("var, var2, var3 := func", body);
+
+ parseMessage(m3, "1.2 : load_the_accumulating_taxes");
+ //TODO: Why there is not test here ?
+ //It's just for resetting the message body ?
+ }
+
+ /**
+ * @param m3 message to be tested
+ */
+ private void trySomeGuardAndIteratorErrors(Object m3) {
+ checkParseException(m3, " [x < 5] 1.2 [x > 6] : ");
+ checkParseException(m3, " 1 [x < 5] / 1.2 : ");
+ checkParseException(m3, " 1 * / 1.2 : ");
+ checkParseException(m3, " 1 // / 1.2 : ");
+ checkParseException(m3, " 1 , 2 [x < 5] / 1.2 : ");
+ checkParseException(m3, " 1 , 2 * / 1.2 : ");
+ checkParseException(m3, " 1 , 2 // / 1.2 : ");
+ checkParseException(m3, "/ 1.2 , 2 : ");
+ checkParseException(m3, "/1.2,2:");
+ }
+
+ /**
+ * @param m3 message to be tested
+ * @throws ParseException if the parser found a syntax error
+ */
+ private void tryGuardAndIteratorSyntax(Object m3) throws ParseException {
+ parseMessage(m3, " 1.2 [ x < 5 ] : ");
+ Object action = Model.getFacade().getAction(m3);
+ assertNotNull(action);
+ Object recurrence = Model.getFacade().getRecurrence(action);
+ Object body = Model.getFacade().getBody(recurrence);
+ assertNotNull(recurrence);
+ assertTrue("[x < 5]".equals(body));
+
+ parseMessage(m3, " 1.2 * [ i = 1..10 ] : ");
+ action = Model.getFacade().getAction(m3);
+ recurrence = Model.getFacade().getRecurrence(action);
+ body = Model.getFacade().getBody(recurrence);
+ assertEquals("*[i = 1..10]", body);
+
+ parseMessage(m3, " 1.2 *// : ");
+ action = Model.getFacade().getAction(m3);
+ recurrence = Model.getFacade().getRecurrence(action);
+ body = Model.getFacade().getBody(recurrence);
+ assertEquals("*[i = 1..10]", body);
+
+ parseMessage(m3, " * // [i=1..] 1.2 : ");
+ action = Model.getFacade().getAction(m3);
+ recurrence = Model.getFacade().getRecurrence(action);
+ body = Model.getFacade().getBody(recurrence);
+ assertEquals("*//[i=1..]", body);
+
+ parseMessage(m3, " 1.2 : ");
+ action = Model.getFacade().getAction(m3);
+ recurrence = Model.getFacade().getRecurrence(action);
+ body = Model.getFacade().getBody(recurrence);
+ assertEquals("*//[i=1..]", body);
+ }
+
+ /**
+ * @param m1 message to be tested
+ * @param m2 message to be tested
+ * @param m3 message to be tested
+ * @throws ParseException if the parser found a syntax error
+ */
+ private void trySomeMoreComplexMoving(Object m1, Object m2,
+ Object m3) throws ParseException {
+ parseMessage(m3, " 1.1.1 : ");
+ assertTrue(Model.getFacade().getActivator(m3) == m2);
+ assertTrue(Model.getFacade().getPredecessors(m3).size() == 0);
+
+ parseMessage(m3, " / 1..2 : ");
+ assertTrue(Model.getFacade().getActivator(m3) == m1);
+ assertTrue(Model.getFacade().getPredecessors(m2).size() == 0);
+ assertTrue(
+ Model.getFacade().getPredecessors(m3).iterator().next() == m2
+ && Model.getFacade().getPredecessors(m3).size() == 1);
+ parseMessage(m3, "");
+ assertTrue(Model.getFacade().getActivator(m3) == m1);
+ assertTrue(
+ Model.getFacade().getPredecessors(m3).iterator().next() == m2
+ && Model.getFacade().getPredecessors(m3).size() == 1);
+ }
+
+ /**
+ * @param m3 message to be tested
+ */
+ private void trySomeErrors(Object m3) {
+ checkParseException(m3, " 2.1 : ");
+ checkParseException(m3, " 1.2 : 1.2 :");
+ checkParseException(m3, " / / 1.2 : ");
+ }
+
+ /**
+ * @param m1 message to be tested
+ * @param m2 message to be tested
+ * @param m3 message to be tested
+ * @throws ParseException if the parser found a syntax error
+ */
+ private void trySimpleMoving(Object m1, Object m2, Object m3)
+ throws ParseException {
+ parseMessage(m3, " \t1.1 : ");
+ assertTrue(Model.getFacade().getActivator(m3) == m1);
+ assertTrue(Model.getFacade().getPredecessors(m3).size() == 0);
+ assertTrue(
+ Model.getFacade().getPredecessors(m2).iterator().next() == m3
+ && Model.getFacade().getPredecessors(m2).size() == 1);
+
+ parseMessage(m3, " / 1.2\t: ");
+ assertTrue(Model.getFacade().getActivator(m3) == m1);
+ assertTrue(Model.getFacade().getPredecessors(m2).size() == 0);
+ assertTrue(
+ Model.getFacade().getPredecessors(m3).iterator().next() == m2
+ && Model.getFacade().getPredecessors(m3).size() == 1);
+ }
+
+ private void parseMessage(Object m, String s) throws ParseException {
+ MessageNotationUml mnu = new MessageNotationUml(m);
+ mnu.parseMessage(m, s);
+ }
+
+ private void checkParseException(Object m, String s) {
+ try {
+ MessageNotationUml mnu = new MessageNotationUml(m);
+ mnu.parseMessage(m, s);
+ assertTrue("Didn't throw for \"" + s + "\" in " + m, false);
+ } catch (ParseException pe) {
+ // The expected exception is thrown.
+ }
+ }
+
+ /**
+ * Test if help is correctly provided.
+ */
+ public void testGetHelp() {
+ Object m = Model.getCollaborationsFactory().createMessage();
+
+ MessageNotationUml notation = new MessageNotationUml(m);
+ String help = notation.getParsingHelp();
+ assertTrue("No help at all given", help.length() > 0);
+ assertTrue("Parsing help not conform for translation",
+ help.startsWith("parsing."));
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestStateBodyNotationUml.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestStateBodyNotationUml.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestStateBodyNotationUml.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,253 @@
+// $Id:TestStateBodyNotationUml.java 12485 2007-05-03 05:59:35Z linus $
+// Copyright (c) 2004-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.notation.providers.uml;
+
+import java.text.ParseException;
+import java.util.Collection;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.Model;
+
+/**
+ * Test StateBodyNotationUml (formerly ParserDisplay): parsing state body.
+ *
+ * @author Michiel
+ */
+public class TestStateBodyNotationUml extends TestCase {
+ private Object aClass;
+ private Object aStateMachine;
+ private Object aState;
+
+ /**
+ * The constructor.
+ *
+ * @param str the name
+ */
+ public TestStateBodyNotationUml(String str) {
+ super(str);
+ InitializeModel.initializeDefault();
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() {
+ Object model =
+ Model.getModelManagementFactory().createModel();
+ Project p = ProjectManager.getManager().getCurrentProject();
+ aClass = Model.getCoreFactory().buildClass(model);
+ Object returnType = p.getDefaultReturnType();
+ Model.getCoreFactory().buildOperation2(aClass, returnType, "myOper");
+ aStateMachine =
+ Model.getStateMachinesFactory().buildStateMachine(aClass);
+ Object top = Model.getFacade().getTop(aStateMachine);
+ aState =
+ Model.getStateMachinesFactory().buildCompositeState(top);
+ }
+
+ /**
+ * Test the parseStateBody() method: succesful creation.
+ */
+ public final void testParseStateBodyCreateIndividually() {
+ checkGenerated(aState, "",
+ false, false, false, 0, false);
+ checkGenerated(aState, "entry/test6",
+ true, false, false, 0, false);
+ checkGenerated(aState, "exit/test7",
+ false, true, false, 0, false);
+ checkGenerated(aState, "do/test8",
+ false, false, true, 0, false);
+ checkGenerated(aState, "test9", //this is not a very useful transition
+ false, false, false, 1, false);
+ }
+
+ /**
+ * Test the parseStateBody() method: succesful creation.
+ */
+ public final void testParseStateBodyCreateCombined() {
+ /* One of everything */
+ checkGenerated(aState, "entry/test1\nexit/b\ndo/it\ninternal/activity",
+ true, true, true, 1, false);
+ /* Upper / Lower case */
+ checkGenerated(aState, "\n\nEntry/a\n\nExit/b\n\nDo/it\n\n\n",
+ true, true, true, 0, false);
+ /* Mixed case */
+ checkGenerated(aState, "ENTRY/test2\nexIT/b\nDO/it",
+ true, true, true, 0, false);
+ /* A complex internal transition */
+ checkGenerated(aState, "internal(test3:int=5,b=4.0:float)[g]/"
+ + "activity(params, p),act(ee);",
+ false, false, false, 1, false);
+ /* These are NOT entry/exit/do activities! */
+ checkGenerated(aState, "entrys/test4\nexiting/b\ndone/it",
+ false, false, false, 3, false);
+ /* Long list of internals */
+ checkGenerated(aState,
+ "a/a\nb/b\nc/c\nd/d\ne/e\nf/f\ng/g\nh/h\ni/i\nj/j\n"
+ + "k/a\nl/b\nm/c\nn/d\no/e\np/f\nq/g\nr/h\ns/i\nt/j",
+ false, false, false, 20, false);
+ }
+
+ /**
+ * Test the parseStateBody() method: syntax errors.
+ */
+ public final void testParseStateBodySyntaxError() {
+ checkGenerated(aState, "do[a/b]test10",
+ false, false, false, 1, true); // or should the 1 be 0 ?
+ }
+
+ /**
+ * Test the parseStateBody() method: changing the signature.
+ */
+ public final void testParseStateBodyRemove() {
+ Object st;
+
+ st =
+ checkGenerated(aState,
+ "entry/test1\nexit/b\ndo/it\ninternal/activity",
+ true, true, true, 1, false);
+ checkChanged(st, "", // deleting it all
+ false, false, false, 0, false);
+
+ st =
+ checkGenerated(aState,
+ "int1/act1\nexit/test2\nint2/act2\ndo/b\nentry/it",
+ true, true, true, 2, false);
+ checkChanged(st, // changing the sequence only
+ "entry/it\nexit/test2\ndo/b\nint1/act1\nint2/act2",
+ true, true, true, 2, false);
+ }
+
+ /**
+ * Test the parseStateBody() method: changing the signature.
+ */
+ public final void testParseStateBodyRemoveInternals() {
+ Object st;
+
+ st =
+ checkGenerated(aState,
+ "int1/act1\nint2/act2\nint3/act3\nint4/act4\nint5/act5",
+ false, false, false, 5, false);
+ checkChanged(st,
+ "int1/act1\nint5/act5\nint4/act4",
+ false, false, false, 3, false);
+ checkChanged(st,
+ "int5/act5\nint4/act4",
+ false, false, false, 2, false);
+ checkChanged(st,
+ "int6/act6\nint4/act4",
+ false, false, false, 2, false);
+ }
+
+ /**
+ * Check if the elements are generated or not.
+ *
+ * @param st the parent state in which a substate is to be created
+ * @param text the text to be parsed
+ * @param entryAction true if an entry action is expected to be created
+ * @param exitAction true if an exit action is expected to be created
+ * @param doAction true if an do activity is expected to be created
+ * @param internals the number of internal transitions
+ * expected to be created
+ * @param exception true if there is a syntax error
+ * and an exception is expected
+ * @return the internal state in which elements are created
+ */
+ private Object checkGenerated(Object st, String text, boolean entryAction,
+ boolean exitAction, boolean doAction,
+ int internals, boolean exception) {
+ Object sst =
+ Model.getStateMachinesFactory().buildSimpleState(st);
+ checkChanged(sst, text, entryAction, exitAction, doAction,
+ internals, exception);
+ return sst;
+ }
+
+ /**
+ * Check if the elements are changed or not.
+ *
+ * @param sst the state to test
+ * @param text the text to be parsed
+ * @param entryAction true if an entry action is expected to be created
+ * @param exitAction true if an exit action is expected to be created
+ * @param doAction true if an do activity is expected to be created
+ * @param internals the number of internal transitions
+ * expected to be created
+ * @param exception true if there is a syntax error
+ * and an exception is expected
+ */
+ private void checkChanged(Object sst, String text,
+ boolean entryAction, boolean exitAction,
+ boolean doAction, int internals, boolean exception) {
+ try {
+ StateBodyNotationUml sbn = new StateBodyNotationUml(sst);
+ sbn.parseStateBody(sst, text);
+ assertTrue("Expected exception did not happen.", !exception);
+ } catch (ParseException e) {
+ assertTrue("Unexpected exception for " + text, exception);
+ }
+ if (entryAction) {
+ assertTrue("Entry Action was not generated for " + text,
+ Model.getFacade().getEntry(sst) != null);
+ } else {
+ assertTrue("Entry Action was generated for " + text,
+ Model.getFacade().getEntry(sst) == null);
+ }
+ if (exitAction) {
+ assertTrue("Exit Action was not generated for " + text,
+ Model.getFacade().getExit(sst) != null);
+ } else {
+ assertTrue("Exit Action was generated for " + text,
+ Model.getFacade().getExit(sst) == null);
+ }
+ if (doAction) {
+ assertTrue("Do Action was not generated for " + text,
+ Model.getFacade().getDoActivity(sst) != null);
+ } else {
+ assertTrue("Do Action was generated for " + text,
+ Model.getFacade().getDoActivity(sst) == null);
+ }
+ Collection c = Model.getFacade().getInternalTransitions(sst);
+ assertTrue("Incorrect number of internal transitions (" + c.size()
+ + ") found for " + text,
+ c.size() == internals);
+ }
+
+ /**
+ * Test if help is correctly provided.
+ */
+ public void testGetHelp() {
+ StateBodyNotationUml notation = new StateBodyNotationUml(aState);
+ String help = notation.getParsingHelp();
+ assertTrue("No help at all given", help.length() > 0);
+ assertTrue("Parsing help not conform for translation",
+ help.startsWith("parsing."));
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestTransitionNotationUml.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestTransitionNotationUml.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/notation/providers/uml/TestTransitionNotationUml.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,340 @@
+// $Id:TestTransitionNotationUml.java 12987 2007-07-05 14:28:59Z mvw $
+// Copyright (c) 2004-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.notation.providers.uml;
+
+import java.text.ParseException;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.Model;
+import org.argouml.notation.NotationProvider;
+
+/**
+ * Test ParserDisplay: parsing transitions.
+ *
+ * @author MVW
+ *
+ */
+public class TestTransitionNotationUml extends TestCase {
+ private Object aClass;
+ private Object aStateMachine;
+ private Object aState;
+
+ /**
+ * The constructor.
+ *
+ * @param str the name
+ */
+ public TestTransitionNotationUml(String str) {
+ super(str);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() {
+ InitializeModel.initializeDefault();
+ assertTrue("Model subsystem init failed.", Model.isInitiated());
+ Project p = ProjectManager.getManager().getCurrentProject();
+ Object model =
+ Model.getModelManagementFactory().createModel();
+ aClass = Model.getCoreFactory().buildClass(model);
+ Object returnType = p.getDefaultReturnType();
+ Model.getCoreFactory().buildOperation2(aClass, returnType, "myOper");
+ aStateMachine =
+ Model.getStateMachinesFactory().buildStateMachine(aClass);
+ Object top = Model.getFacade().getTop(aStateMachine);
+ aState = Model.getStateMachinesFactory().buildCompositeState(top);
+ }
+
+
+ /**
+ * Test for the parseTransition() method.
+ * These should NOT generate a ParseException.
+ */
+ public void testParseTransitionCreate() {
+ checkGenerated(aState, "trigger[guard]/effect", true, true, true,
+ false);
+ checkGenerated(aState, "trigger[]/effect", true, false, true, false);
+ checkGenerated(aState, " tri gg er ( w ) [ ] / e ffect ", true, false,
+ true, false);
+ checkGenerated(aState, "trigger / effect", true, false, true, false);
+ checkGenerated(aState, "/effect", false, false, true, false);
+ checkGenerated(aState, "trigger", true, false, false, false);
+ checkGenerated(aState, "t(a:int=3, b=4.0:double)", true, false, false,
+ false);
+ checkGenerated(aState, "", false, false, false, false);
+ checkGenerated(aState, "[]/", false, false, false, false);
+ checkGenerated(aState, "[ guard ]", false, true, false, false);
+ checkGenerated(aState, "trigger()/", true, false, false, false);
+ }
+
+ /**
+ * Test for the parseTransition() method.
+ * These should generate a ParseException.
+ */
+ public void testParseTransitionNotCreate() {
+ checkGenerated(aState, "trigger[guard/effect", false, false, false,
+ true);
+ checkGenerated(aState, "trigger(", false, false, false, true);
+ checkGenerated(aState, "trigger)/eff()", false, false, false, true);
+ checkGenerated(aState, "trigger(/)", false, false, false, true);
+ checkGenerated(aState, "tr]jhgf[ijh", false, false, false, true);
+ checkGenerated(aState, "tr]/e", false, false, false, true);
+ checkGenerated(aState, "tr/i[gg]er", false, false, false, true);
+ checkGenerated(aState, "tri[g/g]er", false, false, false, true);
+ }
+
+ /**
+ * Check if the transition parts are generated or not. <p>
+ *
+ * An internal transition is chosen to test these cases,
+ * instead of a transition between states. Reason: simplicity.
+ *
+ * @param st the state in which to create an internal transition
+ * @param text the text to be parsed
+ * @param trigger true if we expect a trigger to be generated
+ * @param guard true if we expect a guard to be generated
+ * @param effect true if we expect an effect to be generated
+ * @param exception true if we expect an exception to be thrown
+ * @return the generated internal transition
+ */
+ private Object checkGenerated(Object st, String text, boolean trigger,
+ boolean guard, boolean effect, boolean exception) {
+ Object it =
+ Model.getStateMachinesFactory().buildInternalTransition(st);
+ TransitionNotationUml notation = new TransitionNotationUml(it);
+ try {
+ notation.parseTransition(it, text);
+ assertTrue("Expected exception did not happen.", !exception);
+ } catch (ParseException e) {
+ assertTrue("Unexpected exception: " + e.getMessage(),
+ exception);
+ }
+ if (trigger) {
+ assertTrue("Trigger was not generated for " + text,
+ Model.getFacade().getTrigger(it) != null);
+ } else {
+ assertTrue("Trigger was generated for " + text,
+ Model.getFacade().getTrigger(it) == null);
+ }
+ if (guard) {
+ assertTrue("Guard was not generated for " + text,
+ Model.getFacade().getGuard(it) != null);
+ } else {
+ assertTrue("Guard was generated for " + text,
+ Model.getFacade().getGuard(it) == null);
+ }
+ if (effect) {
+ assertTrue("Effect (action) was not generated for " + text,
+ Model.getFacade().getEffect(it) != null);
+ } else {
+ assertTrue("Effect (action) was generated for " + text,
+ Model.getFacade().getEffect(it) == null);
+ }
+ return it;
+ }
+
+ /**
+ * Test creating modelelements from a given notation, and then
+ * re-generate the notation-string again, and check if they are equal.
+ * Some of these tests are not very usefulll,
+ * since they may fail on white space differences.
+ * TODO: White space should best be ignored.
+ */
+ public void testRoundTrip() {
+ checkGenerateRoundTrip(aState, "trigger [guard] / effect");
+ checkGenerateRoundTrip(aState, "trigger / effect");
+ checkGenerateRoundTrip(aState, "trigger [guard]");
+ checkGenerateRoundTrip(aState, " [guard] / effect");
+ checkGenerateRoundTrip(aState, " / effect");
+ checkGenerateRoundTrip(aState, "trigger");
+ checkGenerateRoundTrip(aState, " [guard]");
+ checkGenerateRoundTrip(aState, "");
+ checkGenerateRoundTrip(aState, "t(a : int = 3, b : double = 4.0)");
+ checkGenerateRoundTrip(aState, " / effect(a:2,r=6)");
+ checkGenerateRoundTrip(aState, "trigger [guard] / eff1; eff2; eff3");
+ }
+
+ private void checkGenerateRoundTrip(Object st, String text) {
+ Object it =
+ Model.getStateMachinesFactory().buildInternalTransition(st);
+ TransitionNotationUml notation = new TransitionNotationUml(it);
+ try {
+ notation.parseTransition(it, text);
+ } catch (ParseException e) {
+ assertTrue("Unexpected exception: " + e.getMessage(), true);
+ }
+ // try creating a string from the generated modelelements:
+ String notationStr = notation.toString(it, null);
+ assertTrue("Notation not correctly generated for " + text + "\n"
+ + "Resulted in: '" + notationStr + "'",
+ text.equals(notationStr));
+ }
+
+ /**
+ * Test for the parseTrigger() method: TimeEvent.
+ * Also changing triggertype is tested.
+ */
+ public void testParseTriggerTimeEvent() {
+ Object trans;
+ Object trig;
+ String text;
+ Object expr;
+
+ //try creating a TimeEvent
+ text = "after(a while)";
+ trans =
+ checkGenerated(aState, text, true, false, false, false);
+ trig = Model.getFacade().getTrigger(trans);
+ assertTrue("Unexpected triggertype found instead of TimeEvent for "
+ + text, Model.getFacade().isATimeEvent(trig));
+ expr = Model.getFacade().getExpression(trig);
+ assertTrue("Incorrectly set TimeExpression for" + text,
+ Model.getFacade().getBody(expr).equals("a while"));
+
+
+ //try changing the triggertype to ChangeEvent
+ text = "when(it happens)";
+ NotationProvider notation = new TransitionNotationUml(trans);
+ notation.parse(trans, text);
+ trig = Model.getFacade().getTrigger(trans);
+ assertTrue("Unexpected triggertype found instead of ChangeEvent",
+ Model.getFacade().isAChangeEvent(trig));
+ }
+
+ /**
+ * Test for the parseTrigger() method: ChangeEvent.
+ * Testing creation and deletion.
+ */
+ public void testParseTriggerChangeEvent() {
+ Object trans;
+ Object trig;
+ String text;
+ Object expr;
+
+ text = "when(it changed)/effect";
+ trans = checkGenerated(aState, text, true, false, true, false);
+ trig = Model.getFacade().getTrigger(trans);
+ assertTrue("Unexpected triggertype found instead of ChangeEvent for "
+ + text, Model.getFacade().isAChangeEvent(trig));
+ expr = Model.getFacade().getExpression(trig);
+ assertTrue("Incorrectly set ChangeExpression for" + text,
+ Model.getFacade().getBody(expr).equals("it changed"));
+
+ text = "/effect";
+ TransitionNotationUml notation = new TransitionNotationUml(trans);
+ try {
+ notation.parseTransition(trans, text);
+ } catch (ParseException e) {
+ assertTrue("Unexpected exception when removing ChangeEvent trigger",
+ true);
+ }
+ trig = Model.getFacade().getTrigger(trans);
+ assertTrue("Trigger not deleted", trig != null);
+ }
+
+ /**
+ * Test for the parseTrigger() method: CallEvent.
+ */
+ public void testParseTriggerCallEvent() {
+ Object trans;
+ Object trig;
+ String text;
+
+ text = "call(a method)";
+ trans = checkGenerated(aState, text, true, false, false, false);
+ trig = Model.getFacade().getTrigger(trans);
+ assertTrue("Unexpected triggertype found instead of CallEvent for "
+ + text, Model.getFacade().isACallEvent(trig));
+
+ text = "call()";
+ trans = checkGenerated(aState, text, true, false, false, false);
+ trig = Model.getFacade().getTrigger(trans);
+ assertTrue("Unexpected triggertype found instead of CallEvent for "
+ + text, Model.getFacade().isACallEvent(trig));
+ }
+
+ /**
+ * Test for the parseTrigger() method: SignalEvent.
+ */
+ public void testParseTriggerSignalEvent() {
+ Object trans;
+ Object trig;
+ String text;
+
+ text = "signal";
+ trans = checkGenerated(aState, text, true, false, false, false);
+ trig = Model.getFacade().getTrigger(trans);
+ assertTrue("Unexpected triggertype found instead of SignalEvent",
+ Model.getFacade().isASignalEvent(trig));
+
+ text = "/effect";
+ TransitionNotationUml notation = new TransitionNotationUml(trans);
+ try {
+ notation.parseTransition(trans, text);
+ } catch (ParseException e) {
+ assertTrue("Unexpected exception when removing SignalEvent trigger",
+ true);
+ }
+ trig = Model.getFacade().getTrigger(trans);
+ assertTrue("Trigger not deleted", trig != null);
+ }
+
+ /**
+ * Test for the parseTrigger() method:
+ * linking of an Operation for a CallEvent.
+ */
+ public void testParseTriggerCallEventOperation() {
+ Object trans;
+ Object trig;
+ String text;
+ Object myOp;
+
+ text = "myOper()"; // this is an existing operation of the class!
+ trans = checkGenerated(aState, text, true, false, false, false);
+ trig = Model.getFacade().getTrigger(trans);
+ assertTrue("Unexpected triggertype found instead of CallEvent for "
+ + text, Model.getFacade().isACallEvent(trig));
+ myOp = Model.getFacade().getOperation(trig);
+ assertTrue("Operation of CallEvent not linked", myOp != null);
+ }
+
+ /**
+ * Test if help is correctly provided.
+ */
+ public void testGetHelp() {
+ Object it =
+ Model.getStateMachinesFactory().buildInternalTransition(aState);
+ TransitionNotationUml notation = new TransitionNotationUml(it);
+ String help = notation.getParsingHelp();
+ assertTrue("No help at all given", help.length() > 0);
+ assertTrue("Parsing help not conform for translation",
+ help.startsWith("parsing."));
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/persistence/TestPersistenceManager.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/persistence/TestPersistenceManager.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/persistence/TestPersistenceManager.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,101 @@
+// $Id:TestPersistenceManager.java 11236 2006-09-26 23:28:47Z bobtarling $
+// Copyright (c) 2006 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.persistence;
+
+import java.io.File;
+
+import javax.swing.JFileChooser;
+import javax.swing.filechooser.FileFilter;
+
+import junit.framework.TestCase;
+
+/**
+ * Test class for PersistenceManager. Actually, the only tested method is
+ * getPersisterFromFileName().
+ *
+ * @since Jun 2, 2006
+ * @author [email protected]
+ */
+public class TestPersistenceManager extends TestCase {
+
+ /**
+ * Constructor for TestPersistenceManager.
+ * @param arg0 is the name of the test case.
+ */
+ public TestPersistenceManager(String arg0) {
+ super(arg0);
+ }
+
+ /**
+ * Test if the getPersisterFromFileName returns a correct implementation.
+ *
+ */
+ public void testGetPersisterFromFileName() {
+ PersistenceManager persistence = PersistenceManager.getInstance();
+ AbstractFilePersister testPersister;
+
+ // test an unknown file
+ testPersister = persistence.getPersisterFromFileName(
+ "unknown.foo");
+ assertNull(testPersister);
+
+ // test project readable files
+ testPersister = persistence.getPersisterFromFileName(
+ "unknown." + new ZargoFilePersister().getExtension());
+ assertNotNull(testPersister);
+
+ testPersister = persistence.getPersisterFromFileName(
+ "unknown." + new XmiFilePersister().getExtension());
+ assertNotNull(testPersister);
+
+ testPersister = persistence.getPersisterFromFileName(
+ "unknown." + new XmlFilePersister().getExtension());
+ assertNotNull(testPersister);
+
+ testPersister = persistence.getPersisterFromFileName(
+ "unknown." + new UmlFilePersister().getExtension());
+ assertNotNull(testPersister);
+
+ testPersister = persistence.getPersisterFromFileName(
+ "unknown." + new ZipFilePersister().getExtension());
+ assertNotNull(testPersister);
+ }
+
+ public void testSetSaveFileChooserFilters() {
+ JFileChooser chooser = new JFileChooser();
+ PersistenceManager persistence = PersistenceManager.getInstance();
+ persistence.setSaveFileChooserFilters(chooser, null);
+
+ FileFilter[] fileFilters = chooser.getChoosableFileFilters();
+ assertNotNull(fileFilters);
+ assertEquals(4, fileFilters.length);
+ FileFilter defaultFileFilter = chooser.getFileFilter();
+ assertNotNull(defaultFileFilter);
+ assertTrue(defaultFileFilter.accept(new File(
+ "foo."
+ + new ZargoFilePersister().getExtension())));
+
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/persistence/TestXmiFilePersister.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/persistence/TestXmiFilePersister.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/persistence/TestXmiFilePersister.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,108 @@
+// $Id:TestXmiFilePersister.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 1996-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.persistence;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.Model;
+
+/**
+ * Testclass for the XMIReader. Placeholder for all saving/loading tests
+ * concerning XMIReader (like the dreaded ClassCastException issues).
+ *
+ * @author [email protected]
+ * @since Jan 17, 2003
+ */
+public class TestXmiFilePersister extends TestCase {
+
+ /**
+ * Constructor for TestXMIReader.
+ * @param arg0 is the name of the test case.
+ */
+ public TestXmiFilePersister(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * This is a regression test for issue 1504.
+ * Test basic serialization to XMI file.
+ */
+ public void testSave() {
+
+ try {
+ Project p = ProjectManager.getManager().makeEmptyProject();
+ Object clazz = Model.getCoreFactory().buildClass(p.getModel());
+ Object returnType =
+ ProjectManager.getManager()
+ .getCurrentProject().getDefaultReturnType();
+ Object oper =
+ Model.getCoreFactory().buildOperation(clazz, returnType);
+ Model.getCoreHelper().setType(
+ Model.getFacade().getParameter(oper, 0),
+ p.findType("String"));
+ File file = new File("test.xmi");
+ XmiFilePersister persister = new XmiFilePersister();
+ p.preSave();
+ persister.save(p, file);
+ p.postSave();
+ } catch (Exception e) {
+ fail("Save resulted in an exception");
+ }
+ }
+
+ /**
+ * This is a regression test for issue 1504.
+ * Test loading from minimal XMI file.
+ */
+ public void testLoadProject() {
+
+ try {
+ File file = new File("test.xmi");
+
+ XmiFilePersister persister = new XmiFilePersister();
+
+ ProjectManager.getManager().makeEmptyProject();
+
+ persister.doLoad(file);
+ } catch (OpenException e) {
+ fail("Load resulted in an exception");
+ } catch (InterruptedException e) {
+ fail("Load resulted in an exception");
+ }
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/persistence/TestZargoFilePersister.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/persistence/TestZargoFilePersister.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/persistence/TestZargoFilePersister.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,170 @@
+// $Id:TestZargoFilePersister.java 12987 2007-07-05 14:28:59Z mvw $
+// Copyright (c) 1996-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.persistence;
+
+import java.io.File;
+import java.net.URL;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.argouml.kernel.Project;
+import org.argouml.model.InitializeModel;
+import org.argouml.notation.InitNotation;
+import org.argouml.notation.providers.java.InitNotationJava;
+import org.argouml.notation.providers.uml.InitNotationUml;
+
+/**
+ * Testcase to load projects without exception.
+ */
+public class TestZargoFilePersister extends TestCase {
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ (new InitNotation()).init();
+ (new InitNotationUml()).init();
+ (new InitNotationJava()).init();
+ }
+
+ /**
+ * The constructor.
+ *
+ * @param name the name
+ */
+ public TestZargoFilePersister(String name) {
+ super(name);
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * @param args the arguments given on the commandline
+ */
+ public static void main(java.lang.String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ /**
+ * @return the test suite
+ */
+ public static Test suite() {
+ TestSuite suite = new TestSuite(TestZargoFilePersister.class);
+
+ return suite;
+ }
+
+ /**
+ * Tests that a project is loadable.
+ *
+ * @param filename of the project file to load
+ * @throws OpenException if something goes wrong.
+ */
+ private Project doLoad(String filename)
+ throws OpenException, InterruptedException {
+ URL url = TestZargoFilePersister.class.getResource(filename);
+ assertTrue("Unintended failure: resource to be tested is not found: "
+ + filename + ", converted to URL: " + url, url != null);
+ ZargoFilePersister persister = new ZargoFilePersister();
+ String name = url.getFile();
+ Project p = persister.doLoad(new File(name));
+ assertTrue("Load Status for " + filename + ".",
+ PersistenceManager.getInstance().getLastLoadStatus());
+ return p;
+ }
+
+ /**
+ * Test loading an old empty zargo.
+ *
+ * @throws Exception when e.g. the file is not found
+ */
+ public void testDoLoad1() throws Exception {
+ doLoad("/testmodels/uml13/Empty.zargo");
+ }
+
+ /**
+ * Test loading a new empty zargo.
+ *
+ * @throws Exception when e.g. the file is not found
+ */
+ public void testDoLoad1a() throws Exception {
+ doLoad("/testmodels/uml14/EmptyProject024.zargo");
+ }
+
+ /**
+ * Test loading UML 1.3 which needs to be upgraded on load zargo.
+ *
+ * @throws Exception when e.g. the file is not found
+ */
+ public void testDoLoad2() throws Exception {
+ doLoad("/testmodels/uml13/Alittlebitofeverything.zargo");
+ }
+
+ /**
+ * Test loading a native UML 1.4 zargo.
+ *
+ * @throws Exception when e.g. the file is not found
+ */
+ public void testDoLoad2a() throws Exception {
+ doLoad("/testmodels/uml14/Alittlebitofeverything.zargo");
+ }
+
+
+ /**
+ * Test saving a zargo.
+ *
+ * @throws Exception when e.g. the file is not found
+ */
+ public void testSave() throws Exception {
+ Project p = doLoad("/testmodels/uml13/Alittlebitofeverything.zargo");
+ ZargoFilePersister persister = new ZargoFilePersister();
+ persister.save(p, new File("Alittlebitofeverything2.zargo"));
+ }
+
+ /**
+ * Test loading some garbage in a zargo.
+ */
+ public void testLoadGarbage() {
+ File file = null;
+ boolean loaded = true;
+ try {
+ file = new File("/testmodels/Garbage.zargo");
+ ZargoFilePersister persister = new ZargoFilePersister();
+ persister.doLoad(file);
+ assertTrue("Load Status",
+ !PersistenceManager.getInstance().getLastLoadStatus());
+ } catch (OpenException io) {
+ // This is the normal case.
+ loaded = false;
+ } catch (InterruptedException iExc) {
+ // This should not happen!
+ loaded = false;
+ }
+ assertTrue("No exception was thrown.", !loaded);
+ }
+}
+
+
+
Added: branches/gsoc2007/b00__1/tests/org/argouml/persistence/package.html
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/persistence/package.html?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/persistence/package.html 2007-08-13 09:07:56-0700
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+ Copyright (c) 1996-99 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.
+-->
+</head>
+<body>
+<!--
+##### TYPE YOUR PACKAGE COMMENTS HERE. BEGIN WITH A #####
+##### ONE-SENTENCE SUMMARY STARTING WITH A VERB LIKE: #####
+Provides for....
+-->
+
+</body>
+</html>
Added: branches/gsoc2007/b00__1/tests/org/argouml/ui/GUITestMultiEditorPane.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/ui/GUITestMultiEditorPane.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/ui/GUITestMultiEditorPane.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,62 @@
+// $Id:GUITestMultiEditorPane.java 12485 2007-05-03 05:59:35Z linus $
+// Copyright (c) 1996-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.ui;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+/**
+ * @author [email protected]
+ * @since Apr 13, 2003
+ */
+public class GUITestMultiEditorPane extends TestCase {
+
+ /**
+ * Constructor for TestMultiEditorPane.
+ *
+ * @param arg0 is the test case name.
+ */
+ public GUITestMultiEditorPane(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Tests the construction of the multieditorpane. Can we construct a
+ * multieditorpane and even have an editor in it?
+ */
+ public void testConstruction() {
+ MultiEditorPane pane = new MultiEditorPane();
+ assertNotNull(pane);
+ assertEquals(pane.getComponents().length, 1);
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/ui/GUITestProjectBrowser.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/ui/GUITestProjectBrowser.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/ui/GUITestProjectBrowser.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,186 @@
+// $Id:GUITestProjectBrowser.java 12485 2007-05-03 05:59:35Z linus $
+// Copyright (c) 2002-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.ui;
+
+import java.beans.PropertyVetoException;
+
+import javax.swing.Action;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.Model;
+import org.argouml.ui.cmd.ActionNew;
+import org.argouml.ui.targetmanager.TargetManager;
+import org.argouml.uml.diagram.static_structure.ui.UMLClassDiagram;
+
+/**
+ * Testing the ProjectBrowser.
+ * The reason for this being a GUITest is that all the tests rely on
+ * that the ProjectBrowser can be created and it can only be created
+ * if there is a real gui available.
+ *
+ * @since Nov 23, 2002
+ * @author [email protected]
+ */
+public class GUITestProjectBrowser extends TestCase {
+
+ /**
+ * Constructor.
+ *
+ * @param arg0 name of the test case
+ */
+ public GUITestProjectBrowser(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Tests that the projectbrowser is created or can be created.
+ * Also test that everything is set up properly within the object.
+ */
+ public void testConstruction() {
+ assertNotNull(ProjectBrowser.getInstance());
+ ProjectBrowser pb = ProjectBrowser.getInstance();
+ assertNotNull(pb.getLocale());
+ assertNotNull(pb.getAppName());
+ assertNotNull(pb.getTabProps());
+ assertNotNull(pb.getStatusBar());
+ assertNotNull(pb.getJMenuBar());
+ assertNotNull(pb.getEditorPane());
+ assertNotNull(pb.getTodoPane());
+ }
+
+ /**
+ * Test the AppName.
+ */
+ public void testAppName() {
+ ProjectBrowser pb = ProjectBrowser.getInstance();
+
+ pb.setAppName("Gurkburk");
+ assertEquals("Gurkburk", pb.getAppName());
+ }
+
+ /**
+ * Test the existance of public static members.
+ */
+ public void compileTestPublicStaticMembers() {
+ new Integer(ProjectBrowser.DEFAULT_COMPONENTWIDTH
+ + ProjectBrowser.DEFAULT_COMPONENTHEIGHT);
+ }
+
+ /**
+ * Test the existance of public members.
+ */
+ public void compileTestPublicMembers() {
+ assertNotNull(ProjectBrowser.getInstance().getDefaultFont());
+ }
+
+
+ /**
+ * Testing the setTarget method in ProjectBrowser.
+ */
+ public void testSetTarget() {
+ Project p = ProjectManager.getManager().getCurrentProject();
+ Object package1 =
+ Model.getModelManagementFactory().buildPackage("test1", null);
+ Object package2 =
+ Model.getModelManagementFactory().buildPackage("test2", null);
+ UMLClassDiagram diagram1 = new UMLClassDiagram(package1);
+ UMLClassDiagram diagram2 = new UMLClassDiagram(package2);
+ p.addMember(diagram1);
+ p.addMember(diagram2);
+
+ TargetManager tm = TargetManager.getInstance();
+
+ tm.setTarget(diagram1);
+ assertEquals("Diagram1 should be the target", diagram1, tm.getTarget());
+
+ tm.setTarget(diagram2);
+ assertEquals("Diagram2 should be the target", diagram2, tm.getTarget());
+
+ p.moveToTrash(package2);
+ Model.getPump().flushModelEvents();
+ assertEquals("The target is not reset to the first diagram",
+ p.getDiagrams().get(0), tm.getTarget());
+ }
+
+ /**
+ * Testing the Window Title of the ProjectBrowser.
+ */
+ public void testSetTitle() {
+ Project p = ProjectManager.getManager().getCurrentProject();
+ ProjectBrowser pb = ProjectBrowser.getInstance();
+ TargetManager tm = TargetManager.getInstance();
+
+ Object package1 =
+ Model.getModelManagementFactory().buildPackage("test1", null);
+ Object package2 =
+ Model.getModelManagementFactory().buildPackage("test2", null);
+ UMLClassDiagram diagram1 = new UMLClassDiagram(package1);
+ UMLClassDiagram diagram2 = new UMLClassDiagram(package2);
+ try {
+ diagram1.setName("diagram1");
+ diagram2.setName("diagram2");
+ } catch (PropertyVetoException e) {
+ assertNotNull("PropertyVetoException " + e, e);
+ }
+
+ p.addMember(diagram1);
+ p.addMember(diagram2);
+
+ Model.getPump().flushModelEvents();
+
+ tm.setTarget(diagram1);
+ assertTrue("Title should contain diagram1 name",
+ pb.getTitle().indexOf(diagram1.getName()) != -1);
+
+ tm.setTarget(diagram2);
+ assertTrue("Title should contain diagram2 name",
+ pb.getTitle().indexOf(diagram2.getName()) != -1);
+
+ assertTrue("Title should contain application name",
+ pb.getTitle().indexOf("Gurkburk") != -1);
+
+ assertTrue("Title should contain *",
+ pb.getTitle().indexOf("*") != -1);
+
+ Action a = new ActionNew();
+ a.putValue("non-interactive", Boolean.TRUE);
+ a.actionPerformed(null);
+
+ assertTrue("Title should not contain *",
+ pb.getTitle().indexOf("*") == -1);
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/ui/TestDetailsPane.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/ui/TestDetailsPane.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/ui/TestDetailsPane.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,128 @@
+// $Id:TestDetailsPane.java 12925 2007-06-29 19:26:52Z mvw $
+// Copyright (c) 1996-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.ui;
+
+import javax.swing.JPanel;
+
+import junit.framework.TestCase;
+
+import org.argouml.cognitive.ui.TabToDo;
+import org.argouml.model.InitializeModel;
+import org.argouml.model.Model;
+import org.argouml.ui.targetmanager.TargetEvent;
+import org.argouml.ui.targetmanager.TargetManager;
+import org.argouml.uml.diagram.static_structure.ui.UMLClassDiagram;
+import org.argouml.uml.ui.TabProps;
+import org.tigris.swidgets.Horizontal;
+
+/**
+ * @author [email protected]
+ * Jul 21, 2003
+ */
+public class TestDetailsPane extends TestCase {
+
+ /**
+ * @param arg0 is the name of the test case.
+ */
+ public TestDetailsPane(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test setting a target.
+ */
+ public void testTargetSet() {
+ DetailsPane pane = new DetailsPane("detail", Horizontal.getInstance());
+ JPanel todoPane = pane.getTab(TabToDo.class);
+ JPanel propertyPane = pane.getTab(TabProps.class);
+// JPanel docPane = pane.getTab(TabDocumentation.class);
+
+ assertNotNull(todoPane);
+ assertNotNull(propertyPane);
+
+ Object o = new Object();
+ TargetEvent e =
+ new TargetEvent(
+ this,
+ TargetEvent.TARGET_SET,
+ new Object[] {
+ null,
+ },
+ new Object[] {
+ o,
+ });
+ pane.targetSet(e);
+ assertEquals("1:", todoPane, pane.getTabs().getSelectedComponent());
+ UMLClassDiagram diagram = new UMLClassDiagram();
+ e =
+ new TargetEvent(
+ this,
+ TargetEvent.TARGET_SET,
+ new Object[] {
+ o,
+ },
+ new Object[] {
+ diagram,
+ });
+ pane.getTabs().setSelectedComponent(todoPane);
+ TargetManager.getInstance().setTarget(diagram);
+ pane.targetSet(e);
+ assertEquals("2:", propertyPane, pane.getTabs().getSelectedComponent());
+ Object clazz = Model.getCoreFactory().createClass();
+ e =
+ new TargetEvent(this,
+ TargetEvent.TARGET_SET,
+ new Object[] {
+ diagram,
+ },
+ new Object[] {
+ clazz,
+ });
+ pane.targetSet(e);
+ assertEquals("3:", propertyPane, pane.getTabs().getSelectedComponent());
+ pane.getTabs().setSelectedComponent(todoPane);
+ pane.targetSet(e);
+ assertEquals("4:", propertyPane, pane.getTabs().getSelectedComponent());
+ // TODO: at the moment setSelectedComponent doesn't take into account
+ // the rather complex tab selection mechanism of DetailsPane. The tab
+ // selection mechanism must be refactored.
+ /*
+ * commented out next piece to remove failure of testcase. The testcase
+ * is probably correct but the implementation of DetailsPane is not
+
+ pane.getTabs().setSelectedComponent(docPane);
+ pane.targetSet(e);
+ assertEquals(docPane, pane.getTabs().getSelectedComponent());
+ */
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/ui/TestMultiEditorPane.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/ui/TestMultiEditorPane.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/ui/TestMultiEditorPane.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,133 @@
+// $Id:TestMultiEditorPane.java 10734 2006-06-11 15:43:58Z mvw $
+// Copyright (c) 1996-2006 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.ui;
+
+import java.awt.Component;
+
+import javax.swing.JTabbedPane;
+
+import junit.framework.TestCase;
+
+import org.argouml.model.Model;
+import org.argouml.ui.targetmanager.TargetEvent;
+import org.argouml.uml.diagram.static_structure.ui.UMLClassDiagram;
+import org.tigris.gef.presentation.FigText;
+
+/**
+ * @author [email protected]
+ * @since Apr 13, 2003
+ */
+public class TestMultiEditorPane extends TestCase {
+
+ /**
+ * Constructor for TestMultiEditorPane.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestMultiEditorPane(String arg0) {
+ super(arg0);
+ }
+
+ /**
+ * Test setting a target.
+ */
+ public void testTargetSet() {
+ try {
+ MultiEditorPane pane = new MultiEditorPane();
+ Component[] tabs = pane.getTabs().getComponents();
+ Object target = new Object();
+ boolean[] shouldBeEnabled = getShouldBeEnabled(target, tabs);
+ TargetEvent e =
+ new TargetEvent(this,
+ TargetEvent.TARGET_SET,
+ new Object[] {
+ null,
+ },
+ new Object[] {
+ target,
+ });
+ pane.targetSet(e);
+ assertEnabled(pane.getTabs(), shouldBeEnabled);
+ target = new UMLClassDiagram();
+ shouldBeEnabled = getShouldBeEnabled(target, tabs);
+ e = new TargetEvent(
+ this,
+ TargetEvent.TARGET_SET,
+ new Object[] {
+ null,
+ },
+ new Object[] {
+ target
+ });
+ pane.targetSet(e);
+ assertEnabled(pane.getTabs(), shouldBeEnabled);
+ target = Model.getCoreFactory().createClass();
+ shouldBeEnabled = getShouldBeEnabled(target, tabs);
+ e =
+ new TargetEvent(this,
+ TargetEvent.TARGET_SET,
+ new Object[] {
+ null,
+ },
+ new Object[] {
+ target,
+ });
+ pane.targetSet(e);
+ assertEnabled(pane.getTabs(), shouldBeEnabled);
+ target = new FigText(0, 0, 0, 0);
+ shouldBeEnabled = getShouldBeEnabled(target, tabs);
+ e = new TargetEvent(this,
+ TargetEvent.TARGET_SET,
+ new Object[] {
+ null,
+ },
+ new Object[] {
+ target,
+ });
+ pane.targetSet(e);
+ assertEnabled(pane.getTabs(), shouldBeEnabled);
+ } catch (Exception ex) {
+ // on a headless system (without display) this will crash
+ }
+ }
+
+ private boolean[] getShouldBeEnabled(Object target, Component[] tabs) {
+ boolean[] shouldBeEnabled = new boolean[tabs.length];
+ for (int i = 0; i < tabs.length; i++) {
+ shouldBeEnabled[i] = ((TabTarget) tabs[i]).shouldBeEnabled(target);
+ }
+ return shouldBeEnabled;
+ }
+
+ private void assertEnabled(
+ JTabbedPane tabbedPane,
+ boolean[] shouldBeEnabled) {
+ for (int i = 0; i < shouldBeEnabled.length; i++) {
+ assertEquals(shouldBeEnabled[i], tabbedPane.isEnabledAt(i));
+ }
+ }
+
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/ui/TestPropertyPanels.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/ui/TestPropertyPanels.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/ui/TestPropertyPanels.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,256 @@
+// $Id:TestPropertyPanels.java 12987 2007-07-05 14:28:59Z mvw $
+// Copyright (c) 1996-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.ui;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.InitializeModel;
+import org.argouml.model.Model;
+import org.argouml.notation.InitNotation;
+import org.argouml.notation.providers.java.InitNotationJava;
+import org.argouml.notation.providers.uml.InitNotationUml;
+import org.argouml.persistence.AbstractFilePersister;
+import org.argouml.persistence.PersistenceManager;
+import org.argouml.ui.targetmanager.TargetEvent;
+import org.argouml.uml.ui.TabProps;
+import org.tigris.swidgets.Horizontal;
+
+/**
+ * TestPropertyPanels attempts to load a project file and iterates through
+ * all known modelelements of this project. For each modelelement it creates
+ * a test case, which tries to invoke the according property panel.
+ * This test implements a simple verification that creation of property panels
+ * is at least exception free. It does not provide a test for the functionality
+ * of the respective modelelements.
+ *
+ * @author mkl
+ */
+public class TestPropertyPanels extends TestCase {
+
+ /**
+ * Name of the zargo file to read.
+ */
+ private static final String TEST_PROPERTY_PANELS_ZARGO =
+ "/testmodels/uml14/GUITestPropertyPanels.zargo";
+
+ private static Project p = null;
+ private Object modelElement;
+
+ /**
+ * For an explanation on why this is static.
+ *
+ * @see #setUp
+ */
+ private static DetailsPane theDetailsPane = null;
+ // private JPanel propertyPane;
+
+ /**
+ * @param me is the type of object to test
+ * @param arg0 is the name of the test case
+ */
+ public TestPropertyPanels(Object me, String arg0) {
+ super(arg0);
+ modelElement = me;
+ }
+
+ /*
+ * Here we are actually violating the test independance since we keep
+ * the DetailsPane from test to test. The reason to do this is to make
+ * it possible to run the tests with less memory requirements.
+ *
+ * Hopefully someone might eventually fix the DetailsPane so that it is
+ * garbage collected properly and this is no longer needed.
+ *
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ (new InitNotation()).init();
+ (new InitNotationUml()).init();
+ (new InitNotationJava()).init();
+
+ if (theDetailsPane == null) {
+ theDetailsPane =
+ new DetailsPane("detail", Horizontal.getInstance());
+ }
+ }
+
+ /**
+ * @param args the arguments given on the commandline
+ */
+ public static void main(java.lang.String[] args) {
+ try {
+ junit.textui.TestRunner.run(suite());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ /**
+ * @return the test suite
+ * @throws Exception any exception
+ */
+ public static Test suite() throws Exception {
+ InitializeModel.initializeDefault();
+ new InitNotation().init();
+ (new InitNotationUml()).init();
+ (new InitNotationJava()).init();
+
+
+ // constains instances of each modelelement
+ // used for testing so that we only use each modelelement
+ // once
+ HashMap<Class, Object> meMap = new HashMap<Class, Object>();
+
+ TestSuite suite =
+ new TestSuite("Tests to access proppanels "
+ + "for all known model elements");
+
+ p = ProjectManager.getManager().makeEmptyProject();
+ URL url =
+ TestPropertyPanels.class.getResource(
+ TEST_PROPERTY_PANELS_ZARGO);
+
+ if (url == null) {
+ System.out.println(TestPropertyPanels.class.getName()
+ + ": WARNING: Inconclusive tests.");
+ System.out.println("This test must be able to"
+ + " find the resource " + TEST_PROPERTY_PANELS_ZARGO
+ + " on the classpath.");
+ System.out.println("Examine your set up and try again!");
+ return suite;
+ }
+
+ File testfile = new File(url.getFile());
+
+ AbstractFilePersister persister =
+ PersistenceManager.getInstance().getPersisterFromFileName(
+ TEST_PROPERTY_PANELS_ZARGO);
+ p = persister.doLoad(testfile);
+ ProjectManager.getManager().setCurrentProject(p);
+ Object model = p.getRoot();
+ Collection me =
+ Model.getModelManagementHelper()
+ .getAllModelElementsOfKind(
+ model,
+ Model.getMetaTypes().getModelElement());
+
+ Iterator meIter = me.iterator();
+
+ while (meIter.hasNext()) {
+ Object obj = meIter.next();
+ if (Model.getFacade().isAUMLElement(obj)) {
+ if (!meMap.containsKey(obj.getClass())) {
+ suite.addTest(new TestPropertyPanels(
+ obj,
+ "PropPanel"
+ + Model.getFacade().getUMLClassName(obj)));
+ meMap.put(obj.getClass(), obj);
+ }
+ }
+ }
+
+ return suite;
+ }
+
+
+
+ /*
+ * @see junit.framework.TestCase#runTest()
+ */
+ protected void runTest() throws Throwable {
+ testPropertyTab();
+ }
+
+ /**
+ * @throws Throwable any error or exception
+ */
+ public void testPropertyTab() throws Throwable {
+ TargetEvent e =
+ new TargetEvent(this,
+ TargetEvent.TARGET_SET,
+ new Object[] {
+ null,
+ },
+ new Object[] {
+ modelElement,
+ });
+ theDetailsPane.targetSet(e);
+
+ // propertyPane = /*TabProps */
+ theDetailsPane.getTab(TabProps.class);
+// theDetailsPane.getNamedTab(Translator.localize("tab.properties"));
+
+ // currently this is in this try block as it does not work
+ // _propertyPanel always has size 0,0
+ /*
+ try {
+ saveImageAsJPEG((BufferedImage)createImageFromComponent(
+ _propertyPane),
+ 1000000, "/Users/mkl/argoimg/"+this.getName() + ".jpg");
+ }
+ catch (Exception ex) {
+ // System.out.println(ex);
+ }
+ */
+ }
+ /*
+ public static Image createImageFromComponent(Component comp) {
+ BufferedImage image = new BufferedImage(comp.getWidth(),
+ comp.getHeight(), BufferedImage.TYPE_INT_BGR);
+ Graphics2D g = image.createGraphics();
+ comp.paint(g);
+ return image;
+ }
+
+
+ public static void saveImageAsJPEG(BufferedImage bi, float quality,
+ String filename) {
+ try {
+ ByteArrayOutputStream boutstream = new ByteArrayOutputStream();
+ JPEGImageEncoder enc = JPEGCodec.createJPEGEncoder(boutstream);
+ JPEGEncodeParam enparam = JPEGCodec.getDefaultJPEGEncodeParam(bi);
+ enparam.setQuality(quality, true );
+ enc.encode(bi, enparam);
+ FileOutputStream fimage = new FileOutputStream( new File(filename));
+ boutstream.writeTo(fimage);
+ fimage.close();
+ }
+ catch (Exception e) {
+ System.out.println(e); }
+ }
+ */
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/ui/TestStylePanel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/ui/TestStylePanel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/ui/TestStylePanel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,138 @@
+// $Id:TestStylePanel.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 1996-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.ui;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.model.Model;
+import org.argouml.ui.targetmanager.TargetEvent;
+import org.argouml.uml.diagram.static_structure.ui.UMLClassDiagram;
+import org.tigris.gef.presentation.FigText;
+
+/**
+ * @author [email protected]
+ * Jul 27, 2003
+ */
+public class TestStylePanel extends TestCase {
+
+ class MockStylePanel extends StylePanel {
+
+ private boolean refreshCalled = false;
+
+ public MockStylePanel() {
+ super("mock");
+ }
+
+ /*
+ * @see org.argouml.ui.TabTarget#refresh()
+ */
+ public void refresh() {
+ super.refresh();
+ refreshCalled = true;
+ }
+
+ /**
+ * @return Returns the refreshCalled.
+ */
+ boolean isRefreshCalled() {
+ return refreshCalled;
+ }
+
+ }
+
+ /**
+ * @param arg0 is the name of the test case.
+ */
+ public TestStylePanel(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test setting a target.
+ */
+ public void testTargetSet() {
+
+ StylePanel pane = new MockStylePanel();
+ Object target = new Object();
+ TargetEvent e =
+ new TargetEvent(this,
+ TargetEvent.TARGET_SET,
+ new Object[] {
+ null,
+ },
+ new Object[] {
+ target,
+ });
+ pane.targetSet(e);
+ // new target is of type object, refresh should not be called
+ assertTrue(!((MockStylePanel) pane).isRefreshCalled());
+ target = new UMLClassDiagram();
+ e = new TargetEvent(this,
+ TargetEvent.TARGET_SET,
+ new Object[] {
+ null,
+ },
+ new Object[] {
+ target,
+ });
+ pane.targetSet(e);
+ // new target is of type UMLClassDiagram, refresh should not be called
+ assertTrue(!((MockStylePanel) pane).isRefreshCalled());
+ target = Model.getCoreFactory().createClass();
+ e = new TargetEvent(this,
+ TargetEvent.TARGET_SET,
+ new Object[] {
+ null,
+ },
+ new Object[] {
+ target,
+ });
+ pane.targetSet(e);
+ // new target is a modelelement, refresh should not be called
+ assertTrue(!((MockStylePanel) pane).isRefreshCalled());
+ target = new FigText(0, 0, 0, 0);
+ e = new TargetEvent(this,
+ TargetEvent.TARGET_SET,
+ new Object[] {
+ null,
+ },
+ new Object[] {
+ target,
+ });
+ pane.targetSet(e);
+ // new target is a fig, refresh should be called
+ assertTrue(((MockStylePanel) pane).isRefreshCalled());
+
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/ui/cmd/GUITestActionGotoDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/ui/cmd/GUITestActionGotoDiagram.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/ui/cmd/GUITestActionGotoDiagram.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,82 @@
+// $Id:GUITestActionGotoDiagram.java 12485 2007-05-03 05:59:35Z linus $
+// Copyright (c) 2004-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.ui.cmd;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.util.CheckMain;
+
+/**
+ * Tests the change of diagram from the command line.
+ */
+public class GUITestActionGotoDiagram extends TestCase {
+ private static final String OUTPUT_FILE1 = "test-out1.gif";
+ private static final String OUTPUT_FILE2 = "test-out2.gif";
+
+ /**
+ * Constructor for GUITestActionGotoDiagram.
+ * @param name The name of the test case.
+ */
+ public GUITestActionGotoDiagram(String name) {
+ super(name);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test dumping a named diagram from a project with contents.
+ */
+ public void testProjectWithContents() {
+ File file =
+ CheckMain.getTestModel(
+ "testmodels/uml14/GUITestPropertyPanels.zargo");
+
+ List<String> c = new ArrayList<String>();
+ c.add("org.argouml.uml.ui.ActionOpenProject=" + file.toString());
+ c.add("org.argouml.uml.ui.ActionSaveGraphics=" + OUTPUT_FILE1);
+ c.add("org.argouml.ui.cmd.ActionGotoDiagram=Deployment Diagram 1");
+ c.add("org.argouml.uml.ui.ActionSaveGraphics=" + OUTPUT_FILE2);
+ CheckMain.doCommand(c);
+
+ assertTrue(new File(OUTPUT_FILE1).exists());
+ assertTrue(new File(OUTPUT_FILE2).exists());
+
+ // TODO: We could check that the contents of the files differ.
+
+ new File(OUTPUT_FILE1).delete();
+ new File(OUTPUT_FILE2).delete();
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/ui/cmd/package.html
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/ui/cmd/package.html?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/ui/cmd/package.html 2007-08-13 09:07:56-0700
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+ Copyright (c) 1996-2004 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.
+-->
+</head>
+<body bgcolor="white">
+<!--
+##### TYPE YOUR PACKAGE COMMENTS HERE. BEGIN WITH A #####
+##### ONE-SENTENCE SUMMARY STARTING WITH A VERB LIKE: #####
+Provides for....
+-->
+
+</body>
+</html>
Added: branches/gsoc2007/b00__1/tests/org/argouml/ui/package.html
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/ui/package.html?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/ui/package.html 2007-08-13 09:07:56-0700
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+ Copyright (c) 1996-99 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.
+-->
+</head>
+<body bgcolor="white">
+<!--
+##### TYPE YOUR PACKAGE COMMENTS HERE. BEGIN WITH A #####
+##### ONE-SENTENCE SUMMARY STARTING WITH A VERB LIKE: #####
+Provides for....
+-->
+
+</body>
+</html>
Added: branches/gsoc2007/b00__1/tests/org/argouml/ui/targetmanager/TestTargetManager.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/ui/targetmanager/TestTargetManager.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/ui/targetmanager/TestTargetManager.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,802 @@
+// $Id:TestTargetManager.java 13007 2007-07-09 20:19:26Z tfmorris $
+// Copyright (c) 2002-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.ui.targetmanager;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.InitializeModel;
+import org.argouml.model.Model;
+import org.argouml.uml.diagram.ArgoDiagram;
+import org.argouml.uml.diagram.ArgoDiagramImpl;
+import org.tigris.gef.presentation.Fig;
+import org.tigris.gef.presentation.FigNode;
+import org.tigris.gef.presentation.FigRect;
+
+/**
+ * @author gebruiker
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class TestTargetManager extends TestCase {
+
+ private boolean targetAddedCalled;
+ private Object targetAddedTarget;
+ private Fig targetAddedFigTarget;
+ private Object targetAddedModelTarget;
+ private Object targetAddedObjects[];
+ private boolean targetSetCalled;
+ private Object targetSetTarget;
+ private Fig targetSetFigTarget;
+ private Object targetSetModelTarget;
+ private Object targetSetObjects[];
+ private boolean targetRemovedCalled;
+ private Object targetRemovedTarget;
+ private Fig targetRemovedFigTarget;
+ private Object targetRemovedModelTarget;
+ private Object targetRemovedObjects[];
+
+ private class TestTargetListener implements TargetListener {
+
+ /*
+ * @see TargetListener#targetAdded(TargetEvent)
+ */
+ public void targetAdded(TargetEvent e) {
+ targetAddedCalled = true;
+ targetAddedTarget = TargetManager.getInstance().getTarget();
+ targetAddedFigTarget = TargetManager.getInstance().getFigTarget();
+ targetAddedModelTarget =
+ TargetManager.getInstance().getModelTarget();
+ targetAddedObjects = e.getNewTargets();
+ }
+
+ /*
+ * @see TargetListener#targetRemoved(TargetEvent)
+ */
+ public void targetRemoved(TargetEvent e) {
+ targetRemovedCalled = true;
+ targetRemovedTarget = TargetManager.getInstance().getTarget();
+ targetRemovedFigTarget = TargetManager.getInstance().getFigTarget();
+ targetRemovedModelTarget =
+ TargetManager.getInstance().getModelTarget();
+ targetRemovedObjects = e.getNewTargets();
+ }
+
+ /*
+ * @see TargetListener#targetSet(TargetEvent)
+ */
+ public void targetSet(TargetEvent e) {
+ targetSetCalled = true;
+ targetSetTarget = TargetManager.getInstance().getTarget();
+ targetSetFigTarget = TargetManager.getInstance().getFigTarget();
+ targetSetModelTarget = TargetManager.getInstance().getModelTarget();
+ targetSetObjects = e.getNewTargets();
+ }
+
+ }
+
+ /**
+ * @param arg0 is the name of the test case.
+ */
+ public TestTargetManager(String arg0) {
+ super(arg0);
+ }
+
+ /**
+ * Test getInstance().
+ */
+ public void testGetInstance() {
+
+ Runnable[] runnables = new Runnable[50];
+ final TargetManager manager = TargetManager.getInstance();
+ for (int i = 0; i < 50; i++) {
+ runnables[i] = new Runnable()
+ {
+ public void run() {
+ assertEquals(manager, TargetManager.getInstance());
+ }
+ };
+
+ }
+ Thread[] threads = new Thread[50];
+ for (int i = 0; i < 50; i++) {
+ threads[i] = new Thread(runnables[i]);
+ threads[i].start();
+ }
+ for (int i = 0; i < 50; i++) {
+ try {
+ threads[i].join();
+ } catch (InterruptedException e) {
+ }
+ }
+ assertTrue(TargetManager.getInstance() != null);
+ }
+
+ /**
+ * Test setTarget().
+ */
+ public void testSetTarget() {
+ Object test = new Object();
+ assertEquals(null, TargetManager.getInstance().getTarget());
+ TargetManager.getInstance().setTarget(test);
+ assertEquals(test, TargetManager.getInstance().getTarget());
+ TargetManager.getInstance().setTarget(null);
+ assertEquals(null, TargetManager.getInstance().getTarget());
+
+ TargetListener listener = new TestTargetListener();
+ TargetManager.getInstance().addTargetListener(listener);
+ targetSetCalled = false;
+ targetSetObjects = null;
+ TargetManager.getInstance().setTarget(test);
+ assertTrue(targetSetCalled);
+ assertTrue(Arrays.equals(new Object[] {test}, targetSetObjects));
+ targetSetCalled = false;
+ TargetManager.getInstance().setTarget(test);
+ assertTrue(!targetSetCalled);
+
+ TargetManager.getInstance().removeTargetListener(listener);
+ }
+
+ /**
+ * Test getTarget().
+ */
+ public void testGetTarget() {
+ TargetListener listener = new TestTargetListener();
+ assertEquals(null, TargetManager.getInstance().getTarget());
+ Object test = new Object();
+ TargetManager.getInstance().setTarget(test);
+ assertEquals(test, TargetManager.getInstance().getTarget());
+
+ TargetManager.getInstance().addTargetListener(listener);
+
+ targetSetTarget = null;
+ TargetManager.getInstance().setTarget(null);
+ assertEquals(null, targetSetTarget);
+
+ targetSetTarget = null;
+ TargetManager.getInstance().setTarget(test);
+ assertEquals(test, targetSetTarget);
+
+ TargetManager.getInstance().setTarget(null);
+ targetAddedTarget = null;
+ TargetManager.getInstance().addTarget(test);
+ assertEquals(test, targetAddedTarget);
+ targetRemovedTarget = null;
+ TargetManager.getInstance().removeTarget(test);
+ assertEquals(null, targetRemovedTarget);
+
+ TargetManager.getInstance().removeTargetListener(listener);
+ }
+
+ /**
+ * Test getTargets().
+ */
+ public void testGetTargets() {
+ Collection<Object> coll, coll2;
+ Object test = new Object();
+ Object test2 = new Object();
+ HashSet<Object> set1 = new HashSet<Object>();
+ set1.add(test);
+ HashSet<Object> set2 = new HashSet<Object>(set1);
+ set2.add(test2);
+
+ TargetManager.getInstance().setTarget(null);
+ assertTrue(TargetManager.getInstance().getTargets().isEmpty());
+ TargetManager.getInstance().setTarget(test);
+ assertEquals(
+ new HashSet<Object>(TargetManager.getInstance().getTargets()),
+ set1);
+ TargetManager.getInstance().setTarget(null);
+ assertTrue(TargetManager.getInstance().getTargets().isEmpty());
+
+ TargetManager.getInstance().setTargets(set2); //TabProps gets selected!
+ TargetManager.getInstance().setTargets(set2); //So, 2nd time right
+ coll = TargetManager.getInstance().getTargets();
+ assertTrue(coll.size() == set2.size());
+ coll2 = new HashSet<Object>(coll);
+ assertEquals(coll2, set2);
+
+ TargetManager.getInstance().setTargets(set1);
+ coll = TargetManager.getInstance().getTargets();
+ coll2 = new HashSet<Object>(coll);
+ assertTrue(coll.size() == set1.size());
+ assertEquals(coll2, set1);
+
+ TargetManager.getInstance().setTargets(new HashSet<Object>());
+ assertTrue(TargetManager.getInstance().getTargets().isEmpty());
+
+ TargetManager.getInstance().addTarget(null);
+ assertTrue(TargetManager.getInstance().getTargets().isEmpty());
+
+ TargetManager.getInstance().addTarget(test);
+ coll = TargetManager.getInstance().getTargets();
+ coll2 = new HashSet<Object>(coll);
+ assertTrue(coll.size() == set1.size());
+ assertEquals(coll2, set1);
+
+ TargetManager.getInstance().addTarget(test2);
+ coll = TargetManager.getInstance().getTargets();
+ coll2 = new HashSet<Object>(coll);
+ assertTrue(coll.size() == set2.size());
+ assertEquals(coll2, set2);
+
+ TargetManager.getInstance().removeTarget(null);
+ coll = TargetManager.getInstance().getTargets();
+ coll2 = new HashSet<Object>(coll);
+ assertTrue(coll.size() == set2.size());
+ assertEquals(coll2, set2);
+
+ TargetManager.getInstance().removeTarget(test2);
+ coll = TargetManager.getInstance().getTargets();
+ coll2 = new HashSet<Object>(coll);
+ assertTrue(coll.size() == set1.size());
+ assertEquals(coll2, set1);
+
+ TargetManager.getInstance().removeTarget(test);
+ assertTrue(TargetManager.getInstance().getTargets().isEmpty());
+ }
+
+ /**
+ * Test setTargets().
+ */
+ public void testSetTargets() {
+ List<Object> test2 = new ArrayList<Object>();
+ test2.add(new Object());
+ test2.add(null);
+ test2.add(new Object());
+ TargetManager.getInstance().setTargets(test2);
+ assertTrue(TargetManager.getInstance()
+ .getTargets().contains(test2.get(0)));
+ assertTrue(!TargetManager.getInstance().getTargets().contains(null));
+ assertTrue(TargetManager.getInstance()
+ .getTargets().contains(test2.get(2)));
+
+ List<Object> test3 = new ArrayList<Object>();
+ test3.add(new Object());
+ test3.add(test3.get(0));
+ TargetManager.getInstance().setTargets(test3);
+ assertTrue(TargetManager.getInstance()
+ .getTargets().contains(test3.get(0)));
+ assertTrue(TargetManager.getInstance().getTargets().size() == 1);
+
+ List<Object> test4 = new ArrayList<Object>();
+ test4.add(test2.get(0));
+ test4.add(test2.get(2));
+
+ List<Object> test5 = new ArrayList<Object>();
+ test5.add(test2.get(2));
+ test5.add(test2.get(0));
+
+ List<Object> test = new ArrayList<Object>();
+ for (int i = 0; i < 10; i++) {
+ test.add(new Object());
+ }
+ TargetManager.getInstance().setTargets(test);
+ assertTrue(Arrays.equals(test.toArray(),
+ (TargetManager.getInstance()
+ .getTargets().toArray())));
+ TargetManager.getInstance().setTargets(null);
+ List expectedValue = new ArrayList();
+ assertTrue(Arrays.equals(expectedValue.toArray(),
+ (TargetManager.getInstance()
+ .getTargets().toArray())));
+
+ TargetListener listener = new TestTargetListener();
+ TargetManager.getInstance().addTargetListener(listener);
+ targetSetCalled = false;
+ targetSetTarget = null;
+ targetSetObjects = null;
+ TargetManager.getInstance().setTargets(test);
+ assertTrue(targetSetCalled);
+ assertEquals(test.get(0), targetSetTarget);
+ assertTrue(Arrays.equals(test.toArray(), targetSetObjects));
+ targetSetCalled = false;
+ TargetManager.getInstance().setTargets(test);
+ assertTrue(!targetSetCalled);
+ test.remove(1);
+ TargetManager.getInstance().setTargets(test);
+ assertTrue(targetSetCalled);
+
+ TargetManager.getInstance().setTargets(test2);
+ targetSetCalled = false;
+ TargetManager.getInstance().setTargets(test4);
+ assertTrue(!targetSetCalled);
+ TargetManager.getInstance().setTargets(test5);
+ assertTrue(targetSetCalled);
+ assertEquals(test5.get(0), targetSetTarget);
+
+ TargetManager.getInstance().removeTargetListener(listener);
+ }
+
+ /**
+ * Test addTarget().
+ */
+ public void testAddTarget() {
+ List<Object> testList = new ArrayList<Object>();
+ for (int i = 0; i < 10; i++) {
+ testList.add(new Object());
+ }
+ Object testObject = new Object();
+ TargetManager.getInstance().addTarget(testObject);
+ assertTrue(TargetManager.getInstance()
+ .getTargets().contains(testObject));
+ TargetManager.getInstance().setTargets(testList);
+ assertTrue(!TargetManager.getInstance()
+ .getTargets().contains(testObject));
+ TargetManager.getInstance().addTarget(testObject);
+ assertTrue(TargetManager.getInstance()
+ .getTargets().contains(testObject));
+ TargetManager.getInstance().addTarget(null);
+ assertTrue(TargetManager.getInstance()
+ .getTargets().contains(testObject));
+ assertTrue(!TargetManager.getInstance().getTargets().contains(null));
+
+ TargetListener listener = new TestTargetListener();
+ TargetManager.getInstance().addTargetListener(listener);
+ TargetManager.getInstance().setTargets(testList);
+ Object oldTarget = TargetManager.getInstance().getTarget();
+ List<Object> newList = new ArrayList<Object>(testList);
+ newList.add(testObject);
+ targetAddedCalled = false;
+ targetAddedTarget = null;
+ targetAddedObjects = null;
+ TargetManager.getInstance().addTarget(testObject);
+ assertTrue(targetAddedCalled);
+ assertTrue(newList.containsAll(Arrays.asList(targetAddedObjects))
+ && newList.size() == targetAddedObjects.length);
+ assertTrue(TargetManager.getInstance().getTarget() == testObject);
+ targetAddedCalled = false;
+ TargetManager.getInstance().addTarget(testObject);
+ assertTrue(!targetAddedCalled);
+
+ TargetManager.getInstance().removeTargetListener(listener);
+ }
+
+ /**
+ * Test removeTarget().
+ */
+ public void testRemoveTarget() {
+ List<Object> testList = new ArrayList<Object>();
+ for (int i = 0; i < 10; i++) {
+ testList.add(new Object());
+ }
+ Object testObject = new Object();
+ TargetManager.getInstance().setTarget(testObject);
+ assertTrue(TargetManager.getInstance()
+ .getTargets().contains(testObject));
+ TargetManager.getInstance().removeTarget(null);
+ assertTrue(TargetManager.getInstance()
+ .getTargets().contains(testObject));
+ TargetManager.getInstance().removeTarget(testObject);
+ assertTrue(TargetManager.getInstance().getTargets().isEmpty());
+ TargetManager.getInstance().removeTarget(null);
+ assertTrue(TargetManager.getInstance().getTargets().isEmpty());
+
+ testList.add(testObject);
+ TargetManager.getInstance().setTargets(testList);
+ assertTrue(TargetManager.getInstance()
+ .getTargets().contains(testObject));
+ TargetManager.getInstance().removeTarget(testObject);
+ assertTrue(!TargetManager.getInstance()
+ .getTargets().contains(testObject));
+
+ TargetListener listener = new TestTargetListener();
+ TargetManager.getInstance().addTargetListener(listener);
+ TargetManager.getInstance().setTargets(testList);
+
+ Object oldTarget = TargetManager.getInstance().getTarget();
+ targetRemovedCalled = false;
+ targetRemovedTarget = null;
+ TargetManager.getInstance().removeTarget(testObject);
+ assertTrue(targetRemovedCalled);
+ assertEquals(oldTarget, TargetManager.getInstance().getTarget());
+ assertEquals(oldTarget, targetRemovedTarget);
+
+ TargetManager.getInstance().setTarget(testObject);
+ targetRemovedTarget = null;
+ targetRemovedObjects = null;
+ TargetManager.getInstance().removeTarget(testObject);
+ assertEquals(null, targetRemovedTarget);
+ assertTrue(Arrays.equals(new Object[] {}, targetRemovedObjects));
+
+ List<Object> testList2 = new ArrayList<Object>();
+ testList2.add(new Object());
+ testList2.add(testObject);
+ TargetManager.getInstance().setTargets(testList2);
+ targetRemovedTarget = null;
+ targetRemovedObjects = null;
+ TargetManager.getInstance().removeTarget(testObject);
+ assertEquals(testList2.get(0), targetRemovedTarget);
+ assertTrue(Arrays.equals(new Object[] {testList2.get(0)},
+ targetRemovedObjects));
+ targetRemovedCalled = false;
+ TargetManager.getInstance().removeTarget(testObject);
+ assertTrue(!targetRemovedCalled);
+
+ TargetManager.getInstance().removeTargetListener(listener);
+ }
+
+ /**
+ * Test getFigTarget().
+ */
+ public void testGetFigTarget() {
+ final Object owner = new Object();
+ final Fig fig = new FigRect(0, 0, 12, 12); fig.setOwner(owner);
+ Object test = new Object();
+ ArgoDiagram diag = new ArgoDiagramImpl() {
+ public Fig getContainingFig(Object obj) {
+ if (obj == owner)
+ return fig;
+ return null;
+ }
+ public void encloserChanged(FigNode enclosed,
+ FigNode oldEncloser, FigNode newEncloser) {
+ }
+ };
+ Project p = ProjectManager.getManager().getCurrentProject();
+ p.addDiagram(diag);
+ TargetManager.getInstance().setTarget(diag);
+ List<Object> list1 = new ArrayList<Object>();
+ List<Object> list2 = new ArrayList<Object>();
+ list2.add(test);
+ List<Object> list3 = new ArrayList<Object>();
+ list3.add(owner);
+ list3.add(test);
+
+ TargetListener listener = new TestTargetListener();
+ TargetManager.getInstance().addTargetListener(listener);
+
+ targetSetFigTarget = null;
+ TargetManager.getInstance().setTarget(null);
+ assertEquals(null, TargetManager.getInstance().getFigTarget());
+ assertEquals(null, targetSetFigTarget);
+
+ targetSetFigTarget = null;
+ TargetManager.getInstance().setTarget(test);
+ assertEquals(null, TargetManager.getInstance().getFigTarget());
+ assertEquals(null, targetSetFigTarget);
+
+ targetSetFigTarget = null;
+ TargetManager.getInstance().setTarget(owner);
+ assertEquals(fig, TargetManager.getInstance().getFigTarget());
+ assertEquals(fig, targetSetFigTarget);
+
+ targetRemovedCalled = false;
+ TargetManager.getInstance().removeTarget(fig);
+ assertEquals(null, TargetManager.getInstance().getFigTarget());
+ assertTrue(targetRemovedCalled);
+
+ targetSetFigTarget = null;
+ TargetManager.getInstance().setTarget(test);
+ assertEquals(null, TargetManager.getInstance().getFigTarget());
+ assertEquals(null, targetSetFigTarget);
+
+ TargetManager.getInstance().setTarget(null);
+ targetAddedFigTarget = null;
+ TargetManager.getInstance().addTarget(test);
+ assertEquals(null, TargetManager.getInstance().getFigTarget());
+ assertEquals(null, targetAddedFigTarget);
+
+ TargetManager.getInstance().setTarget(null);
+ targetAddedFigTarget = null;
+ TargetManager.getInstance().addTarget(owner);
+ assertEquals(fig, TargetManager.getInstance().getFigTarget());
+ assertEquals(fig, targetAddedFigTarget);
+
+ targetRemovedCalled = false;
+ TargetManager.getInstance().removeTarget(null);
+ assertEquals(fig, TargetManager.getInstance().getFigTarget());
+ assertTrue(!targetRemovedCalled);
+
+ targetRemovedFigTarget = null;
+ TargetManager.getInstance().removeTarget(test);
+ assertEquals(fig, TargetManager.getInstance().getFigTarget());
+
+ TargetManager.getInstance().addTarget(test);
+ targetRemovedFigTarget = null;
+ TargetManager.getInstance().removeTarget(owner);
+ assertEquals(null, TargetManager.getInstance().getFigTarget());
+ assertEquals(null, targetRemovedFigTarget);
+
+ targetSetFigTarget = null;
+ TargetManager.getInstance().setTargets(list1);
+ assertEquals(null, TargetManager.getInstance().getFigTarget());
+ assertEquals(null, targetSetFigTarget);
+
+ targetSetFigTarget = null;
+ TargetManager.getInstance().setTargets(list2);
+ assertEquals(null, TargetManager.getInstance().getFigTarget());
+ assertEquals(null, targetSetFigTarget);
+
+ targetSetFigTarget = null;
+ TargetManager.getInstance().setTargets(list3);
+ assertEquals(fig, TargetManager.getInstance().getFigTarget());
+ assertEquals(fig, targetSetFigTarget);
+
+ targetSetFigTarget = null;
+ TargetManager.getInstance().setTargets(list2);
+ assertEquals(null, TargetManager.getInstance().getFigTarget());
+ assertEquals(null, targetSetFigTarget);
+
+ TargetManager.getInstance().removeTargetListener(listener);
+ }
+
+ /**
+ * Test getModelTarget().
+ */
+ public void testGetModelTarget() {
+ Object owner = Model.getCoreFactory().buildClass();
+ Fig fig = new FigRect(0, 0, 12, 12); fig.setOwner(owner);
+ Object test = new Object();
+
+ List<Object> list1 = new ArrayList<Object>();
+ List<Object> list2 = new ArrayList<Object>(); list2.add(test);
+ List<Object> list3 = new ArrayList<Object>(); list3.add(fig); list3.add(test);
+
+ TargetListener listener = new TestTargetListener();
+ TargetManager.getInstance().addTargetListener(listener);
+
+ targetSetModelTarget = null;
+ TargetManager.getInstance().setTarget(null);
+ assertEquals(null, TargetManager.getInstance().getModelTarget());
+ assertEquals(null, targetSetModelTarget);
+
+ targetSetModelTarget = null;
+ TargetManager.getInstance().setTarget(test);
+ assertEquals(null, TargetManager.getInstance().getModelTarget());
+ assertEquals(null, targetSetModelTarget);
+
+ targetSetModelTarget = null;
+ TargetManager.getInstance().setTarget(fig);
+ assertEquals(owner, TargetManager.getInstance().getModelTarget());
+ assertEquals(owner, targetSetModelTarget);
+
+ targetRemovedCalled = false;
+ TargetManager.getInstance().removeTarget(owner);
+ assertEquals(null, TargetManager.getInstance().getModelTarget());
+ assertTrue(targetRemovedCalled);
+
+ targetSetModelTarget = null;
+ TargetManager.getInstance().setTarget(test);
+ assertEquals(null, TargetManager.getInstance().getModelTarget());
+ assertEquals(null, targetSetModelTarget);
+
+ TargetManager.getInstance().setTarget(null);
+ targetAddedModelTarget = null;
+ TargetManager.getInstance().addTarget(test);
+ assertEquals(null, TargetManager.getInstance().getModelTarget());
+ assertEquals(null, targetAddedModelTarget);
+
+ TargetManager.getInstance().setTarget(null);
+ targetAddedModelTarget = null;
+ TargetManager.getInstance().addTarget(fig);
+ assertEquals(owner, TargetManager.getInstance().getModelTarget());
+ assertEquals(owner, targetAddedModelTarget);
+
+ targetAddedModelTarget = null;
+ TargetManager.getInstance().addTarget(test);
+ assertEquals(null, TargetManager.getInstance().getModelTarget());
+ assertEquals(null, targetAddedModelTarget);
+
+ targetRemovedCalled = false;
+ TargetManager.getInstance().removeTarget(null);
+ assertEquals(null, TargetManager.getInstance().getModelTarget());
+ assertTrue(!targetRemovedCalled);
+
+ targetRemovedModelTarget = null;
+ TargetManager.getInstance().removeTarget(test);
+ assertEquals(owner, TargetManager.getInstance().getModelTarget());
+ assertEquals(owner, targetRemovedModelTarget);
+
+ TargetManager.getInstance().addTarget(test);
+ targetRemovedModelTarget = null;
+ TargetManager.getInstance().removeTarget(fig);
+ assertEquals(null, TargetManager.getInstance().getModelTarget());
+ assertEquals(null, targetRemovedModelTarget);
+
+ targetSetModelTarget = null;
+ TargetManager.getInstance().setTargets(list1);
+ assertEquals(null, TargetManager.getInstance().getModelTarget());
+ assertEquals(null, targetSetModelTarget);
+
+ targetSetModelTarget = null;
+ TargetManager.getInstance().setTargets(list2);
+ assertEquals(null, TargetManager.getInstance().getModelTarget());
+ assertEquals(null, targetSetModelTarget);
+
+ targetSetModelTarget = null;
+ TargetManager.getInstance().setTargets(list3);
+ assertEquals(owner, TargetManager.getInstance().getModelTarget());
+ assertEquals(owner, targetSetModelTarget);
+
+ targetSetModelTarget = null;
+ TargetManager.getInstance().setTargets(list2);
+ assertEquals(null, TargetManager.getInstance().getModelTarget());
+ assertEquals(null, targetSetModelTarget);
+
+ TargetManager.getInstance().removeTargetListener(listener);
+ }
+
+ /**
+ * Testing to {@link TargetManager#addTarget(Object) add},
+ * {@link TargetManager#setTarget(Object) set}, and
+ * {@link TargetManager#removeTarget(Object) remove}
+ * a target from within the {@link TargetListener} calls
+ * ({@link TargetListener#targetAdded(TargetEvent)},
+ * {@link TargetListener#targetRemoved(TargetEvent)}, and
+ * {@link TargetListener#targetSet(TargetEvent)}).
+ */
+ public void testTransaction() {
+ class Listener implements TargetListener {
+ private int counter = 0;
+ private List<Object> list = new ArrayList<Object>();
+
+ /*
+ * @see TargetListener#targetAdded(TargetEvent)
+ */
+ public void targetAdded(TargetEvent e) {
+ counter++;
+ TargetManager.getInstance().addTarget(new Object());
+ TargetManager.getInstance().setTarget(new Object());
+ list.add(new Object());
+ TargetManager.getInstance().setTargets(list);
+ TargetManager.getInstance().removeTarget(e.getNewTarget());
+ }
+
+ /*
+ * @see TargetListener#targetRemoved(TargetEvent)
+ */
+ public void targetRemoved(TargetEvent e) {
+ counter++;
+ TargetManager.getInstance().addTarget(new Object());
+ TargetManager.getInstance().setTarget(new Object());
+ list.add(new Object());
+ TargetManager.getInstance().setTargets(list);
+ TargetManager.getInstance().removeTarget(e.getNewTarget());
+ }
+
+ /*
+ * @see TargetListener#targetSet(TargetEvent)
+ */
+ public void targetSet(TargetEvent e) {
+ counter++;
+ TargetManager.getInstance().addTarget(new Object());
+ TargetManager.getInstance().setTarget(new Object());
+ list.add(new Object());
+ TargetManager.getInstance().setTargets(list);
+ TargetManager.getInstance().removeTarget(e.getNewTarget());
+ }
+ }
+
+ Listener listener = new Listener();
+ TargetManager.getInstance().addTargetListener(listener);
+ TargetManager.getInstance().addTarget(new Object());
+ assertEquals(1, listener.counter);
+ assertEquals(1, listener.counter);
+
+ listener = new Listener();
+ TargetManager.getInstance().addTargetListener(listener);
+ TargetManager.getInstance().setTarget(new Object());
+ assertEquals(1, listener.counter);
+
+ listener = new Listener();
+ List<Object> list = new ArrayList<Object>();
+ list.add(new Object());
+ TargetManager.getInstance().addTargetListener(listener);
+ TargetManager.getInstance().setTargets(list);
+ list.add(new Object());
+ assertEquals(1, listener.counter);
+
+ listener = new Listener();
+ TargetManager.getInstance().addTargetListener(listener);
+ TargetManager.getInstance().removeTarget(list.get(0));
+ assertEquals(1, listener.counter);
+ }
+
+ /**
+ * Test navigate().
+ */
+ public void testNavigate() {
+ TargetManager.getInstance().cleanHistory();
+ int numtargets = 10;
+ Object[] targets = new Object[numtargets];
+ for (int i = 0; i < numtargets; i++) {
+ targets[i] = new Object();
+ TargetManager.getInstance().setTarget(targets[i]);
+ }
+ assertTrue(TargetManager.getInstance().navigateBackPossible());
+ assertEquals(false,
+ TargetManager.getInstance().navigateForwardPossible());
+ try {
+ TargetManager.getInstance().navigateForward();
+ fail();
+ }
+ catch (IllegalStateException e) {
+ }
+ TargetManager.getInstance().navigateBackward();
+ assertEquals(targets[8], TargetManager.getInstance().getTarget());
+ assertTrue(TargetManager.getInstance().navigateBackPossible());
+ assertTrue(TargetManager.getInstance().navigateForwardPossible());
+ for (int i = 7; i > 0; i--) {
+ TargetManager.getInstance().navigateBackward();
+ assertEquals(targets[i], TargetManager.getInstance().getTarget());
+ assertTrue(TargetManager.getInstance().navigateBackPossible());
+ assertTrue(TargetManager.getInstance().navigateForwardPossible());
+ }
+ TargetManager.getInstance().navigateBackward();
+ assertTrue(TargetManager.getInstance().navigateForwardPossible());
+ assertEquals(false, TargetManager.getInstance().navigateBackPossible());
+ try {
+ TargetManager.getInstance().navigateBackward();
+ fail();
+ } catch (IllegalStateException e) {
+ }
+ TargetManager.getInstance().navigateForward();
+ assertEquals(targets[1], TargetManager.getInstance().getTarget());
+ assertTrue(TargetManager.getInstance().navigateBackPossible());
+ assertTrue(TargetManager.getInstance().navigateForwardPossible());
+ TargetManager.getInstance().setTarget(targets[9]);
+ assertTrue(TargetManager.getInstance().navigateBackPossible());
+ assertEquals(false,
+ TargetManager.getInstance().navigateForwardPossible());
+ try {
+ TargetManager.getInstance().navigateForward();
+ fail();
+ } catch (IllegalStateException e) {
+ }
+ TargetManager.getInstance().navigateBackward();
+ assertTrue(TargetManager.getInstance().navigateBackPossible());
+ assertTrue(TargetManager.getInstance().navigateForwardPossible());
+ TargetManager.getInstance().navigateBackward();
+ assertTrue(TargetManager.getInstance().navigateForwardPossible());
+ assertEquals(false, TargetManager.getInstance().navigateBackPossible());
+
+
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() {
+ InitializeModel.initializeDefault();
+
+ TargetManager.getInstance().setTarget(null);
+ }
+
+ /*
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() {
+ TargetManager.getInstance().setTarget(null);
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/ui/targetmanager/package.html
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/ui/targetmanager/package.html?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/ui/targetmanager/package.html 2007-08-13 09:07:56-0700
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+ Copyright (c) 1996-99 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.
+-->
+</head>
+<body bgcolor="white">
+<!--
+##### TYPE YOUR PACKAGE COMMENTS HERE. BEGIN WITH A #####
+##### ONE-SENTENCE SUMMARY STARTING WITH A VERB LIKE: #####
+Provides for....
+-->
+
+</body>
+</html>
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/TestProfileJava.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/TestProfileJava.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/TestProfileJava.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,77 @@
+// $Id:TestProfileJava.java 13167 2007-07-27 21:30:24Z tfmorris $
+// Copyright (c) 1996-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.uml;
+
+import java.util.Collection;
+
+import org.argouml.model.Model;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+/**
+ *
+ * @author euluis
+ * @since 0.20
+ * @version 0.00
+ */
+public class TestProfileJava extends TestCase {
+
+ /**
+ * The constructor.
+ *
+ * @param name the name of the test.
+ */
+ public TestProfileJava(String name) {
+ super(name);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test whether we can load default model (profile). ProfileJava will throw
+ * an exception for an invalid profile model, but just create and return an
+ * empty model if the file for the profile doesn't exist. Check
+ * for both failure modes.
+ *
+ * @throws ProfileException
+ * exception thrown by ProfileJava for invalid profile file.
+ */
+ public void testLoadProfileModel() throws ProfileException {
+ ProfileJava profile = new ProfileJava();
+ Object model = profile.getProfileModel();
+ assertNotNull("Can't load profile model", model);
+ Collection stereos = Model.getModelManagementHelper()
+ .getAllModelElementsOfKind(model,
+ Model.getMetaTypes().getStereotype());
+ assertTrue("No stereotypes found in profile model", stereos.size() > 0);
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/TestUUIDManager.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/TestUUIDManager.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/TestUUIDManager.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,61 @@
+// $Id:TestUUIDManager.java 10734 2006-06-11 15:43:58Z mvw $
+// Copyright (c) 1996-2006 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.
+/*
+ * Created on 13.10.2004
+ */
+package org.argouml.uml;
+
+import org.argouml.model.UUIDManager;
+
+import junit.framework.TestCase;
+
+/**
+ * @author MarkusK
+ *
+ */
+public class TestUUIDManager extends TestCase {
+
+
+ /**
+ * The constructor.
+ *
+ * @param name the name of the test
+ */
+ public TestUUIDManager(String name) {
+ super(name);
+ }
+
+ /**
+ * Test the UUIDManager.getInstance().getNewUUID() function.
+ */
+ public void testGetNewUUID() {
+ String uuid1 = UUIDManager.getInstance().getNewUUID();
+ String uuid2 = UUIDManager.getInstance().getNewUUID();
+
+ assertNotNull(uuid1);
+ assertNotNull(uuid2);
+ assertTrue(!uuid1.equals(uuid2));
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/AbstractTestCrTooMany.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/AbstractTestCrTooMany.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/AbstractTestCrTooMany.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,86 @@
+// $Id:AbstractTestCrTooMany.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 2005-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.uml.cognitive.critics;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.model.Model;
+
+public abstract class AbstractTestCrTooMany extends TestCase {
+
+ protected AbstractCrTooMany cr;
+
+ protected Object model;
+
+ protected Object dm;
+
+ int threshold;
+
+ public AbstractTestCrTooMany(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ model = Model.getModelManagementFactory().createModel();
+ }
+
+ protected abstract void createNewModelElement();
+
+ public void testNoThresholdPredicate2() {
+ cr.setThreshold(0);
+ // all tests should consider the threshold as inclusive value
+ assertFalse(cr.predicate2(dm, null));
+ }
+
+ public void testPredicate2() {
+ for (int i = 0; i < 5; i++) {
+ createNewModelElement();
+ }
+ cr.setThreshold(10);
+ assertFalse(cr.predicate2(dm, null));
+ cr.setThreshold(6);
+ assertFalse(cr.predicate2(dm, null));
+ cr.setThreshold(5);
+ assertFalse(cr.predicate2(dm, null));
+ cr.setThreshold(4);
+ assertTrue(cr.predicate2(dm, null));
+ cr.setThreshold(1);
+ assertTrue(cr.predicate2(dm, null));
+ }
+
+ public void testThreshold() {
+ cr.setThreshold(5);
+ assertTrue(cr.getThreshold() == 5);
+ }
+
+ // this test is a bit stupid, but nevertheless...
+ public void testGetWizardClass() {
+ assertTrue(cr.getWizardClass(null).equals(WizTooMany.class));
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/AbstractTestMissingName.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/AbstractTestMissingName.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/AbstractTestMissingName.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,63 @@
+// $Id:AbstractTestMissingName.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 2005-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.uml.cognitive.critics;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.model.Model;
+
+public abstract class AbstractTestMissingName extends TestCase {
+
+ protected Object me = null;
+
+ protected CrUML critic = null;
+
+ public AbstractTestMissingName(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ public void testWrongInput() {
+ assertFalse(critic.predicate2(null, null));
+ }
+
+ public void testHasName() {
+ Model.getCoreHelper().setName(me, "A");
+ assertFalse(critic.predicate2(me, null));
+ }
+
+ public void testHasNoName() {
+ Model.getCoreHelper().setName(me, null);
+ assertTrue(critic.predicate2(me, null));
+ Model.getCoreHelper().setName(me, "");
+ assertTrue(critic.predicate2(me, null));
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrAssocNameConflict.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrAssocNameConflict.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrAssocNameConflict.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,126 @@
+// $Id:TestCrAssocNameConflict.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 2005-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.uml.cognitive.critics;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.model.Model;
+
+public class TestCrAssocNameConflict extends TestCase {
+
+ private CrNameConflict critic = null;
+
+ private Object c1, c2, c3, c4, ns1, ns2;
+
+ /**
+ * Constructor.
+ * @param name test case name
+ */
+ public TestCrAssocNameConflict(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ ns1 = Model.getModelManagementFactory().buildPackage("P1", null);
+ ns2 = Model.getModelManagementFactory().buildPackage("P2", null);
+ c1 = Model.getCoreFactory().buildClass("A", ns1);
+ c2 = Model.getCoreFactory().buildClass("A", ns1);
+ c3 = Model.getCoreFactory().buildClass("B", ns1);
+ c4 = Model.getCoreFactory().buildClass("A", ns2);
+ critic = new CrNameConflict();
+
+ }
+
+ public void testPredicate2() {
+ // {A, A} are offenders
+ assertTrue(critic.predicate2(ns1, null));
+ assertTrue(critic.computeOffenders(ns1).size() == 2);
+
+ // {} no offenders
+ assertFalse(critic.predicate2(ns2, null));
+ assertTrue(critic.computeOffenders(ns2).size() == 0);
+
+ // {A,A,B,B} are offenders
+ Model.getCoreFactory().buildInterface("B", ns1);
+ assertTrue(critic.predicate2(ns1, null));
+ assertTrue(critic.computeOffenders(ns1).size() == 4);
+ }
+
+ public void testGeneralizations() {
+ // generalizations are not required to have unique names within a
+ // namespace
+ Model.getCoreHelper().setName(c1, "C1");
+ Model.getCoreHelper().setName(c2, "C2");
+ Model.getCoreHelper().setName(c3, "C3");
+ Model.getCoreHelper().setName(c4, "C4");
+ Object g1 = Model.getCoreFactory().buildGeneralization(c2, c1);
+ Model.getCoreHelper().setName(g1, "gen1");
+ Object g2 = Model.getCoreFactory().buildGeneralization(c3, c1);
+ Model.getCoreHelper().setName(g2, "gen1");
+ assertFalse(critic.predicate2(ns1, null));
+ assertTrue(critic.computeOffenders(ns1).size() == 0);
+
+ }
+
+ public void testAssociations() {
+ CrAssocNameConflict critic = new CrAssocNameConflict();
+ Model.getCoreHelper().setNamespace(c4, ns1);
+ Object a1, a2, a3;
+ Model.getCoreHelper().setName(c1, "C1");
+ Model.getCoreHelper().setName(c2, "C2");
+ Model.getCoreHelper().setName(c3, "C3");
+ Model.getCoreHelper().setName(c4, "C4");
+ a1 = Model.getCoreFactory().buildAssociation(c1, c2);
+ a2 = Model.getCoreFactory().buildAssociation(c3, c4);
+ Model.getCoreHelper().setName(a1, "A1");
+ Model.getCoreHelper().setName(a2, "A2");
+
+ assertTrue(critic.getAllTypes(a1).contains(c1));
+ assertTrue(critic.getAllTypes(a1).contains(c2));
+
+ // everything ok
+ assertFalse(critic.predicate2(ns1, null));
+ assertTrue(critic.computeOffenders(ns1).size() == 0);
+
+ // same name, different classes, everything ok
+ Model.getCoreHelper().setName(a1, "A2");
+ assertFalse(critic.predicate2(ns1, null));
+ assertEquals(0, critic.computeOffenders(ns1).size());
+
+ // same name, same participants, two offenders
+ a3 = Model.getCoreFactory().buildAssociation(c3, c4);
+ Model.getCoreHelper().setName(a3, "A2");
+ assertEquals(2, critic.getAllTypes(a2).size());
+ assertEquals(2, critic.getAllTypes(a3).size());
+ assertTrue(critic.getAllTypes(a3).containsAll(critic.getAllTypes(a2)));
+ assertTrue(critic.getAllTypes(a2).containsAll(critic.getAllTypes(a3)));
+
+ assertEquals(2, critic.computeOffenders(ns1).size());
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrDupParamName.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrDupParamName.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrDupParamName.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,73 @@
+// $Id:TestCrDupParamName.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 2005-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.uml.cognitive.critics;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.model.Model;
+
+public class TestCrDupParamName extends TestCase {
+
+ private CrUML cr = null;
+
+ public TestCrDupParamName(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+
+ cr = new CrDupParamName();
+ }
+
+ public void testPredicate2() {
+ Object oper = Model.getCoreFactory().createOperation();
+ assertFalse(cr.predicate2(oper, null));
+ Object p1 = Model.getCoreFactory().createParameter();
+ Model.getCoreHelper().setName(p1, "param1");
+ Model.getCoreHelper().setKind(p1,
+ Model.getDirectionKind().getInParameter());
+ assertFalse(cr.predicate2(oper, null));
+ Model.getCoreHelper().addParameter(oper, p1);
+ assertFalse(cr.predicate2(oper, null));
+ Object p2 = Model.getCoreFactory().createParameter();
+ Model.getCoreHelper().setName(p2, "param2");
+ Model.getCoreHelper().setKind(p2,
+ Model.getDirectionKind().getInParameter());
+ Model.getCoreHelper().addParameter(oper, p2);
+ assertFalse(cr.predicate2(oper, null));
+ Model.getCoreHelper().setName(p2, "param1");
+ assertTrue(cr.predicate2(oper, null));
+
+ // test for return parameters. they can ALSO fail!
+ Model.getCoreHelper().setKind(p1,
+ Model.getDirectionKind().getReturnParameter());
+ Model.getCoreHelper().setKind(p2,
+ Model.getDirectionKind().getReturnParameter());
+ assertTrue(cr.predicate2(oper, null));
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrInvalidHistory.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrInvalidHistory.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrInvalidHistory.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,84 @@
+// $Id:TestCrInvalidHistory.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 2006-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.uml.cognitive.critics;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.model.Model;
+
+public class TestCrInvalidHistory extends TestCase {
+
+ private CrUML critic = null;
+
+ private Object statemachine;
+
+ private Object compositestate;
+
+ private Object history;
+
+ private Object state1, state2;
+
+ public TestCrInvalidHistory(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ critic = new CrInvalidHistory();
+ statemachine = Model.getStateMachinesFactory().createStateMachine();
+ compositestate = Model.getStateMachinesFactory()
+ .buildCompositeStateOnStateMachine(statemachine);
+ history = Model.getStateMachinesFactory().buildPseudoState(
+ compositestate);
+ state1 = Model.getStateMachinesFactory().buildSimpleState(
+ compositestate);
+ state2 = Model.getStateMachinesFactory().buildSimpleState(
+ compositestate);
+
+ }
+
+ public void testShallowHistoryKind() {
+ Model.getCoreHelper().setKind(history,
+ Model.getPseudostateKind().getShallowHistory());
+ assertFalse(critic.predicate2(history, null));
+ Model.getStateMachinesFactory().buildTransition(history, state1);
+ assertFalse(critic.predicate2(history, null));
+ Model.getStateMachinesFactory().buildTransition(history, state2);
+ assertTrue(critic.predicate2(history, null));
+ }
+
+ public void testDeepHistoryKind() {
+ Model.getCoreHelper().setKind(history,
+ Model.getPseudostateKind().getDeepHistory());
+ assertFalse(critic.predicate2(history, null));
+ Model.getStateMachinesFactory().buildTransition(history, state1);
+ assertFalse(critic.predicate2(history, null));
+ Model.getStateMachinesFactory().buildTransition(history, state2);
+ assertTrue(critic.predicate2(history, null));
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrInvalidInitial.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrInvalidInitial.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrInvalidInitial.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,75 @@
+// $Id:TestCrInvalidInitial.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 2006-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.uml.cognitive.critics;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.model.Model;
+
+public class TestCrInvalidInitial extends TestCase {
+
+ private CrUML critic = null;
+
+ private Object statemachine;
+
+ private Object compositestate;
+
+ private Object initial;
+
+ private Object state1, state2;
+
+ public TestCrInvalidInitial(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ critic = new CrInvalidInitial();
+ statemachine = Model.getStateMachinesFactory().createStateMachine();
+ compositestate = Model.getStateMachinesFactory()
+ .buildCompositeStateOnStateMachine(statemachine);
+ initial = Model.getStateMachinesFactory().buildPseudoState(
+ compositestate);
+ Model.getCoreHelper().setKind(initial,
+ Model.getPseudostateKind().getInitial());
+ state1 = Model.getStateMachinesFactory().buildSimpleState(
+ compositestate);
+ state2 = Model.getStateMachinesFactory().buildSimpleState(
+ compositestate);
+
+
+ }
+
+ public void testPredicate2() {
+ assertFalse(critic.predicate2(initial, null));
+ Model.getStateMachinesFactory().buildTransition(initial, state1);
+ assertFalse(critic.predicate2(initial, null));
+ Model.getStateMachinesFactory().buildTransition(initial, state2);
+ assertTrue(critic.predicate2(initial, null));
+
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrMissingAttrName.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrMissingAttrName.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrMissingAttrName.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,41 @@
+// $Id:TestCrMissingAttrName.java 11053 2006-08-18 12:17:01Z mkl $
+// Copyright (c) 2005 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.uml.cognitive.critics;
+
+import org.argouml.model.Model;
+
+public class TestCrMissingAttrName extends AbstractTestMissingName {
+
+ public TestCrMissingAttrName(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ critic = new CrMissingAttrName();
+ me = Model.getCoreFactory().createAttribute();
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrMissingClassName.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrMissingClassName.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrMissingClassName.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,41 @@
+// $Id:TestCrMissingClassName.java 11053 2006-08-18 12:17:01Z mkl $
+// Copyright (c) 2005 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.uml.cognitive.critics;
+
+import org.argouml.model.Model;
+
+public class TestCrMissingClassName extends AbstractTestMissingName {
+
+ public TestCrMissingClassName(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ critic = new CrMissingClassName();
+ me = Model.getCoreFactory().createClass();
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrMissingOperName.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrMissingOperName.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrMissingOperName.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,41 @@
+// $Id:TestCrMissingOperName.java 11053 2006-08-18 12:17:01Z mkl $
+// Copyright (c) 2005 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.uml.cognitive.critics;
+
+import org.argouml.model.Model;
+
+public class TestCrMissingOperName extends AbstractTestMissingName {
+
+ public TestCrMissingOperName(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ critic = new CrMissingOperName();
+ me = Model.getCoreFactory().createOperation();
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrMissingStateName.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrMissingStateName.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrMissingStateName.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,41 @@
+// $Id:TestCrMissingStateName.java 11053 2006-08-18 12:17:01Z mkl $
+// Copyright (c) 2005 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.uml.cognitive.critics;
+
+import org.argouml.model.Model;
+
+public class TestCrMissingStateName extends AbstractTestMissingName {
+
+ public TestCrMissingStateName(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ critic = new CrMissingStateName();
+ me = Model.getStateMachinesFactory().createSimpleState();
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrNameConflict.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrNameConflict.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrNameConflict.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,99 @@
+// $Id:TestCrNameConflict.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 2005-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.uml.cognitive.critics;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.model.Model;
+
+/**
+ * Test critic which checks for name conflicts.
+ */
+public class TestCrNameConflict extends TestCase {
+
+ private CrAssocNameConflict critic = null;
+
+ private Object c1, c2, c3, c4, ns1, ns2;
+
+ /**
+ * Constructor.
+ *
+ * @param name test case name
+ */
+ public TestCrNameConflict(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ ns1 = Model.getModelManagementFactory().buildPackage("P1", null);
+ ns2 = Model.getModelManagementFactory().buildPackage("P2", null);
+ c1 = Model.getCoreFactory().buildClass("A", ns1);
+ c2 = Model.getCoreFactory().buildClass("A", ns1);
+ c3 = Model.getCoreFactory().buildClass("B", ns1);
+ c4 = Model.getCoreFactory().buildClass("A", ns2);
+ critic = new CrAssocNameConflict();
+
+ }
+
+ /**
+ * Test critic which checks for name conflicts.
+ */
+ public void testPredicate() {
+ Model.getCoreHelper().setNamespace(c4, ns1);
+ Object a1, a2, a3;
+ Model.getCoreHelper().setName(c1, "C1");
+ Model.getCoreHelper().setName(c2, "C2");
+ Model.getCoreHelper().setName(c3, "C3");
+ Model.getCoreHelper().setName(c4, "C4");
+ a1 = Model.getCoreFactory().buildAssociation(c1, c2);
+ a2 = Model.getCoreFactory().buildAssociation(c3, c4);
+ Model.getCoreHelper().setName(a1, "A1");
+ Model.getCoreHelper().setName(a2, "A2");
+
+ assertTrue(critic.getAllTypes(a1).contains(c1));
+ assertTrue(critic.getAllTypes(a1).contains(c2));
+
+ // everything ok
+ assertFalse(critic.predicate2(ns1, null));
+ assertEquals(0, critic.computeOffenders(ns1).size());
+
+ // same name, different classes, everything ok
+ Model.getCoreHelper().setName(a1, "A2");
+ assertFalse(critic.predicate2(ns1, null));
+
+ // same name, same participants, two offenders
+ a3 = Model.getCoreFactory().buildAssociation(c3, c4);
+ Model.getCoreHelper().setName(a3, "A2");
+ assertEquals(2, critic.getAllTypes(a2).size());
+ assertEquals(2, critic.getAllTypes(a3).size());
+ assertTrue(critic.getAllTypes(a3).containsAll(critic.getAllTypes(a2)));
+ assertTrue(critic.getAllTypes(a2).containsAll(critic.getAllTypes(a3)));
+
+ assertEquals(2, critic.computeOffenders(ns1).size());
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrNoAssociations.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrNoAssociations.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrNoAssociations.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,116 @@
+// $Id:TestCrNoAssociations.java 12681 2007-05-26 22:54:04Z tfmorris $
+// Copyright (c) 2005-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.uml.cognitive.critics;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.model.Model;
+
+public class TestCrNoAssociations extends TestCase {
+
+ private CrNoAssociations critic = null;
+
+ private Object useCase1;
+
+ private Object useCase2;
+
+ private Object useCase3;
+
+ private Object ns;
+
+ private Object actor;
+
+ public TestCrNoAssociations(String arg0) {
+ super(arg0);
+ }
+
+ // simply create 3 usecases and an actor in a package with individual names
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ critic = new CrNoAssociations();
+
+ ns = Model.getModelManagementFactory().buildPackage("Test", null);
+ useCase1 = Model.getUseCasesFactory().createUseCase();
+ Model.getCoreHelper().setName(useCase1, "A");
+ Model.getCoreHelper().setNamespace(useCase1, ns);
+ useCase2 = Model.getUseCasesFactory().createUseCase();
+
+ Model.getCoreHelper().setName(useCase2, "B");
+ Model.getCoreHelper().setNamespace(useCase2, ns);
+
+ useCase3 = Model.getUseCasesFactory().createUseCase();
+ Model.getCoreHelper().setName(useCase3, "C");
+ Model.getCoreHelper().setNamespace(useCase3, ns);
+
+ actor = Model.getUseCasesFactory().createActor();
+ Model.getCoreHelper().setName(actor, "Actor");
+ Model.getCoreHelper().setNamespace(actor, ns);
+ }
+
+ public void testUseCaseNormal() {
+ // All use cases and actors require associations
+ // hence all predicates evalulate to true
+ assertTrue(critic.predicate2(useCase1, null));
+ assertTrue(critic.predicate2(useCase2, null));
+ assertTrue(critic.predicate2(useCase3, null));
+ assertTrue(critic.predicate2(actor, null));
+ }
+
+ public void testUseCaseAssociation() {
+ // build association
+ // build association between actor and top use case.
+ Model.getCoreFactory().buildAssociation(useCase1, actor);
+ assertFalse(critic.predicate2(useCase1, null));
+ assertTrue(critic.predicate2(useCase2, null));
+ assertTrue(critic.predicate2(useCase3, null));
+ assertFalse(critic.predicate2(actor, null));
+ }
+
+ public void testUseCaseExtend() {
+ // build extend
+ // these parameters seem to be in correct order
+ // add an extend. We do not need an assoc on the extending use case
+ Model.getUseCasesFactory().buildExtend(useCase1, useCase3);
+ assertTrue(critic.predicate2(useCase1, null));
+ assertTrue(critic.predicate2(useCase2, null));
+ assertFalse(critic.predicate2(useCase3, null));
+ assertTrue(critic.predicate2(actor, null));
+ }
+
+ public void testUseCaseInclude() {
+ // build include
+ // it seems that the parameters for build include are just the other way
+ // round
+ // add an include: we do not need to have associtions on one
+ Model.getUseCasesFactory().buildInclude(useCase2, useCase1);
+ assertTrue(critic.predicate2(useCase1, null));
+ assertFalse(critic.predicate2(useCase2, null));
+ assertTrue(critic.predicate2(useCase3, null));
+ assertTrue(critic.predicate2(actor, null));
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrNoInitialState.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrNoInitialState.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrNoInitialState.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,66 @@
+// $Id:TestCrNoInitialState.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 2006-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.uml.cognitive.critics;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.model.Model;
+
+public class TestCrNoInitialState extends TestCase {
+
+ private CrUML critic = null;
+
+ private Object statemachine;
+
+ private Object compositestate;
+
+ private Object initial;
+
+
+ public TestCrNoInitialState(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ critic = new CrNoInitialState();
+ statemachine = Model.getStateMachinesFactory().createStateMachine();
+ compositestate = Model.getStateMachinesFactory()
+ .buildCompositeStateOnStateMachine(statemachine);
+ initial = Model.getStateMachinesFactory().buildPseudoState(
+ compositestate);
+
+
+ }
+
+ public void testPredicate2() {
+ assertTrue(critic.predicate2(compositestate, null));
+ Model.getCoreHelper().setKind(initial,
+ Model.getPseudostateKind().getInitial());
+ assertFalse(critic.predicate2(compositestate, null));
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrTooManyAssoc.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrTooManyAssoc.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrTooManyAssoc.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,51 @@
+// $Id:TestCrTooManyAssoc.java 11061 2006-08-20 10:08:33Z mkl $
+// Copyright (c) 2005 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.uml.cognitive.critics;
+
+import org.argouml.model.Model;
+
+public class TestCrTooManyAssoc extends AbstractTestCrTooMany {
+
+ Object dm2;
+
+ public TestCrTooManyAssoc(String arg0) {
+ super(arg0);
+ // TODO Auto-generated constructor stub
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ cr = new CrTooManyAssoc();
+ dm = Model.getCoreFactory().createClass();
+ Model.getCoreHelper().setNamespace(dm, model);
+ dm2 = Model.getCoreFactory().createClass();
+ Model.getCoreHelper().setNamespace(dm2, model);
+ }
+
+ protected void createNewModelElement() {
+ Model.getCoreFactory().buildAssociation(dm, dm2);
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrTooManyAttr.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrTooManyAttr.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrTooManyAttr.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,47 @@
+// $Id:TestCrTooManyAttr.java 12219 2007-03-07 10:18:57Z tfmorris $
+// Copyright (c) 2005-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.uml.cognitive.critics;
+
+import org.argouml.model.Model;
+
+public class TestCrTooManyAttr extends AbstractTestCrTooMany {
+
+ public TestCrTooManyAttr(String arg0) {
+ super(arg0);
+ // TODO Auto-generated constructor stub
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ cr = new CrTooManyAttr();
+ dm = Model.getCoreFactory().createClass();
+ Model.getCoreHelper().setNamespace(dm, model);
+ }
+
+ protected void createNewModelElement() {
+ Model.getCoreFactory().buildAttribute2(dm, dm);
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrTooManyOper.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrTooManyOper.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrTooManyOper.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,46 @@
+// $Id:TestCrTooManyOper.java 12545 2007-05-05 16:22:17Z linus $
+// Copyright (c) 2005-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.uml.cognitive.critics;
+
+import org.argouml.model.Model;
+
+public class TestCrTooManyOper extends AbstractTestCrTooMany {
+
+ public TestCrTooManyOper(String arg0) {
+ super(arg0);
+ // TODO Auto-generated constructor stub
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ cr = new CrTooManyOper();
+ dm = Model.getCoreFactory().createClass();
+ }
+
+ protected void createNewModelElement() {
+ Model.getCoreFactory().buildOperation(dm, null);
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrTooManyStates.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrTooManyStates.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrTooManyStates.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,46 @@
+// $Id:TestCrTooManyStates.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 2005-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.uml.cognitive.critics;
+
+import org.argouml.model.Model;
+
+public class TestCrTooManyStates extends AbstractTestCrTooMany {
+
+ public TestCrTooManyStates(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ dm = Model.getStateMachinesFactory().createCompositeState();
+ cr = new CrTooManyStates();
+ }
+
+ protected void createNewModelElement() {
+ Model.getStateMachinesFactory().buildSimpleState(dm);
+
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrTooManyTransitions.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrTooManyTransitions.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrTooManyTransitions.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,50 @@
+// $Id:TestCrTooManyTransitions.java 11061 2006-08-20 10:08:33Z mkl $
+// Copyright (c) 2005 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.uml.cognitive.critics;
+
+import org.argouml.model.Model;
+
+public class TestCrTooManyTransitions extends AbstractTestCrTooMany {
+
+ Object dm2;
+
+ public TestCrTooManyTransitions(String arg0) {
+ super(arg0);
+ // TODO Auto-generated constructor stub
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ cr = new CrTooManyTransitions();
+ dm = Model.getStateMachinesFactory().createCompositeState();
+ }
+
+ protected void createNewModelElement() {
+ dm2 = Model.getStateMachinesFactory().createCompositeState();
+ Model.getStateMachinesFactory().buildTransition(dm, dm2);
+
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrUnconventionalAttrName.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrUnconventionalAttrName.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrUnconventionalAttrName.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,107 @@
+// $Id:TestCrUnconventionalAttrName.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 2003-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.uml.cognitive.critics;
+
+import org.argouml.model.Model;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+
+/**
+ * Tests for the CrUnconventionalAttrName class.
+ *
+ * @author mkl
+ *
+ */
+public class TestCrUnconventionalAttrName extends TestCase {
+
+
+ private CrUnconventionalAttrName cr = new CrUnconventionalAttrName();
+
+ /**
+ * The constructor.
+ *
+ * @param arg0 the name of the test
+ */
+ public TestCrUnconventionalAttrName(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Not giving a name should not result in a suggestion.
+ */
+ public void testNullName() {
+ assertEquals("attr", cr.computeSuggestion(null));
+ }
+
+ /**
+ * A name not starting with a capital should capitalize the first character.
+ */
+ public void testNoUnderscoreName() {
+ assertEquals("test", cr.computeSuggestion("Test"));
+ }
+
+ /**
+ * A name not starting with a capital should capitalize
+ * the first non-underscore character.
+ */
+ public void testSmallUnderscoreName() {
+ assertEquals("_x", cr.computeSuggestion("_X"));
+ }
+
+ /**
+ * ...and only the first character, not the 2nd.
+ */
+ public void testLongUnderscoreName() {
+ assertEquals("_xx", cr.computeSuggestion("_Xx"));
+ }
+
+ /**
+ * A name that consists of a single underscore should remain untouched.
+ */
+ public void testOnlyUnderscoreName() {
+ assertEquals("_", cr.computeSuggestion("_"));
+ }
+
+ public void testPredicate2() {
+ Object me = Model.getCoreFactory().createAttribute();
+ Model.getCoreHelper().setName(me, null);
+ assertFalse(cr.predicate2(me, null));
+
+ Model.getCoreHelper().setName(me, "UpperCase");
+ assertTrue(cr.predicate2(me, null));
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrUnconventionalClassName.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrUnconventionalClassName.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrUnconventionalClassName.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,82 @@
+// $Id:TestCrUnconventionalClassName.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 2004-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.uml.cognitive.critics;
+
+import org.argouml.model.Model;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+
+/**
+ * Tests for {@link CrUnconventionalClassName}.
+ *
+ * @author mkl
+ */
+public class TestCrUnconventionalClassName extends TestCase {
+ /**
+ * An instance of the class to test.
+ */
+ private CrUnconventionalClassName cr = new CrUnconventionalClassName();
+
+ /**
+ * Constructor.
+ *
+ * @param arg0 The test case name.
+ */
+ public TestCrUnconventionalClassName(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Testing the computation of suggestions.
+ */
+ public void testComputeSuggestion() {
+ assertEquals("", cr.computeSuggestion(null));
+ assertEquals("Test", cr.computeSuggestion("test"));
+ assertEquals("A", cr.computeSuggestion("a"));
+ assertEquals("Fdfdfd", cr.computeSuggestion("23232fdfdfd"));
+ assertEquals("", cr.computeSuggestion("12345"));
+ assertEquals("Foo2354foo", cr.computeSuggestion("foo2354foo"));
+ }
+
+ public void testPredicate2() {
+ Object me = Model.getCoreFactory().createClass();
+ Model.getCoreHelper().setName(me, null);
+ assertFalse(cr.predicate2(me, null));
+
+ Model.getCoreHelper().setName(me, "lowerCase");
+ assertTrue(cr.predicate2(me, null));
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrUnconventionalOperName.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrUnconventionalOperName.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrUnconventionalOperName.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,78 @@
+// $Id:TestCrUnconventionalOperName.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 2004-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.uml.cognitive.critics;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.model.Model;
+
+
+/**
+ * Testing the class {@link CrUnconventionalOperName}.
+ *
+ * @author mkl
+ */
+public class TestCrUnconventionalOperName extends TestCase {
+ /**
+ * An instance of the class to test.
+ */
+ private CrUnconventionalOperName cr = new CrUnconventionalOperName();
+
+ /**
+ * Constructor.
+ *
+ * @param arg0 The test case name.
+ */
+ public TestCrUnconventionalOperName(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Testing of computeSuggestion.
+ */
+ public void testComputeSuggestion() {
+ assertEquals("", cr.computeSuggestion(null));
+ assertEquals("test", cr.computeSuggestion("Test"));
+ assertEquals("t", cr.computeSuggestion("T"));
+ }
+
+ public void testPredicate2() {
+ Object me = Model.getCoreFactory().createOperation();
+ Model.getCoreHelper().setName(me, null);
+ assertFalse(cr.predicate2(me, null));
+
+ Model.getCoreHelper().setName(me, "UpperCase");
+ assertTrue(cr.predicate2(me, null));
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrUnconventionalPackName.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrUnconventionalPackName.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/TestCrUnconventionalPackName.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,80 @@
+// $Id:TestCrUnconventionalPackName.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 2004-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.uml.cognitive.critics;
+
+import org.argouml.model.Model;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+/**
+ * Testing the class {@link CrUnconventionalPackName}.
+ *
+ * @author mkl
+ */
+public class TestCrUnconventionalPackName extends TestCase {
+ /**
+ * An instance of the class to test.
+ */
+ private CrUnconventionalPackName cr = new CrUnconventionalPackName();
+
+ /**
+ * The constructor.
+ *
+ * @param arg0 The test case name.
+ */
+ public TestCrUnconventionalPackName(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Testing computeSuggestion.
+ */
+ public void testComputeSuggestion() {
+ assertEquals("packageName", cr.computeSuggestion(null));
+ assertEquals("x", cr.computeSuggestion("X"));
+ }
+
+ public void testPredicate2() {
+ Object me = Model.getModelManagementFactory().createPackage();
+ Model.getCoreHelper().setName(me, null);
+ assertFalse(cr.predicate2(me, null));
+
+ Model.getCoreHelper().setName(me, "Uppercase");
+ assertTrue(cr.predicate2(me, null));
+
+ Model.getCoreHelper().setName(me, "lowercase");
+ assertFalse(cr.predicate2(me, null));
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/package.html
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/package.html?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/cognitive/critics/package.html 2007-08-13 09:07:56-0700
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN" >
+<html>
+<head>
+<!--
+ Copyright (c) 1996-2004 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.
+-->
+</head>
+<body>
+<!--
+##### TYPE YOUR PACKAGE COMMENTS HERE. BEGIN WITH A #####
+##### ONE-SENTENCE SUMMARY STARTING WITH A VERB LIKE: #####
+Provides for....
+-->
+
+</body>
+</html>
\ No newline at end of file
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/activity/ui/TestUMLActivityDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/activity/ui/TestUMLActivityDiagram.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/activity/ui/TestUMLActivityDiagram.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,63 @@
+// $Id:TestUMLActivityDiagram.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 1996-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.uml.diagram.activity.ui;
+
+import org.argouml.uml.diagram.activity.ActivityDiagramGraphModel;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+/**
+ * General test methods for UMLActivityDiagrams
+ */
+public class TestUMLActivityDiagram extends TestCase {
+
+ /**
+ * The constructor.
+ *
+ * @param name the test name
+ */
+ public TestUMLActivityDiagram(String name) {
+ super(name);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test the UMLActivityDiagram emtpy constructor.
+ * The graph model should always be a ActivityDiagramGraphModel
+ */
+ public void testUMLActivityDiagram() {
+ UMLActivityDiagram diagram = new UMLActivityDiagram();
+ assertTrue(diagram.getGraphModel()
+ instanceof ActivityDiagramGraphModel);
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/collaboration/ui/TestUMLCollaborationDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/collaboration/ui/TestUMLCollaborationDiagram.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/collaboration/ui/TestUMLCollaborationDiagram.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,64 @@
+// $Id:TestUMLCollaborationDiagram.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 1996-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.uml.diagram.collaboration.ui;
+
+import org.argouml.uml.diagram.collaboration.CollabDiagramGraphModel;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+
+/**
+ * General test methods for UMLUseCaseDiagrams
+ */
+public class TestUMLCollaborationDiagram extends TestCase {
+
+ /**
+ * The constructor.
+ *
+ * @param name the test name
+ */
+ public TestUMLCollaborationDiagram(String name) {
+ super(name);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test the UMLCollaborationDiagram emtpy constructor.
+ * The graph model should always be a CollabDiagramGraphModel
+ */
+ public void testUMLCollaborationDiagram() {
+ UMLCollaborationDiagram diagram = new UMLCollaborationDiagram();
+ assertTrue(diagram.getGraphModel()
+ instanceof CollabDiagramGraphModel);
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/deployment/ui/TestUMLDeploymentDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/deployment/ui/TestUMLDeploymentDiagram.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/deployment/ui/TestUMLDeploymentDiagram.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,64 @@
+// $Id:TestUMLDeploymentDiagram.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 1996-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.uml.diagram.deployment.ui;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.uml.diagram.deployment.DeploymentDiagramGraphModel;
+
+
+/**
+ * General test methods for UMLDeploymentDiagrams
+ */
+public class TestUMLDeploymentDiagram extends TestCase {
+
+ /**
+ * The constructor.
+ *
+ * @param name the test name
+ */
+ public TestUMLDeploymentDiagram(String name) {
+ super(name);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test the UMLDeploymentDiagram emtpy constructor.
+ * The graph model should always be a DeploymentDiagramGraphModel
+ */
+ public void testUMLDeploymentDiagram() {
+ UMLDeploymentDiagram diagram = new UMLDeploymentDiagram();
+ assertTrue(diagram.getGraphModel()
+ instanceof DeploymentDiagramGraphModel);
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/sequence/ui/TestUMLSequenceDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/sequence/ui/TestUMLSequenceDiagram.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/sequence/ui/TestUMLSequenceDiagram.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,63 @@
+// $Id:TestUMLSequenceDiagram.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 1996-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.uml.diagram.sequence.ui;
+
+import org.argouml.uml.diagram.sequence.SequenceDiagramGraphModel;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+/**
+ * General test methods for UMLUseCaseDiagrams
+ */
+public class TestUMLSequenceDiagram extends TestCase {
+
+ /**
+ * The constructor.
+ *
+ * @param name the test name
+ */
+ public TestUMLSequenceDiagram(String name) {
+ super(name);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test the UMLUseCaseDiagram emtpy constructor.
+ * The graph model should always be a UseCaseDiagramGraphModel
+ */
+ public void testUMLSequenceDiagram() {
+ UMLSequenceDiagram diagram = new UMLSequenceDiagram();
+ assertTrue(diagram.getGraphModel()
+ instanceof SequenceDiagramGraphModel);
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/state/ui/TestFigClonable.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/state/ui/TestFigClonable.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/state/ui/TestFigClonable.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,148 @@
+// $Id:TestFigClonable.java 12725 2007-05-30 19:02:13Z tfmorris $
+// Copyright (c) 1996-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.uml.diagram.state.ui;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+/**
+ * Tests whether Figs in state.ui are clonable,
+ * apart from FigStateVertex which is abstract.
+ */
+public class TestFigClonable extends TestCase {
+
+ /**
+ * The constructor.
+ *
+ * @param name the test name
+ */
+ public TestFigClonable(String name) {
+ super(name);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Try to clone {@link FigBranchState}.
+ */
+ public void testBranchStateClonable() {
+ FigBranchState fig = new FigBranchState();
+ FigBranchState figClone = (FigBranchState) fig.clone();
+ assertNotNull(figClone);
+ }
+
+ /**
+ * Try to clone {@link FigCompositeState}.
+ */
+ public void testCompositeStateClonable() {
+ FigCompositeState fig = new FigCompositeState();
+ FigCompositeState figClone = (FigCompositeState) fig.clone();
+ assertNotNull(figClone);
+ }
+
+ /**
+ * Try to clone {@link FigDeepHistoryState}.
+ */
+ public void testDeepHistoryStateClonable() {
+ FigDeepHistoryState fig = new FigDeepHistoryState();
+ FigDeepHistoryState figClone = (FigDeepHistoryState) fig.clone();
+ assertNotNull(figClone);
+ }
+
+ /**
+ * Try to clone {@link FigFinalState}.
+ */
+ public void testFinalStateClonable() {
+ FigFinalState fig = new FigFinalState();
+ FigFinalState figClone = (FigFinalState) fig.clone();
+ assertNotNull(figClone);
+ }
+
+
+ /**
+ * Try to clone {@link FigForkState}.
+ */
+ public void testForkStateClonable() {
+ FigForkState fig = new FigForkState();
+ FigForkState figClone = (FigForkState) fig.clone();
+ assertNotNull(figClone);
+ }
+
+ /**
+ * Try to clone {@link FigInitialState}.
+ */
+ public void testInitialStateClonable() {
+ FigInitialState fig = new FigInitialState();
+ FigInitialState figClone = (FigInitialState) fig.clone();
+ assertNotNull(figClone);
+ }
+
+
+ /**
+ * Try to clone {@link FigJoinState}.
+ */
+ public void testJoinStateClonable() {
+ FigJoinState fig = new FigJoinState();
+ FigJoinState figClone = (FigJoinState) fig.clone();
+ assertNotNull(figClone);
+ }
+
+ /**
+ * Try to clone {@link FigShallowHistoryState}.
+ */
+ public void testShallowHistoryStateClonable() {
+ FigShallowHistoryState fig = new FigShallowHistoryState();
+ FigShallowHistoryState figClone = (FigShallowHistoryState) fig.clone();
+ assertNotNull(figClone);
+ }
+
+ /**
+ * Try to clone {@linkFigState}.
+ */
+ public void testSimpleStateClonable() {
+ FigSimpleState fig = new FigSimpleState();
+ FigSimpleState figClone = (FigSimpleState) fig.clone();
+ assertNotNull(figClone);
+ }
+
+
+ /**
+ * Try to clone {@link FigTransistion}.
+ */
+ public void testTransitionClonable() {
+ FigTransition fig = new FigTransition();
+ FigTransition figClone = (FigTransition) fig.clone();
+ assertNotNull(figClone);
+ }
+
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/state/ui/TestUMLStateDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/state/ui/TestUMLStateDiagram.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/state/ui/TestUMLStateDiagram.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,63 @@
+// $Id:TestUMLStateDiagram.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 1996-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.uml.diagram.state.ui;
+
+import org.argouml.uml.diagram.state.StateDiagramGraphModel;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+/**
+ * General test methods for UMLUseCaseDiagrams
+ */
+public class TestUMLStateDiagram extends TestCase {
+
+ /**
+ * The constructor.
+ *
+ * @param name the test name
+ */
+ public TestUMLStateDiagram(String name) {
+ super(name);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test the UMLUseCaseDiagram emtpy constructor.
+ * The graph model should always be a UseCaseDiagramGraphModel
+ */
+ public void testUMLStateDiagram() {
+ UMLStateDiagram diagram = new UMLStateDiagram();
+ assertTrue(diagram.getGraphModel()
+ instanceof StateDiagramGraphModel);
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/state/ui/package.html
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/state/ui/package.html?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/state/ui/package.html 2007-08-13 09:07:56-0700
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+ Copyright (c) 2005 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.
+-->
+</head>
+<body bgcolor="white">
+Tests for the package.
+
+</body>
+</html>
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/static_structure/ui/TestUMLClassDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/static_structure/ui/TestUMLClassDiagram.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/static_structure/ui/TestUMLClassDiagram.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,117 @@
+// $Id:TestUMLClassDiagram.java 12987 2007-07-05 14:28:59Z mvw $
+// Copyright (c) 1996-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.uml.diagram.static_structure.ui;
+
+import java.util.Collections;
+
+import junit.framework.TestCase;
+
+import org.argouml.model.InitializeModel;
+import org.argouml.model.Model;
+import org.argouml.notation.InitNotation;
+import org.argouml.notation.providers.java.InitNotationJava;
+import org.argouml.notation.providers.uml.InitNotationUml;
+import org.argouml.uml.diagram.static_structure.ClassDiagramGraphModel;
+import org.tigris.gef.graph.GraphModel;
+import org.tigris.gef.presentation.Fig;
+
+/**
+ * General test methods for UMLClassDiagrams
+ */
+public class TestUMLClassDiagram extends TestCase {
+
+ private static Object[] nodeTypes;
+
+ /**
+ * The constructor.
+ *
+ * @param name
+ * the test name
+ */
+ public TestUMLClassDiagram(String name) {
+ super(name);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ (new InitNotation()).init();
+ (new InitNotationUml()).init();
+ (new InitNotationJava()).init();
+
+ InitializeModel.initializeDefault();
+ nodeTypes =
+ new Object[] {
+ Model.getCoreFactory().createClass(),
+ Model.getCoreFactory().createComment(),
+ Model.getCoreFactory().createDataType(),
+ Model.getCoreFactory().createEnumeration(),
+ Model.getCommonBehaviorFactory().createException(),
+ Model.getCoreFactory().createInterface(),
+ Model.getModelManagementFactory().createModel(),
+ Model.getModelManagementFactory().createPackage(),
+ Model.getCommonBehaviorFactory().createSignal(),
+ Model.getExtensionMechanismsFactory()
+ .createStereotype(),
+ Model.getModelManagementFactory().createSubsystem(),
+ Model.getUseCasesFactory().createActor(),
+ Model.getUseCasesFactory().createUseCase(),
+ Model.getCommonBehaviorFactory().createObject(),
+ Model.getCommonBehaviorFactory()
+ .createComponentInstance(),
+ Model.getCommonBehaviorFactory().createNodeInstance(),
+ };
+ }
+
+ /**
+ * Test the UMLClassDiagram empty constructor. The graph model should always
+ * be a ClassDiagramGraphModel
+ */
+ public void testUMLClassDiagram() {
+ UMLClassDiagram diagram = new UMLClassDiagram();
+ assertTrue(diagram.getGraphModel() instanceof ClassDiagramGraphModel);
+ }
+
+ /**
+ * Test ClassDiagramRenderer lookup mechanism for resolving model element
+ * types to a Fig which can be added to the diagram.
+ */
+ public void testClassDiagramRenderer() {
+ UMLClassDiagram diagram = new UMLClassDiagram();
+ ClassDiagramRenderer renderer = new ClassDiagramRenderer();
+ GraphModel gm = new ClassDiagramGraphModel();
+ for (int i = 0; i < nodeTypes.length; i++) {
+ Fig fig =
+ renderer.getFigNodeFor(
+ gm, diagram.getLayer(), nodeTypes[i],
+ Collections.EMPTY_MAP);
+ assertNotNull("failed to get Fig for " + nodeTypes[i], fig);
+ diagram.add(fig);
+ }
+
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/ui/TestActionAddAllClassesFromModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/ui/TestActionAddAllClassesFromModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/ui/TestActionAddAllClassesFromModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,100 @@
+// $Id:TestActionAddAllClassesFromModel.java 12987 2007-07-05 14:28:59Z mvw $
+// Copyright (c) 2003-2006 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.uml.diagram.ui;
+
+import junit.framework.TestCase;
+
+import org.argouml.notation.InitNotation;
+import org.argouml.notation.providers.java.InitNotationJava;
+import org.argouml.notation.providers.uml.InitNotationUml;
+import org.argouml.uml.diagram.static_structure.ui.UMLClassDiagram;
+
+/**
+ * @author Timothy M. Lebo
+ * @since November 3, 2003
+ */
+public class TestActionAddAllClassesFromModel extends TestCase {
+
+ private ActionAddAllClassesFromModel action;
+ private UMLClassDiagram diagram;
+
+ /**
+ * Constructor for TestActionAddAllClassesFromModel.
+ * @param arg0 test case name
+ */
+ public TestActionAddAllClassesFromModel(String arg0) {
+ super(arg0);
+ }
+
+ /**
+ * @throws Exception if something goes wrong.
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ (new InitNotation()).init();
+ (new InitNotationUml()).init();
+ (new InitNotationJava()).init();
+
+ diagram = new UMLClassDiagram();
+ action = new ActionAddAllClassesFromModel("Add all classes from model",
+ diagram);
+ }
+
+ /**
+ * @author Timothy M. Lebo
+ * @since November 3, 2003
+ */
+ public void testConstruction() {
+ new ActionAddAllClassesFromModel("Add all classes from model",
+ diagram);
+ }
+
+ /**
+ * Makes sure the option is enabled.
+ *
+ * ActionAddAllClassesFromModel expects to receive a
+ * UMLClassDiagram in its constructor. If the Class of the class
+ * diagrams in argoUML changes, this needs to change also.
+ *
+ * @author Timothy M. Lebo
+ * @since November 3, 2003
+ */
+ public void testShouldBeEnabled() {
+ assertTrue(action.isEnabled());
+ }
+
+ /**
+ * Makes sure the option is not enabled if its diagram isn't
+ * UMLClassDiagram.
+ *
+ * @author Timothy M. Lebo
+ * @since November 3, 2003
+ */
+ public void testShouldNotBeEnabled() {
+ action = new ActionAddAllClassesFromModel("Add all classes from model",
+ new Object());
+ assertEquals(action.isEnabled(), false);
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/ui/TestTabDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/ui/TestTabDiagram.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/ui/TestTabDiagram.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,154 @@
+// $Id:TestTabDiagram.java 12927 2007-06-29 20:13:59Z mvw $
+// Copyright (c) 1996-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.uml.diagram.ui;
+
+import java.util.Date;
+
+import junit.framework.TestCase;
+
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.Model;
+import org.argouml.ui.targetmanager.TargetManager;
+import org.argouml.uml.diagram.ArgoDiagram;
+import org.argouml.uml.diagram.static_structure.ui.FigClass;
+import org.argouml.uml.diagram.static_structure.ui.UMLClassDiagram;
+import org.tigris.gef.graph.presentation.JGraph;
+
+/**
+ * @author [email protected]
+ * @since Apr 13, 2003
+ */
+public class TestTabDiagram extends TestCase {
+
+ private static final int NUMBER_OF_DIAGRAMS = 10;
+
+ private static final boolean PERFORMANCE_TEST = false;
+
+ private ArgoDiagram diagram;
+
+ /**
+ * Constructor for TestTabDiagram.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestTabDiagram(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ diagram = new UMLClassDiagram();
+ }
+
+ /*
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ diagram = null;
+
+ }
+
+ /**
+ * Test diagram tab construction.
+ */
+ public void testConstruction() {
+ try {
+ TabDiagram tabDiagram = new TabDiagram();
+ assertEquals(tabDiagram.getTitle(), "Diagram");
+ } catch (Exception noHead) {
+ }
+ }
+
+ /**
+ * Tests the setTarget method when a diagram is the target.
+ */
+ public void testSetTargetWithDiagram() {
+ try {
+ TabDiagram tabDiagram = new TabDiagram();
+ TargetManager.getInstance().setTarget(diagram);
+ assertEquals(
+ tabDiagram.getJGraph().getGraphModel(),
+ diagram.getGraphModel());
+ assertEquals(tabDiagram.getTarget(), diagram);
+ assertTrue(tabDiagram.shouldBeEnabled(diagram));
+ } catch (Exception noHead) {
+ }
+ }
+
+ /**
+ * Tests the settarget method when the target is not a diagram but a simple
+ * object.
+ *
+ */
+ public void testSetTargetWithNoDiagram() {
+ try {
+ TabDiagram tabDiagram = new TabDiagram();
+ JGraph graph = tabDiagram.getJGraph();
+ TargetManager.getInstance().setTarget(diagram);
+ // the graph should stay the same.
+ assertEquals(tabDiagram.getJGraph(), graph);
+ } catch (Exception noHead) {
+ }
+ }
+
+ /**
+ * Test the performance of adding an operation to 1 class that's
+ * represented on 10 different diagrams. The last created diagram
+ * is the one selected.
+ *
+ */
+ public void testFireModelEventPerformance() {
+ // setup
+ if (PERFORMANCE_TEST) {
+ try {
+ ArgoDiagram[] diagrams = new ArgoDiagram[NUMBER_OF_DIAGRAMS];
+ Project project =
+ ProjectManager.getManager().getCurrentProject();
+ Object clazz = Model.getCoreFactory().buildClass();
+ for (int i = 0; i < NUMBER_OF_DIAGRAMS; i++) {
+ diagrams[i] = new UMLClassDiagram(project.getRoot());
+ diagrams[i].add(
+ new FigClass(diagrams[i].getGraphModel(), clazz));
+ TargetManager.getInstance().setTarget(diagrams[i]);
+ }
+
+ // real test
+ long currentTime = (new Date()).getTime();
+ Object returnType = project.getDefaultReturnType();
+ Model.getCoreFactory().buildOperation(clazz, returnType);
+ System.out.println(
+ "Time needed for adding operation: "
+ + ((new Date()).getTime() - currentTime));
+ } catch (Exception noHead) {
+ }
+ }
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/ui/package.html
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/ui/package.html?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/ui/package.html 2007-08-13 09:07:56-0700
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+ Copyright (c) 1996-99 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.
+-->
+</head>
+<body bgcolor="white">
+<!--
+##### TYPE YOUR PACKAGE COMMENTS HERE. BEGIN WITH A #####
+##### ONE-SENTENCE SUMMARY STARTING WITH A VERB LIKE: #####
+Provides for....
+-->
+
+</body>
+</html>
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/use_case/ui/TestFigClonable.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/use_case/ui/TestFigClonable.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/use_case/ui/TestFigClonable.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,71 @@
+// $Id:TestFigClonable.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 1996-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.uml.diagram.use_case.ui;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+/**
+ * Test if a Fig is cloneable.
+ */
+public class TestFigClonable extends TestCase {
+
+ /**
+ * The constructor.
+ *
+ * @param name the test name
+ */
+ public TestFigClonable(String name) {
+ super(name);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Try to clone {@link FigUseCase}.
+ */
+ public void testUseCaseClonable() {
+ FigUseCase usecase = new FigUseCase();
+ FigUseCase usecaseclone;
+
+ usecaseclone = (FigUseCase) usecase.clone();
+ }
+
+ /**
+ * Try to clone {@link FigActor}.
+ */
+ public void testActorClonable() {
+ FigActor actor = new FigActor();
+ FigActor actorclone;
+
+ actorclone = (FigActor) actor.clone();
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/use_case/ui/TestUMLUseCaseDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/use_case/ui/TestUMLUseCaseDiagram.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/use_case/ui/TestUMLUseCaseDiagram.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,63 @@
+// $Id:TestUMLUseCaseDiagram.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 1996-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.uml.diagram.use_case.ui;
+
+import org.argouml.uml.diagram.use_case.UseCaseDiagramGraphModel;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+/**
+ * General test methods for UMLUseCaseDiagrams
+ */
+public class TestUMLUseCaseDiagram extends TestCase {
+
+ /**
+ * The constructor.
+ *
+ * @param name the test name
+ */
+ public TestUMLUseCaseDiagram(String name) {
+ super(name);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test the UMLUseCaseDiagram emtpy constructor.
+ * The graph model should always be a UseCaseDiagramGraphModel
+ */
+ public void testUMLUseCaseDiagram() {
+ UMLUseCaseDiagram diagram = new UMLUseCaseDiagram();
+ assertTrue(diagram.getGraphModel()
+ instanceof UseCaseDiagramGraphModel);
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/use_case/ui/package.html
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/use_case/ui/package.html?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/diagram/use_case/ui/package.html 2007-08-13 09:07:56-0700
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+ Copyright (c) 2005 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.
+-->
+</head>
+<body bgcolor="white">
+Tests for the package.
+
+</body>
+</html>
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/package.html
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/package.html?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/package.html 2007-08-13 09:07:56-0700
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+ Copyright (c) 1996-2004 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.
+-->
+</head>
+<body bgcolor="white">
+<!--
+##### TYPE YOUR PACKAGE COMMENTS HERE. BEGIN WITH A #####
+##### ONE-SENTENCE SUMMARY STARTING WITH A VERB LIKE: #####
+Provides for....
+-->
+
+</body>
+</html>
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/DummyImportSettings.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/DummyImportSettings.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/DummyImportSettings.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,60 @@
+// $Id:DummyImportSettings.java 12210 2007-03-07 09:28:39Z tfmorris $
+// 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.uml.reveng;
+
+/**
+ * A dummy implementation of the ImportSettings that can be
+ * used by tests.
+ *
+ * @author Tom Morris
+ *
+ */
+public class DummyImportSettings implements ImportSettings {
+
+ public int getImportLevel() {
+ return ImportSettings.DETAIL_FULL;
+ }
+
+ public String getInputSourceEncoding() {
+ return "cp1252";
+ }
+
+ public boolean isAttributeSelected() {
+ return false;
+ }
+
+ public boolean isCreateDiagramsSelected() {
+ return false;
+ }
+
+ public boolean isDatatypeSelected() {
+ return false;
+ }
+
+ public boolean isMinimizeFigsSelected() {
+ return false;
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/TestJavaImportClass.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/TestJavaImportClass.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/TestJavaImportClass.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,492 @@
+// $Id:TestJavaImportClass.java 12730 2007-05-30 19:05:59Z tfmorris $
+// Copyright (c) 1996-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.uml.reveng;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.io.StringReader;
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+import org.argouml.model.Model;
+import org.argouml.uml.reveng.java.JavaLexer;
+import org.argouml.uml.reveng.java.JavaRecognizer;
+import org.argouml.uml.reveng.java.Modeller;
+
+import antlr.RecognitionException;
+import antlr.TokenStreamException;
+
+/**
+ * Test case to test the import of a Java source file. The content of the Java
+ * source file is a private constant at the bottom of the source of this class.
+ * The test methods are specially designed for this Java source constant.
+ * Feeding of the diagram subsystem is disabled; only model elements are
+ * created and checked. For testing with another Java source file, copy this
+ * test case, change the Java source constant and modify the test method (the
+ * setUp method need not be changed).<p>
+ */
+public class TestJavaImportClass extends TestCase {
+ /*
+ * @see junit.framework.TestCase#TestCase(String)
+ */
+ public TestJavaImportClass(String str) {
+ super(str);
+ InitializeModel.initializeDefault();
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() {
+ if (isParsed) {
+ return;
+ }
+
+ JavaLexer lexer = new JavaLexer(new StringReader(PARSERINPUT));
+ assertNotNull("Creation of lexer failed.", lexer);
+
+ lexer.setTokenObjectClass("org.argouml.uml.reveng.java.ArgoToken");
+
+ JavaRecognizer parser = new JavaRecognizer(lexer);
+ assertNotNull("Creation of parser failed.", parser);
+
+ parsedModel = Model.getModelManagementFactory().createModel();
+ assertNotNull("Creation of model failed.", parsedModel);
+
+ Model.getModelManagementFactory().setRootModel(parsedModel);
+
+ Modeller modeller =
+ new Modeller(parsedModel, new DummyImportSettings(),
+ "TestClass.java");
+ assertNotNull("Creation of Modeller instance failed.", modeller);
+
+ try {
+ parser.compilationUnit(modeller, lexer);
+ isParsed = true;
+ } catch (RecognitionException e) {
+ fail("Parsing of Java source failed." + e);
+ } catch (TokenStreamException e) {
+ fail("Parsing of Java source failed." + e);
+ }
+ }
+
+ /**
+ * Test if the package was processed correctly.
+ */
+ public void testPackage() {
+ parsedPackage = Model.getFacade().lookupIn(parsedModel, "testpackage");
+ assertNotNull("No package \"testpackage\" found in model.",
+ parsedPackage);
+ assertEquals("Inconsistent package name.",
+ "testpackage", Model.getFacade().getName(parsedPackage));
+ assertEquals("The namespace of the package should be the model.",
+ parsedModel, Model.getFacade().getNamespace(parsedPackage));
+ assertTrue("The package should be recognized as a package.",
+ Model.getFacade().isAPackage(parsedPackage));
+ }
+
+ /**
+ * Test if the import was processed correctly.
+ */
+ public void testImport() {
+ if (parsedPackage == null) {
+ parsedPackage =
+ Model.getFacade().lookupIn(parsedModel, "testpackage");
+ assertNotNull("No package \"testpackage\" found in model.",
+ parsedPackage);
+ }
+ Collection ownedElements =
+ Model.getFacade().getOwnedElements(parsedPackage);
+ assertNotNull("No elements owned by \"testpackage\".", ownedElements);
+ Object component = null;
+ Iterator iter = ownedElements.iterator();
+ while (iter.hasNext()) {
+ Object element = iter.next();
+ if (Model.getFacade().isAComponent(element)) {
+ component = element;
+ break;
+ }
+ }
+ assertNotNull("No component found.", component);
+ assertEquals("The component name is wrong.",
+ "TestClass.java", Model.getFacade().getName(component));
+ Collection dependencies =
+ Model.getFacade().getClientDependencies(component);
+ assertNotNull("No dependencies found for component.", dependencies);
+ Object permission = null;
+ iter = dependencies.iterator();
+ while (iter.hasNext()) {
+ Object element = iter.next();
+ if (Model.getFacade().isAPermission(element)) {
+ permission = element;
+ break;
+ }
+ }
+ assertNotNull("No import found.", permission);
+ assertEquals("The import name is wrong.",
+ "TestClass.java -> Observer",
+ Model.getFacade().getName(permission));
+ Collection suppliers = Model.getFacade().getSuppliers(permission);
+ assertNotNull("No suppliers found in import.", suppliers);
+ Object supplier = null;
+ iter = suppliers.iterator();
+ if (iter.hasNext()) {
+ supplier = iter.next();
+ }
+ assertNotNull("No supplier found in import.", supplier);
+ assertEquals("The import supplier name is wrong.",
+ "Observer", Model.getFacade().getName(supplier));
+ Object namespace = Model.getFacade().getNamespace(supplier);
+ assertNotNull("The import supplier has no namespace.", namespace);
+ assertEquals("Expected namespace name \"util\".",
+ "util", Model.getFacade().getName(namespace));
+ namespace = Model.getFacade().getNamespace(namespace);
+ assertNotNull("The namespace \"util\" has no namespace.", namespace);
+ assertEquals("Expected namespace name \"java\".",
+ "java", Model.getFacade().getName(namespace));
+ assertEquals("The namespace of \"java\" should be the model.",
+ parsedModel, Model.getFacade().getNamespace(namespace));
+ }
+
+ /**
+ * Test if the import was processed correctly.
+ */
+ public void testClass() {
+ if (parsedPackage == null) {
+ parsedPackage =
+ Model.getFacade().lookupIn(parsedModel, "testpackage");
+ assertNotNull("No package \"testpackage\" found in model.",
+ parsedPackage);
+ }
+ parsedClass = Model.getFacade().lookupIn(parsedPackage, "TestClass");
+ assertNotNull("No class \"TestClass\" found.", parsedClass);
+ assertEquals("Inconsistent class name.",
+ "TestClass", Model.getFacade().getName(parsedClass));
+ assertEquals("The namespace of the class should be \"testpackage\".",
+ parsedPackage, Model.getFacade().getNamespace(parsedClass));
+ assertTrue("The class should be recognized as a class.",
+ Model.getFacade().isAClass(parsedClass));
+ assertTrue("The class should be abstract.",
+ Model.getFacade().isAbstract(parsedClass));
+ assertTrue("The class should be public.",
+ Model.getFacade().isPublic(parsedClass));
+ Collection generalizations =
+ Model.getFacade().getGeneralizations(parsedClass);
+ assertNotNull("No generalizations found for class.", generalizations);
+ Object generalization = null;
+ Iterator iter = generalizations.iterator();
+ if (iter.hasNext()) {
+ generalization = iter.next();
+ }
+ assertNotNull("No generalization found for class.", generalization);
+ assertEquals("The generalization name is wrong.",
+ "TestClass -> Object", Model.getFacade().getName(generalization));
+ assertEquals("The child of the generalization should be the class.",
+ parsedClass, Model.getFacade().getChild(generalization));
+ assertEquals("The parent of the generalization should be \"Object\".",
+ "Object",
+ Model.getFacade().getName(
+ Model.getFacade().getParent(generalization)));
+ Collection dependencies =
+ Model.getFacade().getClientDependencies(parsedClass);
+ assertNotNull("No dependencies found for class.", dependencies);
+ Object abstraction = null;
+ iter = dependencies.iterator();
+ if (iter.hasNext()) {
+ abstraction = iter.next();
+ }
+ assertNotNull("No abstraction found for class.", abstraction);
+ assertEquals("The abstraction name is wrong.",
+ "TestClass -> Observer", Model.getFacade().getName(abstraction));
+ try {
+ assertEquals("The client of the abstraction should be the class.",
+ parsedClass,
+ Model.getFacade().getClients(abstraction)
+ .iterator().next());
+ } catch (IllegalArgumentException ex) {
+ fail("The implementation dependency has no clients.");
+ }
+ try {
+ assertEquals(
+ "The supplier of the abstraction should be \"Observer\".",
+ "Observer", Model.getFacade().getName(
+ Model.getFacade().getSuppliers(abstraction)
+ .iterator().next()));
+ } catch (IllegalArgumentException ex) {
+ fail("The abstraction has no suppliers.");
+ }
+ }
+
+ /**
+ * Test if the attributes were processed correctly.
+ */
+ public void testAttributes() {
+ if (parsedPackage == null) {
+ parsedPackage =
+ Model.getFacade().lookupIn(parsedModel, "testpackage");
+ assertNotNull("No package \"testpackage\" found in model.",
+ parsedPackage);
+ }
+ if (parsedClass == null) {
+ parsedClass =
+ Model.getFacade().lookupIn(parsedPackage, "TestClass");
+ assertNotNull("No class \"TestClass\" found.", parsedClass);
+ }
+ Collection attributes = Model.getFacade().getAttributes(parsedClass);
+ assertNotNull("No attributes found ib class.", attributes);
+ assertEquals("Number of attributes is wrong", 2, attributes.size());
+ Object attribute = null;
+ Object attributeForn = null;
+ Object attributeFors = null;
+ Iterator iter = attributes.iterator();
+ while (iter.hasNext()) {
+ attribute = iter.next();
+ assertTrue("The attribute should be recognized as an attribute.",
+ Model.getFacade().isAAttribute(attribute));
+ if ("n".equals(Model.getFacade().getName(attribute))) {
+ attributeForn = attribute;
+ } else if ("s".equals(Model.getFacade().getName(attribute))) {
+ attributeFors = attribute;
+ }
+ }
+ assertTrue("The attributes have wrong names.",
+ attributeForn != null && attributeFors != null);
+ Object attribType = Model.getFacade().getType(attributeForn);
+ Object initializer = Model.getFacade().getInitialValue(attributeForn);
+ assertTrue("Attribute n should be private.",
+ Model.getFacade().isPrivate(attributeForn));
+ assertFalse("Attribute n should not be final.",
+ Model.getFacade().isReadOnly(attributeForn));
+ assertTrue("Attribute n should have type int.",
+ "int".equals(Model.getFacade().getName(attribType)));
+ assertTrue("Attribute n has no initializer.",
+ Model.getFacade().isInitialized(attributeForn)
+ && initializer != null);
+ assertEquals("The initializer of attribute n is wrong.",
+ " 0", Model.getFacade().getBody(initializer));
+ attribType = Model.getFacade().getType(attributeFors);
+ initializer = Model.getFacade().getInitialValue(attributeFors);
+ assertTrue("Attribute s should be public.",
+ Model.getFacade().isPublic(attributeFors));
+ assertTrue("Attribute s should be static.",
+ Model.getFacade().isStatic(attributeFors));
+ assertTrue("Attribute s should be final.",
+ Model.getFacade().isReadOnly(attributeFors));
+ assertTrue("Attribute s should have type String.",
+ "String".equals(Model.getFacade().getName(attribType)));
+ assertTrue("Attribute s has no initializer.",
+ Model.getFacade().isInitialized(attributeFors)
+ && initializer != null);
+ assertEquals("The initializer of attribute s is wrong.",
+ " \"final String object\"", Model.getFacade().getBody(initializer));
+ }
+
+ /**
+ * Test if the association was processed correctly.
+ */
+ public void testAssociation() {
+ if (parsedPackage == null) {
+ parsedPackage =
+ Model.getFacade().lookupIn(parsedModel, "testpackage");
+ assertNotNull("No package \"testpackage\" found in model.",
+ parsedPackage);
+ }
+ if (parsedClass == null) {
+ parsedClass =
+ Model.getFacade().lookupIn(parsedPackage, "TestClass");
+ assertNotNull("No class \"TestClass\" found.", parsedClass);
+ }
+ Collection associationEnds =
+ Model.getFacade().getAssociationEnds(parsedClass);
+ assertNotNull("No association ends found ib class.", associationEnds);
+ assertEquals("Number of association ends is wrong", 2,
+ associationEnds.size());
+ Object associationEnd = null;
+ Object association = null;
+ int navigableCount = 0;
+ Iterator iter = associationEnds.iterator();
+ while (iter.hasNext()) {
+ associationEnd = iter.next();
+ assertTrue(
+ "The attribute end should be recognized as "
+ + "an attribute end.",
+ Model.getFacade().isAAssociationEnd(associationEnd));
+ assertEquals("The type of both association ends must be the class.",
+ parsedClass, Model.getFacade().getType(associationEnd));
+ if (association == null) {
+ association = Model.getFacade().getAssociation(associationEnd);
+ assertTrue(
+ "The attribute should be recognized as an attribute.",
+ Model.getFacade().isAAssociation(association));
+ assertEquals("The association name is wrong.",
+ "TestClass -> TestClass",
+ Model.getFacade().getName(association));
+ } else {
+ assertEquals(
+ "Association end must belong to the same association.",
+ association,
+ Model.getFacade().getAssociation(associationEnd));
+ }
+ if (Model.getFacade().isNavigable(associationEnd)) {
+ ++navigableCount;
+ }
+ }
+ assertEquals("Only one association end must be navigable.",
+ 1, navigableCount);
+ }
+
+ /**
+ * Test if the operations were processed correctly.
+ */
+ public void testOperations() {
+ if (parsedPackage == null) {
+ parsedPackage =
+ Model.getFacade().lookupIn(parsedModel, "testpackage");
+ assertNotNull("No package \"testpackage\" found in model.",
+ parsedPackage);
+ }
+ if (parsedClass == null) {
+ parsedClass =
+ Model.getFacade().lookupIn(parsedPackage, "TestClass");
+ assertNotNull("No class \"TestClass\" found.", parsedClass);
+ }
+ Collection operations = Model.getFacade().getOperations(parsedClass);
+ assertNotNull("No operations found in class.", operations);
+ assertEquals("Number of operations is wrong", 4, operations.size());
+ Object operation = null;
+ Object operationForTestClass = null;
+ Object operationForupdate = null;
+ Object operationForgetString = null;
+ Object operationForx = null;
+ Iterator iter = operations.iterator();
+ while (iter.hasNext()) {
+ operation = iter.next();
+ assertTrue("The operation should be recognized as an operation.",
+ Model.getFacade().isAOperation(operation));
+ if ("TestClass".equals(Model.getFacade().getName(operation))) {
+ operationForTestClass = operation;
+ } else if ("update".equals(Model.getFacade().getName(operation))) {
+ operationForupdate = operation;
+ } else if ("getString".equals(
+ Model.getFacade().getName(operation))) {
+ operationForgetString = operation;
+ } else if ("x".equals(Model.getFacade().getName(operation))) {
+ operationForx = operation;
+ }
+ }
+ assertTrue("The operations have wrong names.",
+ operationForTestClass != null
+ && operationForupdate != null
+ && operationForgetString != null
+ && operationForx != null);
+ assertTrue("Operation TestClass should be protected.",
+ Model.getFacade().isProtected(operationForTestClass));
+ assertEquals("The body of operation TestClass is wrong.",
+ BODY2, getBody(operationForTestClass));
+ assertTrue("Operation update should be public.",
+ Model.getFacade().isPublic(operationForupdate));
+ assertEquals("The body of operation update is wrong.",
+ BODY1,
+ getBody(operationForupdate));
+ assertTrue("Operation getString should be static.",
+ Model.getFacade().isStatic(operationForgetString));
+ assertTrue("Operation getString should be private.",
+ Model.getFacade().isPrivate(operationForgetString));
+ assertEquals("The body of operation getString is wrong.",
+ BODY3,
+ getBody(operationForgetString));
+ assertTrue("Operation x should be abstract.",
+ Model.getFacade().isAbstract(operationForx));
+ assertTrue("Operation x should have package visibility.",
+ Model.getFacade().isPackage(operationForx));
+ }
+
+ /**
+ * Gets the (first) body of an operation.
+ *
+ * @param operation The operation.
+ * @return The first body.
+ */
+ private static String getBody(Object operation) {
+ String body = null;
+ Collection methods = Model.getFacade().getMethods(operation);
+ if (methods != null && !methods.isEmpty()) {
+ Object expression =
+ Model.getFacade().getBody(methods.iterator().next());
+ body = (String) Model.getFacade().getBody(expression);
+ }
+ return body;
+ }
+
+ /**
+ * Flag, if the Java source is parsed already.
+ */
+ private static boolean isParsed;
+
+ /**
+ * Instances of the model and its components.
+ */
+ private static Object parsedModel;
+ private static Object parsedPackage;
+ private static Object parsedClass;
+
+ private static final String BODY1 =
+ "\n if (arg instanceof TestClass) testClass = (TestClass)arg;\n";
+
+ private static final String BODY2 =
+ "\n // A constructor with a single line comment\n"
+ + " this.n = n;\n";
+
+ private static final String BODY3 =
+ "\n // A static method\n return s;\n";
+
+ /**
+ * Test input for the parser. It's the content of a Java source file. It's
+ * hardcoded here, because this test case strongly depends on this.
+ */
+ private static final String PARSERINPUT =
+ "package testpackage;\n"
+ + "import java.util.Observer;\n"
+ + "/** A Javadoc comment */\n"
+ + "public abstract class TestClass "
+ + "extends Object implements Observer {\n"
+ + " private int n = 0;\n"
+ + " protected static TestClass testClass;\n"
+ + " public static final String s = \"final String object\";\n"
+ + " protected TestClass(int n) {"
+ + BODY2
+ + " }\n"
+ + " public void update(java.util.Observable o, Object arg) {"
+ + BODY1
+ + " }\n"
+ + " /** Another Javadoc comment */\n"
+ + " private static String getString() {"
+ + BODY3
+ + " }\n"
+ + " abstract void x();\n"
+ + " /* A multiline\n"
+ + " comment\n"
+ + " */\n"
+ + "}";
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/TestJavaImportEnumeration.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/TestJavaImportEnumeration.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/TestJavaImportEnumeration.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,356 @@
+// $Id:TestJavaImportEnumeration.java 12730 2007-05-30 19:05:59Z tfmorris $
+// 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.uml.reveng;
+
+import java.io.StringReader;
+import java.util.Collection;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.model.Model;
+import org.argouml.uml.reveng.java.JavaLexer;
+import org.argouml.uml.reveng.java.JavaRecognizer;
+import org.argouml.uml.reveng.java.Modeller;
+
+import antlr.RecognitionException;
+import antlr.TokenStreamException;
+
+/**
+ * Test case to test the import of a Java source file containing a Java 5 enum.
+ * <p>
+ * The content of the Java source file is a private constant at the bottom of
+ * the source of this class. The test methods are specially designed for this
+ * Java source constant. Feeding of the diagram subsystem is disabled; only
+ * model elements are created and checked.
+ * <p>
+ * @author Tom Morris
+ */
+public class TestJavaImportEnumeration extends TestCase {
+ /*
+ * @see junit.framework.TestCase#TestCase(String)
+ */
+ public TestJavaImportEnumeration(String str) {
+ super(str);
+ InitializeModel.initializeDefault();
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() {
+ if (isParsed) {
+ return;
+ }
+
+ JavaLexer lexer = new JavaLexer(new StringReader(PARSERINPUT));
+ assertNotNull("Creation of lexer failed.", lexer);
+
+ lexer.setTokenObjectClass("org.argouml.uml.reveng.java.ArgoToken");
+
+ JavaRecognizer parser = new JavaRecognizer(lexer);
+ assertNotNull("Creation of parser failed.", parser);
+
+ parsedModel = Model.getModelManagementFactory().createModel();
+ assertNotNull("Creation of model failed.", parsedModel);
+
+ Model.getModelManagementFactory().setRootModel(parsedModel);
+
+ Modeller modeller = new Modeller(parsedModel,
+ new DummyImportSettings(), "TestClass.java");
+ assertNotNull("Creation of Modeller instance failed.", modeller);
+
+ try {
+ parser.compilationUnit(modeller, lexer);
+ isParsed = true;
+ } catch (RecognitionException e) {
+ fail("Parsing of Java source failed." + e);
+ } catch (TokenStreamException e) {
+ fail("Parsing of Java source failed." + e);
+ }
+ }
+
+ /**
+ * Test if the class with the enumeration stereotype was created
+ */
+ public void testSimpleEnumeration() {
+ if (parsedPackage == null) {
+ parsedPackage =
+ Model.getFacade().lookupIn(parsedModel, "testpackage");
+ assertNotNull("No package \"testpackage\" found in model.",
+ parsedPackage);
+ }
+ parsedClass = Model.getFacade().lookupIn(parsedPackage, "TestClass");
+
+ Object mainClass = parsedClass;
+ parsedClass = null;
+ parsedClass = getEnumeration(mainClass, "Color");
+
+ // Attributes
+
+ Collection attributes = Model.getFacade().getAttributes(parsedClass);
+ assertNotNull("No attributes found in class.", attributes);
+ assertEquals("Number of attributes is wrong", 3, attributes.size());
+ Object attribute = null;
+ Object attributeGreen = null;
+ Object attributeYellow = null;
+ Object attributeRed = null;
+
+ Iterator iter = attributes.iterator();
+ while (iter.hasNext()) {
+ attribute = iter.next();
+ assertTrue("The attribute should be recognized as an attribute.",
+ Model.getFacade().isAAttribute(attribute));
+ if ("GREEN".equals(Model.getFacade().getName(attribute))) {
+ attributeGreen = attribute;
+ } else if ("YELLOW".equals(Model.getFacade().getName(attribute))) {
+ attributeYellow = attribute;
+ } else if ("RED".equals(Model.getFacade().getName(attribute))) {
+ attributeRed = attribute;
+ }
+ }
+ assertTrue("The attributes have wrong names.",
+ attributeGreen != null
+ || attributeYellow != null
+ || attributeRed != null);
+ assertTrue("Attribute GREEN should be final.",
+ Model.getFacade().isReadOnly(attributeGreen));
+ assertTrue("Attribute GREEN should be static.",
+ Model.getFacade().isStatic(attributeGreen));
+
+ }
+
+ /**
+ * Look up an enumeration by name in its parent namespace
+ * and check that it's properly formed.
+ */
+ private Object getEnumeration(Object namespace, String name) {
+ Object enumeration = Model.getFacade().lookupIn(namespace, name);
+ assertNotNull("failed to find enumeration" + name, enumeration);
+ assertEquals("Inconsistent class name.", name,
+ Model.getFacade().getName(enumeration));
+ Collection stereotypes = Model.getFacade().getStereotypes(enumeration);
+ assertNotNull("no stereotypes found", stereotypes);
+ assertEquals("wrong number of stereotypes found", 1,
+ stereotypes.size());
+ Object stereotype = stereotypes.iterator().next();
+ assertEquals("<<enumeration stereotype>> not found", "enumeration",
+ Model.getFacade().getName(stereotype));
+ return enumeration;
+ }
+
+ /**
+ * Test if the class with the enumeration stereotype was created
+ */
+ public void testEnumeration() {
+ if (parsedPackage == null) {
+ parsedPackage =
+ Model.getFacade().lookupIn(parsedModel, "testpackage");
+ assertNotNull("No package \"testpackage\" found in model.",
+ parsedPackage);
+ }
+ parsedClass = Model.getFacade().lookupIn(parsedPackage, "TestClass");
+ assertNotNull("No class \"TestClass\" found.", parsedClass);
+ assertEquals("Inconsistent class name.",
+ "TestClass", Model.getFacade().getName(parsedClass));
+ assertEquals("The namespace of the class should be \"testpackage\".",
+ parsedPackage, Model.getFacade().getNamespace(parsedClass));
+
+ Object mainClass = parsedClass;
+ parsedClass = null;
+ parsedClass = getEnumeration(mainClass, "MessagePriority");
+
+ // Attributes
+
+ Collection attributes = Model.getFacade().getAttributes(parsedClass);
+ assertNotNull("No attributes found in class.", attributes);
+ assertEquals("Number of attributes is wrong", 4, attributes.size());
+ Object attribute = null;
+ Object attributeVP = null;
+ Object attributeLow = null;
+ Object attributeNormal = null;
+ Object attributeHigh = null;
+
+ Iterator iter = attributes.iterator();
+ while (iter.hasNext()) {
+ attribute = iter.next();
+ assertTrue("The attribute should be recognized as an attribute.",
+ Model.getFacade().isAAttribute(attribute));
+ if ("valuePersist".equals(Model.getFacade().getName(attribute))) {
+ attributeVP = attribute;
+ } else if ("LOW".equals(Model.getFacade().getName(attribute))) {
+ attributeLow = attribute;
+ } else if ("NORMAL".equals(Model.getFacade().getName(attribute))) {
+ attributeNormal = attribute;
+ } else if ("HIGH".equals(Model.getFacade().getName(attribute))) {
+ attributeHigh = attribute;
+ }
+ }
+ assertTrue("The attributes have wrong names.",
+ attributeVP != null
+ || attributeLow != null
+ || attributeNormal != null
+ || attributeHigh != null);
+ assertTrue("Attribute LOW should be final.",
+ Model.getFacade().isReadOnly(attributeLow));
+
+ assertFalse("Attribute valuePersist should not be private.",
+ Model.getFacade().isPrivate(attributeVP));
+ assertFalse("Attribute valuePersist should not be final.",
+ Model.getFacade().isReadOnly(attributeVP));
+ Object attribType = Model.getFacade().getType(attributeVP);
+ assertTrue("Attribute valuePersist should have type short.",
+ "short".equals(Model.getFacade().getName(attribType)));
+
+ // Operations
+
+ Collection operations = Model.getFacade().getOperations(parsedClass);
+ assertNotNull("No operations found in class.", operations);
+ assertEquals("Number of operations is wrong", 3, operations.size());
+ Object operation = null;
+ Object operationMP = null;
+ Object operationCP = null;
+ Object operationGVP = null;
+ iter = operations.iterator();
+ while (iter.hasNext()) {
+ operation = iter.next();
+ assertTrue("The operation should be recognized as an operation.",
+ Model.getFacade().isAOperation(operation));
+ if ("MessagePriority".equals(
+ Model.getFacade().getName(operation))) {
+ operationMP = operation;
+ } else if ("createPersist".equals(Model.getFacade().getName(
+ operation))) {
+ operationCP = operation;
+ } else if ("getValuePersist".equals(
+ Model.getFacade().getName(operation))) {
+ operationGVP = operation;
+ }
+ }
+ assertTrue("The operations have wrong names.",
+ operationMP != null
+ && operationCP != null
+ && operationGVP != null);
+ assertTrue("Constructor MessagePriority should be private.",
+ Model.getFacade().isPrivate(operationMP));
+ assertEquals("The body of operation MessagePriority is wrong.",
+ BODY2, getBody(operationMP));
+ assertTrue("Operation update should be public.",
+ Model.getFacade().isPublic(operationCP));
+ assertEquals("The body of operation update is wrong.",
+ BODY1,
+ getBody(operationCP));
+ assertTrue("Operation createPersist should be static.",
+ Model.getFacade().isStatic(operationCP));
+ assertTrue("Operation getString should be public.",
+ Model.getFacade().isPublic(operationGVP));
+ assertEquals("The body of operation getString is wrong.",
+ BODY3,
+ getBody(operationGVP));
+
+ // TODO: check return types
+
+ }
+
+ /**
+ * Gets the (first) body of an operation.
+ *
+ * @param operation The operation.
+ * @return The first body.
+ */
+ private static String getBody(Object operation) {
+ String body = null;
+ Collection methods = Model.getFacade().getMethods(operation);
+ if (methods != null && !methods.isEmpty()) {
+ Object expression =
+ Model.getFacade().getBody(methods.iterator().next());
+ body = (String) Model.getFacade().getBody(expression);
+ }
+ return body;
+ }
+
+ /**
+ * Flag, if the Java source is parsed already.
+ */
+ private static boolean isParsed;
+
+ /**
+ * Instances of the model and it's components.
+ */
+ private static Object parsedModel;
+ private static Object parsedPackage;
+ private static Object parsedClass;
+
+ private static final String BODY1 =
+ " switch (val) {\n"
+ + " case 1:\n"
+ + " return LOW;\n"
+ + " case 5:\n"
+ + " return NORMAL;\n"
+ + " case 9:\n"
+ + " return HIGH;\n"
+ + " default:\n"
+ + " throw new Exception (\"MessagePriority unknown\");\n"
+ + " }\n";
+
+ private static final String BODY2 = " this.valuePersist = val;\n";
+ private static final String BODY3 = " return this.valuePersist;\n";
+
+ /**
+ * Test input for the parser. It's the content of a Java source file. It's
+ * hardcoded here, because this test case strongly depends on this.
+ */
+ private static final String PARSERINPUT =
+ "package testpackage;\n"
+
+ + "public class TestClass {\n"
+ + " public enum Color {GREEN, YELLOW, RED};"
+ + " public enum MessagePriority {\n"
+ + " LOW ((short) 1),\n"
+ + " NORMAL ((short) 5),\n"
+ + " HIGH ((short) 9);\n"
+ + "\n"
+ + " public static MessagePriority createPersist "
+ + "(final short val) throws Exception {"
+ + BODY1
+ + " }\n"
+ + "\n"
+ + " short valuePersist;\n"
+ + "\n"
+ + " private MessagePriority (final short val) {"
+ + BODY2
+ + " }\n"
+ + "\n"
+ + " public int getValuePersist () {"
+ + BODY3
+ + " }\n"
+ + " }\n"
+
+ + "}";
+
+}
+
+
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/TestJavaImportInterface.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/TestJavaImportInterface.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/TestJavaImportInterface.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,282 @@
+// $Id:TestJavaImportInterface.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 1996-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.uml.reveng;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.io.StringReader;
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+import org.argouml.model.Model;
+import org.argouml.uml.reveng.java.JavaLexer;
+import org.argouml.uml.reveng.java.JavaRecognizer;
+import org.argouml.uml.reveng.java.Modeller;
+
+import antlr.RecognitionException;
+import antlr.TokenStreamException;
+
+/**
+ * Test case to test the import of a Java source file. The content of the Java
+ * source file is a private constant at the bottom of the source of this
+ * class. The test methods are specially designed for this Java source
+ * constant. Feeding of the diagram subsystem is disabled; only model elements
+ * are created and checked. For testing with another Java source file, copy this
+ * test case, change the Java source constant and modify the test method (the
+ * setUp method need not be changed).<p>
+ */
+public class TestJavaImportInterface extends TestCase {
+ /*
+ * @see junit.framework.TestCase#TestCase(String)
+ */
+ public TestJavaImportInterface(String str) {
+ super(str);
+ InitializeModel.initializeDefault();
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() {
+ if (isParsed) {
+ return;
+ }
+
+ JavaLexer lexer = new JavaLexer(new StringReader(PARSERINPUT));
+ assertNotNull("Creation of lexer failed.", lexer);
+
+ lexer.setTokenObjectClass("org.argouml.uml.reveng.java.ArgoToken");
+
+ JavaRecognizer parser = new JavaRecognizer(lexer);
+ assertNotNull("Creation of parser failed.", parser);
+
+ parsedModel = Model.getModelManagementFactory().createModel();
+ assertNotNull("Creation of model failed.", parsedModel);
+
+ Model.getModelManagementFactory().setRootModel(parsedModel);
+
+ Modeller modeller =
+ new Modeller(parsedModel, new DummyImportSettings(),
+ "TestInterface.java");
+ assertNotNull("Creation of Modeller instance failed.", modeller);
+
+ try {
+ parser.compilationUnit(modeller, lexer);
+ isParsed = true;
+ } catch (RecognitionException e) {
+ fail("Parsing of Java source failed." + e);
+ } catch (TokenStreamException e) {
+ fail("Parsing of Java source failed." + e);
+ }
+ }
+
+ /**
+ * Test if the package was processed correctly.
+ */
+ public void testPackage() {
+ parsedPackage = Model.getFacade().lookupIn(parsedModel, "testpackage");
+ assertNotNull("No package \"testpackage\" found in model.",
+ parsedPackage);
+ assertEquals("Inconsistent package name.",
+ "testpackage", Model.getFacade().getName(parsedPackage));
+ assertEquals("The namespace of the package should be the model.",
+ parsedModel, Model.getFacade().getNamespace(parsedPackage));
+ assertTrue("The package should be recognized as a package.",
+ Model.getFacade().isAPackage(parsedPackage));
+ }
+
+ /**
+ * Test if the import was processed correctly.
+ */
+ public void testImport() {
+ if (parsedPackage == null) {
+ parsedPackage =
+ Model.getFacade().lookupIn(parsedModel, "testpackage");
+ assertNotNull("No package \"testpackage\" found in model.",
+ parsedPackage);
+ }
+ Collection ownedElements =
+ Model.getFacade().getOwnedElements(parsedPackage);
+ assertNotNull("No elements owned by \"testpackage\".", ownedElements);
+ Object component = null;
+ Iterator iter = ownedElements.iterator();
+ while (iter.hasNext()) {
+ Object element = iter.next();
+ if (Model.getFacade().isAComponent(element)) {
+ component = element;
+ break;
+ }
+ }
+ assertNotNull("No component found.", component);
+ assertEquals("The component name is wrong.",
+ "TestInterface.java", Model.getFacade().getName(component));
+ Collection dependencies =
+ Model.getFacade().getClientDependencies(component);
+ assertNotNull("No dependencies found for component.", dependencies);
+ Object permission = null;
+ iter = dependencies.iterator();
+ while (iter.hasNext()) {
+ Object element = iter.next();
+ if (Model.getFacade().isAPermission(element)) {
+ permission = element;
+ break;
+ }
+ }
+ assertNotNull("No import found.", permission);
+ assertEquals("The import name is wrong.",
+ "TestInterface.java -> Observer",
+ Model.getFacade().getName(permission));
+ Collection suppliers = Model.getFacade().getSuppliers(permission);
+ assertNotNull("No suppliers found in import.", suppliers);
+ Object supplier = null;
+ iter = suppliers.iterator();
+ if (iter.hasNext()) {
+ supplier = iter.next();
+ }
+ assertNotNull("No supplier found in import.", supplier);
+ assertEquals("The import supplier name is wrong.",
+ "Observer", Model.getFacade().getName(supplier));
+ Object namespace = Model.getFacade().getNamespace(supplier);
+ assertNotNull("The import supplier has no namespace.", namespace);
+ assertEquals("Expected namespace name \"util\".",
+ "util", Model.getFacade().getName(namespace));
+ namespace = Model.getFacade().getNamespace(namespace);
+ assertNotNull("The namespace \"util\" has no namespace.", namespace);
+ assertEquals("Expected namespace name \"java\".",
+ "java", Model.getFacade().getName(namespace));
+ assertEquals("The namespace of \"java\" should be the model.",
+ parsedModel, Model.getFacade().getNamespace(namespace));
+ }
+
+ /**
+ * Test if the import was processed correctly.
+ */
+ public void testInterface() {
+ if (parsedPackage == null) {
+ parsedPackage =
+ Model.getFacade().lookupIn(parsedModel, "testpackage");
+ assertNotNull("No package \"testpackage\" found in model.",
+ parsedPackage);
+ }
+ parsedInterface =
+ Model.getFacade().lookupIn(parsedPackage, "TestInterface");
+ assertNotNull("No interface \"TestInterface\" found.", parsedInterface);
+ assertEquals("Inconsistent interface name.",
+ "TestInterface", Model.getFacade().getName(parsedInterface));
+ assertEquals("The namespace of the interface should be "
+ + "\"testpackage\".",
+ parsedPackage, Model.getFacade().getNamespace(parsedInterface));
+ assertTrue("The interface should be recognized as a interface.",
+ Model.getFacade().isAInterface(parsedInterface));
+ assertTrue("The interface should be public.",
+ Model.getFacade().isPublic(parsedInterface));
+ Collection generalizations =
+ Model.getFacade().getGeneralizations(parsedInterface);
+ assertNotNull("No generalizations found for interface.",
+ generalizations);
+ Object generalization = null;
+ Iterator iter = generalizations.iterator();
+ if (iter.hasNext()) {
+ generalization = iter.next();
+ }
+ assertNotNull("No generalization found for interface.", generalization);
+ assertEquals("The generalization name is wrong.",
+ "TestInterface -> Observer",
+ Model.getFacade().getName(generalization));
+ assertEquals("The child of the generalization should be the interface.",
+ parsedInterface, Model.getFacade().getChild(generalization));
+ assertEquals(
+ "The parent of the generalization should be \"Observer\".",
+ "Observer", Model.getFacade().getName(
+ Model.getFacade().getParent(generalization)));
+ }
+
+ /**
+ * Test if the operations were processed correctly.
+ */
+ public void testOperations() {
+ if (parsedPackage == null) {
+ parsedPackage =
+ Model.getFacade().lookupIn(parsedModel, "testpackage");
+ assertNotNull("No package \"testpackage\" found in model.",
+ parsedPackage);
+ }
+ if (parsedInterface == null) {
+ parsedInterface =
+ Model.getFacade().lookupIn(parsedPackage, "TestInterface");
+ assertNotNull("No interface \"TestInterface\" found.",
+ parsedInterface);
+ }
+ Collection operations =
+ Model.getFacade().getOperations(parsedInterface);
+ assertNotNull("No operations found ib interface.", operations);
+ assertEquals("Number of operations is wrong", 2, operations.size());
+ Object operation = null;
+ Object operationForx = null;
+ Object operationFory = null;
+ Iterator iter = operations.iterator();
+ while (iter.hasNext()) {
+ operation = iter.next();
+ assertTrue("The operation should be recognized as an operation.",
+ Model.getFacade().isAOperation(operation));
+ if ("x".equals(Model.getFacade().getName(operation))) {
+ operationForx = operation;
+ } else if ("y".equals(Model.getFacade().getName(operation))) {
+ operationFory = operation;
+ }
+ }
+ assertTrue("The operations have wrong names.",
+ operationForx != null && operationFory != null);
+ assertTrue("Operation x should be public.",
+ Model.getFacade().isPublic(operationForx));
+ assertTrue("Operation y should be public.",
+ Model.getFacade().isPublic(operationFory));
+ }
+
+ /**
+ * Flag, if the Java source is parsed already.
+ */
+ private static boolean isParsed;
+
+ /**
+ * Instances of the model and it's components.
+ */
+ private static Object parsedModel;
+ private static Object parsedPackage;
+ private static Object parsedInterface;
+
+ /**
+ * Test input for the parser. It's the content of a Java source file. It's
+ * hardcoded here, because this test case strongly depends on this.
+ */
+ private static final String PARSERINPUT =
+ "package testpackage;\n"
+ + "import java.util.Observer;\n"
+ + "/** A Javadoc comment */\n"
+ + "public interface TestInterface extends Observer {\n"
+ + " /** Another Javadoc comment */\n"
+ + " public void x(String a);\n"
+ + " public int y();\n"
+ + "}";
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/TestJavaImportUnicode.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/TestJavaImportUnicode.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/TestJavaImportUnicode.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,334 @@
+// $Id:TestJavaImportUnicode.java 12948 2007-07-01 08:07:22Z linus $
+// 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.uml.reveng;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.io.StringReader;
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.Model;
+import org.argouml.uml.reveng.java.JavaLexer;
+import org.argouml.uml.reveng.java.JavaRecognizer;
+import org.argouml.uml.reveng.java.Modeller;
+
+import antlr.RecognitionException;
+import antlr.TokenStreamException;
+
+/**
+ * Test the import of Java sources which have Unicode characters in
+ * various locations, including in identifiers.
+ *
+ * The content of the Java source file is a private constant at the
+ * bottom of the source of this class.
+ *
+ * The constant is written using the ISO8859-1 encoding so this class
+ * needs to be compiled using that encoding.
+ */
+public class TestJavaImportUnicode extends TestCase {
+ /*
+ * @see junit.framework.TestCase#TestCase(String)
+ */
+ public TestJavaImportUnicode(String str) {
+ super(str);
+ InitializeModel.initializeDefault();
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() {
+ if (isParsed) {
+ return;
+ }
+
+ // This shouldn't be necessary, but the Modeller is going to look in
+ // the project to find the default type for attributes
+ Project project = ProjectManager.getManager().getCurrentProject();
+ assertNotNull("Failed to get/create project context", project);
+
+ JavaLexer lexer = new JavaLexer(new StringReader(PARSERINPUT));
+ assertNotNull("Creation of lexer failed.", lexer);
+
+ lexer.setTokenObjectClass("org.argouml.uml.reveng.java.ArgoToken");
+
+ JavaRecognizer parser = new JavaRecognizer(lexer);
+ assertNotNull("Creation of parser failed.", parser);
+
+ Object parsedModel = Model.getModelManagementFactory().createModel();
+ assertNotNull("Creation of model failed.", parsedModel);
+
+ Model.getModelManagementFactory().setRootModel(parsedModel);
+
+ assertEquals("Setting Root Model failed",
+ Model.getModelManagementFactory().getRootModel(),
+ parsedModel);
+
+ Modeller modeller =
+ new Modeller(parsedModel, new DummyImportSettings(),
+ "TestClass.java");
+ assertNotNull("Creation of Modeller instance failed.", modeller);
+
+ try {
+ parser.compilationUnit(modeller, lexer);
+ isParsed = true;
+ } catch (RecognitionException e) {
+ fail("Parsing of Java source failed." + e);
+ } catch (TokenStreamException e) {
+ fail("Parsing of Java source failed." + e);
+ }
+ }
+
+ /**
+ * Test if the package was processed correctly.
+ */
+ public void testPackage() {
+ Object parsedPackage = lookupPackage();
+ assertEquals("Inconsistent package name.",
+ "téstpackage", Model.getFacade().getName(parsedPackage));
+ assertEquals("The namespace of the package should be the model.",
+ Model.getModelManagementFactory().getRootModel(),
+ Model.getFacade().getNamespace(parsedPackage));
+ assertTrue("The package should be recognized as a package.",
+ Model.getFacade().isAPackage(parsedPackage));
+ }
+
+
+ /**
+ * Test if the import was processed correctly.
+ */
+ public void testClass() {
+ Object parsedPackage = lookupPackage();
+ Object parsedClass = lookupClass(parsedPackage);
+ assertEquals("Inconsistent class name.",
+ "TéstClass", Model.getFacade().getName(parsedClass));
+ assertEquals("The namespace of the class should be \"téstpackage\".",
+ parsedPackage, Model.getFacade().getNamespace(parsedClass));
+ Collection generalizations =
+ Model.getFacade().getGeneralizations(parsedClass);
+ assertNotNull("No generalizations found for class.", generalizations);
+ Object generalization = null;
+ Iterator iter = generalizations.iterator();
+ if (iter.hasNext()) {
+ generalization = iter.next();
+ }
+ assertNotNull("No generalization found for class.", generalization);
+ assertEquals("The generalization name is wrong.",
+ "TéstClass -> Object", Model.getFacade().getName(generalization));
+
+ Collection dependencies =
+ Model.getFacade().getClientDependencies(parsedClass);
+ assertNotNull("No dependencies found for class.", dependencies);
+ Object abstraction = null;
+ iter = dependencies.iterator();
+ if (iter.hasNext()) {
+ abstraction = iter.next();
+ }
+ assertNotNull("No abstraction found for class.", abstraction);
+ assertEquals("The abstraction name is wrong.",
+ "TéstClass -> Observer", Model.getFacade().getName(abstraction));
+
+ }
+
+ /**
+ * Convenience method to lookup and check Package.
+ */
+ private Object lookupPackage() {
+ Object parsedPackage = Model.getFacade().lookupIn(
+ Model.getModelManagementFactory().getRootModel(),
+ "téstpackage");
+ assertNotNull("No package \"téstpackage\" found in model.",
+ parsedPackage);
+ return parsedPackage;
+ }
+
+ /**
+ * Convenience method to lookup and check Class.
+ */
+ private Object lookupClass(Object thePackage) {
+ Object parsedClass =
+ Model.getFacade().lookupIn(thePackage, "TéstClass");
+ assertNotNull("No class \"TéstClass\" found.", parsedClass);
+ return parsedClass;
+ }
+
+ /**
+ * Test if the attributes were processed correctly.
+ */
+ public void testAttributes() {
+ Object parsedPackage = lookupPackage();
+ Object parsedClass = lookupClass(parsedPackage);
+ Collection attributes = Model.getFacade().getAttributes(parsedClass);
+ assertNotNull("No attributes found in class.", attributes);
+ assertEquals("Number of attributes is wrong", 1, attributes.size());
+ Object attribute = null;
+ Object attributeFors = null;
+ Iterator iter = attributes.iterator();
+ while (iter.hasNext()) {
+ attribute = iter.next();
+ assertTrue("The attribute should be recognized as an attribute.",
+ Model.getFacade().isAAttribute(attribute));
+ if ("sé".equals(Model.getFacade().getName(attribute))) {
+ attributeFors = attribute;
+ }
+ }
+ assertTrue("The attribute sé has the wrong name.",
+ attributeFors != null);
+
+ Object initializer = Model.getFacade().getInitialValue(attributeFors);
+ assertTrue("Attribute sé has no initializer.",
+ Model.getFacade().isInitialized(attributeFors)
+ && initializer != null);
+ assertEquals("The initializer of attribute sé is wrong.",
+ " \"final String objéct\"", Model.getFacade().getBody(initializer));
+ }
+
+
+
+ /**
+ * Test if the association was processed correctly.
+ */
+ public void testAssociation() {
+ Object parsedPackage = lookupPackage();
+ Object parsedClass = lookupClass(parsedPackage);
+ Collection associationEnds =
+ Model.getFacade().getAssociationEnds(parsedClass);
+ assertNotNull("No association ends found in class.", associationEnds);
+ assertEquals("Number of association ends is wrong", 2,
+ associationEnds.size());
+ Object associationEnd = null;
+ Object association = null;
+ int navigableCount = 0;
+ Iterator iter = associationEnds.iterator();
+ while (iter.hasNext()) {
+ associationEnd = iter.next();
+ assertTrue(
+ "The attribute end should be recognized as "
+ + "an attribute end.",
+ Model.getFacade().isAAssociationEnd(associationEnd));
+ assertEquals("The type of both association ends must be the class.",
+ parsedClass, Model.getFacade().getType(associationEnd));
+ if (association == null) {
+ association = Model.getFacade().getAssociation(associationEnd);
+ assertTrue(
+ "The attribute should be recognized as an attribute.",
+ Model.getFacade().isAAssociation(association));
+ assertEquals("The association name is wrong.",
+ "TéstClass -> TéstClass",
+ Model.getFacade().getName(association));
+ } else {
+ assertEquals(
+ "Association end must belong to the same association.",
+ association,
+ Model.getFacade().getAssociation(associationEnd));
+ }
+ if (Model.getFacade().isNavigable(associationEnd)) {
+ ++navigableCount;
+ }
+ }
+ assertEquals("Only one association end must be navigable.",
+ 1, navigableCount);
+ }
+
+ /**
+ * Test if the operations were processed correctly.
+ */
+ public void testOperations() {
+ Object parsedPackage = lookupPackage();
+ Object parsedClass = lookupClass(parsedPackage);
+ Collection operations = Model.getFacade().getOperations(parsedClass);
+ assertNotNull("No operations found in class.", operations);
+ assertEquals("Number of operations is wrong", 2, operations.size());
+ Object operation = null;
+ Object operationForTestClass = null;
+ Object operationForupdate = null;
+ Iterator iter = operations.iterator();
+ while (iter.hasNext()) {
+ operation = iter.next();
+ assertTrue("The operation should be recognized as an operation.",
+ Model.getFacade().isAOperation(operation));
+ if ("TéstClass".equals(Model.getFacade().getName(operation))) {
+ operationForTestClass = operation;
+ } else if ("updaté".equals(Model.getFacade().getName(operation))) {
+ operationForupdate = operation;
+ }
+ }
+ assertTrue("The operations have wrong names.",
+ operationForTestClass != null
+ && operationForupdate != null);
+ assertEquals("The body of operation update is wrong.",
+ BODY1,
+ getBody(operationForupdate));
+
+ }
+
+ /**
+ * Gets the (first) body of an operation.
+ *
+ * @param operation The operation.
+ * @return The first body.
+ */
+ private static String getBody(Object operation) {
+ String body = null;
+ Collection methods = Model.getFacade().getMethods(operation);
+ if (methods != null && !methods.isEmpty()) {
+ Object expression =
+ Model.getFacade().getBody(methods.iterator().next());
+ body = (String) Model.getFacade().getBody(expression);
+ }
+ return body;
+ }
+
+ /**
+ * Flag, if the Java source is parsed already.
+ */
+ private static boolean isParsed;
+
+ private static final String BODY1 =
+ "\n if (arg instanceof TéstClass) téstClass = (TéstClass)arg;\n";
+
+ /**
+ * Test input for the parser. It's the content of a Java source file. It's
+ * hardcoded here, because this test case strongly depends on this.
+ */
+ private static final String PARSERINPUT =
+ "package téstpackage;\n"
+ + "import java.util.Observer;\n"
+ + "/** A Javadoc commént */\n"
+ + "public abstract class TéstClass "
+ + "extends Object implements Observer {\n"
+ + " protected static TéstClass téstClass;\n"
+ + " public static final String sé = \"final String objéct\";\n"
+ + " protected TéstClass(int n) {"
+ + " }\n"
+ + " public void updaté(java.util.Observable o, Object arg) {"
+ + BODY1
+ + " }\n"
+
+ + "}";
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/package.html
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/package.html?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/reveng/package.html 2007-08-13 09:07:56-0700
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+ Copyright (c) 1996-99 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.
+-->
+</head>
+<body bgcolor="white">
+<!--
+##### TYPE YOUR PACKAGE COMMENTS HERE. BEGIN WITH A #####
+##### ONE-SENTENCE SUMMARY STARTING WITH A VERB LIKE: #####
+Provides for....
+-->
+
+</body>
+</html>
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/AbstractTestActionAddDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/AbstractTestActionAddDiagram.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/AbstractTestActionAddDiagram.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,205 @@
+// $Id:AbstractTestActionAddDiagram.java 12987 2007-07-05 14:28:59Z mvw $
+// Copyright (c) 2003-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.uml.ui;
+
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.Model;
+import org.argouml.notation.InitNotation;
+import org.argouml.notation.providers.java.InitNotationJava;
+import org.argouml.notation.providers.uml.InitNotationUml;
+import org.argouml.uml.diagram.ArgoDiagram;
+import org.argouml.uml.diagram.UMLMutableGraphSupport;
+
+/**
+ * @author JBranderhorst
+ */
+public abstract class AbstractTestActionAddDiagram extends TestCase {
+
+ /**
+ * The action to be tested.
+ */
+ private ActionAddDiagram action;
+
+ /**
+ * The namespace a created diagram should have.
+ */
+ private Object ns;
+
+ /**
+ * A list with namespaces that should be valid for the diagram to be
+ * created.
+ */
+ private List validNamespaces;
+
+ /**
+ * Constructor for AbstractTestActionAddDiagram.
+ * @param arg0 test case name
+ */
+ public AbstractTestActionAddDiagram(String arg0) {
+ super(arg0);
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Preparations for all test cases.
+ */
+ protected void setUp() {
+ (new InitNotation()).init();
+ (new InitNotationUml()).init();
+ (new InitNotationJava()).init();
+
+ action = getAction();
+
+ ns = getNamespace();
+ validNamespaces = getValidNamespaceClasses();
+ }
+
+ /**
+ * Cleanup after all test cases.
+ */
+ protected void tearDown() {
+ action = null;
+ ns = null;
+ validNamespaces = null;
+ }
+
+ /**
+ * Should return the correct action. (for example, ActionClassDiagram for a
+ * creation of a classdiagram).
+ * @return ActionAddDiagram
+ */
+ protected abstract ActionAddDiagram getAction();
+
+ /**
+ * The namespace.
+ *
+ * @return a valid namespace for the diagram to be tested
+ */
+ protected abstract Object getNamespace();
+
+ /**
+ * Should return a list with classes that implement Namespace
+ * and that are valid to use at creating the diagram.
+ * @return List
+ */
+ protected abstract List getValidNamespaceClasses();
+
+ /**
+ * Tests if a created diagram complies to the following conditions.<ul>
+ * <li>Has a valid namespace
+ * <li>Has a MutableGraphModel
+ * <li>Has a proper name
+ * </ul>
+ */
+ public void testCreateDiagram() {
+ Model.getPump().flushModelEvents();
+ assertTrue("The test case has a non-valid namespace",
+ action.isValidNamespace(ns));
+
+ ArgoDiagram diagram = action.createDiagram(ns);
+ Model.getPump().flushModelEvents();
+ assertNotNull(
+ "The diagram has no namespace",
+ diagram.getNamespace());
+ checkNamespace(diagram);
+ assertNotNull(
+ "The diagram has no graphmodel",
+ diagram.getGraphModel());
+ assertTrue("The graphmodel of the diagram is not a "
+ + "UMLMutableGraphSupport",
+ diagram.getGraphModel() instanceof UMLMutableGraphSupport);
+ assertNotNull("The diagram has no name", diagram.getName());
+ }
+
+ /**
+ * Test if the namespace is correct for the diagram.<p>
+ *
+ * This is the default implementation if the namespace of the
+ * created diagram is the same as the one where the diagram is
+ * created. If not, the specialized test will override this.
+ *
+ * @param diagram The diagram to check the namespace for.
+ */
+ protected void checkNamespace(ArgoDiagram diagram) {
+ assertTrue(
+ "The diagram has a non-valid namespace",
+ action.isValidNamespace(diagram.getNamespace()));
+ }
+
+ /**
+ * Tests if two diagrams created have different names.
+ */
+ public void testDifferentNames() {
+ ArgoDiagram diagram1 = action.createDiagram(ns);
+ // This next line is needed to register the diagram in the project,
+ // since creating a next diagram will need the new name to be compared
+ // with existing diagrams in the project, to validate
+ // there are no duplicates.
+ ProjectManager.getManager().getCurrentProject().addMember(diagram1);
+ ArgoDiagram diagram2 = action.createDiagram(ns);
+ Model.getPump().flushModelEvents();
+ assertTrue(
+ "The created diagrams have the same name",
+ !(diagram1.getName().equals(diagram2.getName())));
+ }
+
+ /**
+ * Tests if the namespace created by getNamespace() is a valid namespace for
+ * the diagram.
+ */
+ public void testValidTestNamespace() {
+ assertTrue(
+ "The namespace with this test is not valid for this diagram",
+ action.isValidNamespace(ns));
+ }
+
+ /**
+ * Tests if the list with namespaces defined in getValidNamespaceClasses
+ * contains only valid namespaces.
+ */
+ public void testValidNamespaces() {
+ Iterator it = validNamespaces.iterator();
+ while (it.hasNext()) {
+ Object type = it.next();
+
+ Object o = Model.getUmlFactory().buildNode(type);
+ String objDesc = "" + o;
+ if (o != null) {
+ objDesc += " (" + o.getClass() + ")";
+ }
+ assertTrue(
+ objDesc
+ + " is not valid namespace for the diagram",
+ action.isValidNamespace(o));
+ }
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/AbstractUMLModelElementListModel2Test.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/AbstractUMLModelElementListModel2Test.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/AbstractUMLModelElementListModel2Test.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,162 @@
+// $Id:AbstractUMLModelElementListModel2Test.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 1996-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.uml.ui;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.model.Model;
+
+/**
+ * An abstract class that serves as a basis for testing listmodels. Only works
+ * for listmodels that can contain multiple elements.
+ * @since Oct 27, 2002
+ * @author [email protected]
+ */
+public abstract class AbstractUMLModelElementListModel2Test extends TestCase {
+ private Object elem;
+ private UMLModelElementListModel2 model;
+
+ /**
+ * Constructor for AbstractUMLModelElementListModel2Test.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public AbstractUMLModelElementListModel2Test(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ buildElement();
+ // Tests used to be coded to assume immediate event delivery.
+ // They've been modified to use flush() where needed. - tfm
+ //oldEventPolicy = MFactoryImpl.getEventPolicy();
+ //MFactoryImpl.setEventPolicy(MFactoryImpl.EVENT_POLICY_IMMEDIATE);
+ buildModel();
+ model.setTarget(elem);
+ Model.getPump().flushModelEvents();
+ }
+
+ /**
+ * Developers should build the target element in this method and assing
+ * this to the variable elem. The target
+ * element is the ModelElement of which the listmodel to be tested shows
+ * an attribute
+ */
+ protected abstract void buildElement();
+
+ /**
+ * Developers should construct the listmodel to be tested in this method and
+ * assign this to the variable model.
+ */
+ protected abstract void buildModel();
+
+ /*
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Model.getUmlFactory().delete(elem);
+ // restore original event policy - not supported by MDR - tfm
+ //MFactoryImpl.setEventPolicy(oldEventPolicy);
+ model = null;
+ }
+
+ /**
+ * Tests the programmatically adding of multiple elements to the list.
+ */
+ public void testAddMultiple() {
+ Object[] elements = fillModel();
+ Model.getPump().flushModelEvents();
+ assertEquals(10, model.getSize());
+ assertEquals(model.getElementAt(5), elements[5]);
+ assertEquals(model.getElementAt(0), elements[0]);
+ assertEquals(model.getElementAt(9), elements[9]);
+ }
+
+ /**
+ * Developers should set the attribute that the listmodel shows in this
+ * method. They should return the contents of the attribute in the form of
+ * a ModelElement[]. The number of elements inside the attribute should be
+ * 10.
+ * @return ModelElement[]
+ */
+ protected abstract Object[] fillModel();
+
+ /**
+ * Test the removal of several elements from the list.
+ */
+ public void testRemoveMultiple() {
+ Object[] elements = fillModel();
+ Model.getPump().flushModelEvents();
+ removeHalfModel(elements);
+ Model.getPump().flushModelEvents();
+ assertEquals(5, model.getSize());
+ assertEquals(elements[5], model.getElementAt(0));
+ }
+
+ /**
+ * Developers should remove half the contents of the attribute in
+ * this method That is: they should remove the upper 5 elements of
+ * the attribute.
+ *
+ * @param elements the element
+ */
+ protected abstract void removeHalfModel(Object[] elements);
+
+ /**
+ * @param theModel The model to set.
+ */
+ protected void setModel(UMLModelElementListModel2 theModel) {
+ model = theModel;
+ }
+
+ /**
+ * @return Returns the model.
+ */
+ protected UMLModelElementListModel2 getModel() {
+ return model;
+ }
+
+ /**
+ * @param theElement The elem to set.
+ */
+ protected void setElem(Object theElement) {
+ elem = theElement;
+ }
+
+ /**
+ * @return Returns the elem.
+ */
+ protected Object getElem() {
+ return elem;
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/GUITestActionOpenProject.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/GUITestActionOpenProject.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/GUITestActionOpenProject.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,105 @@
+// $Id:GUITestActionOpenProject.java 12485 2007-05-03 05:59:35Z linus $
+// Copyright (c) 2004-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.uml.ui;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.kernel.ProjectManager;
+import org.argouml.util.CheckMain;
+
+/**
+ * Testing opening a project from the command line.
+ *
+ * @author Linus Tolke
+ */
+public class GUITestActionOpenProject extends TestCase {
+ /**
+ * @param name The name of the test case.
+ */
+ public GUITestActionOpenProject(String name) {
+ super(name);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test an empty 1.3 project.
+ */
+ public void testEmptyProject13() {
+ doTestActionOpenProject("testmodels/uml13/EmptyProject0161.zargo",
+ "EmptyProject0161");
+ }
+
+ /**
+ * Test a 1.3 project with contents.
+ */
+ public void testProjectWithContents13() {
+ doTestActionOpenProject("testmodels/uml13/GUITestPropertyPanels.zargo",
+ "GUITestPropertyPanels");
+ }
+
+ /**
+ * Test an empty 1.4 project.
+ */
+ public void testEmptyProject14() {
+ doTestActionOpenProject("testmodels/uml14/EmptyProject024.zargo",
+ "EmptyProject024");
+ }
+
+ /**
+ * Test a 1.4 project with contents.
+ */
+ public void testProjectWithContents14() {
+ doTestActionOpenProject("testmodels/uml14/GUITestPropertyPanels.zargo",
+ "GUITestPropertyPanels");
+ }
+
+ /**
+ * Do the actual testing.
+ */
+ private void doTestActionOpenProject(String fileName, String projectName) {
+ File file
+ = CheckMain.getTestModel(fileName);
+
+ List<String> c = new ArrayList<String>();
+ c.add("org.argouml.uml.ui.ActionOpenProject=" + file.getAbsolutePath());
+ CheckMain.doCommand(c);
+
+ assertEquals(projectName,
+ ProjectManager.getManager().getCurrentProject().getBaseName());
+ }
+}
+
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/GUITestActionSaveGraphics.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/GUITestActionSaveGraphics.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/GUITestActionSaveGraphics.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,80 @@
+// $Id:GUITestActionSaveGraphics.java 12485 2007-05-03 05:59:35Z linus $
+// Copyright (c) 2004-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.uml.ui;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.util.CheckMain;
+
+/**
+ * @author Linus Tolke
+ */
+public class GUITestActionSaveGraphics extends TestCase {
+
+ private static final String OUTPUT_FILE = "test-out.gif";
+
+ /**
+ * Constructor for GUITestActionSaveGraphics.
+ *
+ * @param arg0 The name of the test case.
+ */
+ public GUITestActionSaveGraphics(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test dumping a diagram from a project with contents.
+ */
+ public void testProjectWithContents() {
+ File file =
+ CheckMain.getTestModel(
+ "testmodels/uml14/GUITestPropertyPanels.zargo");
+
+ new File(OUTPUT_FILE).delete();
+
+ List<String> c = new ArrayList<String>();
+ c.add("org.argouml.uml.ui.ActionOpenProject=" + file.getAbsolutePath());
+ c.add("org.argouml.uml.ui.ActionSaveGraphics=" + OUTPUT_FILE);
+ CheckMain.doCommand(c);
+
+ assertTrue(new File(OUTPUT_FILE).exists());
+
+ new File(OUTPUT_FILE).delete();
+ }
+}
+
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/MockUMLUserInterfaceContainer.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/MockUMLUserInterfaceContainer.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/MockUMLUserInterfaceContainer.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,136 @@
+// $Id:MockUMLUserInterfaceContainer.java 10736 2006-06-11 17:30:38Z mvw $
+// Copyright (c) 1996-2006 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.uml.ui;
+
+import java.util.Iterator;
+
+import org.argouml.uml.Profile;
+
+/**
+ * @since Oct 12, 2002
+ * @author [email protected]
+ */
+public class MockUMLUserInterfaceContainer
+ implements UMLUserInterfaceContainer {
+
+ private Object target;
+
+ /**
+ * Constructor for MockUMLUserInterfaceContainer.
+ */
+ public MockUMLUserInterfaceContainer() {
+ super();
+ }
+
+ /**
+ * @see org.argouml.uml.ui.UMLUserInterfaceContainer#getTarget()
+ */
+ public Object getTarget() {
+ return target;
+ }
+
+ /**
+ * @see org.argouml.uml.ui.UMLUserInterfaceContainer#getModelElement()
+ */
+ public Object getModelElement() {
+ return null;
+ }
+
+ /**
+ * @see org.argouml.uml.ui.UMLUserInterfaceContainer#getProfile()
+ */
+ public Profile getProfile() {
+ return null;
+ }
+
+ /**
+ * @see org.argouml.uml.ui.UMLUserInterfaceContainer#formatElement(java.lang.Object)
+ */
+ public String formatElement(/*ModelElement*/Object element) {
+ return null;
+ }
+
+ /**
+ * @see org.argouml.uml.ui.UMLUserInterfaceContainer#formatCollection(java.util.Iterator)
+ */
+ public String formatCollection(Iterator iter) {
+ return null;
+ }
+
+ /**
+ * @see org.argouml.uml.ui.UMLUserInterfaceContainer#formatNamespace(java.lang.Object)
+ */
+ public String formatNamespace(/*Namespace*/Object ns) {
+ return null;
+ }
+
+ /**
+ * @see org.argouml.ui.NavigationListener#navigateTo(java.lang.Object)
+ */
+ public void navigateTo(Object element) {
+ }
+
+ /**
+ * @see org.argouml.ui.NavigationListener#open(java.lang.Object)
+ */
+ public void open(Object element) {
+ }
+
+ /**
+ * @see org.argouml.ui.NavigationListener#navigateBack(boolean)
+ */
+ public boolean navigateBack(boolean attempt) {
+ return false;
+ }
+
+ /**
+ * @see org.argouml.ui.NavigationListener#navigateForward(boolean)
+ */
+ public boolean navigateForward(boolean attempt) {
+ return false;
+ }
+
+ /**
+ * @see org.argouml.ui.NavigationListener#isNavigateBackEnabled()
+ */
+ public boolean isNavigateBackEnabled() {
+ return false;
+ }
+
+ /**
+ * @see org.argouml.ui.NavigationListener#isNavigateForwardEnabled()
+ */
+ public boolean isNavigateForwardEnabled() {
+ return false;
+ }
+
+ /**
+ * @param t the target
+ */
+ public void setTarget(Object t) {
+ target = t;
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestActionClassDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestActionClassDiagram.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestActionClassDiagram.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,72 @@
+// $Id:TestActionClassDiagram.java 11517 2006-11-25 05:27:15Z tfmorris $
+// Copyright (c) 1996-2006 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.uml.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.argouml.model.Model;
+
+/**
+ * Test for {@link ActionClassDiagram}.
+ * @author JBranderhorst
+ */
+public class TestActionClassDiagram extends AbstractTestActionAddDiagram {
+
+ /**
+ * Constructor for GUITestActionClassDiagram.
+ * @param arg0 the name of the test case.
+ */
+ public TestActionClassDiagram(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractTestActionAddDiagram#getAction()
+ */
+ protected ActionAddDiagram getAction() {
+ return new ActionClassDiagram();
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractTestActionAddDiagram#getNamespace()
+ */
+ protected Object getNamespace() {
+ // Return a package to use as the Namespace.
+ return Model.getModelManagementFactory().createPackage();
+ }
+
+ /*
+ * @see org.argouml.uml.ui.
+ * AbstractTestActionAddDiagram#getValidNamespaceClasses()
+ */
+ protected List getValidNamespaceClasses() {
+ List returnList = new ArrayList();
+ returnList.add(Model.getMetaTypes().getPackage());
+ returnList.add(Model.getMetaTypes().getModel());
+ return returnList;
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestActionCollaborationDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestActionCollaborationDiagram.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestActionCollaborationDiagram.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,205 @@
+// $Id:TestActionCollaborationDiagram.java 12927 2007-06-29 20:13:59Z mvw $
+// Copyright (c) 2003-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.uml.ui;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.Model;
+import org.argouml.ui.targetmanager.TargetManager;
+import org.argouml.uml.diagram.ArgoDiagram;
+import org.argouml.uml.diagram.UMLMutableGraphSupport;
+import org.tigris.gef.undo.UndoableAction;
+
+/**
+ * Test creation of Collaboration diagrams.
+ * TODO: Test creating on an operation.
+ *
+ * @author [email protected]
+ * @since Jan 9, 2003
+ */
+public class TestActionCollaborationDiagram extends TestCase {
+
+ /**
+ * The action to be tested.
+ */
+ private UndoableAction action;
+
+ /**
+ * The namespace a created diagram should have.
+ */
+ private Object ns;
+
+ /**
+ * A list with namespaces that should be valid for the diagram to be
+ * created.
+ */
+ private List validNamespaces;
+
+ /**
+ * Constructor for TestActionCollaborationDiagram.
+ * @param arg0 name of the test case
+ */
+ public TestActionCollaborationDiagram(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractTestActionAddDiagram#getAction()
+ */
+ protected UndoableAction getAction() {
+ return new ActionCollaborationDiagram();
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractTestActionAddDiagram#getNamespace()
+ */
+ protected Object getNamespace() {
+ Object pack = Model.getModelManagementFactory().createPackage();
+ Object c = Model.getCoreFactory().buildClass(pack);
+ TargetManager.getInstance().setTarget(c);
+ return c;
+ }
+
+ /*
+ * @see AbstractTestActionAddDiagram#getValidNamespaceClasses()
+ */
+ protected List getValidNamespaceClasses() {
+ List rl = new ArrayList();
+ rl.add(Model.getMetaTypes().getUMLClass());
+ return rl;
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() {
+ InitializeModel.initializeDefault();
+ action = getAction();
+ ns = getNamespace();
+ validNamespaces = getValidNamespaceClasses();
+
+ TargetManager.getInstance().setTarget(ns);
+ }
+
+ /**
+ * Test if the namespace is correct for the diagram.<p>
+ *
+ * @param diagram The diagram to check the namespace for.
+ */
+ protected void checkNamespace(ArgoDiagram diagram) {
+ assertTrue(
+ "The Collaboration diagram has a non-valid namespace",
+ Model.getFacade().isACollaboration(diagram.getNamespace()));
+ }
+
+
+ /**
+ * Test creating a diagram.
+ */
+ public void testCreateDiagram() {
+ Model.getPump().flushModelEvents();
+ action.actionPerformed(null);
+ Object d = TargetManager.getInstance().getTarget();
+ assertTrue("No diagram generated", d instanceof ArgoDiagram);
+ Model.getPump().flushModelEvents();
+ ArgoDiagram diagram = (ArgoDiagram) d;
+ assertNotNull(
+ "The diagram has no namespace",
+ diagram.getNamespace());
+ assertNotNull(
+ "The diagram has no graphmodel",
+ diagram.getGraphModel());
+ assertTrue("The graphmodel of the diagram is not a "
+ + "UMLMutableGraphSupport",
+ diagram.getGraphModel() instanceof UMLMutableGraphSupport);
+ assertNotNull("The diagram has no name", diagram.getName());
+ }
+
+ /**
+ * Tests if two diagrams created have different names.
+ */
+ public void testDifferentNames() {
+ action.actionPerformed(null);
+ Object d = TargetManager.getInstance().getTarget();
+ assertTrue("No diagram generated", d instanceof ArgoDiagram);
+ Model.getPump().flushModelEvents();
+ ArgoDiagram diagram1 = (ArgoDiagram) d;
+ // This next line is needed to register the diagram in the project,
+ // since creating a next diagram will need the new name to be compared
+ // with existing diagrams in the project, to validate
+ // there are no duplicates.
+ ProjectManager.getManager().getCurrentProject().addMember(diagram1);
+
+ TargetManager.getInstance().setTarget(ns);
+ action.actionPerformed(null);
+ d = TargetManager.getInstance().getTarget();
+ assertTrue("No diagram generated", d instanceof ArgoDiagram);
+ Model.getPump().flushModelEvents();
+ ArgoDiagram diagram2 = (ArgoDiagram) d;
+
+ Model.getPump().flushModelEvents();
+ assertTrue(
+ "The created diagrams have the same name",
+ !(diagram1.getName().equals(diagram2.getName())));
+ }
+
+ /**
+ * Tests if the list with namespaces defined in getValidNamespaceClasses
+ * contains only valid namespaces.
+ *
+ * TODO: This test does not test anything, really!
+ */
+ public void testValidNamespaces() {
+ Iterator it = validNamespaces.iterator();
+ while (it.hasNext()) {
+ Object type = it.next();
+
+ Object o = Model.getUmlFactory().buildNode(type);
+ Model.getCoreHelper().setNamespace(o, ns);
+ String objDesc = "" + o;
+ if (o != null) {
+ objDesc += " (" + o.getClass() + ")";
+ }
+ TargetManager.getInstance().setTarget(o);
+ Model.getPump().flushModelEvents();
+ action.actionPerformed(null);
+ Object d = TargetManager.getInstance().getTarget();
+ assertTrue(
+ objDesc
+ + " is not valid namespace for the diagram",
+ d instanceof ArgoDiagram);
+ }
+ }
+
+
+
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestActionDeploymentDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestActionDeploymentDiagram.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestActionDeploymentDiagram.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,70 @@
+// $Id:TestActionDeploymentDiagram.java 11517 2006-11-25 05:27:15Z tfmorris $
+// Copyright (c) 2003-2006 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.uml.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.argouml.kernel.ProjectManager;
+
+/**
+ *
+ * @author [email protected]
+ * @since Jan 9, 2003
+ */
+public class TestActionDeploymentDiagram
+ extends AbstractTestActionAddDiagram {
+
+ /**
+ * Constructor.
+ * @param arg0 test case name.
+ */
+ public TestActionDeploymentDiagram(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractTestActionAddDiagram#getAction()
+ */
+ protected ActionAddDiagram getAction() {
+ return new ActionDeploymentDiagram();
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractTestActionAddDiagram#getNamespace()
+ */
+ protected Object getNamespace() {
+ return ProjectManager.getManager().getCurrentProject()
+ .getModel();
+ }
+
+ /*
+ * @see AbstractTestActionAddDiagram#getValidNamespaceClasses()
+ */
+ protected List getValidNamespaceClasses() {
+ return new ArrayList();
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestActionStateDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestActionStateDiagram.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestActionStateDiagram.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,199 @@
+// $Id:TestActionStateDiagram.java 12927 2007-06-29 20:13:59Z mvw $
+// Copyright (c) 2003-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.uml.ui;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.Model;
+import org.argouml.ui.targetmanager.TargetManager;
+import org.argouml.uml.diagram.ArgoDiagram;
+import org.argouml.uml.diagram.UMLMutableGraphSupport;
+import org.tigris.gef.undo.UndoableAction;
+
+/**
+ * TODO: This needs more work.
+ * Test e.g. creation when an operation is selected.
+ *
+ * @author [email protected]
+ * @since Jan 9, 2003
+ */
+public class TestActionStateDiagram extends TestCase {
+
+ /**
+ * The action to be tested.
+ */
+ private UndoableAction action;
+
+ /**
+ * The namespace a created diagram should have.
+ */
+ private Object ns;
+
+ /**
+ * A list with namespaces that should be valid for the diagram to be
+ * created.
+ */
+ private List validNamespaces;
+
+ /**
+ * Constructor.
+ *
+ * @param arg0 test case name
+ */
+ public TestActionStateDiagram(String arg0) {
+ super(arg0);
+ InitializeModel.initializeDefault();
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractTestActionAddDiagram#getAction()
+ */
+ protected UndoableAction getAction() {
+ return new ActionStateDiagram();
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractTestActionAddDiagram#getNamespace()
+ */
+ protected Object getNamespace() {
+ return Model.getCoreFactory().createClass();
+ }
+
+ /*
+ * @see AbstractTestActionAddDiagram#getValidNamespaceClasses()
+ */
+ protected List getValidNamespaceClasses() {
+ List rl = new ArrayList();
+ /*
+ * This needs to be a concrete metatype, so we can't use
+ * the general, but abstract, Classifier. Replace with its
+ * concrete subtypes.
+ */
+ rl.add(Model.getMetaTypes().getUMLClass());
+ rl.add(Model.getMetaTypes().getInterface());
+ rl.add(Model.getMetaTypes().getDataType());
+ rl.add(Model.getMetaTypes().getNode());
+ rl.add(Model.getMetaTypes().getComponent());
+
+ // TODO: this should fail, but it doesn't:
+ rl.add(Model.getMetaTypes().getTransition());
+ return rl;
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() {
+ action = getAction();
+ ns = getNamespace();
+ validNamespaces = getValidNamespaceClasses();
+
+ TargetManager.getInstance().setTarget(ns);
+ }
+
+ /**
+ * Test to create a diagram.
+ */
+ public void testCreateDiagram() {
+ Model.getPump().flushModelEvents();
+ action.actionPerformed(null);
+ Object d = TargetManager.getInstance().getTarget();
+ assertTrue("No diagram generated", d instanceof ArgoDiagram);
+ Model.getPump().flushModelEvents();
+ ArgoDiagram diagram = (ArgoDiagram) d;
+ assertNotNull(
+ "The diagram has no namespace",
+ diagram.getNamespace());
+ assertNotNull(
+ "The diagram has no graphmodel",
+ diagram.getGraphModel());
+ assertTrue("The graphmodel of the diagram is not a "
+ + "UMLMutableGraphSupport",
+ diagram.getGraphModel() instanceof UMLMutableGraphSupport);
+ assertNotNull("The diagram has no name", diagram.getName());
+ }
+
+ /**
+ * Tests if two diagrams created have different names.
+ */
+ public void testDifferentNames() {
+ action.actionPerformed(null);
+ Object d = TargetManager.getInstance().getTarget();
+ assertTrue("No diagram generated", d instanceof ArgoDiagram);
+ Model.getPump().flushModelEvents();
+ ArgoDiagram diagram1 = (ArgoDiagram) d;
+ // This next line is needed to register the diagram in the project,
+ // since creating a next diagram will need the new name to be compared
+ // with existing diagrams in the project, to validate
+ // there are no duplicates.
+ ProjectManager.getManager().getCurrentProject().addMember(diagram1);
+
+ TargetManager.getInstance().setTarget(ns);
+ action.actionPerformed(null);
+ d = TargetManager.getInstance().getTarget();
+ assertTrue("No diagram generated", d instanceof ArgoDiagram);
+ Model.getPump().flushModelEvents();
+ ArgoDiagram diagram2 = (ArgoDiagram) d;
+
+ Model.getPump().flushModelEvents();
+ assertTrue(
+ "The created diagrams have the same name",
+ !(diagram1.getName().equals(diagram2.getName())));
+ }
+
+ /**
+ * Tests if the list with namespaces defined in getValidNamespaceClasses
+ * contains only valid namespaces.
+ *
+ * TODO: This test does not test anything, really!
+ */
+ public void testValidNamespaces() {
+ Iterator it = validNamespaces.iterator();
+ while (it.hasNext()) {
+ Object type = it.next();
+
+ Object o = Model.getUmlFactory().buildNode(type);
+ String objDesc = "" + o;
+ if (o != null) {
+ objDesc += " (" + o.getClass() + ")";
+ }
+ TargetManager.getInstance().setTarget(o);
+ Model.getPump().flushModelEvents();
+ action.actionPerformed(null);
+ Object d = TargetManager.getInstance().getTarget();
+ assertTrue(
+ objDesc
+ + " is not valid namespace for the diagram",
+ d instanceof ArgoDiagram);
+ }
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestActionUseCaseDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestActionUseCaseDiagram.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestActionUseCaseDiagram.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,81 @@
+// $Id:TestActionUseCaseDiagram.java 11517 2006-11-25 05:27:15Z tfmorris $
+// Copyright (c) 1996-2006 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.uml.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.argouml.model.Model;
+
+/**
+ * Test for {@link ActionUseCaseDiagram}.
+ * @author [email protected]
+ * @since Jan 9, 2003
+ */
+public class TestActionUseCaseDiagram
+ extends AbstractTestActionAddDiagram {
+
+ /**
+ * Constructor
+ * @param arg0 test case name.
+ */
+ public TestActionUseCaseDiagram(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractTestActionAddDiagram#getAction()
+ */
+ protected ActionAddDiagram getAction() {
+ return new ActionUseCaseDiagram();
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractTestActionAddDiagram#getNamespace()
+ */
+ protected Object getNamespace() {
+ return Model.getModelManagementFactory().createPackage();
+ }
+
+ /*
+ * @see AbstractTestActionAddDiagram#getValidNamespaceClasses()
+ */
+ protected List getValidNamespaceClasses() {
+ List rl = new ArrayList();
+ rl.add(Model.getMetaTypes().getPackage());
+ /*
+ * This needs to be a concrete metatype, so we can't use
+ * the general, but abstract, Classifier. Replace with its
+ * concrete subtypes.
+ */
+ rl.add(Model.getMetaTypes().getUMLClass());
+ rl.add(Model.getMetaTypes().getInterface());
+ rl.add(Model.getMetaTypes().getDataType());
+ rl.add(Model.getMetaTypes().getNode());
+ rl.add(Model.getMetaTypes().getComponent());
+ return rl;
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestSourcePathController.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestSourcePathController.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestSourcePathController.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,173 @@
+// $Id:TestSourcePathController.java 12485 2007-05-03 05:59:35Z linus $
+// Copyright (c) 2004-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.uml.ui;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+import java.io.File;
+
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.Model;
+import org.argouml.uml.reveng.ImportInterface;
+
+/**
+ * Test SourcePathController implementation.
+ * @author euluis
+ * @since 0.17.3
+ * @see SourcePathController
+ */
+public class TestSourcePathController extends TestCase {
+
+ /** the model to use during testing */
+ private Object model;
+
+ /** A class model element... */
+ private Object modelElem;
+ /** its source path */
+ private String modelElemSourcePath;
+ /** and the corresponding file */
+ private File modelElemSourcePathFile;
+
+ /** A class model element without a source path defined */
+ private Object modelElemWithoutSrcPath;
+
+ /** Number of model elements in the setup model with source path set. */
+ private int numOfMEsWithSrcPath;
+
+ /** The SourcePathController instance. */
+ private SourcePathController srcCtrl;
+
+ /**
+ * Creates a new instance of TestSourcePathController.
+ *
+ * @param arg0 name of the test case
+ */
+ public TestSourcePathController(String arg0) {
+ super(arg0);
+ InitializeModel.initializeDefault();
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() {
+ modelElemSourcePath = "ArgoUML/issues2579/src";
+ // setup the Project due to its use in SourcePathTableModel ctor
+ ProjectManager.getManager().makeEmptyProject();
+ model = ProjectManager.getManager().getCurrentProject().getRoot();
+ Object taggedValue = Model.getExtensionMechanismsFactory()
+ .buildTaggedValue(ImportInterface.SOURCE_PATH_TAG,
+ modelElemSourcePath);
+ Model.getExtensionMechanismsHelper().addTaggedValue(model, taggedValue);
+
+ // create a class model element
+ modelElem = Model.getCoreFactory().buildClass("AClass", model);
+ taggedValue = Model.getExtensionMechanismsFactory().buildTaggedValue(
+ ImportInterface.SOURCE_PATH_TAG, modelElemSourcePath);
+ Model.getExtensionMechanismsHelper().addTaggedValue(
+ modelElem, taggedValue);
+ modelElemSourcePathFile = new File(modelElemSourcePath);
+
+ modelElemWithoutSrcPath = Model.getCoreFactory().buildClass(
+ "AClassWithoutSrcPath", model);
+ srcCtrl = new SourcePathControllerImpl();
+
+ // REMEMBER to change this if you change the number of MEs with source
+ // path settings
+ numOfMEsWithSrcPath = 2;
+ }
+
+ /**
+ * Test the SourcePathController creation.
+ */
+ public void testCreation() {
+ SourcePathController sourcePathCtrl = new SourcePathControllerImpl();
+ assertNotNull(sourcePathCtrl);
+ }
+
+ /**
+ * Test retrieving the source path of a specific element.
+ */
+ public void testSimpleGetSourcePath() {
+ File srcPath = srcCtrl.getSourcePath(modelElem);
+ assertEquals(modelElemSourcePathFile, srcPath);
+ }
+
+ /**
+ * Test getting the source path for a model element without it.
+ */
+ public void testGetSourcePath4MEWithoutSourcePath() {
+ File srcPath = srcCtrl.getSourcePath(modelElemWithoutSrcPath);
+ assertNull(srcPath);
+ }
+
+ /**
+ * Test retrieving all source path settings in the model.
+ */
+ public void testGetSourcePathSettings() {
+ SourcePathTableModel srcPathSets = srcCtrl.getSourcePathSettings();
+ assertEquals(numOfMEsWithSrcPath, srcPathSets.getRowCount());
+ for (int i = 0; i < srcPathSets.getRowCount(); i++) {
+ assertEquals(modelElemSourcePathFile.toString(),
+ (String) srcPathSets.getValueAt(i,
+ SourcePathTableModel.SOURCE_PATH_COLUMN));
+ }
+ }
+
+ /**
+ * Test deletion of the source path settings for a model element.
+ */
+ public void testDeleteSourcePathSettings() {
+ srcCtrl.deleteSourcePath(modelElem);
+ assertNull(srcCtrl.getSourcePath(modelElem));
+ }
+
+ /**
+ * Test setting the source path of a model element.
+ */
+ public void testSetSourcePath() {
+ assertEquals(modelElemSourcePathFile,
+ srcCtrl.getSourcePath(modelElem));
+ File newSrcPath = new File("../new/source/path");
+ srcCtrl.setSourcePath(modelElem, newSrcPath);
+ assertEquals(newSrcPath, srcCtrl.getSourcePath(modelElem));
+ }
+
+ /**
+ * Test setting the source path according to the contents of Table model.
+ */
+ public void testSetSourcePathSettings() {
+ SourcePathTableModel srcPathSets = srcCtrl.getSourcePathSettings();
+ assertEquals(numOfMEsWithSrcPath, srcPathSets.getRowCount());
+ File newSrcPath = new File("../new/source/path");
+ for (int i = 0; i < srcPathSets.getRowCount(); i++) {
+ srcPathSets.setValueAt(newSrcPath.toString(), i,
+ SourcePathTableModel.SOURCE_PATH_COLUMN);
+ }
+ srcCtrl.setSourcePath(srcPathSets);
+ assertEquals(newSrcPath, srcCtrl.getSourcePath(modelElem));
+ assertEquals(newSrcPath, srcCtrl.getSourcePath(model));
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestTabStyle.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestTabStyle.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestTabStyle.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,114 @@
+// $Id:TestTabStyle.java 10734 2006-06-11 15:43:58Z mvw $
+// Copyright (c) 2003-2006 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.uml.ui;
+
+import junit.framework.TestCase;
+
+import org.argouml.ui.StylePanel;
+import org.argouml.ui.StylePanelFigNodeModelElement;
+import org.argouml.uml.diagram.state.ui.FigSimpleState;
+import org.argouml.uml.diagram.state.ui.FigTransition;
+import org.argouml.uml.diagram.static_structure.ui.FigClass;
+import org.argouml.uml.diagram.static_structure.ui.FigInstance;
+import org.argouml.uml.diagram.static_structure.ui.FigInterface;
+import org.argouml.uml.diagram.static_structure.ui.FigLink;
+import org.argouml.uml.diagram.static_structure.ui.StylePanelFigClass;
+import org.argouml.uml.diagram.static_structure.ui.StylePanelFigInterface;
+import org.argouml.uml.diagram.ui.FigAssociation;
+import org.argouml.uml.diagram.ui.FigEdgeModelElement;
+import org.argouml.uml.diagram.ui.FigGeneralization;
+import org.argouml.uml.diagram.ui.FigNodeModelElement;
+import org.argouml.uml.diagram.ui.FigRealization;
+import org.argouml.uml.diagram.ui.SPFigEdgeModelElement;
+import org.argouml.uml.diagram.use_case.ui.FigActor;
+import org.argouml.uml.diagram.use_case.ui.FigUseCase;
+import org.argouml.uml.diagram.use_case.ui.StylePanelFigUseCase;
+
+/**
+ * @author mkl
+ *
+ */
+public class TestTabStyle extends TestCase {
+
+ /**
+ * The constructor.
+ *
+ * @param arg the name
+ */
+ public TestTabStyle(String arg) {
+ super(arg);
+ }
+
+ /**
+ * Test findPanelFor().
+ */
+ public void testFindPanelFor() {
+
+ TabStyle tabStyle = new TabStyle();
+
+ StylePanel panel;
+
+ panel = tabStyle.findPanelFor(FigClass.class);
+ assertTrue(panel instanceof StylePanelFigClass);
+
+ panel = tabStyle.findPanelFor(FigInterface.class);
+ assertTrue(panel instanceof StylePanelFigInterface);
+
+ panel = tabStyle.findPanelFor(FigUseCase.class);
+ assertTrue(panel instanceof StylePanelFigUseCase);
+
+ panel = tabStyle.findPanelFor(FigNodeModelElement.class);
+ assertTrue(panel instanceof StylePanelFigNodeModelElement);
+
+ panel = tabStyle.findPanelFor(FigEdgeModelElement.class);
+ assertTrue(panel instanceof SPFigEdgeModelElement);
+
+ panel = tabStyle.findPanelFor(FigSimpleState.class);
+ assertTrue(panel instanceof StylePanelFigNodeModelElement);
+
+ panel = tabStyle.findPanelFor(FigTransition.class);
+ assertTrue(panel instanceof SPFigEdgeModelElement);
+
+ panel = tabStyle.findPanelFor(FigActor.class);
+ assertTrue(panel instanceof StylePanelFigNodeModelElement);
+
+ panel = tabStyle.findPanelFor(FigInstance.class);
+ assertTrue(panel instanceof StylePanelFigNodeModelElement);
+
+ panel = tabStyle.findPanelFor(FigLink.class);
+ assertTrue(panel instanceof SPFigEdgeModelElement);
+
+ panel = tabStyle.findPanelFor(FigGeneralization.class);
+ assertTrue(panel instanceof SPFigEdgeModelElement);
+
+ panel = tabStyle.findPanelFor(FigRealization.class);
+ assertTrue(panel instanceof SPFigEdgeModelElement);
+
+ panel = tabStyle.findPanelFor(FigAssociation.class);
+ assertTrue(panel instanceof SPFigEdgeModelElement);
+
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestUMLTagDefinitionComboBoxModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestUMLTagDefinitionComboBoxModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/TestUMLTagDefinitionComboBoxModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,103 @@
+// $Id:TestUMLTagDefinitionComboBoxModel.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 1996-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.uml.ui;
+
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.Model;
+import org.argouml.ui.targetmanager.TargetEvent;
+import org.argouml.uml.ui.foundation.extension_mechanisms.UMLTagDefinitionComboBoxModel;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+/**
+ * Test cases for the UMLTagDefinitionComboBoxModel class.
+ *
+ * @author euluis
+ * @since 0.20
+ */
+public class TestUMLTagDefinitionComboBoxModel extends TestCase {
+
+ private Object model;
+
+ private Object theClass;
+
+ private Object theStereotype;
+
+ private Project proj;
+
+ /**
+ * Default constructor.
+ */
+ public TestUMLTagDefinitionComboBoxModel() {
+ super("TestUMLTagDefinitionComboBoxModel");
+ }
+ /**
+ * Constructor.
+ * @param arg0 test name
+ */
+ public TestUMLTagDefinitionComboBoxModel(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ proj = ProjectManager.getManager().getCurrentProject();
+ model = proj.getModel();
+
+ theClass = Model.getCoreFactory().buildClass("TheClass", model);
+ theStereotype = Model.getExtensionMechanismsFactory().buildStereotype(
+ theClass, "containedStereotype", model);
+ }
+
+ /**
+ * Test if a tag definition owned by a stereotype is available to be
+ * applied in a class to which the stereotype is applied.
+ */
+ public void testTagDefinitionFromStereotypeApplicableToStereotypedClass() {
+ Object theTagDefinition = Model.getExtensionMechanismsFactory().
+ buildTagDefinition("TagDefinition", theStereotype, null);
+ // Testing with more than one, since it failed with a manual test I
+ // made.
+ Object theTagDefinition2 = Model.getExtensionMechanismsFactory().
+ buildTagDefinition("TagDefinition2", theStereotype, null);
+ Model.getCoreHelper().addStereotype(theClass, theStereotype);
+ UMLTagDefinitionComboBoxModel tagDefComboBoxModel =
+ new UMLTagDefinitionComboBoxModel();
+ Object[] added = {theClass};
+ tagDefComboBoxModel.targetAdded(new TargetEvent(this, "TARGET_ADDED",
+ new Object[0], added));
+ assertTrue("The TagDefinition should be contained!",
+ tagDefComboBoxModel.contains(theTagDefinition));
+ assertTrue("The TagDefinition2 should be contained!",
+ tagDefComboBoxModel.contains(theTagDefinition2));
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationEndRoleBaseListModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationEndRoleBaseListModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationEndRoleBaseListModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,157 @@
+// $Id:TestUMLAssociationEndRoleBaseListModel.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 1996-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.uml.ui.behavior.collaborations;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.model.Model;
+import org.argouml.uml.ui.UMLModelElementListModel2;
+
+/**
+ * @since Oct 27, 2002
+ * @author [email protected]
+ */
+public class TestUMLAssociationEndRoleBaseListModel extends TestCase {
+
+ private Object elem;
+ private UMLModelElementListModel2 model;
+ private Object baseAssoc;
+ private Object baseEnd;
+ private Object assocRole;
+
+ /**
+ * Constructor for TestUMLAssociationEndRoleBaseListModel.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestUMLAssociationEndRoleBaseListModel(String arg0) {
+ super(arg0);
+ }
+
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+
+ Object classifier = Model.getCoreFactory().createClass();
+ Object collaboration =
+ Model.getCollaborationsFactory().buildCollaboration(classifier);
+
+ elem = Model.getCollaborationsFactory().createAssociationEndRole();
+
+ Object classNamespace =
+ Model.getModelManagementFactory().createPackage();
+ baseAssoc =
+ Model.getCoreFactory().buildAssociation(
+ Model.getCoreFactory().buildClass("from", classNamespace),
+ false,
+ Model.getCoreFactory().buildClass("to", classNamespace),
+ true,
+ "association");
+ Model.getCoreHelper().addOwnedElement(collaboration, baseAssoc);
+
+ Object from =
+ Model.getCollaborationsFactory().buildClassifierRole(collaboration);
+ Object to =
+ Model.getCollaborationsFactory().buildClassifierRole(collaboration);
+
+ assocRole =
+ Model.getCollaborationsFactory().buildAssociationRole(from, to);
+
+ Model.getCoreHelper().setName(assocRole, "TestAssocRole");
+
+ Model.getCoreHelper().setAssociation(elem, assocRole);
+ Model.getCollaborationsHelper().setBase(assocRole, baseAssoc);
+
+ baseEnd = Model.getCoreFactory().createAssociationEnd();
+ Model.getCoreHelper().setAssociation(baseEnd, baseAssoc);
+
+ model = new UMLAssociationEndRoleBaseListModel();
+ model.setTarget(elem);
+ Model.getPump().flushModelEvents();
+ }
+
+ /*
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ Model.getUmlFactory().delete(elem);
+ Model.getUmlFactory().delete(assocRole);
+
+ Collection connections = Model.getFacade().getConnections(baseAssoc);
+ Model.getUmlFactory().delete(baseAssoc);
+
+ Iterator iter = connections.iterator();
+ while (iter.hasNext()) {
+ Model.getUmlFactory().delete(iter.next());
+ }
+ connections = null;
+
+ Model.getUmlFactory().delete(baseEnd);
+ model = null;
+ super.tearDown();
+ }
+
+ /**
+ * Test setting the Base.
+ */
+ public void testAdd() {
+ Model.getCollaborationsHelper().setBase(elem, baseEnd);
+ Model.getPump().flushModelEvents();
+ assertEquals(1, model.getSize());
+ assertEquals(baseEnd, model.getElementAt(0));
+ }
+
+ /**
+ * Testing that we have an empty model to begin with.
+ */
+ public void testEmpty() {
+ assertEquals(0, model.getSize());
+ try {
+ model.getElementAt(0);
+ fail();
+ } catch (ArrayIndexOutOfBoundsException ex) {
+ // This is what we expect.
+ }
+ }
+
+ /**
+ * Test removing.
+ */
+ public void testRemove() {
+ Model.getCollaborationsHelper().setBase(elem, baseEnd);
+ Model.getCollaborationsHelper().setBase(elem, null);
+ Model.getPump().flushModelEvents();
+ assertEquals(0, model.getSize());
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleAssociationEndRoleListModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleAssociationEndRoleListModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleAssociationEndRoleListModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,82 @@
+// $Id:TestUMLAssociationRoleAssociationEndRoleListModel.java 11517 2006-11-25 05:27:15Z tfmorris $
+// Copyright (c) 1996-2006 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.uml.ui.behavior.collaborations;
+
+import org.argouml.model.Model;
+import org.argouml.uml.ui.AbstractUMLModelElementListModel2Test;
+
+/**
+ * @since Oct 27, 2002
+ * @author [email protected]
+ */
+public class TestUMLAssociationRoleAssociationEndRoleListModel
+ extends AbstractUMLModelElementListModel2Test {
+
+ /**
+ * Constructor for TestUMLAssociationRoleAssociationEndRoleListModel.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestUMLAssociationRoleAssociationEndRoleListModel(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#buildElement()
+ */
+ protected void buildElement() {
+ setElem(Model.getCollaborationsFactory().createAssociationRole());
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#buildModel()
+ */
+ protected void buildModel() {
+ setModel(new UMLAssociationRoleAssociationEndRoleListModel());
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#fillModel()
+ */
+ protected Object[] fillModel() {
+ Object[] ends = new Object[10];
+ for (int i = 0; i < ends.length; i++) {
+ ends[i] =
+ Model.getCollaborationsFactory().createAssociationEndRole();
+ Model.getCoreHelper().setAssociation(ends[i], getElem());
+ }
+ return ends;
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#removeHalfModel(Object[])
+ */
+ protected void removeHalfModel(Object[] elements) {
+ for (int i = 0; i < 5; i++) {
+ Model.getCoreHelper().removeConnection(getElem(), elements[i]);
+ }
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleBaseComboBoxModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleBaseComboBoxModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleBaseComboBoxModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,195 @@
+// $Id:TestUMLAssociationRoleBaseComboBoxModel.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 1996-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.uml.ui.behavior.collaborations;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.Model;
+import org.argouml.ui.targetmanager.TargetEvent;
+
+/**
+ * @since Oct 30, 2002
+ * @author [email protected]
+ */
+public class TestUMLAssociationRoleBaseComboBoxModel extends TestCase {
+
+ /**
+ * The count of elements that we create in this test.
+ */
+ private static final int NO_ELEMENTS_IN_TEST = 10;
+
+ /**
+ * The element that we work on.
+ */
+ private Object elem;
+
+ /**
+ * The model that we work on.
+ */
+ private UMLAssociationRoleBaseComboBoxModel model;
+
+ /**
+ * The list of bases that we use for the test.
+ */
+ private Object[] bases;
+
+ /**
+ * Constructor for TestUMLAssociationRoleBaseComboBoxModel.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestUMLAssociationRoleBaseComboBoxModel(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+
+ Project p = ProjectManager.getManager().getCurrentProject();
+ model = new UMLAssociationRoleBaseComboBoxModel();
+ Object class1 = Model.getCoreFactory().createClass();
+ Object class2 = Model.getCoreFactory().createClass();
+ Object m = Model.getModelManagementFactory().createModel();
+ p.setRoot(m);
+ Model.getCoreHelper().setNamespace(class1, m);
+ Model.getCoreHelper().setNamespace(class2, m);
+ bases = new Object[NO_ELEMENTS_IN_TEST];
+ for (int i = 0; i < NO_ELEMENTS_IN_TEST; i++) {
+ bases[i] =
+ Model.getCoreFactory().buildAssociation(class1, class2);
+ }
+ Object role1 =
+ Model.getCollaborationsFactory().createClassifierRole();
+ Object role2 =
+ Model.getCollaborationsFactory().createClassifierRole();
+ Model.getCollaborationsHelper().addBase(role1, class1);
+ Model.getCollaborationsHelper().addBase(role2, class2);
+ Object col =
+ Model.getCollaborationsFactory().createCollaboration();
+ Model.getCoreHelper().setNamespace(role1, col);
+ Model.getCoreHelper().setNamespace(role2, col);
+ elem =
+ Model.getCollaborationsFactory().buildAssociationRole(role1, role2);
+ model.targetSet(new TargetEvent(this,
+ TargetEvent.TARGET_SET,
+ new Object[0],
+ new Object[] {
+ elem,
+ }));
+ Model.getPump().flushModelEvents();
+ }
+
+ /*
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Model.getUmlFactory().delete(elem);
+ model = null;
+ }
+
+ /**
+ * Test setup.
+ */
+ public void testSetUp() {
+ // there is one extra element due to the empty element that
+ // the user can select
+ assertEquals(NO_ELEMENTS_IN_TEST + 1, model.getSize());
+
+ // Somewhere in the middle
+ assertTrue(model.contains(bases[NO_ELEMENTS_IN_TEST / 2]));
+
+ assertTrue(model.contains(bases[0]));
+ assertTrue(model.contains(bases[NO_ELEMENTS_IN_TEST - 1]));
+ }
+
+ /**
+ * Test setting the Base.
+ */
+ public void testSetBase() {
+ Model.getCollaborationsHelper().setBase(elem, bases[0]);
+ Model.getPump().flushModelEvents();
+ assertTrue(model.getSelectedItem() == bases[0]);
+ }
+
+ /**
+ * Test setting the Base.
+ */
+ public void testChangeBase() {
+ Model.getCollaborationsHelper().setBase(elem, bases[0]);
+ Model.getPump().flushModelEvents();
+ Model.getCollaborationsHelper().setBase(elem, bases[1]);
+ Model.getPump().flushModelEvents();
+ assertTrue(model.getSelectedItem() == bases[1]);
+ }
+
+ /**
+ * Test deleting selected Base.
+ */
+ public void testDeleteBase() {
+ Model.getCollaborationsHelper().setBase(elem, bases[1]);
+ Model.getUmlFactory().delete(bases[1]);
+ Model.getPump().flushModelEvents();
+ assertNull(model.getSelectedItem());
+ }
+
+ /**
+ * Test setting the Base to null.
+ */
+ public void testSetBaseToNull() {
+ Model.getCollaborationsHelper().setBase(elem, bases[0]);
+ Model.getCollaborationsHelper().setBase(elem, null);
+ Model.getPump().flushModelEvents();
+ assertNull(model.getSelectedItem());
+ }
+
+ /**
+ * Test removing the Base.
+ */
+ public void testRemoveBase() {
+ Model.getUmlFactory().delete(bases[NO_ELEMENTS_IN_TEST - 1]);
+ // One can only delete a assoc by changing target,
+ // so let's simulate that:
+ /* TODO: Get rid of this! */
+ model.targetSet(new TargetEvent(this,
+ TargetEvent.TARGET_SET,
+ new Object[0],
+ new Object[] {
+ elem,
+ }));
+ // there is one extra element since removal of the base is allowed.
+ Model.getPump().flushModelEvents();
+ assertEquals(NO_ELEMENTS_IN_TEST + 1 - 1, model.getSize());
+ assertTrue(!model.contains(bases[NO_ELEMENTS_IN_TEST - 1]));
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleMessageListModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleMessageListModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleMessageListModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,84 @@
+// $Id:TestUMLAssociationRoleMessageListModel.java 11517 2006-11-25 05:27:15Z tfmorris $
+// Copyright (c) 1996-2006 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.
+
+// $header$
+package org.argouml.uml.ui.behavior.collaborations;
+
+import org.argouml.model.Model;
+import org.argouml.uml.ui.AbstractUMLModelElementListModel2Test;
+
+/**
+ * @since Oct 27, 2002
+ * @author [email protected]
+ */
+public class TestUMLAssociationRoleMessageListModel
+ extends AbstractUMLModelElementListModel2Test {
+
+ /**
+ * Constructor for TestUMLAssociationRoleMessageListModel.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestUMLAssociationRoleMessageListModel(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#buildElement()
+ */
+ protected void buildElement() {
+ setElem(Model.getCollaborationsFactory().createAssociationRole());
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#buildModel()
+ */
+ protected void buildModel() {
+ setModel(new UMLAssociationRoleMessageListModel());
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#fillModel()
+ */
+ protected Object[] fillModel() {
+ Object[] messages = new Object[10];
+ for (int i = 0; i < messages.length; i++) {
+ messages[i] = Model.getCollaborationsFactory().createMessage();
+ Model.getCollaborationsHelper().addMessage(getElem(), messages[i]);
+ }
+ return messages;
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#removeHalfModel(Object[])
+ */
+ protected void removeHalfModel(Object[] elements) {
+ for (int i = 0; i < 5; i++) {
+ Model.getCollaborationsHelper().removeMessage(
+ getElem(),
+ elements[i]);
+ }
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLClassifierRoleAvailableContentsListModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLClassifierRoleAvailableContentsListModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLClassifierRoleAvailableContentsListModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,100 @@
+// $Id:TestUMLClassifierRoleAvailableContentsListModel.java 11517 2006-11-25 05:27:15Z tfmorris $
+// Copyright (c) 1996-2006 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.uml.ui.behavior.collaborations;
+
+import org.argouml.model.Model;
+import org.argouml.uml.ui.AbstractUMLModelElementListModel2Test;
+
+/**
+ * @since Oct 27, 2002
+ * @author [email protected]
+ */
+public class TestUMLClassifierRoleAvailableContentsListModel
+ extends AbstractUMLModelElementListModel2Test {
+
+ private Object base;
+
+ /**
+ * Constructor for TestUMLClassifierRoleAvailableContentsListModel.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestUMLClassifierRoleAvailableContentsListModel(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#buildElement()
+ */
+ protected void buildElement() {
+ setElem(Model.getCollaborationsFactory().createClassifierRole());
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#buildModel()
+ */
+ protected void buildModel() {
+ setModel(new UMLClassifierRoleAvailableContentsListModel());
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#fillModel()
+ */
+ protected Object[] fillModel() {
+ Object[] elements = new Object[10];
+ for (int i = 0; i < elements.length; i++) {
+ elements[i] = Model.getCoreFactory().createClass();
+ Model.getCoreHelper().addOwnedElement(base, elements[i]);
+ }
+ return elements;
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#removeHalfModel(Object[])
+ */
+ protected void removeHalfModel(Object[] elements) {
+ for (int i = 0; i < 5; i++) {
+ Model.getCoreHelper().removeOwnedElement(base, elements[i]);
+ }
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ base = Model.getCoreFactory().createClass();
+ Model.getCollaborationsHelper().addBase(getElem(), base);
+ }
+
+ /*
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Model.getUmlFactory().delete(base);
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLClassifierRoleAvailableFeaturesListModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLClassifierRoleAvailableFeaturesListModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLClassifierRoleAvailableFeaturesListModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,100 @@
+// $Id:TestUMLClassifierRoleAvailableFeaturesListModel.java 11517 2006-11-25 05:27:15Z tfmorris $
+// Copyright (c) 1996-2006 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.uml.ui.behavior.collaborations;
+
+import org.argouml.model.Model;
+import org.argouml.uml.ui.AbstractUMLModelElementListModel2Test;
+
+/**
+ * @since Oct 27, 2002
+ * @author [email protected]
+ */
+public class TestUMLClassifierRoleAvailableFeaturesListModel
+ extends AbstractUMLModelElementListModel2Test {
+
+ private Object base;
+
+ /**
+ * Constructor for TestUMLClassifierRoleAvailableFeaturesListModel.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestUMLClassifierRoleAvailableFeaturesListModel(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#buildElement()
+ */
+ protected void buildElement() {
+ setElem(Model.getCollaborationsFactory().createClassifierRole());
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#buildModel()
+ */
+ protected void buildModel() {
+ setModel(new UMLClassifierRoleAvailableFeaturesListModel());
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#fillModel()
+ */
+ protected Object[] fillModel() {
+ Object[] features = new Object[10];
+ for (int i = 0; i < features.length; i++) {
+ features[i] = Model.getCoreFactory().createOperation();
+ Model.getCoreHelper().addFeature(base, features[i]);
+ }
+ return features;
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#removeHalfModel(Object[])
+ */
+ protected void removeHalfModel(Object[] elements) {
+ for (int i = 0; i < 5; i++) {
+ Model.getCoreHelper().removeFeature(base, elements[i]);
+ }
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ base = Model.getCoreFactory().createClass();
+ Model.getCollaborationsHelper().addBase(getElem(), base);
+ }
+
+ /*
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Model.getUmlFactory().delete(base);
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLClassifierRoleBaseListModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLClassifierRoleBaseListModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLClassifierRoleBaseListModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,81 @@
+// $Id:TestUMLClassifierRoleBaseListModel.java 11517 2006-11-25 05:27:15Z tfmorris $
+// Copyright (c) 1996-2006 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.uml.ui.behavior.collaborations;
+
+import org.argouml.model.Model;
+import org.argouml.uml.ui.AbstractUMLModelElementListModel2Test;
+
+/**
+ * @since Oct 27, 2002
+ * @author [email protected]
+ */
+public class TestUMLClassifierRoleBaseListModel
+ extends AbstractUMLModelElementListModel2Test {
+
+ /**
+ * Constructor for TestUMLClassifierRoleBaseListModel.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestUMLClassifierRoleBaseListModel(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#buildElement()
+ */
+ protected void buildElement() {
+ setElem(Model.getCollaborationsFactory().createClassifierRole());
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#buildModel()
+ */
+ protected void buildModel() {
+ setModel(new UMLClassifierRoleBaseListModel());
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#fillModel()
+ */
+ protected Object[] fillModel() {
+ Object[] bases = new Object[10];
+ for (int i = 0; i < bases.length; i++) {
+ bases[i] = Model.getCoreFactory().createClass();
+ Model.getCollaborationsHelper().addBase(getElem(), bases[i]);
+ }
+ return bases;
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#removeHalfModel(Object[])
+ */
+ protected void removeHalfModel(Object[] elements) {
+ for (int i = 0; i < 5; i++) {
+ Model.getCollaborationsHelper().removeBase(getElem(), elements[i]);
+ }
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLCollaborationConstraintListModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLCollaborationConstraintListModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLCollaborationConstraintListModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,86 @@
+// $Id:TestUMLCollaborationConstraintListModel.java 11517 2006-11-25 05:27:15Z tfmorris $
+// Copyright (c) 1996-2006 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.uml.ui.behavior.collaborations;
+
+import org.argouml.model.Model;
+import org.argouml.uml.ui.AbstractUMLModelElementListModel2Test;
+
+
+/**
+ * @since Oct 27, 2002
+ * @author [email protected]
+ */
+public class TestUMLCollaborationConstraintListModel
+ extends AbstractUMLModelElementListModel2Test {
+
+ /**
+ * Constructor for TestUMLCollaborationConstraintListModel.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestUMLCollaborationConstraintListModel(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#buildElement()
+ */
+ protected void buildElement() {
+ setElem(Model.getCollaborationsFactory().createCollaboration());
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#buildModel()
+ */
+ protected void buildModel() {
+ setModel(new UMLCollaborationConstrainingElementListModel());
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#fillModel()
+ */
+ protected Object[] fillModel() {
+ Object[] constraints = new Object[10];
+ for (int i = 0; i < constraints.length; i++) {
+ constraints[i] = Model.getCoreFactory().createConstraint();
+ Model.getCollaborationsHelper().addConstrainingElement(
+ getElem(),
+ constraints[i]);
+ }
+ return constraints;
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#removeHalfModel(Object[])
+ */
+ protected void removeHalfModel(Object[] elements) {
+ for (int i = 0; i < 5; i++) {
+ Model.getCollaborationsHelper().removeConstrainingElement(
+ getElem(),
+ elements[i]);
+ }
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLCollaborationRepresentedClassifierComboBoxModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLCollaborationRepresentedClassifierComboBoxModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLCollaborationRepresentedClassifierComboBoxModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,109 @@
+// $Id:TestUMLCollaborationRepresentedClassifierComboBoxModel.java 12485 2007-05-03 05:59:35Z linus $
+// Copyright (c) 1996-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.uml.ui.behavior.collaborations;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.Model;
+import org.argouml.ui.targetmanager.TargetEvent;
+import org.argouml.ui.targetmanager.TargetManager;
+
+/**
+ * @since Oct 28, 2002
+ * @author [email protected]
+ */
+public class TestUMLCollaborationRepresentedClassifierComboBoxModel
+ extends TestCase {
+
+ private Object elem;
+// private Object oper;
+ private Object clazz;
+ private UMLCollaborationRepresentedClassifierComboBoxModel model;
+
+ /**
+ * Constructor for TestUMLCollaborationRepresentedClassifierComboBoxModel.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestUMLCollaborationRepresentedClassifierComboBoxModel(String arg0) {
+ super(arg0);
+ InitializeModel.initializeDefault();
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ elem = Model.getCollaborationsFactory().createCollaboration();
+ model = new UMLCollaborationRepresentedClassifierComboBoxModel();
+ TargetManager.getInstance().setTarget(elem);
+ Model.getPump().flushModelEvents();
+
+ Project p = ProjectManager.getManager().getCurrentProject();
+ Object m = p.getRoot();
+ clazz = Model.getCoreFactory().buildClass(m);
+ Model.getCollaborationsHelper().setRepresentedClassifier(elem, clazz);
+ Model.getPump().flushModelEvents();
+ /* Simulate a target change. */
+ model.targetSet(new TargetEvent(this, null, null, new Object[] {elem}));
+ }
+
+ /*
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Model.getUmlFactory().delete(elem);
+ model = null;
+ }
+
+ /**
+ * Test setRepresentedClassifier().
+ */
+ public void testSetRepresentedOperation() {
+ /* Now the model should contain
+ * the one operation + the "" for clearing. */
+ assertEquals(2, model.getSize());
+ assertEquals(clazz, model.getElementAt(0));
+ }
+
+ /**
+ * Test removing the represented operation.
+ */
+ public void testExtraRepresentedOperation() {
+ Object cl2 = Model.getCoreFactory().createClass();
+ Model.getCollaborationsHelper().setRepresentedClassifier(elem, cl2);
+ /* Simulate a target change. */
+ model.targetSet(new TargetEvent(this, null, null, new Object[] {elem}));
+ Model.getPump().flushModelEvents();
+ assertEquals(3, model.getSize());
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLCollaborationRepresentedOperationComboBoxModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLCollaborationRepresentedOperationComboBoxModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLCollaborationRepresentedOperationComboBoxModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,112 @@
+// $Id:TestUMLCollaborationRepresentedOperationComboBoxModel.java 12485 2007-05-03 05:59:35Z linus $
+// Copyright (c) 1996-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.uml.ui.behavior.collaborations;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.Model;
+import org.argouml.ui.targetmanager.TargetEvent;
+import org.argouml.ui.targetmanager.TargetManager;
+
+/**
+ * @since Oct 29, 2002
+ * @author [email protected]
+ */
+public class TestUMLCollaborationRepresentedOperationComboBoxModel
+ extends TestCase {
+
+ private Object elem;
+ private Object oper;
+ private UMLCollaborationRepresentedOperationComboBoxModel model;
+
+ /**
+ * Constructor for TestUMLCollaborationRepresentedOperationComboBoxModel.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestUMLCollaborationRepresentedOperationComboBoxModel(String arg0) {
+ super(arg0);
+ InitializeModel.initializeDefault();
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ elem = Model.getCollaborationsFactory().createCollaboration();
+ model = new UMLCollaborationRepresentedOperationComboBoxModel();
+ TargetManager.getInstance().setTarget(elem);
+ Model.getPump().flushModelEvents();
+
+ Project p = ProjectManager.getManager().getCurrentProject();
+ Object m = p.getRoot();
+ Object clazz = Model.getCoreFactory().buildClass(m);
+ oper = Model.getCoreFactory().createOperation();
+ Model.getCoreHelper().setOwner(oper, clazz);
+ Model.getCollaborationsHelper().setRepresentedOperation(elem, oper);
+ Model.getPump().flushModelEvents();
+ /* Simulate a target change. */
+ model.targetSet(new TargetEvent(this, null, null, new Object[] {elem}));
+ }
+
+ /*
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Model.getUmlFactory().delete(elem);
+ model = null;
+ }
+
+ /**
+ * Test setting the represented operation.
+ */
+ public void testSetRepresentedOperation() {
+ /*
+ * Now the model should contain
+ * the one operation + the "" for clearing.
+ */
+ assertEquals(2, model.getSize());
+ assertEquals(oper, model.getElementAt(0));
+ }
+
+ /**
+ * Test removing the represented operation.
+ */
+ public void testExtraRepresentedOperation() {
+ Object op = Model.getCoreFactory().createOperation();
+ Model.getCollaborationsHelper().setRepresentedOperation(elem, op);
+ /* Simulate a target change. */
+ model.targetSet(new TargetEvent(this, null, null, new Object[] {elem}));
+ Model.getPump().flushModelEvents();
+ assertEquals(3, model.getSize());
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLInteractionCollaborationListModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLInteractionCollaborationListModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLInteractionCollaborationListModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,97 @@
+// $Id:TestUMLInteractionCollaborationListModel.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 1996-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.uml.ui.behavior.collaborations;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.model.Model;
+
+/**
+ * @since Oct 30, 2002
+ * @author [email protected]
+ */
+public class TestUMLInteractionCollaborationListModel extends TestCase {
+
+ private Object elem;
+ private UMLInteractionContextListModel model;
+
+ /**
+ * Constructor for TestUMLInteractionCollaborationListModel.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestUMLInteractionCollaborationListModel(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+
+ elem = Model.getCollaborationsFactory().createInteraction();
+ model = new UMLInteractionContextListModel();
+ model.setTarget(elem);
+ Model.getPump().flushModelEvents();
+ }
+
+ /*
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Model.getUmlFactory().delete(elem);
+ model = null;
+ }
+
+ /**
+ * Test setContext().
+ */
+ public void testSetContext() {
+ Object col =
+ Model.getCollaborationsFactory().createCollaboration();
+ Model.getCollaborationsHelper().setContext(elem, col);
+ Model.getPump().flushModelEvents();
+ assertEquals(1, model.getSize());
+ assertEquals(col, model.getElementAt(0));
+ }
+
+ /**
+ * Test setContext(null).
+ */
+ public void testRemoveContext() {
+ Object col =
+ Model.getCollaborationsFactory().createCollaboration();
+ Model.getCollaborationsHelper().setContext(elem, col);
+ Model.getCollaborationsHelper().setContext(elem, null);
+ Model.getPump().flushModelEvents();
+ assertEquals(0, model.getSize());
+ assertTrue(model.isEmpty());
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLInteractionMessagesListModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLInteractionMessagesListModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLInteractionMessagesListModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,82 @@
+// $Id:TestUMLInteractionMessagesListModel.java 11517 2006-11-25 05:27:15Z tfmorris $
+// Copyright (c) 1996-2006 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.uml.ui.behavior.collaborations;
+
+import org.argouml.model.Model;
+import org.argouml.uml.ui.AbstractUMLModelElementListModel2Test;
+
+/**
+ * @since Oct 30, 2002
+ * @author [email protected]
+ */
+public class TestUMLInteractionMessagesListModel
+ extends AbstractUMLModelElementListModel2Test {
+
+ /**
+ * Constructor for TestUMLInteractionMessagesListModel.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestUMLInteractionMessagesListModel(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#buildElement()
+ */
+ protected void buildElement() {
+ setElem(Model.getCollaborationsFactory().createInteraction());
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#buildModel()
+ */
+ protected void buildModel() {
+ setModel(new UMLInteractionMessagesListModel());
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#fillModel()
+ */
+ protected Object[] fillModel() {
+ Object[] messages = new Object[10];
+ for (int i = 0; i < messages.length; i++) {
+ messages[i] = Model.getCollaborationsFactory().createMessage();
+ Model.getCollaborationsHelper().addMessage(getElem(), messages[i]);
+ }
+ return messages;
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#removeHalfModel(Object[])
+ */
+ protected void removeHalfModel(Object[] elements) {
+ for (int i = 0; i < 5; i++) {
+ Model.getCollaborationsHelper().removeMessage(getElem(),
+ elements[i]);
+ }
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLMessageActionListModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLMessageActionListModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLMessageActionListModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,97 @@
+// $Id:TestUMLMessageActionListModel.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 1996-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.uml.ui.behavior.collaborations;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.model.Model;
+
+/**
+ * @since Oct 30, 2002
+ * @author [email protected]
+ */
+public class TestUMLMessageActionListModel
+ extends TestCase {
+
+ private UMLMessageActionListModel model;
+ private Object elem;
+
+ /**
+ * Constructor for TestUMLMessageActionListModel.
+ *
+ * @param arg0 is the name of the test case.
+ */
+ public TestUMLMessageActionListModel(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+
+ elem = Model.getCollaborationsFactory().createMessage();
+ model = new UMLMessageActionListModel();
+ model.setTarget(elem);
+ Model.getPump().flushModelEvents();
+ }
+
+ /*
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Model.getUmlFactory().delete(elem);
+ model = null;
+ }
+
+ /**
+ * Test setAction().
+ */
+ public void testSetAction() {
+ Object action =
+ Model.getCommonBehaviorFactory().createUninterpretedAction();
+ Model.getCollaborationsHelper().setAction(elem, action);
+ Model.getPump().flushModelEvents();
+ assertEquals(1, model.getSize());
+ assertEquals(action, model.getElementAt(0));
+ }
+
+ /**
+ * Test setAction() for removing.
+ */
+ public void testRemoveAction() {
+ Object action =
+ Model.getCommonBehaviorFactory().createUninterpretedAction();
+ Model.getCollaborationsHelper().setAction(elem, action);
+ Model.getCollaborationsHelper().setAction(elem, null);
+ Model.getPump().flushModelEvents();
+ assertEquals(0, model.getSize());
+ assertTrue(model.isEmpty());
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLMessageActivatorComboBoxModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLMessageActivatorComboBoxModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLMessageActivatorComboBoxModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,144 @@
+// $Id:TestUMLMessageActivatorComboBoxModel.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 1996-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.uml.ui.behavior.collaborations;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.model.Model;
+import org.argouml.ui.targetmanager.TargetEvent;
+
+/**
+ * @since Nov 2, 2002
+ * @author [email protected]
+ */
+public class TestUMLMessageActivatorComboBoxModel extends TestCase {
+
+ /**
+ * The number of elements that we use for the test.
+ */
+ private static final int NO_OF_ELEMENTS = 10;
+
+ /**
+ * The list of elements that we use for the test.
+ */
+ private Object[] activators;
+
+ /**
+ * The model that we test.
+ */
+ private UMLMessageActivatorComboBoxModel model;
+
+ /**
+ * The element that we test.
+ */
+ private Object elem;
+
+ /**
+ * Constructor for TestUMLMessageActivatorComboBoxModel.
+ * @param arg0 is the name of the test case.
+ */
+ public TestUMLMessageActivatorComboBoxModel(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ elem = Model.getCollaborationsFactory().createMessage();
+ activators = new Object[NO_OF_ELEMENTS];
+ Object m = Model.getModelManagementFactory().createModel();
+ Object inter =
+ Model.getCollaborationsFactory().createInteraction();
+ Object col =
+ Model.getCollaborationsFactory().createCollaboration();
+ Model.getCollaborationsHelper().setContext(inter, col);
+ Model.getCoreHelper().setNamespace(col, m);
+ Model.getCollaborationsHelper().addMessage(inter, elem);
+ for (int i = 0; i < NO_OF_ELEMENTS; i++) {
+ activators[i] = Model.getCollaborationsFactory().createMessage();
+ Model.getCollaborationsHelper().addMessage(inter, activators[i]);
+ }
+ model = new UMLMessageActivatorComboBoxModel();
+ model.targetSet(new TargetEvent(this, "set", new Object[0],
+ new Object[] {elem}));
+ Model.getPump().flushModelEvents();
+ }
+
+ /*
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Model.getUmlFactory().delete(elem);
+ for (int i = 0; i < NO_OF_ELEMENTS; i++) {
+ Model.getUmlFactory().delete(activators[i]);
+ }
+ model = null;
+ }
+
+ /**
+ * Test setup.
+ */
+ public void testSetUp() {
+ assertEquals(NO_OF_ELEMENTS, model.getSize());
+ assertTrue(model.contains(activators[NO_OF_ELEMENTS / 2]));
+ assertTrue(model.contains(activators[0]));
+ assertTrue(model.contains(activators[NO_OF_ELEMENTS - 1]));
+ }
+
+ /**
+ * Test setActivator().
+ */
+ public void testSetActivator() {
+ Model.getCollaborationsHelper().setActivator(elem, activators[0]);
+ Model.getPump().flushModelEvents();
+ // One can only do this by changing target,
+ // so let's simulate that:
+ model.targetSet(new TargetEvent(this,
+ TargetEvent.TARGET_SET,
+ new Object[0],
+ new Object[] {
+ elem,
+ }));
+ assertTrue(model.getSelectedItem() == activators[0]);
+ }
+
+ /**
+ * Test removing.
+ */
+ public void testRemoveBase() {
+ Model.getUmlFactory().delete(activators[NO_OF_ELEMENTS - 1]);
+ Model.getPump().flushModelEvents();
+ assertEquals("The element count should have reduced",
+ NO_OF_ELEMENTS - 1, model.getSize());
+ assertTrue("The model should no longer contain the delete element",
+ !model.contains(activators[NO_OF_ELEMENTS - 1]));
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLMessagePredecessorListModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLMessagePredecessorListModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLMessagePredecessorListModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,81 @@
+// $Id:TestUMLMessagePredecessorListModel.java 11517 2006-11-25 05:27:15Z tfmorris $
+// Copyright (c) 1996-2006 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.uml.ui.behavior.collaborations;
+
+import org.argouml.model.Model;
+import org.argouml.uml.ui.AbstractUMLModelElementListModel2Test;
+
+/**
+ * @since Oct 30, 2002
+ * @author [email protected]
+ */
+public class TestUMLMessagePredecessorListModel
+ extends AbstractUMLModelElementListModel2Test {
+
+ /**
+ * Constructor for TestUMLMessagePredecessorListModel.
+ * @param arg0 is the name of the test case.
+ */
+ public TestUMLMessagePredecessorListModel(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#buildElement()
+ */
+ protected void buildElement() {
+ setElem(Model.getCollaborationsFactory().createMessage());
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#buildModel()
+ */
+ protected void buildModel() {
+ setModel(new UMLMessagePredecessorListModel());
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#fillModel()
+ */
+ protected Object[] fillModel() {
+ Object[] pres = new Object[10];
+ for (int i = 0; i < pres.length; i++) {
+ pres[i] = Model.getCollaborationsFactory().createMessage();
+ Model.getCollaborationsHelper().addPredecessor(getElem(), pres[i]);
+ }
+ return pres;
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#removeHalfModel(Object[])
+ */
+ protected void removeHalfModel(Object[] elements) {
+ for (int i = 0; i < 5; i++) {
+ Model.getCollaborationsHelper().removePredecessor(getElem(),
+ elements[i]);
+ }
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLMessageReceiverListModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLMessageReceiverListModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLMessageReceiverListModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,99 @@
+// $Id:TestUMLMessageReceiverListModel.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 1996-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.uml.ui.behavior.collaborations;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.model.Model;
+import org.argouml.uml.ui.MockUMLUserInterfaceContainer;
+
+/**
+ * @since Oct 30, 2002
+ * @author [email protected]
+ */
+public class TestUMLMessageReceiverListModel extends TestCase {
+
+ private UMLMessageReceiverListModel model;
+ private Object elem;
+
+ /**
+ * Constructor for TestUMLMessageReceiverListModel.
+ * @param arg0 is the name of the test case.
+ */
+ public TestUMLMessageReceiverListModel(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+
+ elem = Model.getCollaborationsFactory().createMessage();
+ MockUMLUserInterfaceContainer cont =
+ new MockUMLUserInterfaceContainer();
+ cont.setTarget(elem);
+ model = new UMLMessageReceiverListModel();
+ model.setTarget(elem);
+ Model.getPump().flushModelEvents();
+ }
+
+ /*
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Model.getUmlFactory().delete(elem);
+ model = null;
+ }
+
+ /**
+ * Test setReceiver().
+ */
+ public void testSetReceiver() {
+ Object role =
+ Model.getCollaborationsFactory().createClassifierRole();
+ Model.getCommonBehaviorHelper().setReceiver(elem, role);
+ Model.getPump().flushModelEvents();
+ assertEquals(1, model.getSize());
+ assertEquals(role, model.getElementAt(0));
+ }
+
+ /**
+ * Test setReceiver() with null argument.
+ */
+ public void testRemoveReceiver() {
+ Object role =
+ Model.getCollaborationsFactory().createClassifierRole();
+ Model.getCommonBehaviorHelper().setReceiver(elem, role);
+ Model.getCommonBehaviorHelper().setReceiver(elem, null);
+ Model.getPump().flushModelEvents();
+ assertEquals(0, model.getSize());
+ assertTrue(model.isEmpty());
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLMessageSenderListModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLMessageSenderListModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLMessageSenderListModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,100 @@
+// $Id:TestUMLMessageSenderListModel.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 1996-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.uml.ui.behavior.collaborations;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.model.Model;
+import org.argouml.uml.ui.MockUMLUserInterfaceContainer;
+
+/**
+ * @since Oct 30, 2002
+ * @author [email protected]
+ */
+public class TestUMLMessageSenderListModel extends TestCase {
+
+ private UMLMessageSenderListModel model;
+ private Object elem;
+
+ /**
+ * Constructor for TestUMLMessageSenderListModel.
+ * @param arg0 is the name of the test case.
+ */
+ public TestUMLMessageSenderListModel(String arg0) {
+ super(arg0);
+ }
+
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+
+ elem = Model.getCollaborationsFactory().createMessage();
+ MockUMLUserInterfaceContainer cont =
+ new MockUMLUserInterfaceContainer();
+ cont.setTarget(elem);
+ model = new UMLMessageSenderListModel();
+ model.setTarget(elem);
+ Model.getPump().flushModelEvents();
+ }
+
+ /*
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Model.getUmlFactory().delete(elem);
+ model = null;
+ }
+
+ /**
+ * Test setSender().
+ */
+ public void testSetSender() {
+ Object role =
+ Model.getCollaborationsFactory().createClassifierRole();
+ Model.getCollaborationsHelper().setSender(elem, role);
+ Model.getPump().flushModelEvents();
+ assertEquals(1, model.getSize());
+ assertEquals(role, model.getElementAt(0));
+ }
+
+ /**
+ * Test setSender() with null argument.
+ */
+ public void testRemoveReceiver() {
+ Object role =
+ Model.getCollaborationsFactory().createClassifierRole();
+ Model.getCollaborationsHelper().setSender(elem, role);
+ Model.getCollaborationsHelper().setSender(elem, null);
+ Model.getPump().flushModelEvents();
+ assertEquals(0, model.getSize());
+ assertTrue(model.isEmpty());
+ }
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/package.html
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/package.html?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/collaborations/package.html 2007-08-13 09:07:56-0700
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+ Copyright (c) 1996-99 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.
+-->
+</head>
+<body bgcolor="white">
+<!--
+##### TYPE YOUR PACKAGE COMMENTS HERE. BEGIN WITH A #####
+##### ONE-SENTENCE SUMMARY STARTING WITH A VERB LIKE: #####
+Provides for....
+-->
+
+</body>
+</html>
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/common_behavior/TestActionNewReception.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/common_behavior/TestActionNewReception.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/common_behavior/TestActionNewReception.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,68 @@
+// $Id:TestActionNewReception.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 2003-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.uml.ui.behavior.common_behavior;
+
+import javax.swing.Action;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.i18n.Translator;
+
+/**
+ * Test for the ActionNewReception.
+ *
+ * @author mkl
+ */
+public class TestActionNewReception extends TestCase {
+
+ /**
+ * The constructor.
+ *
+ * @param arg0 the name of the test
+ */
+ public TestActionNewReception(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ Translator.init("en");
+ InitializeModel.initializeDefault();
+ }
+
+ /**
+ * Test whether the icon of this action can be found.
+ */
+ public void testHasIcon() {
+ ActionNewReception action = new ActionNewReception();
+
+ assertNotNull(action.getValue(Action.SMALL_ICON));
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/common_behavior/TestUMLReceptionSignalComboBoxModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/common_behavior/TestUMLReceptionSignalComboBoxModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/common_behavior/TestUMLReceptionSignalComboBoxModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,142 @@
+// $Id:TestUMLReceptionSignalComboBoxModel.java 12483 2007-05-02 20:20:37Z linus $
+// Copyright (c) 1996-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.uml.ui.behavior.common_behavior;
+
+import junit.framework.TestCase;
+import org.argouml.model.InitializeModel;
+
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.Model;
+import org.argouml.ui.targetmanager.TargetEvent;
+
+/**
+ * @since Nov 2, 2002
+ * @author [email protected]
+ */
+public class TestUMLReceptionSignalComboBoxModel extends TestCase {
+
+ /**
+ * The number of elements used in the tests.
+ */
+ private static final int NO_OF_ELEMENTS = 10;
+
+ /**
+ * The elements that we use for the test.
+ */
+ private Object[] signals;
+
+ /**
+ * The tested model.
+ */
+ private UMLReceptionSignalComboBoxModel model;
+
+ /**
+ * The element.
+ */
+ private Object elem;
+
+ /**
+ * Constructor for TestUMLReceptionSignalComboBoxModel.
+ *
+ * @param arg0
+ * is the name of the test case.
+ */
+ public TestUMLReceptionSignalComboBoxModel(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ InitializeModel.initializeDefault();
+ Project p = ProjectManager.getManager().getCurrentProject();
+ elem = Model.getCommonBehaviorFactory().createReception();
+ signals = new Object[NO_OF_ELEMENTS];
+ Object m = Model.getModelManagementFactory().createModel();
+ p.setRoot(m);
+ Model.getCoreHelper().setNamespace(elem, m);
+ for (int i = 0; i < NO_OF_ELEMENTS; i++) {
+ signals[i] = Model.getCommonBehaviorFactory().createSignal();
+ Model.getCoreHelper().addOwnedElement(m, signals[i]);
+ }
+ model = new UMLReceptionSignalComboBoxModel();
+ model.targetSet(new TargetEvent(this, "set", new Object[0],
+ new Object[] {elem}));
+ Model.getPump().flushModelEvents();
+ }
+
+ /*
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Model.getUmlFactory().delete(elem);
+ for (int i = 0; i < NO_OF_ELEMENTS; i++) {
+ Model.getUmlFactory().delete(signals[i]);
+ }
+ model = null;
+ }
+
+ /**
+ * Set up the test.
+ */
+ public void testSetUp() {
+ assertEquals(NO_OF_ELEMENTS, model.getSize());
+ assertTrue(model.contains(signals[NO_OF_ELEMENTS / 2]));
+ assertTrue(model.contains(signals[0]));
+ assertTrue(model.contains(signals[NO_OF_ELEMENTS - 1]));
+ }
+
+ /**
+ * Test setSignal().
+ */
+ public void testSetSignal() {
+ Model.getCommonBehaviorHelper().setSignal(elem, signals[0]);
+ Model.getPump().flushModelEvents();
+ // One can only do this by changing target,
+ // so let's simulate that:
+ model.targetSet(new TargetEvent(this,
+ TargetEvent.TARGET_SET,
+ new Object[0],
+ new Object[] {
+ elem,
+ }));
+ assertTrue(model.getSelectedItem() == signals[0]);
+ }
+
+ /**
+ * Test removing signals.
+ */
+ public void testRemoveSignal() {
+ Model.getUmlFactory().delete(signals[NO_OF_ELEMENTS - 1]);
+ Model.getPump().flushModelEvents();
+ assertEquals(NO_OF_ELEMENTS - 1, model.getSize());
+ assertTrue(!model.contains(signals[NO_OF_ELEMENTS - 1]));
+ }
+
+}
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/common_behavior/package.html
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/common_behavior/package.html?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/common_behavior/package.html 2007-08-13 09:07:56-0700
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+ Copyright (c) 1996-99 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.
+-->
+</head>
+<body bgcolor="white">
+<!--
+##### TYPE YOUR PACKAGE COMMENTS HERE. BEGIN WITH A #####
+##### ONE-SENTENCE SUMMARY STARTING WITH A VERB LIKE: #####
+Provides for....
+-->
+
+</body>
+</html>
Added: branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/use_cases/TestUMLExtendExtensionPointListModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/use_cases/TestUMLExtendExtensionPointListModel.java?view=auto&rev=13301
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/tests/org/argouml/uml/ui/behavior/use_cases/TestUMLExtendExtensionPointListModel.java 2007-08-13 09:07:56-0700
@@ -0,0 +1,82 @@
+// $Id:TestUMLExtendExtensionPointListModel.java 11517 2006-11-25 05:27:15Z tfmorris $
+// Copyright (c) 1996-2006 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.uml.ui.behavior.use_cases;
+
+import org.argouml.model.Model;
+import org.argouml.uml.ui.AbstractUMLModelElementListModel2Test;
+
+/**
+ * @since Oct 29, 2002
+ * @author [email protected]
+ */
+public class TestUMLExtendExtensionPointListModel
+ extends AbstractUMLModelElementListModel2Test {
+
+ /**
+ * Constructor for TestUMLExtendExtensionPointListModel.
+ * @param arg0 is the name of the test case.
+ */
+ public TestUMLExtendExtensionPointListModel(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#buildElement()
+ */
+ protected void buildElement() {
+ setElem(Model.getUseCasesFactory().createExtend());
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#buildModel()
+ */
+ protected void buildModel() {
+ setModel(new UMLExtendExtensionPointListModel());
+ }
+
+ /*
+ * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#fillModel()
+ */
+ protected Object[] fillModel() {
+ Object[] points = new Object[10];
+ for (int i = 0; i < 10; i++) {
+ points[i] = Model.getUseCasesFactory().createExtensionPoint();