Ignore:
Timestamp:
12/21/05 11:21:12 (19 years ago)
Author:
boris
Message:
  • moved out code that handles communication with OMC to a separate plugin
File:
1 edited

Legend:

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

    r228 r240  
    4848import org.eclipse.core.resources.IProject;
    4949import org.modelica.mdt.core.IModelicaClass.Type;
    50 import org.modelica.mdt.internal.core.ElementLocation;
    51 import org.modelica.mdt.internal.omcproxy.ConnectException;
    52 import org.modelica.mdt.internal.omcproxy.InvocationError;
    53 import org.modelica.mdt.internal.omcproxy.OMCProxy;
    54 import org.modelica.mdt.internal.omcproxy.UnexpectedReplyException;
     50import org.modelica.mdt.compiler.CompilerInstantiationException;
     51import org.modelica.mdt.compiler.ConnectException;
     52import org.modelica.mdt.compiler.IElementLocation;
     53import org.modelica.mdt.compiler.InvocationError;
     54import org.modelica.mdt.compiler.UnexpectedReplyException;
     55import org.modelica.mdt.internal.compiler.CompilerProxy;
    5556import org.modelica.mdt.test.util.Area51Projects;
    5657import org.modelica.mdt.test.util.Utility;
     
    6566    private IFile nested_models_mo;
    6667   
    67     protected void setUp() throws ConnectException
     68    protected void setUp()
     69        throws ConnectException, CompilerInstantiationException
    6870    {
    6971        Area51Projects.createProjects();
     
    9092       
    9193        /* we need to load modelica package */
    92         OMCProxy.loadSystemLibrary();
     94        CompilerProxy.loadSystemLibrary();
    9395    }
    9496   
    9597    /**
    9698     * test OMCProxy.getRestrictionType()
     99     * @throws CompilerInstantiationException
    97100     */
    98101    public void testGetRestrictionType()
    99         throws ConnectException, UnexpectedReplyException
     102        throws ConnectException, UnexpectedReplyException,
     103            CompilerInstantiationException
    100104    {
    101         if (OMCProxy.getRestrictionType("Modelica") != Type.PACKAGE)
     105        if (CompilerProxy.getRestrictionType("Modelica") != Type.PACKAGE)
    102106        {
    103107            fail("Modelica class' restriction type is wrong");
    104108        }
    105         if (OMCProxy.getRestrictionType("Modelica.Blocks.Examples.BusUsage")
     109        if (CompilerProxy.getRestrictionType("Modelica.Blocks.Examples.BusUsage")
    106110                != Type.MODEL)
    107111        {
     
    109113                    "restriction type is wrong");
    110114        }
    111         if (OMCProxy.getRestrictionType("Modelica.Math.log")
     115        if (CompilerProxy.getRestrictionType("Modelica.Math.log")
    112116                != Type.FUNCTION)
    113117        {
    114118            fail("Modelica.Math.log class' restriction type is wrong");
    115119        }
    116         if (OMCProxy.getRestrictionType("Modelica.Icons.Record")
     120        if (CompilerProxy.getRestrictionType("Modelica.Icons.Record")
    117121                != Type.RECORD)
    118122        {
    119123            fail("Modelica.Icons.Record class' restriction type is wrong");
    120124        }
    121         if (OMCProxy.getRestrictionType("Modelica.Electrical.Analog.Interfaces.Pin")
     125        if (CompilerProxy.getRestrictionType("Modelica.Electrical.Analog.Interfaces.Pin")
    122126                != Type.CONNECTOR)
    123127        {
     
    125129                    "restriction type is wrong");
    126130        }
    127         if (OMCProxy.getRestrictionType("Modelica.Blocks.Continuous.Der")
     131        if (CompilerProxy.getRestrictionType("Modelica.Blocks.Continuous.Der")
    128132                != Type.BLOCK)
    129133        {
     
    131135                    "restriction type is wrong");
    132136        }
    133         if (OMCProxy.getRestrictionType("Modelica.SIunits.Lethargy")
     137        if (CompilerProxy.getRestrictionType("Modelica.SIunits.Lethargy")
    134138                != Type.TYPE)
    135139        {
     
    137141        }
    138142       
    139         OMCProxy.loadFileInteractive(nested_models_mo);
    140         if (OMCProxy.getRestrictionType("hepp.hehehe")
     143        CompilerProxy.loadFileInteractive(nested_models_mo);
     144        if (CompilerProxy.getRestrictionType("hepp.hehehe")
    141145                != Type.CLASS)
    142146        {
     
    144148        }
    145149    }
    146    
    147 //  /**
    148 //   * test OMCProxy.getPackages()
    149 //   */
    150 //  public void testGetPackages() throws CompilerException
    151 //  {
    152 //      OMCProxy.loadSystemLibrary();
    153 //      String[] str = OMCProxy.getPackages("Modelica");
    154 //     
    155 //      assertNotNull("Could not fetch Modelica package", str);
    156 //     
    157 //      Vector<String> packages = new Vector<String>();
    158 //      for(String s : str)
    159 //      {
    160 //          packages.addElement(s);
    161 //      }
    162 //     
    163 //      assertTrue(packages.containsAll(modelicaLibraryPackages));
    164 //  }
    165150   
    166151    /**
    167152     * test OMCProxy.getElementLocation()
     153     * @throws CompilerInstantiationException
    168154     */
    169155    public void testGetElementLocation()
    170         throws ConnectException, UnexpectedReplyException, InvocationError
     156        throws ConnectException, UnexpectedReplyException, InvocationError,
     157            CompilerInstantiationException
    171158    {
    172         OMCProxy.loadFileInteractive(nested_models_mo);
     159        CompilerProxy.loadFileInteractive(nested_models_mo);
    173160
    174161        /*
    175162         * we are basicaly only interested in getting the right line number
    176163         */
    177         ElementLocation loc = OMCProxy.getElementLocation("nested_models");     
     164        IElementLocation loc = CompilerProxy.getElementLocation("nested_models");       
    178165        assertTrue(loc.getPath().endsWith("nested_models.mo"));
    179166        assertEquals(loc.getLine(), 1);
    180167       
    181         loc = OMCProxy.getElementLocation("nested_models.hepp");       
     168        loc = CompilerProxy.getElementLocation("nested_models.hepp");       
    182169        assertEquals(loc.getLine(), 3);
    183170
    184         loc = OMCProxy.getElementLocation("nested_models.foo");     
     171        loc = CompilerProxy.getElementLocation("nested_models.foo");       
    185172        assertEquals(loc.getLine(), 4);
    186173       
    187         loc = OMCProxy.getElementLocation("nested_models.foo.bar");     
     174        loc = CompilerProxy.getElementLocation("nested_models.foo.bar");       
    188175        assertEquals(loc.getLine(), 5);
    189176       
    190         loc = OMCProxy.getElementLocation("muu");       
     177        loc = CompilerProxy.getElementLocation("muu");     
    191178        assertEquals(loc.getLine(), 8);
    192179       
    193         loc = OMCProxy.getElementLocation("foo");       
     180        loc = CompilerProxy.getElementLocation("foo");     
    194181        assertEquals(loc.getLine(), 14);
    195182
    196         loc = OMCProxy.getElementLocation("hej");       
     183        loc = CompilerProxy.getElementLocation("hej");     
    197184        assertEquals(loc.getLine(), 19);
    198185
    199         loc = OMCProxy.getElementLocation("hej.ine_paketen");       
     186        loc = CompilerProxy.getElementLocation("hej.ine_paketen");     
    200187        assertEquals(loc.getLine(), 20);
    201188
    202         loc = OMCProxy.getElementLocation("hej.hejhej");       
     189        loc = CompilerProxy.getElementLocation("hej.hejhej");       
    203190        assertEquals(loc.getLine(), 22);
    204191
    205         loc = OMCProxy.getElementLocation("hej.hejhej.foo");       
     192        loc = CompilerProxy.getElementLocation("hej.hejhej.foo");       
    206193        assertEquals(loc.getLine(), 23);
    207194
    208         loc = OMCProxy.getElementLocation("hepp");     
     195        loc = CompilerProxy.getElementLocation("hepp");     
    209196        assertEquals(loc.getLine(), 30);
    210197
    211         loc = OMCProxy.getElementLocation("hepp.hopp");     
     198        loc = CompilerProxy.getElementLocation("hepp.hopp");       
    212199        assertEquals(loc.getLine(), 31);
    213200
    214         loc = OMCProxy.getElementLocation("hepp.hehehe");       
     201        loc = CompilerProxy.getElementLocation("hepp.hehehe");     
    215202        assertEquals(loc.getLine(), 33);
    216203
Note: See TracChangeset for help on using the changeset viewer.