/**
  * This method may be overridden by subclasses as restore tests are doing.
  *
  * @throws CoreException
  */
 protected void setupProjectAndTestModel() throws CoreException {
   m_sys = getSystemModel(projectName);
   if (firstTime) {
     // ensureAvailableAndLoaded(domainName, false,false);
     loadProject(projectName);
     firstTime = false;
   }
   project = getProjectHandle(projectName);
   modelRoot =
       Ooaofooa.getInstance(
           Ooaofooa.createModelRootId(getProjectHandle(projectName), "MultiLevelModel", true),
           true);
   graphicsModelRoot = Ooaofgraphics.getInstance(modelRoot.getId());
   Ooaofooa.setPersistEnabled(true);
 }
 @Override
 public void setUp() throws Exception {
   super.setUp();
   CorePlugin.getDefault()
       .getPreferenceStore()
       .setValue(BridgePointPreferencesStore.USE_DEFAULT_NAME_FOR_CREATION, false);
   Ooaofooa.setPersistEnabled(true);
 }
  //  System
  @Test
  public void testRenameSystem_ThruME_NoEditor() throws Exception {
    performRenameComponentThruMEGenerics(
        "SystemModel", projectName, EditorTestUtilities.EDITOR_TYPE_NONE, false, 0);
    if (toRunTests()) // avoid to rename in setup pass
    projectName += "_n"; // projectName changed for coming tests
    //   super.setupProject(projectName);
    // ((BaseTest)this).get// = getProjectHandle(projectName).getProject();
    super.setupProject(projectName);
    m_sys = getSystemModel(projectName);
    modelRoot =
        Ooaofooa.getInstance(
            Ooaofooa.createModelRootId(getProjectHandle(projectName), projectName, true), true);

    //    graphicsModelRoot = Ooaofgraphics.getInstance(modelRoot.getId());
    getProject().delete(true, null);
  }
  public void doTestRenameSQ_CP() throws Exception {
    RenameTestGenerics renTest = new RenameTestGenerics();
    renTest.setUp();
    Display d = Display.getDefault();
    while (d.readAndDispatch()) ;

    Ooaofooa.getDefaultInstance().addModelChangeListener(instantListener);
    Ooaofooa.getDefaultInstance().addModelChangeListener(batchedListener);
    Ooaofgraphics c = Ooaofgraphics.getInstance(modelRoot.getId());
    c.addModelChangeListener(instantListener);
    c.addModelChangeListener(batchedListener);

    try {
      renTest.testRenameSQ_CP();

      while (d.readAndDispatch()) {}
    } catch (Exception e) {
      fail("Test rename of model Elements Failed: " + e.toString()); // $NON-NLS-1$
    }

    // Comparing Events
    assertTrue(
        "No events heard by instant listener",
        instantListener.eventsList.size() > 0); // $NON-NLS-1$
    assertTrue(
        "No events heard by batched listener",
        batchedListener.eventsList.size() > 0); // $NON-NLS-1$
    // the number of events will be different by two
    // this is due to the fact that deltas that affect
    // the same element's name are not collected only the
    // first delta found is updated.  This test collects
    // events that were fired, in the case of an instant
    // listener the update needs to be fired, for a batched
    // listener it does not.
    assertEquals(
        "Number of Events in the instant Listener: "
            + instantListener.eventsList.size()
            + " is not same as in batched listener: "
            + batchedListener.eventsList.size(),
        instantListener.eventsList.size() - 1,
        batchedListener.eventsList.size()); // $NON-NLS-1$//$NON-NLS-2$

    Ooaofooa.getDefaultInstance().removeModelChangeListener(instantListener);
    Ooaofooa.getDefaultInstance().removeModelChangeListener(batchedListener);
  }
  public void doTestDeleteModelElement() throws Exception {
    BaseTest.dispatchEvents(0);
    ActionTestGenerics delAction = new ActionTestGenerics();
    delAction.setUp();
    modelRoot = BaseTest.getDefaultTestInstance();

    Ooaofooa.getDefaultInstance().addModelChangeListener(instantListener);
    Ooaofooa.getDefaultInstance().addModelChangeListener(batchedListener);
    Ooaofgraphics c = Ooaofgraphics.getInstance(modelRoot.getId());
    c.addModelChangeListener(instantListener);
    c.addModelChangeListener(batchedListener);
    try {
      delAction.testDeleteEP_PKG();

      BaseTest.dispatchEvents(0);

    } catch (Exception e) {
      fail("Test deletion of model Element Failed: " + e.toString()); // $NON-NLS-1$
    }

    // Comparing Events
    assertTrue(
        "No events heard by instant listener",
        instantListener.eventsList.size() > 0); // $NON-NLS-1$
    assertTrue(
        "No events heard by batched listener",
        batchedListener.eventsList.size() > 0); // $NON-NLS-1$
    // the number of events will be different by one
    // this is due to the fact that deltas that affect
    // the same element's name are not collected only the
    // first delta found is updated.  This test collects
    // events that were fired, in the case of an instant
    // listener the update needs to be fired, for a batched
    // listener it does not.
    assertEquals(
        "Number of Events in the instant Listener: "
            + instantListener.eventsList.size() // $NON-NLS-1$
            + " is not same as in batched listener: "
            + batchedListener.eventsList.size(), // $NON-NLS-1$
        instantListener.eventsList.size(),
        batchedListener.eventsList.size() + 1);

    Ooaofooa.getDefaultInstance().removeModelChangeListener(instantListener);
    Ooaofooa.getDefaultInstance().removeModelChangeListener(batchedListener);
  }
