protected void setUp() throws Exception { initialize(); buildWindow(); if (this.parentTest == null) { File scXmlLocation = FileTools.resourceFile("/SessionsXMLTestModel/XMLSchemaSessions.xml", getClass()); SCPlugin scPlugin = (SCPlugin) SCPluginFactory.instance() .createPlugin(buildWorkbenchContext().getApplicationContext()); projectNode = buildProjectNode( AllSCTests.loadSessions(scXmlLocation), scPlugin, buildWorkbenchContext().getApplicationContext()); // projectNode = (ProjectNode) scPlugin.open(scXmlLocation, buildWorkbenchContext()); } else { SCAbstractPanelTest test = (SCAbstractPanelTest) this.parentTest; projectNode = test.projectNode; } // Create the proper tree data so that the session nodes will be available TreeModelAdapter treeModel = new TreeModelAdapter(projectNode); treeModel.addTreeModelListener(buildTreeModelListener()); nodeHolder = buildNodeHolder(projectNode); selectionHolder = buildSelectionHolder(buildSelection()); super.setUp(); }
public void testLoadSchemaFromClasspath() throws ResourceException, URISyntaxException { String absoluteSchemaFilePath = FileTools.resourceFile("/schema/" + this.adjustSchemaName("BasicSchema.xsd")) .getAbsolutePath(); File testSchemasDirectory = new File(absoluteSchemaFilePath).getParentFile().getParentFile(); String testSchemasDirectoryPath = testSchemasDirectory.getPath(); String schemaResourceName = absoluteSchemaFilePath.substring(testSchemasDirectoryPath.length() + 1); // test schema not on classpath MWOXProject project = new MWOXProject( "Test Load Schema From Classpath", MappingsModelTestTools.buildSPIManager()); MWXmlSchemaRepository schemaRepository = project.getSchemaRepository(); try { schemaRepository.createSchemaFromClasspath("SchemaFromClasspath", schemaResourceName); assertTrue("ResourceException was not thrown.", false); } catch (ResourceException re) { } catch (Throwable t) { assertTrue("ResourceException was not thrown.", false); } // test schema on classpath project.getRepository().addClasspathEntry(testSchemasDirectoryPath); schemaRepository.createSchemaFromClasspath("SchemaFromClasspath", schemaResourceName); }
private void verifyJavaExport(MWRelationalProject project) throws Exception { this.configureDeploymentLogin(project); // write the project first, so it can be read via the command-line project.setSaveDirectory(this.tempDir); new ProjectIOManager().write(project); project.setProjectSourceDirectoryName(this.tempDir.getPath()); project.setProjectSourceClassName(this.className(project)); List classpathEntries = new ArrayList(); classpathEntries.add(this.tempDir.getAbsolutePath()); classpathEntries.add(Classpath.locationFor(MWProject.class)); // elmwcore.jar classpathEntries.add(Classpath.locationFor(JavaSourceGenerator.class)); // eclipselinkmw.jar classpathEntries.add(Classpath.locationFor(ValueHolderInterface.class)); // ecilpselink.jar classpathEntries.add(Classpath.locationFor(XMLParserConfiguration.class)); // xercesImpl.jar classpathEntries.add( FileTools.resourceFile("/platforms.dpr").getParentFile().getAbsolutePath()); // config dir Classpath classpath = new Classpath(classpathEntries); String input = project.saveFile().getAbsolutePath(); String output = project.projectSourceFile().getAbsolutePath(); // String log = new File(this.tempDir, "JavaSourceGenerator.log").getAbsolutePath(); String[] args = new String[] {input, output}; JavaTools.java(JavaSourceGenerator.class.getName(), classpath.path(), args); // JavaSourceGenerator.main(args); this.compileAndCheckJavaExport(project); }
private void showErrorReadOnlyMessage(WorkbenchContext workbenchContext) { String fileName = FileTools.canonicalFile(topLinkSessions().getPath()).getPath(); String message = resourceRepository() .getString( "SAVE_READ_ONLY_ERROR_MESSAGE", workbenchContext.getApplicationContext().getApplication().getShortProductName(), fileName, StringTools.CR); LabelArea label = new LabelArea(message); JOptionPane.showMessageDialog( workbenchContext.getCurrentWindow(), label, workbenchContext.getApplicationContext().getApplication().getShortProductName(), JOptionPane.WARNING_MESSAGE); }
public void testLoadingTopLinkSessions() throws Exception { URL url = getClass().getResource("/toplink.sessions.xml.zip"); assertTrue("File missing: toplink.sessions.xml.zip", url != null); File location = FileTools.buildFile(url); ZipFile zipFile = new ZipFile(location); Vector exceptions = new Vector(); int count = 0; for (Enumeration enumeration = zipFile.entries(); enumeration.hasMoreElements(); ) { ZipEntry entry = (ZipEntry) enumeration.nextElement(); if (!entry.isDirectory()) { File file = null; // Copy the content from the zip entry into a "unzipped" file try { file = prepareSessionsXmlFile(zipFile, entry); readSessionsXml(file); count++; } catch (Throwable e) { exceptions.add(new Problem(file, e)); } // Clean after if (file != null) { file.delete(); } } } if (exceptions.isEmpty()) { assertEquals("The number of file read is not accurate.", count, 70); } else { showResults(exceptions); } }
public void testLoadSchemaFromFile() throws ResourceException, URISyntaxException { String absoluteSchemaFilePath = FileTools.resourceFile("/schema/" + this.adjustSchemaName("BasicSchema.xsd")) .getAbsolutePath(); File testSchemasDirectory = new File(absoluteSchemaFilePath).getParentFile().getParentFile(); String testSchemasDirectoryPath = testSchemasDirectory.getPath(); String relativeSchemaFilePath = "." + absoluteSchemaFilePath.substring(testSchemasDirectoryPath.length()); MWOXProject project = new MWOXProject("Test Load Schema From File", MappingsModelTestTools.buildSPIManager()); project.setSaveDirectory(testSchemasDirectory); MWXmlSchemaRepository repository = project.getSchemaRepository(); // test absolute file location MWXmlSchema absolutePathSchema = repository.createSchemaFromFile("AbsolutePathSchemaFromFile", absoluteSchemaFilePath); absolutePathSchema.reload(); // test relative file location MWXmlSchema relativePathSchema = repository.createSchemaFromFile("RelativePathSchemaFromFile", relativeSchemaFilePath); relativePathSchema.reload(); }