[commit] r2625 - in trunk: GME/Mga Tests/GPyUnit Tests/GPyUnit/GME_310 Tests/GPyUnit/util
GMESRC Repository Notifications
gme-commit at list.isis.vanderbilt.edu
Wed Apr 13 13:08:47 CDT 2016
Author: ksmyth
Date: Wed Apr 13 13:08:47 2016
New Revision: 2625
Log:
Prevent DetachFromArchetype for targets of derived references.
Modified:
trunk/GME/Mga/MgaDeriveOps.cpp
trunk/Tests/GPyUnit/GME_310/__init__.py
trunk/Tests/GPyUnit/GME_371.py
trunk/Tests/GPyUnit/util/__init__.py
Modified: trunk/GME/Mga/MgaDeriveOps.cpp
==============================================================================
--- trunk/GME/Mga/MgaDeriveOps.cpp Wed Apr 13 13:08:43 2016 (r2624)
+++ trunk/GME/Mga/MgaDeriveOps.cpp Wed Apr 13 13:08:47 2016 (r2625)
@@ -311,7 +311,7 @@
// ----------------------------------------
-// Attach/detach (freshly implemented)
+// Attach/detach
// ----------------------------------------
HRESULT FCO::DetachFromArcheType ()
{
@@ -329,7 +329,20 @@
}
SelfMark(OBJEVENT_SUBT_INST);
- CoreObjMark( self[ATTRID_PARENT], OBJEVENT_LOSTCHILD);
+
+ // Need to run this check: "inherited ref can only refer to a derived instance of the target of its base"
+ CoreObjs segs = self[ATTRID_REFERENCE + ATTRID_COLLECTION];
+ ITERATE_THROUGH(segs) {
+ CComPtr<IMgaFCO> ffco;
+ ObjForCore(ITER)->getinterface(&ffco);
+ COMTHROW(ffco->Check());
+ }
+
+ CComPtr<IMgaFCO> selfFco;
+ ObjForCore(ITER)->getinterface(&selfFco);
+ COMTHROW(selfFco->Check());
+
+ CoreObjMark(self[ATTRID_PARENT], OBJEVENT_LOSTCHILD);
} COMCATCH_IN_TRANSACTION(;);
return S_OK;
Modified: trunk/Tests/GPyUnit/GME_310/__init__.py
==============================================================================
--- trunk/Tests/GPyUnit/GME_310/__init__.py Wed Apr 13 13:08:43 2016 (r2624)
+++ trunk/Tests/GPyUnit/GME_310/__init__.py Wed Apr 13 13:08:47 2016 (r2625)
@@ -5,6 +5,7 @@
import os.path
import unittest
from GPyUnit.util import DispatchEx
+from GPyUnit.util import dec_disable_early_binding
def _adjacent_file(file):
import os.path
@@ -51,6 +52,7 @@
#print "Reference file '%s' matches output '%s'" % (self.correct_file, self.output_file)
class TestDerivedRefport(unittest.TestCase):
+ input_filename = "DerivedRefport.xme"
def __init__(self, *kargs, **kwds):
super(TestDerivedRefport, self).__init__(*kargs, **kwds)
@@ -58,7 +60,7 @@
from GPyUnit import util
util.register_xmp(_adjacent_file("GME310ModelRefportTest.xmp"))
- mga = util.parse_xme(self.connstr, _adjacent_file("DerivedRefport.xme"))
+ mga = util.parse_xme(self.connstr, _adjacent_file(self.input_filename))
mga.Save()
mga.Close()
@@ -67,6 +69,34 @@
return "MGA=" + _adjacent_file("DerivedRefport_test.mga")
+class TestDerivedRefport2(unittest.TestCase):
+ input_filename = "DerivedRefport.xme"
+ def __init__(self, *kargs, **kwds):
+ super(TestDerivedRefport2, self).__init__(*kargs, **kwds)
+
+ @dec_disable_early_binding
+ def test(self):
+ from GPyUnit import util
+ util.register_xmp(_adjacent_file("GME310ModelRefportTest.xmp"))
+
+ mga = util.parse_xme(self.connstr, _adjacent_file(self.input_filename))
+ mga.BeginTransactionInNewTerr()
+ referredDerived = mga.ObjectByPath("/@KindFolder/@ReferredDerived")
+ try:
+ # this is illegal because a derived reference will point to a non-derived target
+ referredDerived.DetachFromArcheType()
+ except util.com_error as e:
+ self.assertIn('Invalid reference target', str(e))
+
+ mga.CommitTransaction()
+ mga.Save()
+ mga.Close()
+
+ @property
+ def connstr(self):
+ return "MGA=" + _adjacent_file("DerivedRefport_test2.mga")
+
+
class TestRefportAPI(unittest.TestCase):
def __init__(self, *kargs, **kwds):
super(TestRefportAPI, self).__init__(*kargs, **kwds)
Modified: trunk/Tests/GPyUnit/GME_371.py
==============================================================================
--- trunk/Tests/GPyUnit/GME_371.py Wed Apr 13 13:08:43 2016 (r2624)
+++ trunk/Tests/GPyUnit/GME_371.py Wed Apr 13 13:08:47 2016 (r2625)
@@ -1,6 +1,6 @@
import unittest
import os
-from GPyUnit.util import DispatchEx
+from GPyUnit.util import DispatchEx, com_error
class TestParser(unittest.TestCase):
def test_ParseMetaGME(self):
@@ -12,15 +12,8 @@
mga.Create("MGA=tmp.mga", paradigm)
terr = mga.BeginTransactionInNewTerr()
- import platform
- if platform.system() != 'Java':
- from pythoncom import com_error
- exc_type = com_error
- else:
- import org.isis.jaut.InvokeException
- exc_type = org.isis.jaut.InvokeException
# GME-371: this would crash
- self.assertRaises(exc_type, xme.ParseProject, mga, inputfile)
+ self.assertRaises(com_error, xme.ParseProject, mga, inputfile)
return
mga.CommitTransaction()
terr.Destroy()
Modified: trunk/Tests/GPyUnit/util/__init__.py
==============================================================================
--- trunk/Tests/GPyUnit/util/__init__.py Wed Apr 13 13:08:43 2016 (r2624)
+++ trunk/Tests/GPyUnit/util/__init__.py Wed Apr 13 13:08:47 2016 (r2625)
@@ -3,6 +3,7 @@
import os
import sys
import unittest
+import platform
_opts = type("Options", (object,), {
'Dispatch_x64': False,
@@ -188,3 +189,8 @@
project.Close(True)
return ("MetaGME", meta_gme_connstr, None, meta_gme_guid, 1)
+if platform.system() != 'Java':
+ from pythoncom import com_error
+else:
+ import org.isis.jaut.InvokeException
+ com_error = org.isis.jaut.InvokeException
More information about the gme-commit
mailing list