示例#6
0
  /* (non-Javadoc)
   * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
   */
  public void stop(BundleContext context) throws Exception {
    if (CanvasPlugin.isActivated) {
      super.stop(context);

      Ooaofooa.getDefaultInstance().removeModelChangeListener(modelChangeListener);

      TransactionManager.getSingleton().removeTransactionListener(transactionListener);
    }
  }
 @Override
 public void tearDown() {
   errorTxt = "";
   while (PlatformUI.getWorkbench().getDisplay().readAndDispatch()) ;
   UITestingUtilities.clearGraphicalSelection();
   CorePlugin.getDefault()
       .getPreferenceStore()
       .setValue(BridgePointPreferencesStore.USE_DEFAULT_NAME_FOR_CREATION, true);
   Ooaofooa.setPersistEnabled(false);
 }
  /* (non-Javadoc)
   * @see junit.framework.TestCase#setUp()
   */
  protected void setUp() throws Exception {
    super.setUp();

    if (!firstSetup) {

      String modelName = "testOAL1";

      TestingUtilities.importTestingProjectIntoWorkspace("testOAL1");

      project = ResourcesPlugin.getWorkspace().getRoot().getProject("testOAL1");
      m_sys = getSystemModel(project.getName());

      String modelRootId = Ooaofooa.createModelRootId(project, modelName, true);
      modelRoot = Ooaofooa.getInstance(modelRootId, true);
    }

    firstSetup = true;

    populateFunctionInstances();
    populateBridgeInstances();
    class Object_test1_c implements ClassQueryInterface_c {
      Object_test1_c(String id) {
        m_id = id;
      }

      private String m_id;

      public boolean evaluate(Object inst) {
        ModelClass_c selected = (ModelClass_c) inst;
        return selected.getKey_lett().equals(m_id);
      }
    }
    ModelClass_c diskObj =
        ModelClass_c.ModelClassInstance(modelRoot, new Object_test1_c("D_D")); // $NON-NLS-1$
    ModelClass_c libObj =
        ModelClass_c.ModelClassInstance(modelRoot, new Object_test1_c("D_H")); // $NON-NLS-1$
    populateTransformerInstances(diskObj, false);
    populateTransformerInstances(libObj, true);
    populateStateActionInstances();
    populateMDAInstances();
  }
  @Before
  public void setUp() throws Exception {
    super.setUp();
    if (!initialized) {
      CorePlugin.disableParseAllOnResourceChange();
      TestVerifierRunTimeErrorMsgs.projectName = projectName;

      // set perspective switch dialog on launch
      DebugUIPlugin.getDefault()
          .getPluginPreferences()
          .setValue(IDebugUIConstants.PLUGIN_ID + ".switch_to_perspective", "always");

      CorePlugin.getDefault()
          .getPluginPreferences()
          .setDefault(BridgePointPreferencesStore.ALLOW_IMPLICIT_COMPONENT_ADDRESSING, true);

      // initialize test model
      final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);

      loadProject(projectName);

      m_sys =
          SystemModel_c.SystemModelInstance(
              Ooaofooa.getDefaultInstance(),
              new ClassQueryInterface_c() {

                public boolean evaluate(Object candidate) {
                  return ((SystemModel_c) candidate).getName().equals(project.getName());
                }
              });

      Ooaofooa.setPersistEnabled(true);
      delayGlobalUpgrade = false;
      modelRoot = (Ooaofooa) m_sys.getModelRoot();
      initialized = true;
    }
  }
  public void doTestRenameO_ATTR() throws Exception {
    RenameTestGenerics renTest = new RenameTestGenerics();
    renTest.setUp();
    Display d = Display.getDefault();
    while (d.readAndDispatch()) ;

    Ooaofooa.getDefaultInstance().addModelChangeListener(instantListener);
    Ooaofooa.getDefaultInstance().addModelChangeListener(batchedListener);
    Ooaofgraphics c = Ooaofgraphics.getInstance(modelRoot.getId());
    c.addModelChangeListener(instantListener);
    c.addModelChangeListener(batchedListener);

    try {
      renTest.testRenameO_ATTR();

      while (d.readAndDispatch()) {}
    } catch (Exception e) {
      fail("Test rename of model Elements Failed: " + e.toString()); // $NON-NLS-1$
    }

    // Comparing Events
    assertTrue(
        "No events heard by instant listener",
        instantListener.eventsList.size() > 0); // $NON-NLS-1$
    assertTrue(
        "No events heard by batched listener",
        batchedListener.eventsList.size() > 0); // $NON-NLS-1$
    assertEquals(
        "Number of Events in the instant Listener: "
            + instantListener.eventsList.size()
            + " is not same as in batched listener: "
            + batchedListener.eventsList.size(),
        instantListener.eventsList.size(),
        batchedListener.eventsList.size() + 1); // $NON-NLS-1$//$NON-NLS-2$
    Ooaofooa.getDefaultInstance().removeModelChangeListener(instantListener);
    Ooaofooa.getDefaultInstance().removeModelChangeListener(batchedListener);
  }
  public void doTestCreateModelElement() throws Exception {
    ActionTestGenerics test = new ActionTestGenerics();
    test.setUp();
    modelRoot = BaseTest.getDefaultTestInstance();
    Ooaofooa.getDefaultInstance().addModelChangeListener(instantListener);
    Ooaofooa.getDefaultInstance().addModelChangeListener(batchedListener);
    Ooaofgraphics c = Ooaofgraphics.getInstance(modelRoot.getId());
    c.addModelChangeListener(instantListener);
    c.addModelChangeListener(batchedListener);
    try {
      // Test add Instance State Machine
      // Must turn off ConsistencyTransactionListener - the test will check the
      // consistency of the relevant individual components
      Ooaofooa.setConsistencyEnabled(false);
      test.testNewO_OBJInstanceStateMachine();
      // Turn consistency checking back on.
      Ooaofooa.setConsistencyEnabled(true);

      Display d = Display.getDefault();
      while (d.readAndDispatch()) {}

    } catch (Exception e) {
      fail("Test creation of model Element Failed: " + e.toString()); // $NON-NLS-1$
    }

    // Comparing Events
    assertTrue(
        "No events heard by instant listener",
        instantListener.eventsList.size() > 0); // $NON-NLS-1$
    assertTrue(
        "No events heard by batched listener",
        batchedListener.eventsList.size() > 0); // $NON-NLS-1$
    // the number of events will be different by one
    // this is due to the fact that deltas that affect
    // the same element's name are not collected only the
    // first delta found is updated.  This test collects
    // events that were fired, in the case of an instant
    // listener the update needs to be fired, for a batched
    // listener it does not.
    assertEquals(
        "Number of Events in the instant Listener: "
            + instantListener.eventsList.size()
            + " is not same as in batched listener: "
            + batchedListener.eventsList.size(),
        instantListener.eventsList.size() - 1,
        batchedListener.eventsList.size()); // $NON-NLS-1$//$NON-NLS-2$

    // the events should be in a different order, the instant listener updates Model_c.OOA_ID
    // at a different time that the batch listener
    assertFalse(
        "Batched events are in same order as instance events",
        instantListener.eventsList.equals(batchedListener.eventsList)); // $NON-NLS-1$//$NON-NLS-2$

    Ooaofooa.getDefaultInstance().removeModelChangeListener(instantListener);
    Ooaofooa.getDefaultInstance().removeModelChangeListener(batchedListener);
  }
