[jbosstools-commits] JBoss Tools SVN: r23868 - in trunk/hibernatetools: tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Mon Aug 2 12:28:53 EDT 2010


Author: vyemialyanchyk
Date: 2010-08-02 12:28:53 -0400 (Mon, 02 Aug 2010)
New Revision: 23868

Modified:
   trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConfigurationXMLFactory.java
   trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConfigurationXMLStrings.java
   trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/CodeGenXMLFactoryTest.java
Log:
https://jira.jboss.org/browse/JBIDE-6518 - adjust after code review - simplify factories methods use

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConfigurationXMLFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConfigurationXMLFactory.java	2010-08-02 15:49:40 UTC (rev 23867)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConfigurationXMLFactory.java	2010-08-02 16:28:53 UTC (rev 23868)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007-2010 Red Hat, Inc.
+ * 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,
@@ -10,6 +10,7 @@
  ******************************************************************************/
 package org.hibernate.console;
 
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -113,6 +114,13 @@
 			el.addAttribute(prName, val);
 		}
 	}
+
+	public String createConfigurationXML() {
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		Element element = createRoot();
+		dump(baos, element);
+		return baos.toString();
+	}
 	
 	public static void dump(OutputStream os, Element element) {
 		// try to "pretty print" it

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConfigurationXMLStrings.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConfigurationXMLStrings.java	2010-08-02 15:49:40 UTC (rev 23867)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConfigurationXMLStrings.java	2010-08-02 16:28:53 UTC (rev 23868)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007-2010 Red Hat, Inc.
+ * 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,

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-08-02 15:49:40 UTC (rev 23867)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/CodeGenXMLFactoryTest.java	2010-08-02 16:28:53 UTC (rev 23868)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007-2010 Red Hat, Inc.
+ * 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,
@@ -11,7 +11,6 @@
 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;
@@ -24,12 +23,10 @@
 import java.util.List;
 import java.util.Map;
 
-import org.dom4j.Element;
 import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
 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;
@@ -139,40 +136,40 @@
 
 	public void testCodeGenXMLFactoryRevengAll() {
 		String codeGen = codeGenXMLFactory(true, true, false);
-		String specimen = getSpecimen("AntCodeGenReveng_test1.xml"); //$NON-NLS-1$
-		assertEquals(specimen.trim(), codeGen.trim().replaceAll("\n", "\r\n")); //$NON-NLS-1$ //$NON-NLS-2$
+		String specimen = getSample("AntCodeGenReveng_test1.xml"); //$NON-NLS-1$
+		assertEquals(specimen.trim(), codeGen.replaceAll("\n", "\r\n")); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	public void testCodeGenXMLFactoryRevengOne() {
 		String codeGen = codeGenXMLFactory(true, false, false);
-		String specimen = getSpecimen("AntCodeGenReveng_test2.xml"); //$NON-NLS-1$
-		assertEquals(specimen.trim(), codeGen.trim().replaceAll("\n", "\r\n")); //$NON-NLS-1$ //$NON-NLS-2$
+		String sample = getSample("AntCodeGenReveng_test2.xml"); //$NON-NLS-1$
+		assertEquals(sample.trim(), codeGen.replaceAll("\n", "\r\n")); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	public void testCodeGenXMLFactoryAll() {
 		String codeGen = codeGenXMLFactory(false, true, false);
-		String specimen = getSpecimen("AntCodeGen_test1.xml"); //$NON-NLS-1$
-		assertEquals(specimen.trim(), codeGen.trim().replaceAll("\n", "\r\n")); //$NON-NLS-1$ //$NON-NLS-2$
+		String sample = getSample("AntCodeGen_test1.xml"); //$NON-NLS-1$
+		assertEquals(sample.trim(), codeGen.replaceAll("\n", "\r\n")); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	public void testCodeGenXMLFactoryOne() {
 		String codeGen = codeGenXMLFactory(false, false, false);
-		String specimen = getSpecimen("AntCodeGen_test2.xml"); //$NON-NLS-1$
-		assertEquals(specimen.trim(), codeGen.trim().replaceAll("\n", "\r\n")); //$NON-NLS-1$ //$NON-NLS-2$
+		String sample = getSample("AntCodeGen_test2.xml"); //$NON-NLS-1$
+		assertEquals(sample.trim(), codeGen.replaceAll("\n", "\r\n")); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	public void testCodeGenXMLFactoryJpaAll() {
 		String codeGen = codeGenXMLFactory(false, true, true);
 		codeGen = updatePaths(codeGen);
-		String specimen = getSpecimen("AntCodeGenJpa_test1.xml"); //$NON-NLS-1$
-		assertEquals(specimen.trim(), codeGen.trim().replaceAll("\n", "\r\n")); //$NON-NLS-1$ //$NON-NLS-2$
+		String sample = getSample("AntCodeGenJpa_test1.xml"); //$NON-NLS-1$
+		assertEquals(sample.trim(), codeGen.replaceAll("\n", "\r\n")); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	public void testCodeGenXMLFactoryJpaOne() {
 		String codeGen = codeGenXMLFactory(false, false, true);
 		codeGen = updatePaths(codeGen);
-		String specimen = getSpecimen("AntCodeGenJpa_test2.xml"); //$NON-NLS-1$
-		assertEquals(specimen.trim(), codeGen.trim().replaceAll("\n", "\r\n")); //$NON-NLS-1$ //$NON-NLS-2$
+		String sample = getSample("AntCodeGenJpa_test2.xml"); //$NON-NLS-1$
+		assertEquals(sample.trim(), codeGen.replaceAll("\n", "\r\n")); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 	
 	public String updatePaths(String codeGen) {
@@ -219,15 +216,11 @@
 		testLCAttr.put(HBMTEMPLATE0_PROPERTIES, expProps2);
 		testLCAttr.put(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER, reveng);
 		TestLaunchConfig testLC = new TestLaunchConfig(testLCAttr);
-		CodeGenXMLFactory cgfXML = new CodeGenXMLFactory4Test(testLC, jpa);
-		Element rootBuildXml = cgfXML.createRoot();
-		ConfigurationXMLFactory.dump(System.out, rootBuildXml);
-		ByteArrayOutputStream baos = new ByteArrayOutputStream();
-		ConfigurationXMLFactory.dump(baos, rootBuildXml);
-		return baos.toString();
+		CodeGenXMLFactory codeGenFactory = new CodeGenXMLFactory4Test(testLC, jpa);
+		return codeGenFactory.createCodeGenXML();
 	}
 
-	public String getSpecimen(String fileName) {
+	public String getSample(String fileName) {
 		File resourceFile = null;
 		try {
 			resourceFile = getResourceItem(SAMPLE_PATH + fileName);



More information about the jbosstools-commits mailing list