You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by pp...@apache.org on 2010/10/13 21:35:11 UTC

svn commit: r1022256 - in /openjpa/tools/trunk/openjpa-tools/src: main/java/org/apache/openjpa/tools/ main/java/org/apache/openjpa/tools/action/ main/java/org/apache/openjpa/tools/util/ main/resources/org/apache/openjpa/tools/ test/java/org/apache/open...

Author: ppoddar
Date: Wed Oct 13 19:35:11 2010
New Revision: 1022256

URL: http://svn.apache.org/viewvc?rev=1022256&view=rev
Log:
Add standard OpenJPA logging support instead of JDK style logging

Added:
    openjpa/tools/trunk/openjpa-tools/src/main/resources/org/apache/openjpa/tools/localizer.properties   (with props)
Removed:
    openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/util/LogRecordFormatter.java
Modified:
    openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/MigrationTool.java
    openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/action/Actions.java
    openjpa/tools/trunk/openjpa-tools/src/test/java/org/apache/openjpa/tools/TestMigratedOutput.java

Modified: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/MigrationTool.java
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/MigrationTool.java?rev=1022256&r1=1022255&r2=1022256&view=diff
==============================================================================
--- openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/MigrationTool.java (original)
+++ openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/MigrationTool.java Wed Oct 13 19:35:11 2010
@@ -47,10 +47,15 @@ import javax.xml.transform.TransformerFa
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 
+import org.apache.openjpa.conf.OpenJPAConfiguration;
+import org.apache.openjpa.lib.log.Log;
+import org.apache.openjpa.lib.log.LogFactoryImpl;
+import org.apache.openjpa.lib.log.LogFactoryImpl.LogImpl;
 import org.apache.openjpa.lib.util.Files;
+import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.lib.util.Options;
 import org.apache.openjpa.tools.action.Actions;
-import org.apache.openjpa.tools.util.LogRecordFormatter;
+import org.apache.openjpa.util.UserException;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Comment;
 import org.w3c.dom.Document;