示例#12
0
 private void configureRGOReference(NonRootModelElement rgo, NonRootModelElement rto) {
   TransactionManager manager = TransactionManager.getSingleton();
   Transaction transaction = null;
   String association = ElementMap.getAssociationFor(getMethodName().replaceAll("test", ""));
   NonRootModelElement newRto =
       getElement(getMethodName().replaceAll("test", ""), rto.getClass(), true);
   try {
     transaction =
         manager.startTransaction("Adjust RGO", new Ooaofooa[] {Ooaofooa.getDefaultInstance()});
     if (rgo instanceof ProvidedExecutableProperty_c) {
       // need to reassign the provision
       Interface_c iface = Interface_c.getOneC_IOnR4003((ExecutableProperty_c) newRto);
       Provision_c provision = Provision_c.getOneC_POnR4501((ProvidedExecutableProperty_c) rgo);
       provision.Unformalize(false);
       provision.Formalize(iface.getId(), false);
       this.rgo = ProvidedExecutableProperty_c.getOneSPR_PEPOnR4501(provision);
     } else if (rgo instanceof RequiredExecutableProperty_c) {
       // need to reassign the requirement
       Interface_c iface = Interface_c.getOneC_IOnR4003((ExecutableProperty_c) newRto);
       Requirement_c requirement =
           Requirement_c.getOneC_ROnR4500((RequiredExecutableProperty_c) rgo);
       requirement.Unformalize(false);
       requirement.Formalize(iface.getId(), false);
       // need to reset the RGO
       this.rgo = RequiredExecutableProperty_c.getOneSPR_REPOnR4500(requirement);
     } else {
       Method getMethod = getAccessorMethod(rgo, rto);
       NonRootModelElement existing =
           (NonRootModelElement) getMethod.invoke(rto, new Object[] {rgo});
       Method method = getUnrelateMethod(association, existing, rgo);
       method.invoke(existing, new Object[] {rgo});
       method = getRelateMethod(association, newRto, rgo);
       method.invoke(newRto, new Object[] {rgo});
     }
   } catch (Exception e) {
     fail(e.getMessage());
     if (transaction != null) {
       manager.cancelTransaction(transaction);
     }
   } finally {
     if (transaction != null) {
       manager.endTransaction(transaction);
       rgoUpdateSuccessful = true;
     }
   }
   BaseTest.dispatchEvents(0);
 }
 private void createElement(String creationMethod, Object container) {
   // new a test Model Class
   Transaction transaction = null;
   try {
     transaction =
         TransactionManager.getSingleton()
             .startTransaction(
                 "Create test element.",
                 new ModelElement[] {
                   Ooaofooa.getDefaultInstance(), Ooaofgraphics.getDefaultInstance()
                 });
     Method method = Cl_c.findMethod(container, creationMethod, new Class<?>[0]);
     Cl_c.doMethod(method, container, new Object[0]);
     TransactionManager.getSingleton().endTransaction(transaction);
   } catch (TransactionException e) {
     if (transaction != null) {
       TransactionManager.getSingleton().cancelTransaction(transaction, e);
     }
   }
   // allow reconciler to kick in
   BaseTest.dispatchEvents(0);
 }
  /* (non-Javadoc)
   * @see org.eclipse.ui.IPersistableElement#saveState(org.eclipse.ui.IMemento)
   */
  public void saveState(IMemento memento) {
    String root_id = m_input.getModelRoot().getId();
    Ooaofooa modelRoot = Ooaofooa.getInstance(root_id, false);

    memento.putString(GraphicalEditorFactory.TAG_MODELROOTID, m_input.getModelRoot().getId());
    memento.putString(GraphicalEditorFactory.TAG_OOAID, m_input.getOoa_id().toString());
    memento.putInteger(GraphicalEditorFactory.TAG_OOATYPE, m_input.getOoa_type());
    memento.putInteger(GraphicalEditorFactory.TAG_MODELTYPE, m_input.getModel_type());
    NonRootModelElement nrme = (NonRootModelElement) m_input.getRepresents();
    if (nrme == null) {
      nrme =
          (NonRootModelElement)
              Cl_c.Getinstancefromooa_id(modelRoot, m_input.getOoa_id(), m_input.getOoa_type());
    }

    // if there's no way to get a component path, then don't save the tag
    // CanvasFactory.createElement() will check for the tag's existence
    // before doing anything
    if (nrme != null) {
      memento.putString(GraphicalEditorFactory.TAG_COMPONENTPATH, nrme.getContent());
    }
  }
