Author: vyemialyanchyk
Date: 2010-10-13 08:50:09 -0400 (Wed, 13 Oct 2010)
New Revision: 25783
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/testLaunchCfg_0.launch
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/testLaunchCfg_1.launch
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ExporterAttributesTest.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/LaunchConfigTestProject.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/utils/ResourceReadUtils.java
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/CodeGenXMLFactoryTest.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ConsolePluginAllTests.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/launchcfg/TestWorkingCopy.java
Log:
https://jira.jboss.org/browse/JBIDE-7285 - fixed
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/testLaunchCfg_0.launch
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/testLaunchCfg_0.launch
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/testLaunchCfg_0.launch 2010-10-13
12:50:09 UTC (rev 25783)
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="no"?>
+<launchConfiguration
type="org.hibernate.eclipse.launch.CodeGenerationLaunchConfigurationType">
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry
value="org.hibernate.eclipse.launch.CodeGenerationLaunchGroup"/>
+<listEntry
value="org.hibernate.eclipse.launch.ConsoleConfigurationLaunchGroup"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER"
value="org.eclipse.ant.ui.AntClasspathProvider"/>
+<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH"
value="true"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE"
value="org.hibernate.codegen.CodeGenMain"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS"
value="..../AppData/Local/Temp/codegenbuildxml/4fbe6bbb-9013-4ef2-8175-5b13f714ae00/build.xml"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR"
value="qwert"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS"
value="-cp
....\hibernate_eclipse_plugins_short\z-codegen\target\org.hibernate.codegen-1.0.0.GA.jar"/>
+<stringAttribute key="org.hibernate.tools.buildXml"
value="\qwert\target\build.xml"/>
+<stringAttribute key="org.hibernate.tools.codeGenLaunchJar"
value="....\trunk\hibernatetools\plugins\org.hibernate.eclipse\lib\extern\org.hibernate.codegen.jar"/>
+<stringAttribute key="org.hibernate.tools.configurationname"
value="qwert"/>
+<booleanAttribute key="org.hibernate.tools.ejb3"
value="true"/>
+<listAttribute key="org.hibernate.tools.exporters">
+<listEntry value="org.hibernate.tools.hbm2java"/>
+<listEntry value="org.hibernate.tools.hbm2hbmxml"/>
+<listEntry value="org.hibernate.tools.hbm2dao"/>
+<listEntry value="org.hibernate.tools.hbmtemplate"/>
+<listEntry value="org.hibernate.tools.hbm2cfgxml"/>
+<listEntry value="org.hibernate.tools.hbm2doc"/>
+<listEntry value="org.hibernate.tools.hbm2ddl"/>
+<listEntry value="8"/>
+<listEntry value="9"/>
+<listEntry value="10"/>
+<listEntry value="11"/>
+<listEntry value="12"/>
+<listEntry value="13"/>
+<listEntry value="14"/>
+<listEntry value="15"/>
+</listAttribute>
+<booleanAttribute key="org.hibernate.tools.exporters.10"
value="true"/>
+<stringAttribute key="org.hibernate.tools.exporters.10.extension_id"
value="org.hibernate.tools.hbm2java"/>
+<booleanAttribute key="org.hibernate.tools.exporters.11"
value="true"/>
+<stringAttribute key="org.hibernate.tools.exporters.11.extension_id"
value="org.hibernate.tools.hbmtemplate"/>
+<booleanAttribute key="org.hibernate.tools.exporters.12"
value="true"/>
+<stringAttribute key="org.hibernate.tools.exporters.12.extension_id"
value="org.hibernate.tools.hbm2cfgxml"/>
+<booleanAttribute key="org.hibernate.tools.exporters.13"
value="true"/>
+<stringAttribute key="org.hibernate.tools.exporters.13.extension_id"
value="org.hibernate.tools.hbm2hbmxml"/>
+<booleanAttribute key="org.hibernate.tools.exporters.14"
value="true"/>
+<stringAttribute key="org.hibernate.tools.exporters.14.extension_id"
value="org.hibernate.tools.hbm2doc"/>
+<booleanAttribute key="org.hibernate.tools.exporters.15"
value="true"/>
+<stringAttribute key="org.hibernate.tools.exporters.15.extension_id"
value="org.hibernate.tools.hbm2ddl"/>
+<booleanAttribute key="org.hibernate.tools.exporters.8"
value="true"/>
+<stringAttribute key="org.hibernate.tools.exporters.8.extension_id"
value="org.hibernate.tools.hbmtemplate"/>
+<mapAttribute key="org.hibernate.tools.exporters.8.properties">
+<mapEntry key="file_pattern"
value="{package-name}/{class-name}.java"/>
+<mapEntry key="for_each" value="11111111111111"/>
+<mapEntry key="outputdir"
value="\LaunchConfigTestProject\temp_test_out_folder"/>
+<mapEntry key="template_name" value="pojo/Pojo.ftl"/>
+<mapEntry key="template_path"
value="\LaunchConfigTestProject\temp_test_out_folder"/>
+</mapAttribute>
+<booleanAttribute key="org.hibernate.tools.exporters.9"
value="true"/>
+<stringAttribute key="org.hibernate.tools.exporters.9.extension_id"
value="org.hibernate.tools.hbm2dao"/>
+<booleanAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2cfgxml"
value="true"/>
+<stringAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2cfgxml.extension_id"
value="org.hibernate.tools.hbm2cfgxml"/>
+<mapAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2cfgxml.properties">
+<mapEntry key="outputdir"
value="\LaunchConfigTestProject\temp_test_out_folder"/>
+</mapAttribute>
+<booleanAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2dao"
value="true"/>
+<stringAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2dao.extension_id"
value="org.hibernate.tools.hbm2dao"/>
+<mapAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2dao.properties">
+<mapEntry key="outputdir"
value="\LaunchConfigTestProject\temp_test_out_folder"/>
+</mapAttribute>
+<booleanAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2ddl"
value="true"/>
+<stringAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2ddl.extension_id"
value="org.hibernate.tools.hbm2ddl"/>
+<mapAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2ddl.properties">
+<mapEntry key="outputFileName" value="schema.sql"/>
+<mapEntry key="outputdir"
value="\LaunchConfigTestProject\temp_test_out_folder"/>
+<mapEntry key="schemaUpdate" value="true"/>
+<mapEntry key="scriptToConsole" value="true"/>
+</mapAttribute>
+<booleanAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2doc"
value="true"/>
+<stringAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2doc.extension_id"
value="org.hibernate.tools.hbm2doc"/>
+<mapAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2doc.properties">
+<mapEntry key="outputdir"
value="\LaunchConfigTestProject\temp_test_out_folder"/>
+</mapAttribute>
+<booleanAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2hbmxml"
value="true"/>
+<stringAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2hbmxml.extension_id"
value="org.hibernate.tools.hbm2hbmxml"/>
+<mapAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2hbmxml.properties">
+<mapEntry key="outputdir"
value="\LaunchConfigTestProject\temp_test_out_folder"/>
+</mapAttribute>
+<booleanAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2java"
value="true"/>
+<stringAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2java.extension_id"
value="org.hibernate.tools.hbm2java"/>
+<mapAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2java.properties">
+<mapEntry key="destdir" value="qwerty"/>
+<mapEntry key="destdir2" value="qw"/>
+<mapEntry key="ejb3" value="true"/>
+<mapEntry key="jdk5" value="true"/>
+<mapEntry key="outputdir"
value="\LaunchConfigTestProject\temp_test_out_folder"/>
+</mapAttribute>
+<booleanAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbmtemplate"
value="true"/>
+<stringAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbmtemplate.extension_id"
value="org.hibernate.tools.hbmtemplate"/>
+<mapAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbmtemplate.properties">
+<mapEntry key="file_pattern"
value="${package-name}/${class-name}.java"/>
+<mapEntry key="for_each" value="entity"/>
+<mapEntry key="outputdir"
value="\LaunchConfigTestProject\temp_test_out_folder"/>
+<mapEntry key="template_name" value="pojo/Pojo.ftl"/>
+</mapAttribute>
+<booleanAttribute key="org.hibernate.tools.jdk5"
value="true"/>
+<stringAttribute key="org.hibernate.tools.outputdir"
value="\LaunchConfigTestProject\temp_test_out_folder"/>
+<stringAttribute key="org.hibernate.tools.package"
value="qqqqqqqqqqqqqqqqqqqqqqqqqqqq"/>
+<booleanAttribute key="org.hibernate.tools.prefercompositeids"
value="true"/>
+<booleanAttribute key="org.hibernate.tools.reveng.detect_many_to_many"
value="false"/>
+<booleanAttribute key="org.hibernate.tools.reveng.detect_one_to_one"
value="false"/>
+<booleanAttribute key="org.hibernate.tools.reveng.detect_optimistc_lock"
value="false"/>
+<stringAttribute key="org.hibernate.tools.revengfile"
value="\qwert\src\hibernate.reveng.xml"/>
+<booleanAttribute key="org.hibernate.tools.schema2hbm"
value="true"/>
+<booleanAttribute key="org.hibernate.tools.useExternalProcess"
value="true"/>
+<booleanAttribute key="org.hibernate.tools.useOwnTemplates"
value="false"/>
+</launchConfiguration>
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/testLaunchCfg_1.launch
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/testLaunchCfg_1.launch
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/testLaunchCfg_1.launch 2010-10-13
12:50:09 UTC (rev 25783)
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="no"?>
+<launchConfiguration
type="org.hibernate.eclipse.launch.CodeGenerationLaunchConfigurationType">
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry
value="org.hibernate.eclipse.launch.CodeGenerationLaunchGroup"/>
+<listEntry
value="org.hibernate.eclipse.launch.ConsoleConfigurationLaunchGroup"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER"
value="org.eclipse.ant.ui.AntClasspathProvider"/>
+<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH"
value="true"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE"
value="org.hibernate.codegen.CodeGenMain"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS"
value="...../AppData/Local/Temp/codegenbuildxml/4fbe6bbb-9013-4ef2-8175-5b13f714ae00/build.xml"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR"
value="qwert"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS"
value="-cp
....\hibernate_eclipse_plugins_short\z-codegen\target\org.hibernate.codegen-1.0.0.GA.jar"/>
+<stringAttribute key="org.hibernate.tools.buildXml"
value="\qwert\target\build.xml"/>
+<stringAttribute key="org.hibernate.tools.codeGenLaunchJar"
value="....\trunk\hibernatetools\plugins\org.hibernate.eclipse\lib\extern\org.hibernate.codegen.jar"/>
+<stringAttribute key="org.hibernate.tools.configurationname"
value="qwert"/>
+<booleanAttribute key="org.hibernate.tools.ejb3"
value="true"/>
+<listAttribute key="org.hibernate.tools.exporters">
+<listEntry value="org.hibernate.tools.hbm2java"/>
+<listEntry value="org.hibernate.tools.hbm2hbmxml"/>
+<listEntry value="org.hibernate.tools.hbm2dao"/>
+<listEntry value="org.hibernate.tools.hbmtemplate"/>
+<listEntry value="org.hibernate.tools.hbm2cfgxml"/>
+<listEntry value="org.hibernate.tools.hbm2doc"/>
+<listEntry value="org.hibernate.tools.hbm2ddl"/>
+<listEntry value="8"/>
+<listEntry value="9"/>
+<listEntry value="10"/>
+<listEntry value="11"/>
+<listEntry value="12"/>
+<listEntry value="13"/>
+<listEntry value="14"/>
+<listEntry value="15"/>
+</listAttribute>
+<booleanAttribute key="org.hibernate.tools.exporters.10"
value="true"/>
+<stringAttribute key="org.hibernate.tools.exporters.10.extension_id"
value="org.hibernate.tools.hbm2java"/>
+<booleanAttribute key="org.hibernate.tools.exporters.11"
value="true"/>
+<stringAttribute key="org.hibernate.tools.exporters.11.extension_id"
value="org.hibernate.tools.hbmtemplate"/>
+<booleanAttribute key="org.hibernate.tools.exporters.12"
value="true"/>
+<stringAttribute key="org.hibernate.tools.exporters.12.extension_id"
value="org.hibernate.tools.hbm2cfgxml"/>
+<booleanAttribute key="org.hibernate.tools.exporters.13"
value="true"/>
+<stringAttribute key="org.hibernate.tools.exporters.13.extension_id"
value="org.hibernate.tools.hbm2hbmxml"/>
+<booleanAttribute key="org.hibernate.tools.exporters.14"
value="true"/>
+<stringAttribute key="org.hibernate.tools.exporters.14.extension_id"
value="org.hibernate.tools.hbm2doc"/>
+<booleanAttribute key="org.hibernate.tools.exporters.15"
value="true"/>
+<stringAttribute key="org.hibernate.tools.exporters.15.extension_id"
value="org.hibernate.tools.hbm2ddl"/>
+<booleanAttribute key="org.hibernate.tools.exporters.8"
value="true"/>
+<stringAttribute key="org.hibernate.tools.exporters.8.extension_id"
value="org.hibernate.tools.hbmtemplate"/>
+<mapAttribute key="org.hibernate.tools.exporters.8.properties">
+<mapEntry key="file_pattern"
value="{package-name}/{class-name}.java"/>
+<mapEntry key="for_each" value="11111111111111"/>
+<mapEntry key="outputdir" value="temp_test_out_folder"/>
+<mapEntry key="template_name" value="pojo/Pojo.ftl"/>
+<mapEntry key="template_path"
value="\LaunchConfigTestProject\temp_test_out_folder"/>
+</mapAttribute>
+<booleanAttribute key="org.hibernate.tools.exporters.9"
value="true"/>
+<stringAttribute key="org.hibernate.tools.exporters.9.extension_id"
value="org.hibernate.tools.hbm2dao"/>
+<booleanAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2cfgxml"
value="true"/>
+<stringAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2cfgxml.extension_id"
value="org.hibernate.tools.hbm2cfgxml"/>
+<mapAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2cfgxml.properties">
+<mapEntry key="outputdir"
value="\LaunchConfigTestProject\temp_test_out_folder"/>
+</mapAttribute>
+<booleanAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2dao"
value="true"/>
+<stringAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2dao.extension_id"
value="org.hibernate.tools.hbm2dao"/>
+<mapAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2dao.properties">
+<mapEntry key="outputdir"
value="\LaunchConfigTestProject\temp_test_out_folder"/>
+</mapAttribute>
+<booleanAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2ddl"
value="true"/>
+<stringAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2ddl.extension_id"
value="org.hibernate.tools.hbm2ddl"/>
+<mapAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2ddl.properties">
+<mapEntry key="outputFileName" value="schema.sql"/>
+<mapEntry key="outputdir"
value="\LaunchConfigTestProject\temp_test_out_folder"/>
+<mapEntry key="schemaUpdate" value="true"/>
+<mapEntry key="scriptToConsole" value="true"/>
+</mapAttribute>
+<booleanAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2doc"
value="true"/>
+<stringAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2doc.extension_id"
value="org.hibernate.tools.hbm2doc"/>
+<mapAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2doc.properties">
+<mapEntry key="outputdir"
value="\LaunchConfigTestProject\temp_test_out_folder"/>
+</mapAttribute>
+<booleanAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2hbmxml"
value="true"/>
+<stringAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2hbmxml.extension_id"
value="org.hibernate.tools.hbm2hbmxml"/>
+<mapAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2hbmxml.properties">
+<mapEntry key="outputdir"
value="\LaunchConfigTestProject\temp_test_out_folder"/>
+</mapAttribute>
+<booleanAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2java"
value="true"/>
+<stringAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2java.extension_id"
value="org.hibernate.tools.hbm2java"/>
+<mapAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2java.properties">
+<mapEntry key="destdir" value="qwerty"/>
+<mapEntry key="destdir2" value="qw"/>
+<mapEntry key="ejb3" value="true"/>
+<mapEntry key="jdk5" value="true"/>
+<mapEntry key="outputdir"
value="\LaunchConfigTestProject\temp_test_out_folder"/>
+</mapAttribute>
+<booleanAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbmtemplate"
value="true"/>
+<stringAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbmtemplate.extension_id"
value="org.hibernate.tools.hbmtemplate"/>
+<mapAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbmtemplate.properties">
+<mapEntry key="file_pattern"
value="${package-name}/${class-name}.java"/>
+<mapEntry key="for_each" value="entity"/>
+<mapEntry key="outputdir"
value="\LaunchConfigTestProject\temp_test_out_folder"/>
+<mapEntry key="template_name" value="pojo/Pojo.ftl"/>
+</mapAttribute>
+<booleanAttribute key="org.hibernate.tools.jdk5"
value="true"/>
+<stringAttribute key="org.hibernate.tools.outputdir"
value="temp_test_out_folder_not_exist"/>
+<stringAttribute key="org.hibernate.tools.package"
value="qqqqqqqqqqqqqqqqqqqqqqqqqqqq"/>
+<booleanAttribute key="org.hibernate.tools.prefercompositeids"
value="true"/>
+<booleanAttribute key="org.hibernate.tools.reveng.detect_many_to_many"
value="false"/>
+<booleanAttribute key="org.hibernate.tools.reveng.detect_one_to_one"
value="false"/>
+<booleanAttribute key="org.hibernate.tools.reveng.detect_optimistc_lock"
value="false"/>
+<stringAttribute key="org.hibernate.tools.revengfile"
value="\qwert\src\hibernate.reveng.xml"/>
+<booleanAttribute key="org.hibernate.tools.schema2hbm"
value="true"/>
+<booleanAttribute key="org.hibernate.tools.useExternalProcess"
value="true"/>
+<booleanAttribute key="org.hibernate.tools.useOwnTemplates"
value="false"/>
+</launchConfiguration>
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/CodeGenXMLFactoryTest.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/CodeGenXMLFactoryTest.java 2010-10-13
11:56:09 UTC (rev 25782)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/CodeGenXMLFactoryTest.java 2010-10-13
12:50:09 UTC (rev 25783)
@@ -10,10 +10,7 @@
******************************************************************************/
package org.hibernate.eclipse.console.test;
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileReader;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
@@ -26,22 +23,18 @@
import java.util.Properties;
import java.util.TreeMap;
-import org.dom4j.Document;
-import org.dom4j.DocumentException;
-import org.dom4j.DocumentHelper;
-import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.datatools.connectivity.IConnectionProfile;
import org.eclipse.datatools.connectivity.internal.ConnectionProfile;
import org.eclipse.debug.core.ILaunchConfiguration;
-import org.hibernate.console.ConfigurationXMLFactory;
import org.hibernate.console.preferences.ConsoleConfigurationPreferences;
import org.hibernate.eclipse.console.ExtensionManager;
import org.hibernate.eclipse.console.model.impl.ExporterDefinition;
import org.hibernate.eclipse.console.model.impl.ExporterFactoryStrings;
import org.hibernate.eclipse.console.test.launchcfg.TestConsoleConfigurationPreferences;
import org.hibernate.eclipse.console.test.launchcfg.TestLaunchConfig;
+import org.hibernate.eclipse.console.test.utils.ResourceReadUtils;
import org.hibernate.eclipse.launch.CodeGenXMLFactory;
import org.hibernate.eclipse.launch.CodeGenerationStrings;
import org.hibernate.eclipse.launch.ExporterAttributes;
@@ -53,10 +46,6 @@
* @author Vitali Yemialyanchyk
*/
public class CodeGenXMLFactoryTest extends TestCase {
-
- public static final String LN_1 = "\n"; //$NON-NLS-1$
- public static final String LN_2 = "\r\n"; //$NON-NLS-1$
-
public static final String SAMPLE_PATH = "res/sample/"; //$NON-NLS-1$
public static final String PROJECT_LIB_PATH = "res/project/lib/";
//$NON-NLS-1$
@@ -242,28 +231,6 @@
}
}
- /**
- * Parse, i.e. adjust xml text so attributes for same xml
- * will be in one order.
- *
- * @param sample
- * @return adjusted xml
- */
- public String adjustXmlText(String sample) {
- Document doc = null;
- try {
- doc = DocumentHelper.parseText(sample);
- } catch (DocumentException e) {
- // ignore
- }
- if (doc == null) {
- return sample;
- }
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ConfigurationXMLFactory.dump(baos, doc.getRootElement());
- return baos.toString().trim();
- }
-
public void testCodeGenXMLFactoryRevengAll() {
TestLaunchConfig testLaunchConfig = createTestLaunchConfig(true, true, false);
CodeGenXMLFactory codeGenFactory = new CodeGenXMLFactory4TestSimple(testLaunchConfig);
@@ -494,41 +461,12 @@
return testLaunchConfig;
}
-
public String getSample(String fileName) {
- File resourceFile = null;
- try {
- resourceFile = getResourceItem(SAMPLE_PATH + fileName);
- } catch (IOException e1) {
- }
- if (resourceFile == null || !resourceFile.exists()) {
- return null;
- }
- StringBuffer cbuf = new StringBuffer((int) resourceFile.length());
- try {
- String ls = System.getProperties().getProperty("line.separator", LN_1);
//$NON-NLS-1$
- BufferedReader in = new BufferedReader(new FileReader(resourceFile));
- String str;
- while ((str = in.readLine()) != null) {
- cbuf.append(str + ls);
- }
- in.close();
- } catch (IOException e) {
- }
- return adjustXmlText(cbuf.toString());
+ return ResourceReadUtils.getSample(SAMPLE_PATH + fileName);
}
- protected File getResourceItem(String strResPath) throws IOException {
- IPath resourcePath = new Path(strResPath);
- File resourceFolder = resourcePath.toFile();
- URL entry = HibernateConsoleTestPlugin.getDefault().getBundle().getEntry(
- strResPath);
- String tplPrjLcStr = strResPath;
- if (entry != null) {
- URL resProject = FileLocator.resolve(entry);
- tplPrjLcStr = FileLocator.resolve(resProject).getFile();
- }
- resourceFolder = new File(tplPrjLcStr);
- return resourceFolder;
+ public String adjustXmlText(String sample) {
+ return ResourceReadUtils.adjustXmlText(sample);
}
+
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ConsolePluginAllTests.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ConsolePluginAllTests.java 2010-10-13
11:56:09 UTC (rev 25782)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ConsolePluginAllTests.java 2010-10-13
12:50:09 UTC (rev 25783)
@@ -34,6 +34,9 @@
//
https://jira.jboss.org/browse/JBIDE-6838
suite.addTestSuite(CodeGenXMLFactoryTest.class);
+ //
https://jira.jboss.org/browse/JBIDE-7285
+ suite.addTestSuite(ExporterAttributesTest.class);
+
// core tests
//Properties properties = new Properties();
//properties.load(ConsolePluginAllTests.class.getResourceAsStream("plugintest-hibernate.properties"));
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ExporterAttributesTest.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ExporterAttributesTest.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ExporterAttributesTest.java 2010-10-13
12:50:09 UTC (rev 25783)
@@ -0,0 +1,258 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.console.test;
+
+import java.io.InputStream;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.internal.core.LaunchManager;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.KnownConfigurations;
+import org.hibernate.eclipse.console.model.impl.ExporterFactory;
+import org.hibernate.eclipse.console.model.impl.ExporterFactoryStrings;
+import org.hibernate.eclipse.console.test.launchcfg.TestConsoleConfigurationPreferences;
+import org.hibernate.eclipse.console.test.project.LaunchConfigTestProject;
+import org.hibernate.eclipse.console.test.utils.ResourceReadUtils;
+import org.hibernate.eclipse.launch.CodeGenerationStrings;
+import org.hibernate.eclipse.launch.ExporterAttributes;
+import org.hibernate.tool.hbm2x.ArtifactCollector;
+import org.hibernate.tool.hbm2x.Exporter;
+import org.hibernate.tool.hbm2x.GenericExporter;
+import org.hibernate.tool.hbm2x.Hbm2DDLExporter;
+import org.hibernate.tool.hbm2x.QueryExporter;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Vitali Yemialyanchyk
+ */
+@SuppressWarnings("restriction")
+public class ExporterAttributesTest extends TestCase {
+
+ private ConsoleConfiguration consoleCfg;
+ private LaunchConfigTestProject project;
+ private LaunchManager launchManager = new LaunchManager();
+
+ public ExporterAttributesTest(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ this.project = new LaunchConfigTestProject();
+
+ TestConsoleConfigurationPreferences cfgprefs = new
TestConsoleConfigurationPreferences();
+ consoleCfg = new ConsoleConfiguration(cfgprefs);
+ KnownConfigurations.getInstance().addConfiguration(consoleCfg, true);
+ }
+
+ protected void tearDown() throws Exception {
+ this.project.deleteIProject();
+ this.project = null;
+
+ KnownConfigurations.getInstance().removeAllConfigurations();
+ consoleCfg = null;
+ }
+
+ public void testExporterAttributes() {
+ final String fileName_0 = LaunchConfigTestProject.LAUNCH_TEST_FILE_0;
+ checkCorrectLaunchConfigurationFile(fileName_0);
+ final String fileName_1 = LaunchConfigTestProject.LAUNCH_TEST_FILE_1;
+ checkIncorrectLaunchConfigurationFile(fileName_1);
+ }
+
+ @SuppressWarnings({ "rawtypes", "unused" })
+ public void checkCorrectLaunchConfigurationFile(final String fileName) {
+ // IWorkspace ws = ResourcesPlugin.getWorkspace();
+ String str1, str2;
+ ILaunchConfiguration launchConfig = loadLaunchConfigFromFile(fileName);
+ Map attrMap = null;
+ try {
+ attrMap = launchConfig.getAttributes();
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ assertNotNull(attrMap);
+ ExporterAttributes exporterAttributes = null;
+ try {
+ exporterAttributes = new ExporterAttributes(launchConfig);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ assertNotNull(exporterAttributes);
+ // check is configuration correct
+ assertNull(exporterAttributes.checkExporterAttributes());
+ List<ExporterFactory> exporterFactories =
exporterAttributes.getExporterFactories();
+ Set<ExporterFactory> selectedExporters = new HashSet<ExporterFactory>();
+ selectedExporters.addAll(exporterFactories);
+ Set<String> deletedExporterIds = new HashSet<String>();
+ ILaunchConfigurationWorkingCopy launchConfigWC = null;
+ try {
+ launchConfigWC = launchConfig.getWorkingCopy();
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ assertNotNull(launchConfigWC);
+ //
+ str1 = getProject().getSample(fileName);
+ str1 = ResourceReadUtils.adjustXmlText(str1);
+ //
+ assertNotNull(getProject());
+ assertNotNull(getProject().getIProject());
+ assertNotNull(getProject().getIProject().getFile(fileName));
+ //
+ InputStream is = null;
+ try {
+ is = getProject().getIProject().getFile(fileName).getContents();
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ assertNotNull(is);
+ str2 = ResourceReadUtils.readStream(is);
+ str2 = ResourceReadUtils.adjustXmlText(str2);
+ assertEquals(str1, str2);
+ // update and save lc - so fileName from the project updated
+ try {
+ ExporterAttributes.saveExporterFactories(launchConfigWC, exporterFactories,
+ selectedExporters, deletedExporterIds);
+ launchConfigWC.doSave();
+ } catch (CoreException e) {
+ fail(e.getMessage());
+ }
+ //
+ is = null;
+ try {
+ is = getProject().getIProject().getFile(fileName).getContents();
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ assertNotNull(is);
+ str2 = ResourceReadUtils.readStream(is);
+ str2 = ResourceReadUtils.adjustXmlText(str2);
+ assertEquals(str1, str2);
+ //
+ ArtifactCollector artifactCollector = new ArtifactCollector();
+ ExporterAttributes expAttr = exporterAttributes;
+ // Global properties
+ Properties props = new Properties();
+ props.put(CodeGenerationStrings.EJB3, "" + expAttr.isEJB3Enabled());
//$NON-NLS-1$
+ props.put(CodeGenerationStrings.JDK5, "" + expAttr.isJDK5Enabled());
//$NON-NLS-1$
+ consoleCfg.build();
+ Configuration cfg = consoleCfg.getConfiguration();
+ assertNotNull(cfg);
+ Set<String> outputDirectories = new HashSet<String>();
+ for (int i = 0; i < exporterFactories.size(); i++) {
+ Properties globalProperties = new Properties();
+ globalProperties.putAll(props);
+ ExporterFactory ef = exporterFactories.get(i);
+ //
+ Properties propsForTesting = new Properties();
+ propsForTesting.putAll(globalProperties);
+ propsForTesting.putAll(ef.getProperties());
+ //
+ Exporter exporter = null;
+ outputDirectories.clear();
+ try {
+ exporter = ef.createConfiguredExporter(cfg,
+ expAttr.getOutputPath(), expAttr.getTemplatePath(), globalProperties,
+ outputDirectories, artifactCollector);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ assertNotNull(exporter);
+ assertTrue(outputDirectories.size() > 0);
+ Properties propsFromExporter = exporter.getProperties();
+ String exporterDefinitionId = ef.getExporterDefinitionId();
+ // test special handling for GenericExporter
+ if (exporterDefinitionId.equals("org.hibernate.tools.hbmtemplate")) {
//$NON-NLS-1$
+ assertTrue(exporter instanceof GenericExporter);
+ assertNull(propsFromExporter.getProperty(ExporterFactoryStrings.FILE_PATTERN));
+ assertNull(propsFromExporter.getProperty(ExporterFactoryStrings.TEMPLATE_NAME));
+ assertNull(propsFromExporter.getProperty(ExporterFactoryStrings.FOR_EACH));
+ GenericExporter ge = (GenericExporter) exporter;
+ assertEquals(propsForTesting.getProperty(ExporterFactoryStrings.FILE_PATTERN),
ge.getFilePattern());
+ assertEquals(propsForTesting.getProperty(ExporterFactoryStrings.TEMPLATE_NAME),
ge.getTemplateName());
+ // to test GenericExporter should provide public getter but it doesn't
+ //assertEquals(propsForTesting.getProperty(ExporterFactoryStrings.FOR_EACH),
ge.getForEach());
+ }
+ // test special handling for Hbm2DDLExporter
+ if (exporterDefinitionId.equals("org.hibernate.tools.hbm2ddl")) {
//$NON-NLS-1$
+ assertTrue(exporter instanceof Hbm2DDLExporter);
+ assertNull(propsFromExporter.getProperty(ExporterFactoryStrings.EXPORTTODATABASE));
+ Hbm2DDLExporter ddlExporter = (Hbm2DDLExporter) exporter;
+ // to test Hbm2DDLExporter should provide public getter but it doesn't
+ //assertEquals(propsForTesting.getProperty(ExporterFactoryStrings.EXPORTTODATABASE),
ddlExporter.getExport());
+ }
+ // test special handling for QueryExporter
+ if (exporterDefinitionId.equals("org.hibernate.tools.query")) {
//$NON-NLS-1$
+ assertTrue(exporter instanceof QueryExporter);
+ assertNull(propsFromExporter.getProperty(ExporterFactoryStrings.QUERY_STRING));
+ assertNull(propsFromExporter.getProperty(ExporterFactoryStrings.OUTPUTFILENAME));
+ QueryExporter queryExporter = (QueryExporter)exporter;
+ // to test QueryExporter should provide public getter but it doesn't
+ //List<String> queryStrings = queryExporter.getQueries();
+ //assertEquals(1, queryStrings.size());
+ //assertEquals(propsForTesting.getProperty(ExporterFactoryStrings.QUERY_STRING),
queryStrings.get(0));
+ //assertEquals(propsForTesting.getProperty(ExporterFactoryStrings.OUTPUTFILENAME),
queryExporter.getFileName());
+ }
+ //try {
+ // exporter.start();
+ //} catch (HibernateException he) {
+ // he.printStackTrace();
+ //}
+ }
+ assertTrue(artifactCollector.getFileTypes().size() == 0);
+ }
+
+ @SuppressWarnings({ "rawtypes" })
+ public void checkIncorrectLaunchConfigurationFile(final String fileName) {
+ ILaunchConfiguration launchConfig = loadLaunchConfigFromFile(fileName);
+ Map attrMap = null;
+ try {
+ attrMap = launchConfig.getAttributes();
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ assertNotNull(attrMap);
+ ExporterAttributes exporterAttributes = null;
+ try {
+ exporterAttributes = new ExporterAttributes(launchConfig);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ assertNotNull(exporterAttributes);
+ // check is configuration correct
+ assertNotNull(exporterAttributes.checkExporterAttributes());
+ }
+
+ protected LaunchConfigTestProject getProject() {
+ return this.project;
+ }
+
+ public ILaunchConfiguration loadLaunchConfigFromFile(String fileName) {
+ IPath path = new Path(fileName);
+ IFile ifile = getProject().getIProject().getFile(path);
+ ILaunchConfiguration launchConfig = launchManager.getLaunchConfiguration((IFile)
ifile);
+ return launchConfig;
+ }
+}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/launchcfg/TestWorkingCopy.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/launchcfg/TestWorkingCopy.java 2010-10-13
11:56:09 UTC (rev 25782)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/launchcfg/TestWorkingCopy.java 2010-10-13
12:50:09 UTC (rev 25783)
@@ -93,11 +93,11 @@
}
public void setAttribute(String attributeName, boolean value) {
- Assert.fail(ConsoleTestMessages.RefactoringTest_method_not_tested);
+ attributes.put(attributeName, value);
}
- public void setAttributes(Map attributes) {
- Assert.fail(ConsoleTestMessages.RefactoringTest_method_not_tested);
+ public void setAttributes(Map attribs) {
+ attributes.putAll(attribs);
}
public void setContainer(IContainer container) {
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/LaunchConfigTestProject.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/LaunchConfigTestProject.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/LaunchConfigTestProject.java 2010-10-13
12:50:09 UTC (rev 25783)
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.console.test.project;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaModelException;
+import org.hibernate.eclipse.console.test.utils.ResourceReadUtils;
+
+/**
+ * @author Vitali Yemialyanchyk
+ */
+public class LaunchConfigTestProject extends TestProject {
+
+ public static final String TEST_TMP_OUT_FOLDER = "temp_test_out_folder";
//$NON-NLS-1$
+ public static final String PROJECT_PATH = "res/project/"; //$NON-NLS-1$
+ public static final String LAUNCH_TEST_FILE_0 = "testLaunchCfg_0.launch";
//$NON-NLS-1$
+ public static final String LAUNCH_TEST_FILE_1 = "testLaunchCfg_1.launch";
//$NON-NLS-1$
+
+ public LaunchConfigTestProject() {
+ super("LaunchConfigTestProject"); //$NON-NLS-1$
+ }
+
+ public LaunchConfigTestProject(String projectName) {
+ super(projectName);
+ }
+
+ protected void buildProject() throws JavaModelException, CoreException, IOException {
+ super.buildProject();
+ IPackageFragmentRoot tst = createFolder(TEST_TMP_OUT_FOLDER);
+ tst.getResource().refreshLocal(IResource.DEPTH_INFINITE, null);
+ importLaunchConfigFileToProject(LAUNCH_TEST_FILE_0);
+ importLaunchConfigFileToProject(LAUNCH_TEST_FILE_1);
+ }
+
+ public String getSample(String fileName) {
+ return ResourceReadUtils.getSample(PROJECT_PATH + fileName);
+ }
+
+ public void importLaunchConfigFileToProject(String fileName) throws CoreException {
+ getIProject().getFile(fileName).create(
+ new ByteArrayInputStream(getSample(fileName).getBytes()),
+ false, new NullProgressMonitor());
+ }
+}
+
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/utils/ResourceReadUtils.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/utils/ResourceReadUtils.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/utils/ResourceReadUtils.java 2010-10-13
12:50:09 UTC (rev 25783)
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.console.test.utils;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.hibernate.console.ConfigurationXMLFactory;
+import org.hibernate.eclipse.console.test.HibernateConsoleTestPlugin;
+
+/**
+ * @author Vitali Yemialyanchyk
+ */
+public class ResourceReadUtils {
+
+ public static final String LN_1 = "\n"; //$NON-NLS-1$
+ public static final String LN_2 = "\r\n"; //$NON-NLS-1$
+
+ /**
+ * Parse, i.e. adjust xml text so attributes for same xmls
+ * will be in one order.
+ *
+ * @param sample
+ * @return adjusted xml
+ */
+ public static String adjustXmlText(String sample) {
+ Document doc = null;
+ try {
+ doc = DocumentHelper.parseText(sample);
+ } catch (DocumentException e) {
+ // ignore
+ }
+ if (doc == null) {
+ return sample;
+ }
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ConfigurationXMLFactory.dump(baos, doc.getRootElement());
+ return baos.toString().trim();
+ }
+
+ public static String getSample(String fileName) {
+ File resourceFile = null;
+ try {
+ resourceFile = getResourceItem(fileName);
+ } catch (IOException e1) {
+ }
+ if (resourceFile == null || !resourceFile.exists()) {
+ return null;
+ }
+ StringBuffer cbuf = new StringBuffer((int) resourceFile.length());
+ try {
+ String ls = System.getProperties().getProperty("line.separator", LN_1);
//$NON-NLS-1$
+ BufferedReader in = new BufferedReader(new FileReader(resourceFile));
+ String str;
+ while ((str = in.readLine()) != null) {
+ cbuf.append(str + ls);
+ }
+ in.close();
+ } catch (IOException e) {
+ }
+ return adjustXmlText(cbuf.toString());
+ }
+
+ public static File getResourceItem(String strResPath) throws IOException {
+ IPath resourcePath = new Path(strResPath);
+ File resourceFolder = resourcePath.toFile();
+ URL entry = HibernateConsoleTestPlugin.getDefault().getBundle().getEntry(
+ strResPath);
+ String tplPrjLcStr = strResPath;
+ if (entry != null) {
+ URL resProject = FileLocator.resolve(entry);
+ tplPrjLcStr = FileLocator.resolve(resProject).getFile();
+ }
+ resourceFolder = new File(tplPrjLcStr);
+ return resourceFolder;
+ }
+
+ public static String readStream(InputStream is) {
+ StringBuffer sb = new StringBuffer(""); //$NON-NLS-1$
+ try {
+ byte[] b = new byte[4096];
+ while (true) {
+ int l = is.read(b, 0, b.length);
+ if (l < 0) {
+ break;
+ }
+ sb.append(new String(b, 0, l));
+ }
+ is.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return sb.toString();
+ }
+}
+