Author: mvw
Date: 2008-06-02 11:15:30-0700
New Revision: 14863
Modified:
trunk/src/argouml-app/tests/org/argouml/notation/providers/TestNotationProviderFactory2.java
trunk/src/argouml-app/tests/org/argouml/notation/providers/java/TestModelElementNameNotationJava.java
trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestActionStateNotationUml.java
trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestCallStateNotationUml.java
trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestClassifierRoleNotationUml.java
trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestEnumerationLiteralNotationUml.java
trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestMessageNotationUml.java
trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestStateBodyNotationUml.java
trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestTransitionNotationUml.java
Log:
Improved testing.
Modified: trunk/src/argouml-app/tests/org/argouml/notation/providers/TestNotationProviderFactory2.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/tests/org/argouml/notation/providers/TestNotationProviderFactory2.java?view=diff&rev=14863&p1=trunk/src/argouml-app/tests/org/argouml/notation/providers/TestNotationProviderFactory2.java&p2=trunk/src/argouml-app/tests/org/argouml/notation/providers/TestNotationProviderFactory2.java&r1=14862&r2=14863
==============================================================================
--- trunk/src/argouml-app/tests/org/argouml/notation/providers/TestNotationProviderFactory2.java (original)
+++ trunk/src/argouml-app/tests/org/argouml/notation/providers/TestNotationProviderFactory2.java 2008-06-02 11:15:30-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 2007 The Regents of the University of California. All
+// Copyright (c) 2007-2008 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
@@ -27,14 +27,17 @@
import java.util.Map;
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.model.InitializeModel;
+import org.argouml.model.Model;
+import org.argouml.notation.InitNotation;
import org.argouml.notation.Notation;
import org.argouml.notation.NotationName;
import org.argouml.notation.NotationProvider;
+import org.argouml.notation.providers.uml.InitNotationUml;
import org.argouml.profile.init.InitProfileSubsystem;
@@ -54,7 +57,10 @@
*/
protected void setUp() throws Exception {
InitializeModel.initializeDefault();
+ assertTrue("Model subsystem init failed.", Model.isInitiated());
new InitProfileSubsystem().init();
+ (new InitNotation()).init();
+ (new InitNotationUml()).init();
name = Notation.makeNotation(
"Test",
null,
Modified: trunk/src/argouml-app/tests/org/argouml/notation/providers/java/TestModelElementNameNotationJava.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/tests/org/argouml/notation/providers/java/TestModelElementNameNotationJava.java?view=diff&rev=14863&p1=trunk/src/argouml-app/tests/org/argouml/notation/providers/java/TestModelElementNameNotationJava.java&p2=trunk/src/argouml-app/tests/org/argouml/notation/providers/java/TestModelElementNameNotationJava.java&r1=14862&r2=14863
==============================================================================
--- trunk/src/argouml-app/tests/org/argouml/notation/providers/java/TestModelElementNameNotationJava.java (original)
+++ trunk/src/argouml-app/tests/org/argouml/notation/providers/java/TestModelElementNameNotationJava.java 2008-06-02 11:15:30-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 2007 The Regents of the University of California. All
+// Copyright (c) 2007-2008 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
@@ -27,9 +27,9 @@
import java.util.HashMap;
import junit.framework.TestCase;
-import org.argouml.model.InitializeModel;
import org.argouml.kernel.ProjectManager;
+import org.argouml.model.InitializeModel;
import org.argouml.model.Model;
import org.argouml.notation.providers.ModelElementNameNotation;
import org.argouml.profile.init.InitProfileSubsystem;
@@ -86,4 +86,29 @@
private Object getModel() {
return ProjectManager.getManager().getCurrentProject().getModel();
}
+
+ /**
+ * Test if help is correctly provided.
+ */
+ public void testGetHelpOperation() {
+ ModelElementNameNotation notation =
+ new ModelElementNameNotationJava(theClass);
+ 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 the notationProvider refuses to instantiate
+ * without showing it the right UML element.
+ */
+ public void testValidObjectCheck() {
+ try {
+ new ModelElementNameNotationJava(new Object());
+ fail("The NotationProvider did not throw for a wrong UML element.");
+ } catch (IllegalArgumentException e) {
+ /* Everything fine... */
+ }
+ }
}
Modified: trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestActionStateNotationUml.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestActionStateNotationUml.java?view=diff&rev=14863&p1=trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestActionStateNotationUml.java&p2=trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestActionStateNotationUml.java&r1=14862&r2=14863
==============================================================================
--- trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestActionStateNotationUml.java (original)
+++ trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestActionStateNotationUml.java 2008-06-02 11:15:30-0700
@@ -174,10 +174,24 @@
* Test if help is correctly provided.
*/
public void testGetHelp() {
- ActionStateNotationUml notation = new ActionStateNotationUml(aActionState);
+ ActionStateNotationUml notation =
+ new ActionStateNotationUml(aActionState);
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 the notationProvider refuses to instantiate
+ * without showing it the right UML element.
+ */
+ public void testValidObjectCheck() {
+ try {
+ new ActionStateNotationUml(aStateMachine);
+ fail("The NotationProvider did not throw for a wrong UML element.");
+ } catch (IllegalArgumentException e) {
+ /* Everything fine... */
+ }
+ }
}
Modified: trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestCallStateNotationUml.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestCallStateNotationUml.java?view=diff&rev=14863&p1=trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestCallStateNotationUml.java&p2=trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestCallStateNotationUml.java&r1=14862&r2=14863
==============================================================================
--- trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestCallStateNotationUml.java (original)
+++ trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestCallStateNotationUml.java 2008-06-02 11:15:30-0700
@@ -266,4 +266,17 @@
assertTrue("Parsing help not conform for translation",
help.startsWith("parsing."));
}
+
+ /**
+ * Test if the notationProvider refuses to instantiate
+ * without showing it the right UML element.
+ */
+ public void testValidObjectCheck() {
+ try {
+ new CallStateNotationUml(aState);
+ fail("The NotationProvider did not throw for a wrong UML element.");
+ } catch (IllegalArgumentException e) {
+ /* Everything fine... */
+ }
+ }
}
Modified: trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestClassifierRoleNotationUml.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestClassifierRoleNotationUml.java?view=diff&rev=14863&p1=trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestClassifierRoleNotationUml.java&p2=trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestClassifierRoleNotationUml.java&r1=14862&r2=14863
==============================================================================
--- trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestClassifierRoleNotationUml.java (original)
+++ trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestClassifierRoleNotationUml.java 2008-06-02 11:15:30-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 2006-2007 The Regents of the University of California. All
+// Copyright (c) 2006-2008 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
@@ -29,8 +29,8 @@
import java.util.Iterator;
import junit.framework.TestCase;
-import org.argouml.model.InitializeModel;
+import org.argouml.model.InitializeModel;
import org.argouml.model.Model;
import org.argouml.profile.init.InitProfileSubsystem;
@@ -205,4 +205,17 @@
assertTrue("Parsing help not conform for translation",
help.startsWith("parsing."));
}
+
+ /**
+ * Test if the notationProvider refuses to instantiate
+ * without showing it the right UML element.
+ */
+ public void testValidObjectCheck() {
+ try {
+ new ClassifierRoleNotationUml(null);
+ fail("The NotationProvider did not throw for a wrong UML element.");
+ } catch (IllegalArgumentException e) {
+ /* Everything fine... */
+ }
+ }
}
Modified: trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestEnumerationLiteralNotationUml.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestEnumerationLiteralNotationUml.java?view=diff&rev=14863&p1=trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestEnumerationLiteralNotationUml.java&p2=trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestEnumerationLiteralNotationUml.java&r1=14862&r2=14863
==============================================================================
--- trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestEnumerationLiteralNotationUml.java (original)
+++ trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestEnumerationLiteralNotationUml.java 2008-06-02 11:15:30-0700
@@ -73,9 +73,13 @@
* @throws ParseException if the parsing fails
*/
public void testEnumerationLiteralName() throws ParseException {
+ checkLiterals(1,
+ new String[] {""});
checkName(aLiteral, "name", "name");
checkName(aLiteral, "name2", "name2");
checkName(aLiteral, "name;create second one", "name");
+ checkLiterals(2,
+ new String[] {"name", "create second one"});
checkName(aLiteral, "na me", "na me");
checkName(aLiteral, " name ", "name");
checkName(aLiteral, "<<>>name2", "name2");
@@ -85,11 +89,18 @@
checkName(aLiteral, " << stereotype >> name", "name");
checkName(aLiteral,
" << stereotype >> name3; << stereotype >> name4", "name3");
+ checkLiterals(3,
+ new String[] {"name3", "name4", "create second one"});
checkName(aLiteral, "name;<<s2>>nameX", "name");
+ checkLiterals(4,
+ new String[] {"name", "nameX", "name4", "create second one"});
checkName(aLiteral, "µôèéàü$", "µôèéàü$");
checkName(aLiteral, "name;", "name");
checkName(aLiteral, " \u00AB stereotype \u00BB name3", "name3");
checkName(aLiteral, "name;\u00ABstereotype\u00BBname", "name");
+ checkLiterals(5,
+ new String[] {"name", "name",
+ "nameX", "name4", "create second one"});
}
/**
@@ -104,18 +115,38 @@
private void checkName(Object element, String text, String name)
throws ParseException {
- if (Model.getFacade().isAEnumerationLiteral(element)) {
- EnumerationLiteralNotationUml eln =
- new EnumerationLiteralNotationUml(element);
- eln.parseEnumerationLiteralFig(
- Model.getFacade().getEnumeration(element),
- element, text);
- assertEquals(text
- + " gave wrong name: "
- + Model.getFacade().getName(element),
- name, Model.getFacade().getName(element));
- } else {
- fail("Can only check name of a enumeration literal");
+ EnumerationLiteralNotationUml eln =
+ new EnumerationLiteralNotationUml(element);
+ eln.parseEnumerationLiteralFig(
+ Model.getFacade().getEnumeration(element),
+ element, text);
+ assertEquals(text
+ + " gave wrong name: "
+ + Model.getFacade().getName(element),
+ name, Model.getFacade().getName(element));
+ }
+
+ /**
+ * Check if the number of literals is equal to the given number.
+ * Check if the names of the literals are equal to the ones given.
+ *
+ * @param count the supposed number of literals
+ * @param names the supposed names of the literals
+ */
+ private void checkLiterals(int count, String[] names) {
+ List literals =
+ Model.getFacade().getEnumerationLiterals(aEnumeration);
+ assertEquals("Unexpected number of Literals", count,
+ literals.size());
+ if (count != literals.size()) {
+ /* No need to check any further if we fail the 1st part. */
+ return;
+ }
+ int i = 0;
+ for (Object lit : literals) {
+ String name = Model.getFacade().getName(lit);
+ if (name == null) name = "";
+ assertEquals("Unexpected Literal name", name, names[i++]);
}
}
@@ -206,6 +237,10 @@
checkGenerate(aLiteral, "", npArguments);
checkName(aLiteral, " << s1, s2, s3 >> name3", "name3");
checkGenerate(aLiteral, "<<s1,s2,s3>> name3", npArguments);
+ npArguments.put("leftGuillemot", "\u00AB");
+ npArguments.put("rightGuillemot", "\u00BB");
+ /* TODO: Make this work: */
+// checkGenerate(aLiteral, "\u00ABs1,s2,s3\u00BB name3", npArguments);
}
private void checkGenerate(Object literal, String text, Map args) {
Modified: trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestMessageNotationUml.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestMessageNotationUml.java?view=diff&rev=14863&p1=trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestMessageNotationUml.java&p2=trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestMessageNotationUml.java&r1=14862&r2=14863
==============================================================================
--- trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestMessageNotationUml.java (original)
+++ trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestMessageNotationUml.java 2008-06-02 11:15:30-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 1996-2007 The Regents of the University of California. All
+// Copyright (c) 1996-2008 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
@@ -28,9 +28,10 @@
import java.util.Iterator;
import junit.framework.TestCase;
-import org.argouml.model.InitializeModel;
+import org.argouml.model.InitializeModel;
import org.argouml.model.Model;
+import org.argouml.notation.InitNotation;
import org.argouml.profile.init.InitProfileSubsystem;
/**
@@ -56,7 +57,11 @@
public void setUp() throws Exception {
super.setUp();
InitializeModel.initializeDefault();
- new InitProfileSubsystem().init();
+// new InitProfileSubsystem().init();
+ assertTrue("Model subsystem init failed.", Model.isInitiated());
+ (new InitProfileSubsystem()).init();
+ (new InitNotation()).init();
+ (new InitNotationUml()).init();
}
/**
@@ -477,4 +482,19 @@
assertTrue("Parsing help not conform for translation",
help.startsWith("parsing."));
}
+
+ /**
+ * Test if the notationProvider refuses to instantiate
+ * without showing it the right UML element.
+ */
+ public void testValidObjectCheck() {
+ Object coll = Model.getCollaborationsFactory().createCollaboration();
+ Object inter = Model.getCollaborationsFactory().buildInteraction(coll);
+ try {
+ new MessageNotationUml(inter);
+ fail("The NotationProvider did not throw for a wrong UML element.");
+ } catch (IllegalArgumentException e) {
+ /* Everything fine... */
+ }
+ }
}
Modified: trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestStateBodyNotationUml.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestStateBodyNotationUml.java?view=diff&rev=14863&p1=trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestStateBodyNotationUml.java&p2=trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestStateBodyNotationUml.java&r1=14862&r2=14863
==============================================================================
--- trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestStateBodyNotationUml.java (original)
+++ trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestStateBodyNotationUml.java 2008-06-02 11:15:30-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 2004-2007 The Regents of the University of California. All
+// Copyright (c) 2004-2008 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
@@ -28,10 +28,10 @@
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.InitializeModel;
import org.argouml.model.Model;
import org.argouml.profile.init.InitProfileSubsystem;
@@ -252,4 +252,16 @@
help.startsWith("parsing."));
}
+ /**
+ * Test if the notationProvider refuses to instantiate
+ * without showing it the right UML element.
+ */
+ public void testValidObjectCheck() {
+ try {
+ new StateBodyNotationUml(aClass);
+ fail("The NotationProvider did not throw for a wrong UML element.");
+ } catch (IllegalArgumentException e) {
+ /* Everything fine... */
+ }
+ }
}
Modified: trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestTransitionNotationUml.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestTransitionNotationUml.java?view=diff&rev=14863&p1=trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestTransitionNotationUml.java&p2=trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestTransitionNotationUml.java&r1=14862&r2=14863
==============================================================================
--- trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestTransitionNotationUml.java (original)
+++ trunk/src/argouml-app/tests/org/argouml/notation/providers/uml/TestTransitionNotationUml.java 2008-06-02 11:15:30-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 2004-2007 The Regents of the University of California. All
+// Copyright (c) 2004-2008 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
@@ -27,10 +27,10 @@
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.InitializeModel;
import org.argouml.model.Model;
import org.argouml.notation.NotationProvider;
import org.argouml.profile.init.InitProfileSubsystem;
@@ -339,4 +339,17 @@
assertTrue("Parsing help not conform for translation",
help.startsWith("parsing."));
}
+
+ /**
+ * Test if the notationProvider refuses to instantiate
+ * without showing it the right UML element.
+ */
+ public void testValidObjectCheck() {
+ try {
+ new TransitionNotationUml(aState);
+ fail("The NotationProvider did not throw for a wrong UML element.");
+ } catch (IllegalArgumentException e) {
+ /* Everything fine... */
+ }
+ }
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.