@@ -123,17 +128,15 @@ public class MigrationTool  {
      * Standard JDK logger with a specialized formatter to augment location information
      * in the input document from the SAX parser.
      */
-    private Logger             _logger;
-    private LogRecordFormatter _formatter;
+    private static LogImpl             _logger;
+    private static final Localizer _loc = Localizer.forPackage(MigrationTool.class);
 
     public static void main(String[] args) throws Exception {
+        _logger = (LogImpl)new LogFactoryImpl().getLog(OpenJPAConfiguration.LOG_TOOL);
     	new MigrationTool().run(args);
     }
     
     public void run(String[] args) throws Exception {
-        _logger = Logger.getLogger(getClass().getPackage().getName());
-        _formatter = new LogRecordFormatter();
-        
     	Properties defaults = new Properties();
     	defaults.setProperty("output", "stdout");
     	defaults.setProperty("error",  "stderr");
@@ -172,21 +175,21 @@ public class MigrationTool  {
     
     public void setInput(String input) {
     	_input = getInputStream(input);
-        _formatter.setSource(input);
     }
     
     public void setOutput(String output) {
     	try {
     		_output = Files.getOutputStream(output, Thread.currentThread().getContextClassLoader());
+            _logger.info(_loc.get("output-resource", output));
     	} catch (Exception ex) {
     		try {
-    			String[] paths = output.split(File.separator);
     			File file = new File(output);
     			file.mkdirs();
     			file.createNewFile();
     			_output = new FileOutputStream(file);
+                _logger.info(_loc.get("output-file", file));
     		} catch (IOException e) {
-    			throw new RuntimeException("Error creating [" + output + "]", e);
+    			throw new UserException(_loc.get("output-bad", output), e);
     		}
     	}
     }
@@ -200,9 +203,6 @@ public class MigrationTool  {
         } else {
             handler = new FileHandler(errorOutput, false);
         }
-        _logger.setUseParentHandlers(false);
-        handler.setFormatter(_formatter);
-        _logger.addHandler(handler);
     }
     
     public void setActions(String actions) throws Exception {
@@ -210,7 +210,7 @@ public class MigrationTool  {
     }
     
     public void setVerbose(boolean verbose) {
-        _logger.setLevel(verbose ? Level.INFO : Level.WARNING);
+        _logger.setLevel(verbose ? Log.TRACE : Log.INFO);
     }
     
     /**
@@ -239,7 +239,7 @@ public class MigrationTool  {
         for (int i = 0; i < M; i++) {
             Element element = (Element)actions.item(i);
             String sourceTag = element.getAttribute("for");
-            _logger.info("Building action list for [" + sourceTag + "]");
+            _logger.info(_loc.get("action-build", sourceTag));
             actionMap.put(sourceTag, createAction(element));
         }
         is.close();
@@ -268,7 +268,7 @@ public class MigrationTool  {
                 return c.getTemplate(e);
             }
         }
-        throw new RuntimeException("No action for " + e.getNodeName());
+        throw new RuntimeException(_loc.get("element-action-missing", e.getNodeName()).toString());
     }
     
     void addSchemaToRoot() {
@@ -309,13 +309,12 @@ public class MigrationTool  {
     protected Element executeActions(Document target, Element source, Element current) {
         List<Actions> actions = actionMap.get(source.getNodeName());
         if (actions == null) {
-            _logger.severe("Element [" +  source.getNodeName() + "] is unknown");
-            throw new RuntimeException("No action for element [" +  source.getNodeName() + "]");
+            throw new RuntimeException(_loc.get("element-unknown", source.getNodeName()).toString());
         }
         if (actions.isEmpty()) {
             return null;
         }
-        _logger.info("Processing source [" + source.getNodeName() + "] with " + actions.size() + " actions");
+        _logger.info(_loc.get("element-process", source.getNodeName(), actions.size()));
         List<String> consumedAttrs = new ArrayList<String>();
         List<String> consumedElements = new ArrayList<String>();
         
@@ -323,15 +322,12 @@ public class MigrationTool  {
         Actions action = actions.get(0);
         Element newElement = (Element)action.run(target, source, current, consumedAttrs, consumedElements, _logger);
         if (newElement == null) {
-            throw new RuntimeException("The first action " + action + " returned a null element." + 
-                    "But the root element can not be null");
+            throw new RuntimeException(_loc.get("root-action-null", action).toString());
         }
         Element root = newElement;
         
         for (int i = 1; i < actions.size(); i++) {
             action = actions.get(i);
-            _logger.info("Processing source [" + source.getNodeName() + "] "
-                + i + "-th Action " + action.getClass().getSimpleName()); 
             Node newNode = action.run(target, source, root, consumedAttrs, consumedElements, _logger);
             
             if (newNode != null) {
@@ -353,7 +349,7 @@ public class MigrationTool  {
                 case RENAME_NODE:
                     break;
                 default:
-                    throw new RuntimeException("Result of " + action + " not handled");
+                    throw new RuntimeException(_loc.get("action-not-processed", action).toString());
                 }
             }
         }
@@ -373,7 +369,7 @@ public class MigrationTool  {
         leftoverAttrNames.removeAll(consumedAttrs);
         if (!leftoverAttrNames.isEmpty()) {
             for (String a : leftoverAttrNames) {
-                _logger.warning("Attribute [" + a + "] is not processed");
+                _logger.warn(_loc.get("attr-skipped", a));
             }
         }
         return newElement;
@@ -403,14 +399,19 @@ public class MigrationTool  {
         return names;
     }
     
-    private InputStream getInputStream(String v) {
-        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(v);
-        if (is != null)
+    private InputStream getInputStream(String resource) {
+        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
+        if (is != null) {
+            _logger.info(_loc.get("input-resource", resource));
             return is;
+        }
         try {
-            return new FileInputStream(new File(v));
+            File file = new File(resource);
+            is = new FileInputStream(file);
+            _logger.info(_loc.get("input-file", file));
+            return is;
         } catch (Exception e) {
-            throw new RuntimeException(this + " can not convert [" + v + "] into an input stream", e);
+            throw new UserException(_loc.get("input-bad", resource), e);
         }
     }
     

Modified: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/action/Actions.java
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/action/Actions.java?rev=1022256&r1=1022255&r2=1022256&view=diff
==============================================================================
--- openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/action/Actions.java (original)
+++ openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/action/Actions.java Wed Oct 13 19:35:11 2010
@@ -24,8 +24,11 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.logging.Logger;
 
+import org.apache.openjpa.lib.log.Log;
+import org.apache.openjpa.lib.util.Localizer;
+import org.apache.openjpa.tools.MigrationTool;
+import org.apache.openjpa.util.UserException;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -54,6 +57,12 @@ import org.w3c.dom.NodeList;
  *
  */
 public interface Actions {
+    static final Localizer _loc = Localizer.forPackage(MigrationTool.class);
+    static final String TO    = "to";
+    static final String FROM  = "from";
+    static final String NAME  = "name";
+    static final String WARN  = "warn";
+    
     /**
      * Get the enumeration code of this action.
      * Actions are orderable based on the ordinal values of this enumeration.
@@ -76,7 +85,7 @@ public interface Actions {
      * this action have skipped the given source.  
      */
     public Node run(Document targetDoc, Element source, Element current,
-            Collection<String> consumedAttrs, Collection<String> consumedElements, Logger logger);
+            Collection<String> consumedAttrs, Collection<String> consumedElements, Log logger);
     
     
     /**
@@ -146,10 +155,11 @@ public interface Actions {
         
         protected final Element original;
         protected final Code order;
-        
+        protected boolean silent;
         protected Abstract(Code o, Element s) {
             order    = o;
             original = s;
+            silent = "false".equalsIgnoreCase(s.getAttribute(WARN));
         }
         
         
@@ -166,8 +176,7 @@ public interface Actions {
          */
         protected String getAttribute(String attrName) {
             if (!original.hasAttribute(attrName)) {
-                throw new IllegalArgumentException(this + " requires the input element must " +
-                        " have an attribute [" + attrName + "]");
+                throw new IllegalArgumentException(_loc.get("attr-missing", this, attrName).toString());
             }
             return original.getAttribute(attrName);
         }
@@ -180,9 +189,7 @@ public interface Actions {
         protected String getAttribute(String attrName, String defValue) {
             if (!original.hasAttribute(attrName)) {
                 if (defValue == null || defValue.trim().length() == 0) {
-                    throw new IllegalArgumentException(this + " requires the input element must " +
-                        " have an attribute [" + attrName + "] or defaulted by the value of [" +
-                        defValue + "]");
+                    throw new IllegalArgumentException(_loc.get("attr-missing-def", this, attrName).toString());
                 } else {
                     return defValue;
                 }
@@ -190,19 +197,28 @@ public interface Actions {
             return original.getAttribute(attrName);
         }
         
-        protected Element getElementByName(Element base, String name, boolean mustExist) {
-            NodeList nodes = base.getElementsByTagName(name);
+        /**
+         * Gets single child element of the given base element. If the parent does not have exactly one child
+         * of the given name then an error is raised.
+         *  
+         * @param base parent element
+         * @param name name of the child element
+         * @param mustExist if true raises exception on absent child  
+         * @return
+         */
+        protected Element getElementByName(Element parent, String child, boolean mustExist) {
+            NodeList nodes = parent.getElementsByTagName(child);
             int N = nodes.getLength();
             if (N == 0) {
                 if (mustExist)
-                    throw new IllegalArgumentException(base.getNodeName() + " must have a [" + name 
-                            + "] sub-element");
+                    throw new IllegalArgumentException(_loc.get("element-child-missing", 
+                        parent.getNodeName(), child).toString()); 
                 else
                     return null;
             } else if (N > 1) {
                 if (mustExist)
-                    throw new IllegalArgumentException(base.getNodeName() + " must have a single " +
-                            "[" + name + "] sub-element but has " + N + " elements");
+                    throw new IllegalArgumentException(_loc.get("element-child-extra", 
+                        parent.getNodeName(), child, N).toString()); 
                 else {
                     return (Element)nodes.item(0);
                 }
@@ -211,7 +227,7 @@ public interface Actions {
         }
         
         public String toString() {
-            return "Action:[" + original.getNodeName() + "]";
+            return original.getNodeName();
         }
         
     }
@@ -223,23 +239,23 @@ public interface Actions {
      *
      */
     public static class RenameNode extends Abstract {
-        private final String sourceName;
+        private String sourceName;
         private final String targetName;
         
         public RenameNode(Element node) {
             super(Code.RENAME_NODE, node);
-            targetName  = getAttribute("to", node.getParentNode().getNodeName());
-            sourceName = getAttribute("from", targetName);
+            targetName = getAttribute(TO, node.getParentNode().getNodeName());
         }
         
         /**
          * Creates an element without any attribute or sub-element. 
          */
         public Element run(Document targetDoc, Element source, Element current,
-                Collection<String> consumedAttrs, Collection<String> consumedElements, Logger logger) {
+                Collection<String> consumedAttrs, Collection<String> consumedElements, Log logger) {
+            sourceName = source.getNodeName();
             consumedElements.add(sourceName);
             Element newElement = targetDoc.createElement(targetName);
-            logger.info(this + " renamed " + sourceName + " to " + targetName);
+            logger.info(_loc.get("rename-node", this, sourceName, targetName));
             return newElement;
         }
     }
@@ -252,8 +268,8 @@ public interface Actions {
 
         public RenameChildNode(Element s) {
             super(Code.RENAME_CHILD_NODE, s);
-            sourceName = getAttribute("from");
-            targetName  = getAttribute("to", "from");
+            sourceName = getAttribute(FROM);
+            targetName  = getAttribute(TO, sourceName);
             
             NodeList values = s.getElementsByTagName("ignore-attr");
             int M = values.getLength();
@@ -264,13 +280,13 @@ public interface Actions {
         }
 
         public Node run(Document targetDoc, Element source, Element current,
-                Collection<String> consumedAttrs, Collection<String> consumedElements, Logger logger) {
+                Collection<String> consumedAttrs, Collection<String> consumedElements, Log logger) {
             Element sourceNode = getElementByName(source, sourceName, false);
             if (sourceNode == null)
                 return null;
             consumedElements.add(sourceName);
             Element newNode = targetDoc.createElement(targetName);
-            logger.info("renamed " + sourceName + " to " + targetName);
+            logger.info(_loc.get("rename-child-node", this, sourceName, targetName));
             NamedNodeMap attrs = sourceNode.getAttributes();
             int M = attrs.getLength();
             for (int i = 0; i< M ; i++) {
@@ -278,7 +294,7 @@ public interface Actions {
                 if (!_ignores.contains(sourceAttr.getNodeName())) {
                     newNode.setAttribute(sourceAttr.getNodeName(), sourceAttr.getValue());
                 } else {
-                    logger.warning("ignored attribute " + sourceAttr + " in " + sourceName);
+                    logger.warn(_loc.get("attr-ignored", this, sourceAttr, sourceName));
                 }
             }
             return newNode;
@@ -292,19 +308,19 @@ public interface Actions {
         
         public RenameAttr(Element e) {
             super(Code.RENAME_ATTR, e);
-            sourceName = e.getAttribute("from");
-            targetName = e.getAttribute("to");
+            sourceName = e.getAttribute(FROM);
+            targetName = e.getAttribute(TO);
             
             NodeList values = e.getElementsByTagName("map-value");
             int M = values.getLength();
             for (int i = 0; i < M; i++) {
                 Element item = (Element)values.item(i);
-                _valueMap.put(item.getAttribute("from"), item.getAttribute("to"));
+                _valueMap.put(item.getAttribute(FROM), item.getAttribute(TO));
             }
         }
 
         public Attr run(Document targetDoc, Element source, Element current,
-                Collection<String> consumedAttrs, Collection<String> consumedElements, Logger logger) {
+                Collection<String> consumedAttrs, Collection<String> consumedElements, Log logger) {
             if (source.hasAttribute(sourceName)) {
                 consumedAttrs.add(sourceName);
                 Attr newAttr = targetDoc.createAttribute(targetName);
@@ -328,7 +344,7 @@ public interface Actions {
         }
         
         public Element run(Document targetDoc, Element source, Element current,
-                Collection<String> consumedAttrs, Collection<String> consumedElements, Logger logger) {
+                Collection<String> consumedAttrs, Collection<String> consumedElements, Log logger) {
             Element dummy = targetDoc.createElement(dummyName);
             return dummy;
         }
@@ -350,26 +366,26 @@ public interface Actions {
         
         public PromoteAttr(Element e) {
             super(Code.PROMOTE_ATTR, e);
-            sourceName = e.getAttribute("from");
-            targetName = e.getAttribute("to");
+            sourceName = e.getAttribute(FROM);
+            targetName = e.getAttribute(TO);
             targetAttrName = e.getAttribute("as");
             
             NodeList values = e.getElementsByTagName("consume-attr");
             int M = values.getLength();
             for (int i = 0; i < M; i++) {
                 Element item = (Element)values.item(i);
-                borrow.put(item.getAttribute("from"), item.getAttribute("to"));
+                borrow.put(item.getAttribute(FROM), item.getAttribute(TO));
             }
             values = e.getElementsByTagName("map-value");
             M = values.getLength();
             for (int i = 0; i < M; i++) {
                 Element item = (Element)values.item(i);
-                _valueMap.put(item.getAttribute("from"), item.getAttribute("to"));
+                _valueMap.put(item.getAttribute(FROM), item.getAttribute(TO));
             }
         }
         
         public Element run(Document targetDoc, Element source, Element current,
-                Collection<String> consumedAttrs, Collection<String> consumedElements, Logger logger) {
+                Collection<String> consumedAttrs, Collection<String> consumedElements, Log logger) {
             if (!source.hasAttribute(sourceName))
                 return null;
             consumedAttrs.add(sourceName);
@@ -395,33 +411,32 @@ public interface Actions {
     
     
     public static class IgnoreAttr extends Abstract {
-        boolean silent = false;
         public IgnoreAttr(Element e) {
             super(Code.IGNORE_ATTR, e);
-            silent = "false".equalsIgnoreCase(e.getAttribute("warn"));
         }
 
         public Node run(Document targetDoc, Element source, Element current,
-                Collection<String> consumedAttrs, Collection<String> consumedElements, Logger logger) {
+                Collection<String> consumedAttrs, Collection<String> consumedElements, Log logger) {
             String attr = original.getAttribute("name");
-            if (!silent) logger.warning("ignored " + source.getNodeName() + "." + attr);
+            if (!silent) logger.warn(_loc.get("attr-ignored", this, attr, source.getNodeName()));
             consumedAttrs.add(attr);
             return null;
         }
     }
     
     public static class IgnoreNode extends Abstract {
-        boolean silent = false;
         public IgnoreNode(Element e) {
             super(Code.IGNORE_NODE, e);
-            silent = "false".equalsIgnoreCase(e.getAttribute("warn"));
         }
 
         public Node run(Document targetDoc, Element source, Element current,
-                Collection<String> consumedAttrs, Collection<String> consumedElements, Logger logger) {
-            String node = original.getAttribute("name");
-            if (!silent) logger.warning("ignored " + source.getNodeName() + "/" + node);
+                Collection<String> consumedAttrs, Collection<String> consumedElements, Log logger) {
+            String node = original.getAttribute(NAME);
             consumedElements.add(node);
+            Element child = getElementByName(current, node, false);
+            if (child != null && !silent) {
+                logger.warn(_loc.get("element-ignored", this, source.getNodeName(), node));
+            }
             return null;
         }
     }
@@ -438,14 +453,14 @@ public interface Actions {
         String targetAttrName;
         public SplitNode(Element e) {
             super(Code.SPLIT_NODE, e);
-            sourceName = e.getAttribute("from");
-            targetName = e.getAttribute("to");
+            sourceName = e.getAttribute(FROM);
+            targetName = e.getAttribute(TO);
             sourceAttrName = e.getAttribute("on");
             targetAttrName = getAttribute("as", sourceAttrName);
         }
 
         public Node run(Document targetDoc, Element source, Element current,
-                Collection<String> consumedAttrs, Collection<String> consumedElements, Logger logger) {
+                Collection<String> consumedAttrs, Collection<String> consumedElements, Log logger) {
             Element forParent  = targetDoc.createElement(targetName);
             Element sourceChild = getElementByName(source, sourceName, false);
             if (sourceChild == null)
@@ -469,7 +484,7 @@ public interface Actions {
         }
 
         public Node run(Document targetDoc, Element source, Element current,
-                Collection<String> consumedAttrs, Collection<String> consumedElements, Logger logger) {
+                Collection<String> consumedAttrs, Collection<String> consumedElements, Log logger) {
             consumedAttrs.add("embed-xml");
             consumedAttrs.add("mutable");
             consumedAttrs.add("outer-join");
@@ -484,8 +499,8 @@ public interface Actions {
             }
             consumedElements.add(realTag);
             Element newElement = targetDoc.createElement(realTag);
-            newElement.setAttribute("name", source.getAttribute("name"));
-            consumedAttrs.add("name");
+            newElement.setAttribute(NAME, source.getAttribute("name"));
+            consumedAttrs.add(NAME);
             if (realElement.hasAttribute("class")) {
                 newElement.setAttribute("target-entity", realElement.getAttribute("class"));
             }

Added: openjpa/tools/trunk/openjpa-tools/src/main/resources/org/apache/openjpa/tools/localizer.properties
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/resources/org/apache/openjpa/tools/localizer.properties?rev=1022256&view=auto
==============================================================================
--- openjpa/tools/trunk/openjpa-tools/src/main/resources/org/apache/openjpa/tools/localizer.properties (added)
+++ openjpa/tools/trunk/openjpa-tools/src/main/resources/org/apache/openjpa/tools/localizer.properties Wed Oct 13 19:35:11 2010
@@ -0,0 +1,41 @@
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------------
+input-resource: Reading resource "{0}"
+input-file: Reading file "{0}"
+intput-bad: Failed to open input "{0}"
+
+output-resource: Setting output resource "{0}"
+output-file: Setting output file "{0}"
+output-bad: Failed to create output "{0}"
+
+action-build: Building action list for input element "{0}"
+
+element-process: Processing element "{0}" 
+element-action: Running "{0}" action on element "{1}"
+root-action-null: The first (root) action {0} returned a null result. But the root action result must not be null.
+element-unknown: Encountered element "{0}" with no corresponding actions
+element-action-missing: Encountered element "{0}" with no registered actions
+action-not-processed: Result of action <{0}> is not handled
+element-child-missing: Expected parent element "{0}" to contain element "{1}} as a child element. 
+element-child-extra: Expected parent element "{0}" to contain exactly one element "{1}} as a child element, \
+	but has {2} child elements.
+element-ignored: Ignored child element "{2}" of parent element "{1}" [Action <{0}>]	
+rename-node: renaming element "{1}" to element "{2}" [Action <{0}>]
+rename-child-node: renaming child element "{1}" to element "{2}" [Action <{0}>]
+
+attr-ignored: ignored attribute "{1}" in element "{2}"
+attr-skipped: Attribute "{0}" is skipped by all actions
+attr-missing: Action <{0}> requires that a value must be specified for attribute "{1}".
+attr-missing-def: Action <{0}> requires that attribute "{1}" must have a value or a non-null default value.
+
+ 
\ No newline at end of file

Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/org/apache/openjpa/tools/localizer.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/org/apache/openjpa/tools/localizer.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: openjpa/tools/trunk/openjpa-tools/src/test/java/org/apache/openjpa/tools/TestMigratedOutput.java
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/test/java/org/apache/openjpa/tools/TestMigratedOutput.java?rev=1022256&r1=1022255&r2=1022256&view=diff
==============================================================================
--- openjpa/tools/trunk/openjpa-tools/src/test/java/org/apache/openjpa/tools/TestMigratedOutput.java (original)
+++ openjpa/tools/trunk/openjpa-tools/src/test/java/org/apache/openjpa/tools/TestMigratedOutput.java Wed Oct 13 19:35:11 2010
@@ -25,6 +25,20 @@ import javax.xml.parsers.SAXParserFactor
 
 import junit.framework.TestCase;
 
+/**
+ * Tests migration of proprietory mapping descriptors to standard JPA object-relational mapping.
+ * <br>
+ * Requires following in the classpath:
+ * <LI><code>META-INF/orm_2_0-xsd.rsrc</code>  
+ * <LI><code>${dir}${sample}.hbm.xml</code> input descriptor where <code>${sample}</code> is the
+ * value of the system property <code>sample</code> and defaults to <code>sample</code>. And
+ * <code>${dir}</code> is the classpath-relative directory of the input descriptor file.
+ * <code>${dir}</code> is the value of the system property <code>dir</code>  and defaults to 
+ * <code>target/test-classes/</code> with the forward slash at the end and as well as file separator.
+ * 
+ * @author Pinaki Poddar
+ *
+ */
 public class TestMigratedOutput extends TestCase {
     static final String W3C_XML_SCHEMA       = "http://www.w3.org/2001/XMLSchema"; 
     static final String JAXP_SCHEMA_SOURCE   = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -54,14 +68,15 @@ public class TestMigratedOutput extends 
     
     
     public void testSampleIsJPACompliant() {
-        migrateAndValidate(System.getProperty("sample","sample"));
+        migrateAndValidate(System.getProperty("dir","target/test-classes/"), System.getProperty("sample","sample"));
     }
     
-    void migrateAndValidate(String type) {
-        String outDir = "target/test-classes/";
+    void migrateAndValidate(String dir, String type) {
         String input  = type + ".hbm.xml";
         String output = type + ".orm.xml";
-        String[] args = {"-input", input, "-output", outDir + output};
+        String[] args = {"-input", input, "-output", dir + output};
+        System.err.println("Input  Descriptor [" + input + "]");
+        System.err.println("Output Descriptor [" + output + "]");
         SchemaErrorDetector parserError = new SchemaErrorDetector(output, false);
         try {
             MigrationTool.main(args);