/** Set up the stress testing environment. */ protected void setUp() { // create the properties map of BaseNode. properties = StressTestHelper.getProperties(); // get the graphNode here. graphNode = StressTestHelper.getGraphNode(2); // create the structure of the Subsystem here. nameNode = new GraphNode(); stereotypeNode = new GraphNode(); namespaceNode = new GraphNode(); // set the initializing size and position. nameNode.setPosition(StressTestHelper.createPoint(0, 0)); nameNode.setSize(StressTestHelper.createDimension(10, 10)); stereotypeNode.setPosition(StressTestHelper.createPoint(0, 0)); stereotypeNode.setSize(StressTestHelper.createDimension(10, 10)); namespaceNode.setPosition(StressTestHelper.createPoint(0, 0)); namespaceNode.setSize(StressTestHelper.createDimension(10, 10)); // create the NameCompartment here. GraphNode nameCompartment = new GraphNode(); nameCompartment.addContained(stereotypeNode); nameCompartment.addContained(nameNode); nameCompartment.addContained(namespaceNode); graphNode.addContained(nameCompartment); }
/** * Clean the stress test environment. * * @throws Exception if any exception occurs when setting. */ protected void tearDown() throws Exception { // clear all namespaces. StressTestHelper.clearNamespace(); // clear all diagrams here. UMLModelManager.getInstance().clearDiagrams(); }
/** * This method will check the action's name and type value. * * @param action the action instance to be checked. * @param name the name of action. * @param type the type of action. * @throws Exception if any exception occurs when testing. */ private void checkCreateDiagramAction(CreateDiagramAction action, String name, String type) throws Exception { // check the attributes here. assertNotNull("The CreateDiagramAction constructor is incorrect.", action); // add the diagram into UMLModelManager. action.execute(); // check the diagram here. Diagram diagram = UMLModelManager.getInstance().getDiagrams().get(0); assertEquals("The CreateDiagramAction constructor is incorrect.", diagram.getName(), name); Uml1SemanticModelBridge modelBridge = (Uml1SemanticModelBridge) diagram.getOwner(); assertEquals( "The CreateDiagramAction constructor is incorrect.", modelBridge.getElement(), owner); /* * BugFix: UML-9507 */ // assertEquals("The CreateDiagramAction constructor is incorrect.", // StressTestHelper.findTypePropertyValue(diagram), type); assertEquals( "The CreateDiagramAction constructor is incorrect.", StressTestHelper.getTypeInfo(diagram), type); // remove the diagram from UMLModelManager. action.undo(); }
/** * Basic stress test of <code>notifyGraphNodeChange()</code> method. * * @throws Exception if if any exception occurs when testing. */ public void testUseCaseNode_notifyGraphNodeChange_Text() throws Exception { for (int i = 0; i < LOOPTIMES; i++) { int width = 50 + i; int height = 30 + i; graphNode.setSize(StressTestHelper.createDimension(width, height)); node = new UseCaseNode(graphNode, properties); // notify the node change here. node.notifyGraphNodeChange("node changed."); // check the result here. assertEquals( "The UseCaseNode notifyGraphNodeChange method is incorrect.", "topcoderSoft", node.getNameCompartment().getText()); assertEquals( "The UseCaseNode notifyGraphNodeChange method is incorrect.", "<<type1, type2>>", node.getStereotypeCompartment().getText()); assertEquals( "The UseCaseNode notifyGraphNodeChange method is incorrect.", "com.topcoder.soft", node.getNamespaceCompartment().getText()); } }
/** * Basic stress test of <code>notifyGraphNodeChange()</code> method. * * @throws Exception if if any exception occurs when testing. */ public void testUseCaseNode_notifyGraphNodeChange_AbsolutePosition() throws Exception { GraphNode dv = new GraphNode(); dv.setPosition(StressTestHelper.createPoint(0, 0)); GraphNode ssNode = StressTestHelper.getGraphNode(1); ssNode.setSize(StressTestHelper.createDimension(400, 800)); ssNode.setPosition(StressTestHelper.createPoint(100, 200)); ssNode.setContainer(dv); graphNode.setContainer(ssNode); ssNode.addContained(graphNode); // create a use case node here. node = new UseCaseNode(graphNode, properties); // change the node and test it. for (int i = 0; i < LOOPTIMES; i++) { int width = 40 + i; int height = 80 + i; graphNode.setSize(StressTestHelper.createDimension(width, height)); int x = 10 + i; int y = 20 + i; graphNode.setPosition(StressTestHelper.createPoint(x, y)); // notify the node change here. node.notifyGraphNodeChange("node changed."); // check the Node here. // get the location to test. assertEquals("The notifyGraphNodeChange method is incorrect.", 105 + i, node.getLocation().x); assertEquals("The notifyGraphNodeChange method is incorrect.", 215 + i, node.getLocation().y); } }
/** * Set up the stress testing environment. * * @throws Exception if any exception occurs when setting. */ protected void setUp() throws Exception { // clear all namespaces here. StressTestHelper.clearNamespace(); ConfigManager cm = ConfigManager.getInstance(); // load config files. cm.add(CONFIG_FILE); cm.add("Config.xml"); // set the model manager here. UMLModelManager.getInstance().clearDiagrams(); UMLModelManager.getInstance().setProjectLanguage("JAVA"); UMLModelManager.getInstance() .setProjectConfigurationManager( new ProjectConfigurationManager(UMLModelManager.getInstance())); }
/** * Basic stress test of <code>UseCaseNode</code>'s constructor. * * @throws Exception if if any exception occurs when testing. */ public void testUseCaseNodeCtor_Times() throws Exception { for (int i = 0; i < LOOPTIMES; i++) { int width = 50 + i; int height = 30 + i; graphNode.setSize(StressTestHelper.createDimension(width, height)); node = new UseCaseNode(graphNode, properties); // check the result here. assertNotNull("The UseCaseNode constructor is incorrect.", node); assertEquals( "The UseCaseNode constructor is incorrect.", nameNode, node.getNameCompartment().getGraphNode()); assertEquals( "The UseCaseNode constructor is incorrect.", stereotypeNode, node.getStereotypeCompartment().getGraphNode()); assertEquals( "The UseCaseNode constructor is incorrect.", namespaceNode, node.getNamespaceCompartment().getGraphNode()); // check the compartment text here. assertEquals( "The UseCaseNode constructor is incorrect.", "topcoderSoft", node.getNameCompartment().getText()); assertEquals( "The UseCaseNode constructor is incorrect.", "<<type1, type2>>", node.getStereotypeCompartment().getText()); assertEquals( "The UseCaseNode constructor is incorrect.", "com.topcoder.soft", node.getNamespaceCompartment().getText()); } }