Changeset 1087


Ignore:
Timestamp:
11/09/11 23:25:44 (13 years ago)
Author:
masberg
Message:

More refactoring, use modern JUnit notation, make some tests more thorough.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/org.modelica.mdt.test/src/org/modelica/mdt/test/TestInnerClass.java

    r1086 r1087  
    4242package org.modelica.mdt.test;
    4343
     44import static org.junit.Assert.assertTrue;
     45
    4446import java.io.InputStream;
    4547import java.util.Collection;
     
    5153import org.eclipse.core.runtime.Platform;
    5254import org.eclipse.jface.resource.ImageDescriptor;
    53 import org.eclipse.jface.text.IRegion;
    5455import org.eclipse.ui.model.IWorkbenchAdapter;
    5556import org.modelica.mdt.core.IDefinitionLocation;
     
    5758import org.modelica.mdt.core.IModelicaComponent;
    5859import org.modelica.mdt.core.IModelicaElement;
     60import org.modelica.mdt.core.IModelicaFolder;
    5961import org.modelica.mdt.core.IModelicaImport;
    6062import org.modelica.mdt.core.IModelicaSourceFile;
     
    7375import org.osgi.framework.BundleException;
    7476
    75 import junit.framework.TestCase;
     77import static org.junit.Assert.assertEquals;
     78import static org.junit.Assert.assertFalse;
     79import static org.junit.Assert.assertNotNull;
    7680
    7781/**
    7882 * test org.modelica.mdt.core.compiler.InnerClass class' code
    7983 */
    80 public class TestInnerClass extends TestCase {
     84public class TestInnerClass {
    8185    /* the file on which we make the changing locations test */
    8286    private static final String CHANGING_FILE = "changing_file.mo";
     
    8892    private IModelicaProject proj;
    8993
    90     @Override
    91     protected void setUp() throws Exception {
     94    @org.junit.Before
     95    public void setUp()
     96            throws ConnectException, UnexpectedReplyException, InvocationError, CompilerInstantiationException, CoreException {
    9297        Area51Projects.createProjects();
    9398
     99        proj = Utility.getProject(Area51Projects.MODELICA_PROJECT_NAME);
     100
     101        IModelicaFolder rootFolder = proj.getRootFolder();
     102
    94103        /* navigate to the model 'component_bananza' */
    95         proj = Utility.getProject(Area51Projects.MODELICA_PROJECT_NAME);
    96 
    97         IModelicaSourceFile file =
    98                 Utility.findModelicaFileInFolder(proj.getRootFolder(),
    99                         "component_model.mo");
    100 
    101         componentsBananza = null;
    102         for (IModelicaElement el : file.getChildren()) {
    103             if (el instanceof InnerClass) {
    104                 String elementName = el.getElementName();
    105 
    106                 if (elementName.equals("components_bananza")) {
    107                     componentsBananza = (InnerClass)el;
    108                     break;
     104        {
     105            IModelicaSourceFile file = Utility.findModelicaFileInFolder(rootFolder, "component_model.mo");
     106            Collection<? extends IModelicaElement> children = file.getChildren();
     107            for (IModelicaElement el : children) {
     108                if (el instanceof InnerClass) {
     109                    String elementName = el.getElementName();
     110
     111                    if (elementName.equals("components_bananza")) {
     112                        componentsBananza = (InnerClass)el;
     113                        break;
     114                    }
    109115                }
    110116            }
     117
     118            assertNotNull("Could not find the model components_bananza", componentsBananza);
    111119        }
    112120
    113121        /* navigate to the model 'import_rich_model' */
    114         file = Utility.findModelicaFileInFolder(proj.getRootFolder(),
    115                 "import_rich_model.mo");
    116 
    117         importRichModel = null;
    118         for (IModelicaElement el : file.getChildren()) {
    119             if (el instanceof InnerClass) {
    120                 String elementName = el.getElementName();
    121 
    122                 if (elementName.equals("import_rich_model")) {
    123                     importRichModel = (InnerClass)el;
    124                     break;
     122        {
     123            IModelicaSourceFile file = Utility.findModelicaFileInFolder(rootFolder, "import_rich_model.mo");
     124            Collection<? extends IModelicaElement> children = file.getChildren();
     125            for (IModelicaElement el : children) {
     126                if (el instanceof InnerClass) {
     127                    String elementName = el.getElementName();
     128
     129                    if (elementName.equals("import_rich_model")) {
     130                        importRichModel = (InnerClass)el;
     131                        break;
     132                    }
    125133                }
    126134            }
     135
     136            assertNotNull("could not find the model import_rich_model", importRichModel);
    127137        }
    128 
    129         assertNotNull("could not find the model import_rich_model",
    130                 importRichModel);
    131138    }
    132139
     
    134141     * do some sanity checks on InnerClass children
    135142     */
     143    @org.junit.Test
    136144    public void testChildren()
    137145            throws ConnectException, UnexpectedReplyException,  InvocationError, CoreException, CompilerInstantiationException, BundleException {
     
    213221            }
    214222        }
    215         IRegion reg = null;
    216         IWorkbenchAdapter wbAdapter = null;
    217         /*
    218          * sanity checks on components_bananza.a_type
    219          */
    220         IModelicaComponent.Visibility visibility = IModelicaComponent.Visibility.NONE;
    221         testChild(a_type, "a_type", "components_bananza.a_type", "component_model.mo", visibility, 11, 5, 11, 27, "a_type");
    222 //      assertNotNull("components_bananza.a_type not found", a_type);
    223 //      assertEquals("wrong element name", "a_type", a_type.getElementName());
    224 //      assertEquals("wrong element full name",
    225 //              "components_bananza.a_type", a_type.getFullName());
    226 //      assertTrue("fishy file path",
    227 //              a_type.getFilePath().endsWith("component_model.mo"));
    228 //      IRegion reg = a_type.getLocation().getRegion();
    229 //      assertEquals("wrong start offset", 342, reg.getOffset());
    230 //      assertEquals("wrong length", 364-342+1, reg.getLength());
    231 //
    232 //      /* check if element is adaptable */
    233 //      assertTrue("element object must be adaptable",
    234 //              (a_type instanceof IAdaptable));
    235 //
    236 //      /* check if we can convert element to workbench adapter */
    237 //      IWorkbenchAdapter wbAdapter =
    238 //              (IWorkbenchAdapter)a_type.getAdapter(IWorkbenchAdapter.class);
    239 //
    240 //      assertNotNull("could not fetch workbench adapter", wbAdapter);
    241 //      assertEquals("wrong label", "a_type",
    242 //              wbAdapter.getLabel(a_type));
    243 //      assertNotNull("no image provided",
    244 //              wbAdapter.getImageDescriptor(a_type));
    245 
    246         /*
    247          * sanity checks on components_bananza.a_package
    248          */
    249         testChild(a_package, "a_package", "components_bananza.a_package", "component_model.mo", visibility, 4, 5, 4, 36, "a_package");
    250 //      assertNotNull("components_bananza.a_package not found", a_package);
    251 //      assertEquals("wrong element name", "a_package",
    252 //              a_package.getElementName());
    253 //      assertEquals("wrong element full name", "components_bananza.a_package",
    254 //              a_package.getFullName());
    255 //      assertTrue("fishy file path",
    256 //              a_package.getFilePath().endsWith("component_model.mo"));
    257 //      reg = a_package.getLocation().getRegion();
    258 //      assertEquals("wrong start offset", 95, reg.getOffset());
    259 //      assertEquals("wrong length", 126-95+1, reg.getLength());
    260 //
    261 //      /* check if element is adaptable */
    262 //      assertTrue("element object must be adaptable",
    263 //              (a_package instanceof IAdaptable));
    264 //
    265 //      /* check if we can convert element to workbench adapter */
    266 //      wbAdapter = (IWorkbenchAdapter)a_package.getAdapter(IWorkbenchAdapter.class);
    267 //
    268 //      assertNotNull("could not fetch workbench adapter", wbAdapter);
    269 //      wbAdapter.getLabel(a_package);
    270 //      assertEquals("wrong label", "a_package",
    271 //              wbAdapter.getLabel(a_package));
    272 //      assertNotNull("no image provided",
    273 //              wbAdapter.getImageDescriptor(a_package));
    274 
    275         /*
    276          * sanity checks on components_bananza.a_block
    277          */
    278         testChild(a_block, "a_block", "components_bananza.a_block", "component_model.mo", visibility, 9, 5, 9, 30, "a_block");
    279 //      assertNotNull("components_bananza.a_block not found", a_block);
    280 //      assertEquals("wrong element name", "a_block",
    281 //              a_block.getElementName());
    282 //      assertEquals("wrong element full name", "components_bananza.a_block",
    283 //              a_block.getFullName());
    284 //      assertTrue("fishy file path",
    285 //              a_block.getFilePath().endsWith("component_model.mo"));
    286 //      reg = a_block.getLocation().getRegion();
    287 //      assertEquals("wrong start offset", 271, reg.getOffset());
    288 //      assertEquals("wrong length", 296-271+1, reg.getLength());
    289 //
    290 //      /* check if element is adaptable */
    291 //      assertTrue("element object must be adaptable",
    292 //              (a_block instanceof IAdaptable));
    293 //
    294 //      /* check if we can convert element to workbench adapter */
    295 //      wbAdapter = (IWorkbenchAdapter)a_block.getAdapter(IWorkbenchAdapter.class);
    296 //
    297 //      assertNotNull("could not fetch workbench adapter", wbAdapter);
    298 //      assertEquals("wrong label", "a_block",
    299 //              wbAdapter.getLabel(a_block));
    300 //      assertNotNull("no image provided",
    301 //              wbAdapter.getImageDescriptor(a_block));
    302 
    303         /*
    304          * sanity checks on components_bananza.a_class
    305          */
    306         testChild(a_class, "a_class", "components_bananza.a_class", "component_model.mo", visibility, 5, 5, 5, 30, "a_class");
    307 //      assertNotNull("components_bananza.a_class not found", a_class);
    308 //      assertEquals("wrong element name", "a_class", a_class.getElementName());
    309 //      assertEquals("wrong element full name", "components_bananza.a_class",
    310 //              a_class.getFullName());
    311 //      assertTrue("fishy file path",
    312 //              a_class.getFilePath().endsWith("component_model.mo"));
    313 //      reg = a_class.getLocation().getRegion();
    314 //      assertEquals("wrong start offset", 132, reg.getOffset());
    315 //      assertEquals("wrong length", 157-132+1, reg.getLength());
    316 //
    317 //      /* check if element is adaptable */
    318 //      assertTrue("element object must be adaptable",
    319 //              (a_class instanceof IAdaptable));
    320 //
    321 //      /* check if we can convert element to workbench adapter */
    322 //      wbAdapter = (IWorkbenchAdapter)a_class.getAdapter(IWorkbenchAdapter.class);
    323 //
    324 //      assertNotNull("could not fetch workbench adapter", wbAdapter);
    325 //      assertEquals("wrong label", "a_class",
    326 //              wbAdapter.getLabel(a_class));
    327 //      assertNotNull("no image provided",
    328 //              wbAdapter.getImageDescriptor(a_class));
    329 
    330         /*
    331          * sanity checks on components_bananza.a_connector
    332          */
    333         testChild(a_connector, "a_connector", "components_bananza.a_connector", "component_model.mo", visibility, 7, 5, 7, 42, "a_connector");
    334 //      assertNotNull("components_bananza.a_connector not found", a_connector);
    335 //      assertEquals("wrong element name", "a_connector",
    336 //              a_connector.getElementName());
    337 //      assertEquals("wrong element full name", "components_bananza.a_connector",
    338 //              a_connector.getFullName());
    339 //      assertTrue("fishy file path",
    340 //              a_connector.getFilePath().endsWith("component_model.mo"));
    341 //      reg = a_connector.getLocation().getRegion();
    342 //      assertEquals("wrong start offset", 194, reg.getOffset());
    343 //      assertEquals("wrong length", 231-194+1, reg.getLength());
    344 //
    345 //      /* check if element is adaptable */
    346 //      assertTrue("element object must be adaptable",
    347 //              (a_connector instanceof IAdaptable));
    348 //
    349 //      /* check if we can convert element to workbench adapter */
    350 //      wbAdapter = (IWorkbenchAdapter)a_connector.getAdapter(IWorkbenchAdapter.class);
    351 //
    352 //      assertNotNull("could not fetch workbench adapter", wbAdapter);
    353 //      assertEquals("wrong label", "a_connector",
    354 //              wbAdapter.getLabel(a_connector));
    355 //      assertNotNull("no image provided",
    356 //              wbAdapter.getImageDescriptor(a_connector));
    357 
    358         /*
    359          * sanity checks on components_bananza.a_function
    360          */
    361         testChild(a_function, "a_function", "components_bananza.a_function", "component_model.mo", visibility, 10, 5, 10, 39, "a_function");
    362 //      assertNotNull("components_bananza.a_function not found", a_function);
    363 //      assertEquals("wrong element name", "a_function",
    364 //              a_function.getElementName());
    365 //      assertEquals("wrong element full name", "components_bananza.a_function",
    366 //              a_function.getFullName());
    367 //      assertTrue("fishy file path",
    368 //              a_function.getFilePath().endsWith("component_model.mo"));
    369 //      reg = a_function.getLocation().getRegion();
    370 //      assertEquals("wrong start offset", 302, reg.getOffset());
    371 //      assertEquals("wrong length", 336-302+1, reg.getLength());
    372 //
    373 //      /* check if element is adaptable */
    374 //      assertTrue("element object must be adaptable",
    375 //              (a_function instanceof IAdaptable));
    376 //
    377 //      /* check if we can convert element to workbench adapter */
    378 //      wbAdapter = (IWorkbenchAdapter)a_function.getAdapter(IWorkbenchAdapter.class);
    379 //
    380 //      assertNotNull("could not fetch workbench adapter", wbAdapter);
    381 //      assertEquals("wrong label", "a_function",
    382 //              wbAdapter.getLabel(a_function));
    383 //      assertNotNull("no image provided",
    384 //              wbAdapter.getImageDescriptor(a_function));
    385 
    386         /*
    387          * sanity checks on components_bananza.a_model
    388          */
    389         testChild(a_model, "a_model", "components_bananza.a_model", "component_model.mo", visibility, 6, 5, 6, 30, "a_model");
    390 //      assertNotNull("components_bananza.a_model not found", a_model);
    391 //      assertEquals("wrong element name", "a_model", a_model.getElementName());
    392 //      assertEquals("wrong element full name", "components_bananza.a_model",
    393 //              a_model.getFullName());
    394 //      assertTrue("fishy file path",
    395 //              a_model.getFilePath().endsWith("component_model.mo"));
    396 //      reg = a_model.getLocation().getRegion();
    397 //      assertEquals("wrong start offset", 163, reg.getOffset());
    398 //      assertEquals("wrong length", 188-163+1, reg.getLength());
    399 //
    400 //      /* check if element is adaptable */
    401 //      assertTrue("element object must be adaptable",
    402 //              (a_model instanceof IAdaptable));
    403 //
    404 //      /* check if we can convert element to workbench adapter */
    405 //      wbAdapter = (IWorkbenchAdapter)a_model.getAdapter(IWorkbenchAdapter.class);
    406 //
    407 //      assertNotNull("could not fetch workbench adapter", wbAdapter);
    408 //      assertEquals("wrong label", "a_model",
    409 //              wbAdapter.getLabel(a_model));
    410 //      assertNotNull("no image provided",
    411 //              wbAdapter.getImageDescriptor(a_model));
    412 
    413         /*
    414          * sanity checks on components_bananza.a_record
    415          */
    416         testChild(a_record, "a_record", "components_bananza.a_record", "component_model.mo", visibility, 8, 5, 8, 33, "a_record");
    417 //      assertNotNull("components_bananza.a_record not found", a_record);
    418 //      assertEquals("wrong element name", "a_record", a_record.getElementName());
    419 //      assertEquals("wrong element full name", "components_bananza.a_record",
    420 //              a_record.getFullName());
    421 //      assertTrue("fishy file path",
    422 //              a_record.getFilePath().endsWith("component_model.mo"));
    423 //      reg = a_record.getLocation().getRegion();
    424 //      assertEquals("wrong start offset", 237, reg.getOffset());
    425 //      assertEquals("wrong length", 265-237+1, reg.getLength());
    426 //
    427 //      /* check if element is adaptable */
    428 //      assertTrue("element object must be adaptable",
    429 //              (a_record instanceof IAdaptable));
    430 //
    431 //      /* check if we can convert element to workbench adapter */
    432 //      wbAdapter = (IWorkbenchAdapter)a_record.getAdapter(IWorkbenchAdapter.class);
    433 //
    434 //      assertNotNull("could not fetch workbench adapter", wbAdapter);
    435 //      assertEquals("wrong label", "a_record",
    436 //              wbAdapter.getLabel(a_record));
    437 //      assertNotNull("no image provided",
    438 //              wbAdapter.getImageDescriptor(a_record));
    439 
    440         /*
    441          * sanity checks on components_bananza.a_real
    442          */
    443         visibility = IModelicaComponent.Visibility.PUBLIC;
    444         testChild(a_real, "a_real", "components_bananza.a_real", "component_model.mo", visibility, 2, 5, 2, 34, "a_real");
    445 //      assertNotNull("components_bananza.a_real not found", a_real);
    446 //      assertEquals("wrong element name", "a_real", a_real.getElementName());
    447 //      assertEquals("wrong element full name", "components_bananza.a_real",
    448 //              a_real.getFullName());
    449 //      assertEquals("wrong visibility", a_real.getVisibility(),
    450 //              IModelicaComponent.Visibility.PUBLIC);
    451 //
    452 //      reg = a_real.getLocation().getRegion();
    453 //      assertEquals("wrong start offset", 29, reg.getOffset());
    454 //      assertEquals("wrong length", 58-29+1, reg.getLength());
    455 //
    456 //      /* check if element is adaptable */
    457 //      assertTrue("element object must be adaptable",
    458 //              (a_real instanceof IAdaptable));
    459 //
    460 //      /* check if we can convert element to workbench adapter */
    461 //      wbAdapter = (IWorkbenchAdapter)a_real.getAdapter(IWorkbenchAdapter.class);
    462 //
    463 //      assertNotNull("could not fetch workbench adapter", wbAdapter);
    464 //      assertEquals("wrong label", "a_real",
    465 //              wbAdapter.getLabel(a_real));
    466 //      assertNotNull("no image provided",
    467 //              wbAdapter.getImageDescriptor(a_real));
    468 
    469         /*
    470          * sanity checks on components_bananza.a_undocumented_real
    471          */
    472         assertNotNull("components_bananza.an_undocumented_real not found",
    473                 an_undocumented_real);
    474         assertEquals("wrong element name", "an_undocumented_real",
    475                 an_undocumented_real.getElementName());
    476         assertEquals("wrong element full name",
    477                 "components_bananza.an_undocumented_real",
    478                 an_undocumented_real.getFullName());
    479         assertEquals("wrong visibility", an_undocumented_real.getVisibility(),
    480                 IModelicaComponent.Visibility.PUBLIC);
    481         reg = an_undocumented_real.getLocation().getRegion();
    482         assertEquals("wrong start offset", 64, reg.getOffset());
    483         assertEquals("wrong length", 89-64+1, reg.getLength());
    484 
    485         /* check if element is adaptable */
    486         assertTrue("element object must be adaptable",
    487                 (an_undocumented_real instanceof IAdaptable));
    488 
    489         /* check if we can convert element to workbench adapter */
    490         wbAdapter =
    491                 (IWorkbenchAdapter)an_undocumented_real.getAdapter(IWorkbenchAdapter.class);
    492 
    493         assertNotNull("could not fetch workbench adapter", wbAdapter);
    494         assertEquals("wrong label", "an_undocumented_real",
    495                 wbAdapter.getLabel(an_undocumented_real));
    496         assertNotNull("no image provided",
    497                 wbAdapter.getImageDescriptor(an_undocumented_real));
    498 
    499         /*
    500          * sanity checks on components_bananza.a_protected_integer
    501          */
    502         assertNotNull("components_bananza.a_protected_integer not found",
    503                 a_protected_integer);
    504         assertEquals("wrong element name", "a_protected_integer",
    505                 a_protected_integer.getElementName());
    506         assertEquals("wrong element full name",
    507                 "components_bananza.a_protected_integer",
    508                 a_protected_integer.getFullName());
    509         assertEquals("wrong visibility", a_protected_integer.getVisibility(),
    510                 IModelicaComponent.Visibility.PROTECTED);
    511         reg = a_protected_integer.getLocation().getRegion();
    512         assertEquals("wrong start offset", 407, reg.getOffset());
    513         assertEquals("wrong length", 451-407+1, reg.getLength());
    514 
    515         /* check if element is adaptable */
    516         assertTrue("element object must be adaptable",
    517                 (a_protected_integer instanceof IAdaptable));
    518 
    519         /* check if we can convert element to workbench adapter */
    520         wbAdapter = (IWorkbenchAdapter)a_protected_integer.getAdapter(IWorkbenchAdapter.class);
    521 
    522         assertNotNull("could not fetch workbench adapter", wbAdapter);
    523         assertEquals("wrong label", "a_protected_integer",
    524                 wbAdapter.getLabel(a_protected_integer));
    525         assertNotNull("no image provided",
    526                 wbAdapter.getImageDescriptor(a_protected_integer));
    527 
    528         /*
    529          * sanity checks on components_bananza.a_protected_real
    530          */
    531         assertNotNull("components_bananza.a_protected_real not found",
    532                 a_protected_real);
    533         assertEquals("wrong element name", "a_protected_real",
    534                 a_protected_real.getElementName());
    535         assertEquals("wrong element full name",
    536                 "components_bananza.a_protected_real",
    537                 a_protected_real.getFullName());
    538         assertEquals("wrong visibility", a_protected_real.getVisibility(),
    539                 IModelicaComponent.Visibility.PROTECTED);
    540         reg = a_protected_real.getLocation().getRegion();
    541         assertEquals("wrong start offset", 380, reg.getOffset());
    542         assertEquals("wrong length", 401-380+1, reg.getLength());
    543 
    544         /* check if element is adaptable */
    545         assertTrue("element object must be adaptable",
    546                 (a_protected_real instanceof IAdaptable));
    547 
    548         /* check if we can convert element to workbench adapter */
    549         wbAdapter =
    550                 (IWorkbenchAdapter)a_protected_real.getAdapter(IWorkbenchAdapter.class);
    551 
    552         assertNotNull("could not fetch workbench adapter", wbAdapter);
    553         assertEquals("wrong label", "a_protected_real",
    554                 wbAdapter.getLabel(a_protected_real));
    555         assertNotNull("no image provided",
    556                 wbAdapter.getImageDescriptor(a_protected_real));
     223
     224        testChild(a_type, IModelicaClass.class, "a_type", "components_bananza.a_type", "component_model.mo",
     225                IModelicaComponent.Visibility.NONE, 11, 5, 11, 27, "a_type");
     226
     227        testChild(a_package, IModelicaClass.class, "a_package", "components_bananza.a_package", "component_model.mo",
     228                IModelicaComponent.Visibility.NONE, 4, 5, 4, 36, "a_package");
     229
     230        testChild(a_block, IModelicaClass.class, "a_block", "components_bananza.a_block", "component_model.mo",
     231                IModelicaComponent.Visibility.NONE, 9, 5, 9, 30, "a_block");
     232
     233        testChild(a_class, IModelicaClass.class, "a_class", "components_bananza.a_class", "component_model.mo",
     234                IModelicaComponent.Visibility.NONE, 5, 5, 5, 30, "a_class");
     235
     236        testChild(a_connector, IModelicaClass.class, "a_connector", "components_bananza.a_connector", "component_model.mo",
     237                IModelicaComponent.Visibility.NONE, 7, 5, 7, 42, "a_connector");
     238
     239        testChild(a_function, IModelicaClass.class, "a_function", "components_bananza.a_function", "component_model.mo",
     240                IModelicaComponent.Visibility.NONE, 10, 5, 10, 39, "a_function");
     241
     242        testChild(a_model, IModelicaClass.class, "a_model", "components_bananza.a_model", "component_model.mo",
     243                IModelicaComponent.Visibility.NONE, 6, 5, 6, 30, "a_model");
     244
     245        testChild(a_record, IModelicaClass.class, "a_record", "components_bananza.a_record", "component_model.mo",
     246                IModelicaComponent.Visibility.NONE, 8, 5, 8, 33, "a_record");
     247
     248        testChild(a_real, IModelicaComponent.class, "a_real", "components_bananza.a_real", "component_model.mo",
     249                IModelicaComponent.Visibility.PUBLIC, 2, 5, 2, 34, "a_real");
     250
     251        testChild(an_undocumented_real, IModelicaComponent.class, "an_undocumented_real", "components_bananza.an_undocumented_real",
     252                "component_model.mo", IModelicaComponent.Visibility.PUBLIC, 3, 5, 3, 30, "an_undocumented_real");
     253
     254        testChild(a_protected_integer, IModelicaComponent.class, "a_protected_integer", "components_bananza.a_protected_integer",
     255                "component_model.mo", IModelicaComponent.Visibility.PROTECTED, 14, 5, 14, 49, "a_protected_integer");
     256
     257        testChild(a_protected_real, IModelicaComponent.class, "a_protected_real", "components_bananza.a_protected_real",
     258                "component_model.mo", IModelicaComponent.Visibility.PROTECTED, 13, 5, 13, 26, "a_protected_real");
    557259    }
    558260
     
    560262     * do some sanity checks on InnerClass' imports
    561263     */
     264    @org.junit.Test
    562265    public void testImports()
    563266            throws ConnectException, UnexpectedReplyException, InvocationError, CompilerInstantiationException, CoreException {
     
    591294    }
    592295
     296    @org.junit.Test
    593297    public void testIsEncapsulated()
    594298            throws ConnectException, CompilerInstantiationException, UnexpectedReplyException, InvocationError, CoreException {
     
    663367     * its location is updated
    664368     */
     369    @org.junit.Test
    665370    public void testLocationUpdates()
    666371            throws CoreException, ConnectException, CompilerInstantiationException, UnexpectedReplyException, InvocationError {
     
    681386    }
    682387
    683     private void testChild(IModelicaElement element, String elementName, String fullName, String pathEndsWith,
     388    private void testChild(IModelicaElement element, Class<?> expectedClass, String elementName, String fullName, String pathEndsWith,
    684389            IModelicaComponent.Visibility visibility, int startLine, int startCol, int endLine, int endCol, String label)
    685390                    throws ConnectException, UnexpectedReplyException, InvocationError, CompilerInstantiationException, CoreException {
    686391        assertNotNull("The element with the expected full name \"" + fullName + "\" was not found.", element);
    687        
     392
     393        Class<?> actualClass = element.getClass();
     394        String expectedClassName = expectedClass.getCanonicalName();
     395        String actualClassName = actualClass.getCanonicalName();
     396        String errorClass = "The actual class \"" + actualClassName + "\" is not an instance of the expected class \"" + expectedClassName + "\".";
     397
     398        assertTrue(errorClass, expectedClass.isAssignableFrom(actualClass));
     399
    688400        String actualElementName = element.getElementName();
    689401        String actualFullName = element.getFullName();
    690        
     402
    691403        IModelicaComponent.Visibility actualVisibility = element.getVisibility();
    692404
Note: See TracChangeset for help on using the changeset viewer.