Author: dgolovin
Date: 2008-02-06 20:13:52 -0500 (Wed, 06 Feb 2008)
New Revision: 6139
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ConsoleConfigurationTest.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/HibernateConsoleTest.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestProject.java
Log:
fix for hibernate console tests errors
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ConsoleConfigurationTest.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ConsoleConfigurationTest.java 2008-02-06
22:16:02 UTC (rev 6138)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ConsoleConfigurationTest.java 2008-02-07
01:13:52 UTC (rev 6139)
@@ -1,11 +1,14 @@
package org.hibernate.eclipse.console.test;
import java.io.File;
+import java.io.IOException;
import java.net.URL;
import java.util.Properties;
import junit.framework.TestCase;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
import org.hibernate.SessionFactory;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.console.ConsoleConfigurationListener;
@@ -13,6 +16,7 @@
import org.hibernate.console.KnownConfigurations;
import org.hibernate.console.QueryPage;
import org.hibernate.console.preferences.ConsoleConfigurationPreferences;
+import org.osgi.framework.Bundle;
import org.w3c.dom.Element;
public class ConsoleConfigurationTest extends TestCase {
@@ -54,7 +58,15 @@
}
public File getConfigXMLFile() {
- return null;
+ File xmlConfig = null;
+ Bundle bundle = HibernateConsoleTestPlugin.getDefault().getBundle();
+ try {
+ URL url =
FileLocator.resolve(bundle.getEntry("/res/project/hibernate.cfg.xml"));
+ xmlConfig = new File(url.getFile());
+ } catch (IOException e) {
+ fail("Cannot find /res/project/hibernate.cfg.xml file");
+ }
+ return xmlConfig;
}
public Properties getProperties() {
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/HibernateConsoleTest.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/HibernateConsoleTest.java 2008-02-06
22:16:02 UTC (rev 6138)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/HibernateConsoleTest.java 2008-02-07
01:13:52 UTC (rev 6139)
@@ -1,9 +1,13 @@
package org.hibernate.eclipse.console.test;
+import java.util.logging.Logger;
+
import junit.framework.TestCase;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.jobs.IJobManager;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.ui.IPackagesViewPart;
import org.eclipse.jdt.ui.JavaUI;
@@ -106,10 +110,21 @@
* Wait until all background tasks are complete.
*/
public void waitForJobs() {
- while (Platform.getJobManager().currentJob() != null)
+ while (noMoreJobs())
delay(1000);
}
+ public boolean noMoreJobs() {
+ Job[] queuedJobs= Job.getJobManager().find(null);
+ for (int i= 0; i < queuedJobs.length; i++) {
+ Job entry= queuedJobs[i];
+ if (entry.getState() == Job.RUNNING || entry.getState() == Job.WAITING) {
+ return false;
+ }
+ }
+ return true;
+ }
+
protected SimpleTestProject getProject() {
return this.project;
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestProject.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestProject.java 2008-02-06
22:16:02 UTC (rev 6138)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestProject.java 2008-02-07
01:13:52 UTC (rev 6139)
@@ -14,6 +14,8 @@
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -27,6 +29,7 @@
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
@@ -38,6 +41,7 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.core.PackageFragmentRoot;
+import org.hibernate.eclipse.console.test.HibernateConsoleTestPlugin;
/**
@@ -109,13 +113,16 @@
project.delete(true, true, null);
}
- private void buildBigTestProject() throws JavaModelException, CoreException {
+ private void buildBigTestProject() throws JavaModelException, CoreException, IOException
{
project = buildNewProject(PROJECT_NAME);
javaProject = buildJavaProject(project);
-
IPath resourcePath = new Path(RESOURCE_PATH);
File resourceFolder = resourcePath.toFile();
+ URL entry =
HibernateConsoleTestPlugin.getDefault().getBundle().getEntry(RESOURCE_PATH);
+ URL resProject = FileLocator.resolve(entry);
+ String tplPrjLcStr= FileLocator.resolve(resProject).getFile();
+ resourceFolder = new File(tplPrjLcStr);
if (!resourceFolder.exists())
throw new RuntimeException("Folder " + RESOURCE_PATH + " not
found!");
@@ -340,7 +347,7 @@
StringWriter writer = new StringWriter();
int bytes_read;
while ((bytes_read = reader.read(buffer)) != -1)
- {
+ {resourceFolder.exists()
writer.write(buffer, 0, bytes_read);
}
return (writer.toString());
Show replies by date