示例#15
0
 private void hookListeners() {
   modelChangeListener = new CanvasModelListener();
   Ooaofooa.getDefaultInstance().addModelChangeListener(modelChangeListener);
   transactionListener = new CanvasTransactionListener();
   TransactionManager.getSingleton().addTransactionListener(transactionListener);
 }
示例#16
0
 @Before
 public void setUp() throws Exception {
   Ooaofooa.setPersistEnabled(true);
   super.setUp();
 }
示例#17
0
 private NonRootModelElement getElement(String key, Class<?> elementType, boolean nonDefault) {
   NonRootModelElement element = null;
   String name = elementType.getSimpleName();
   if (key.startsWith("A")) {
     name = name + "_RTO";
   } else {
     name = name + "_RGO";
   }
   if (elementType == ImportedReference_c.class) {
     // name will match RTO
     name = "InterfaceReference_c_RTO";
   }
   if (elementType == PortReference_c.class && rto instanceof Port_c) {
     name = "Port_c_RTO";
   }
   if (elementType == InterfaceReference_c.class && rto instanceof Port_c) {
     // name will match RTO
     name = "PortReference_c_RTO";
   }
   if (elementType == InterfaceReference_c.class && rto instanceof Interface_c) {
     // name will match RTO
     name = "Interface_c_RTO";
   }
   if (elementType == ComponentReference_c.class) {
     // name will match RTO
     name = "Component_c_RTO";
   }
   if (elementType == ProvidedExecutableProperty_c.class) {
     // need to locate the Provided Operation
     elementType = ProvidedOperation_c.class;
     // also the name will be ExecutableProperty_c_RTO
     name = "ExecutableProperty_c_RTO";
   }
   if (elementType == RequiredExecutableProperty_c.class) {
     // need to locate the Provided Operation
     elementType = RequiredOperation_c.class;
     // also the name will be ExecutableProperty_c_RTO
     name = "ExecutableProperty_c_RTO";
   }
   if (nonDefault) {
     name = name + "_ND";
   }
   Ooaofooa[] instances = Ooaofooa.getInstances();
   for (Ooaofooa ooa : instances) {
     InstanceList list = ooa.getInstanceList(elementType);
     for (Object elem : list) {
       NonRootModelElement test = (NonRootModelElement) elem;
       if (test.isProxy()) {
         continue;
       }
       if (test.getName().contains(name) && (!nonDefault && !test.getName().contains("ND"))) {
         element = test;
         break;
       }
       if (test.getName().contains(name) && (nonDefault && test.getName().contains("ND"))) {
         element = test;
         break;
       }
     }
     if (element != null) {
       break;
     }
   }
   if (elementType == ProvidedOperation_c.class) {
     return ProvidedExecutableProperty_c.getOneSPR_PEPOnR4503((ProvidedOperation_c) element);
   }
   if (elementType == RequiredOperation_c.class) {
     return RequiredExecutableProperty_c.getOneSPR_REPOnR4502((RequiredOperation_c) element);
   }
   assertNotNull(
       "Missing test element with details : Type->" + elementType + " Name->" + name, element);
   return element;
 }