Changeset 1235 for trunk/org.modelica.mdt.test
- Timestamp:
- 01/24/12 21:44:17 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/org.modelica.mdt.test/src/org/modelica/mdt/test/TestStandardLibrary.java
r1096 r1235 41 41 42 42 package org.modelica.mdt.test; 43 44 import static org.junit.Assert.assertEquals; 45 import static org.junit.Assert.assertFalse; 46 import static org.junit.Assert.assertNotNull; 47 import static org.junit.Assert.assertNull; 48 import static org.junit.Assert.assertTrue; 43 49 44 50 import java.util.Collection; … … 66 72 import org.osgi.framework.BundleException; 67 73 68 import static org.junit.Assert.assertEquals;69 import static org.junit.Assert.assertFalse;70 import static org.junit.Assert.assertNotNull;71 import static org.junit.Assert.assertNull;72 import static org.junit.Assert.assertTrue;73 74 74 /** 75 75 * Do some sanity checks regarding the standard library … … 77 77 public class TestStandardLibrary { 78 78 private IStandardLibrary standardLibrary; 79 79 80 80 @org.junit.Before 81 81 public void setUp() throws BundleException { 82 /* 83 * the adapter factory that handles standard library object 84 * is installed by the org.modelica.mdt.ui plugin, 85 * make sure it is loaded before running tests 86 */ 82 // the adapter factory that handles standard library object 83 // is installed by the org.modelica.mdt.ui plugin, 84 // make sure it is loaded before running tests 87 85 Bundle bundle = Platform.getBundle("org.modelica.mdt.ui"); 88 86 bundle.start(); 89 87 90 88 IModelicaRoot modelicaRoot = ModelicaCore.getModelicaRoot(); 91 89 standardLibrary = modelicaRoot.getStandardLibrary(null); … … 102 100 @org.junit.Test 103 101 public void testStandardLibraryAdapter() { 104 / * check if standard library object is adaptable */105 assertTrue("standard library object must be adaptable",106 (standardLibrary instanceof IAdaptable));107 108 / * check if we can convert standard library to workbench adapter */102 // check if standard library object is adaptable 103 boolean instanceOfIAdaptable = standardLibrary instanceof IAdaptable; 104 assertTrue("standard library object must be adaptable", instanceOfIAdaptable); 105 106 // check if we can convert standard library to workbench adapter 109 107 IWorkbenchAdapter wbAdapter = 110 (IWorkbenchAdapter)standardLibrary.getAdapter(IWorkbenchAdapter.class);108 (IWorkbenchAdapter)standardLibrary.getAdapter(IWorkbenchAdapter.class); 111 109 112 110 assertNotNull("could not fetch workbench adapter", wbAdapter); 113 114 /* FIXME : wbAdapter.getLabel(standardLibrary) is returning something weird right now, 115 * at least on Windows, let's disable this test until we can investigate. */ 111 116 112 String label = wbAdapter.getLabel(standardLibrary); 117 assertEquals("wrong label", "Standard Library", label); 113 assertTrue("wrong label", label.startsWith("Libraries: ")); 114 assertTrue("wrong label", label.endsWith("omlibrary")); 118 115 ImageDescriptor imageDescriptor = wbAdapter.getImageDescriptor(standardLibrary); 119 116 assertNotNull("no image provided", imageDescriptor); … … 125 122 @org.junit.Test 126 123 public void testStandardLibraryElements() 127 throws ConnectException, UnexpectedReplyException, InvocationError, CompilerInstantiationException, CoreException {128 / * Fetch the Modelica package from the standard library. */124 throws ConnectException, UnexpectedReplyException, InvocationError, CompilerInstantiationException, CoreException { 125 // Fetch the Modelica package from the standard library. 129 126 Collection<IModelicaClass> packages = standardLibrary.getPackages(); 130 127 InnerClass modelica = null; 131 132 String desiredPackageName = "Modelica 3.2";133 128 129 String desiredPackageName = "Modelica"; 130 134 131 for (IModelicaClass modelicaClass : packages) { 135 132 String elementName = modelicaClass.getElementName(); 136 133 137 134 if (elementName.equals(desiredPackageName)) { 138 135 modelica = (InnerClass)modelicaClass; … … 142 139 assertNotNull("Could not find standard library package \"" + desiredPackageName + "\".", modelica); 143 140 144 /* 145 * do checks on Modelica package 146 */ 141 // do checks on Modelica package 147 142 IResource modelicaResource = modelica.getResource(); 148 143 assertNull("Standard library should be defined outside of workspace.", modelicaResource); … … 150 145 boolean modelicaFilePathEmpty = modelicaFilePath.equals(""); 151 146 assertFalse("Empty path to the source file.", modelicaFilePathEmpty); 152 // IRegion reg = modelica.getLocation(); 153 // assertTrue("negative element region can't be", reg.getOffset() >= 0); 154 // assertTrue("elements length must be positive", reg.getLength() > 0); 155 156 /* 157 * do checks on Modelica.Blocks and Modelica.Constants packages 158 */ 147 //IRegion reg = modelica.getLocation(); 148 //assertTrue("negative element region can't be", reg.getOffset() >= 0); 149 //assertTrue("elements length must be positive", reg.getLength() > 0); 150 151 // do checks on Modelica.Blocks and Modelica.Constants packages 159 152 InnerClass blocks = null; 160 153 InnerClass constants = null; … … 162 155 for (IModelicaElement el : modelicaChildren) { 163 156 String name = el.getElementName(); 164 157 165 158 if (name.equals("Blocks")) { 166 159 blocks = (InnerClass)el; … … 170 163 } 171 164 } 172 173 / * check Modelica.Blocks */165 166 // check Modelica.Blocks 174 167 assertNotNull("Could not find package Modelica.Blocks in standard library.", blocks); 175 168 IResource blocksResource = blocks.getResource(); … … 178 171 boolean blocksFilePathEmpty = blocksFilePath.equals(""); 179 172 assertFalse("Empty path to the source file.", blocksFilePathEmpty); 180 //reg = blocks.getLocation();181 //assertTrue("negative element region can't be", reg.getOffset() >= 0);182 //assertTrue("elements length must be positive", reg.getLength() > 0);183 184 / * check Modelica.Blocks imports */173 //reg = blocks.getLocation(); 174 //assertTrue("negative element region can't be", reg.getOffset() >= 0); 175 //assertTrue("elements length must be positive", reg.getLength() > 0); 176 177 // check Modelica.Blocks imports 185 178 boolean foundSIimport = false; 186 179 Collection<IModelicaImport> blocksImports = blocks.getImports(); … … 194 187 } 195 188 break; 196 / * ignore all other types of imports */189 // ignore all other types of imports 197 190 } 198 191 } 199 192 assertTrue("Could not find the representation of 'import SI = Modelica.SIunits;' statement", foundSIimport); 200 201 /* check Modelica.Constants */ 202 193 194 // check Modelica.Constants 203 195 assertNotNull("Could not find package Modelica.Constants in standard library.", constants); 204 196 IResource constantsResource = constants.getResource(); … … 207 199 boolean constantsFilePathEmpty = constantsFilePath.equals(""); 208 200 assertFalse("Empty path to the source file", constantsFilePathEmpty); 209 // reg = constants.getLocation(); 210 // assertTrue("negative element region can't be", reg.getOffset() >= 0); 211 // assertTrue("elements length must be positive", reg.getLength() > 0); 212 213 /* 214 * do checks on Modelica.Constants components 215 */ 201 //reg = constants.getLocation(); 202 //assertTrue("negative element region can't be", reg.getOffset() >= 0); 203 //assertTrue("elements length must be positive", reg.getLength() > 0); 204 205 // do checks on Modelica.Constants components 216 206 Collection<IModelicaElement> constantsChildren = constants.getChildren(); 217 207 IModelicaComponent pi = null; … … 219 209 for (IModelicaElement el : constantsChildren) { 220 210 String name = el.getElementName(); 221 211 222 212 if (name.equals("pi")) { 223 213 pi = (IModelicaComponent)el; … … 228 218 } 229 219 230 / * check Modelica.Constants.pi */220 // check Modelica.Constants.pi 231 221 assertNotNull("Could not find package Modelica.Constants.pi in standard library.", pi); 232 222 IModelicaComponent.Visibility piVisibility = pi.getVisibility(); … … 237 227 boolean piFilePathEmpty = piFilePath.equals(""); 238 228 assertFalse("Empty path to the source file.", piFilePathEmpty); 239 //reg = pi.getLocation();240 //assertTrue("negative element region can't be", reg.getOffset() >= 0);241 //assertTrue("elements length must be positive", reg.getLength() > 0);242 243 / * check Modelica.Constants.D2R */229 //reg = pi.getLocation(); 230 //assertTrue("negative element region can't be", reg.getOffset() >= 0); 231 //assertTrue("elements length must be positive", reg.getLength() > 0); 232 233 // check Modelica.Constants.D2R 244 234 assertNotNull("Could not find package Modelica.Constants.pi in standard library.", D2R); 245 235 IModelicaComponent.Visibility d2rVisibility = D2R.getVisibility(); … … 250 240 boolean d2rFilePathEmpty = d2rFilePath.equals(""); 251 241 assertFalse("Empty path to the source file.", d2rFilePathEmpty); 252 //reg = pi.getLocation();253 //assertTrue("negative element region can't be", reg.getOffset() >= 0);254 //assertTrue("elements length must be positive", reg.getLength() > 0);255 256 / * check Modelica.Constants imports */242 //reg = pi.getLocation(); 243 //assertTrue("negative element region can't be", reg.getOffset() >= 0); 244 //assertTrue("elements length must be positive", reg.getLength() > 0); 245 246 // check Modelica.Constants imports 257 247 foundSIimport = false; 258 248 boolean foundNonSIimport = false; … … 271 261 } 272 262 break; 273 / * ignore all other types of imports */274 } 275 } 276 263 // ignore all other types of imports 264 } 265 } 266 277 267 assertTrue("Could not find the representation of 'import SI = Modelica.SIunits;' statement", foundSIimport); 278 268 assertTrue("Could not find the representation of 'import NonSI = Modelica.SIunits.Conversions.NonSIunits;' statement", foundNonSIimport);
Note: See TracChangeset
for help on using the changeset viewer.