COPASI API  4.16.103
test000094.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/sbml/unittests/test000094.cpp,v $
3 // $Revision: 1.3 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/09/30 16:37:14 $
7 // End CVS Header
8 
9 // Copyright (C) 2011 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 #include <sstream>
15 #include "utilities.hpp"
17 #include "copasi/model/CModel.h"
19 
20 #include <sbml/SBMLDocument.h>
21 #include <sbml/Model.h>
22 
24 
25 #include "test000094.h"
26 
27 
28 // these are testcases for handling SBML models with required and non-required packages
29 
30 CCopasiDataModel* test000094::pCOPASIDATAMODEL = NULL;
31 
33 {
34  // Create the root container.
35  CCopasiRootContainer::init(0, NULL, false);
36  // Create the global data model.
38 }
39 
41 {
43 }
44 
46 {
47  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
48  bool failed = false;
49 
50  try
51  {
53  }
54  catch (const CCopasiException& e)
55  {
56 
57  failed = true;
58  }
59 
60  CPPUNIT_ASSERT_MESSAGE("The model should have failed loading because it contains a required package.", failed == true);
61  // check for the error message in the COPASI message stack
62 }
63 
65 {
66  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
67  bool result = pDataModel->importSBMLFromString(test000094::MODEL_STRING2);
68  CPPUNIT_ASSERT(result == true);
69  CModel *pModel = pDataModel->getModel();
70  CPPUNIT_ASSERT(pModel != NULL);
71  CPPUNIT_ASSERT(pDataModel->getCurrentSBMLDocument() != NULL);
72 }
73 
74 
75 /**
76  * This model contains a required package which COPASI does not understand, so
77  * we refuse to load the model.
78  */
79 const char* test000094::MODEL_STRING1 = \
80  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
81  "<sbml xmlns=\"http://www.sbml.org/sbml/level3/version1/core\" level=\"3\" version=\"1\"\n"
82  " xmlns:ppp=\"http://www.sbml.org/sbml/level3/version1/some_package/version1\"\n"
83  " ppp:required=\"true\">\n"
84  " <model id=\"Model_1\" name=\"New Model\">\n"
85  " <ppp:some_package>\n"
86  " </ppp:some_package>\n"
87  " </model>\n"
88  "</sbml>\n";
89 
90 /**
91  * This model contains a package that is not required, so COPASI should just
92  * ignore it and load the model.
93  */
94 const char* test000094::MODEL_STRING2 = \
95  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
96  "<sbml xmlns=\"http://www.sbml.org/sbml/level3/version1/core\" level=\"3\" version=\"1\"\n"
97  " xmlns:ppp=\"http://www.sbml.org/sbml/level3/version1/some_package/version1\"\n"
98  " ppp:required=\"false\">\n"
99  " <model id=\"Model_1\" name=\"New Model\">\n"
100  " <ppp:element>\n"
101  " </ppp:element>\n"
102  " </model>\n"
103  "</sbml>\n";
104 
SBMLDocument * getCurrentSBMLDocument()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000094.h:36
void test_notrequired_package()
Definition: test000094.cpp:64
void test_required_package()
Definition: test000094.cpp:45
static const char * MODEL_STRING2
Definition: test000094.h:35
void setUp()
Definition: test000094.cpp:32
static CCopasiDataModel * addDatamodel()
void tearDown()
Definition: test000094.cpp:40
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
static void init(int argc, char *argv[], const bool &withGui=false)
static const char * MODEL_STRING1
Definition: test000094.h:34
Definition: CModel.h:50