Author: jacopoc Date: Mon Oct 27 07:13:36 2014 New Revision: 1634459 URL: http://svn.apache.org/r1634459 Log: A pretty large commit (I couldn't isolate the changes in smaller atomic commits as I was hoping) that includes the following: * moved the json-lib jar (json-lib-2.2.3-jdk15.jar) from the framework/webapp to the framework/base component: this will facilitate the definition of a small set of classes for the management of JSON conversions; in one of the next commits we will replace json-lib with jackson library * removed the SQL select Parser.jj (parser definition) and its unit tests: it was not used (and never used) by any OFBiz code * removed the JSON.jj (parser definition) and its unit tests: it was not used (and never used) by any OFBiz code apart from the JSON Converters (now migrated to json-lib, see next items in this list) some utility methods in UtilIO.java (that have been removed too because they have never been used in OFBiz) * removed the JavaCC jar and related ant scripts because no more needed after the removal of Parser.jj and JSON.jj * converted the JSONConverter code that was based on JSON.jj to json-lib; some of the converters (the ones for basic type conversions) have been removed because they didn't seem to be useful; some new converters have been created (for List/Map to JSON conversions) * added a new class org.ofbiz.base.conversion.JSON that have been contributed by Adrian Crum that will be used as a facade for simplifying the client code and for hiding the specific JSON library being used; at the moment the class is not used but one of the next commit should address this by converting the signatures of the JSON Converters to use this class rather than the json-lib JSON class * in CommonEvents, converted some client code to use the new JSON Converter framework; however this code will be modified soon to use the org.ofbiz.base.conversion.JSON object instead * removed an unused method: ImageManagementServices.toJsonObject(...) * added TestBooleanConverters to the list of tests (it was missing) * new unit tests for the new JSON converters
Added: ofbiz/branches/json-integration-refactoring/framework/base/lib/json-lib-2.2.3-jdk15.jar - copied unchanged from r1634077, ofbiz/branches/json-integration-refactoring/framework/webapp/lib/json-lib-2.2.3-jdk15.jar ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/JSON.java ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/test/TestJSONConverters.java (with props) Removed: ofbiz/branches/json-integration-refactoring/framework/base/ant-scripts/ofbiz-jjtree.groovy ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/JSONResult.java ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/json/ ofbiz/branches/json-integration-refactoring/framework/entity/src/org/ofbiz/entity/sql/SQLUtil.java ofbiz/branches/json-integration-refactoring/framework/sql/src/org/ofbiz/sql/Main.java ofbiz/branches/json-integration-refactoring/framework/sql/src/org/ofbiz/sql/Parser.jj ofbiz/branches/json-integration-refactoring/framework/sql/src/org/ofbiz/sql/test/SQLTest.java ofbiz/branches/json-integration-refactoring/framework/webapp/lib/json-lib-2.2.3-jdk15.jar ofbiz/branches/json-integration-refactoring/lib/ Modified: ofbiz/branches/json-integration-refactoring/.classpath ofbiz/branches/json-integration-refactoring/LICENSE ofbiz/branches/json-integration-refactoring/NOTICE ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java ofbiz/branches/json-integration-refactoring/framework/base/build.xml ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/JSONConverters.java ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/test/MiscTests.java ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/util/UtilIO.java ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/util/test/UtilIOTests.java ofbiz/branches/json-integration-refactoring/framework/base/testdef/basetests.xml ofbiz/branches/json-integration-refactoring/framework/common/src/org/ofbiz/common/CommonEvents.java ofbiz/branches/json-integration-refactoring/framework/sql/build.xml ofbiz/branches/json-integration-refactoring/framework/sql/src/org/ofbiz/sql/test/SelectTest.java ofbiz/branches/json-integration-refactoring/macros.xml Modified: ofbiz/branches/json-integration-refactoring/.classpath URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/.classpath?rev=1634459&r1=1634458&r2=1634459&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/.classpath (original) +++ ofbiz/branches/json-integration-refactoring/.classpath Mon Oct 27 07:13:36 2014 @@ -33,6 +33,7 @@ <classpathentry kind="lib" path="framework/base/lib/jdbm-1.0-SNAPSHOT.jar"/> <classpathentry kind="lib" path="framework/base/lib/jdom-1.1.jar"/> <classpathentry kind="lib" path="framework/base/lib/jpim-0.1.jar"/> + <classpathentry kind="lib" path="framework/base/lib/json-lib-2.2.3-jdk15.jar"/> <classpathentry kind="lib" path="framework/base/lib/juel-impl-2.2.7.jar"/> <classpathentry kind="lib" path="framework/base/lib/juel-spi-2.2.7.jar"/> <classpathentry kind="lib" path="framework/base/lib/junit-dep-4.10.jar"/> @@ -130,7 +131,6 @@ <classpathentry kind="lib" path="framework/testtools/lib/org.springframework.core-3.1.0.M2.jar"/> <classpathentry kind="lib" path="framework/webapp/lib/ezmorph-0.9.1.jar"/> <classpathentry kind="lib" path="framework/webapp/lib/iText-2.1.7.jar"/> - <classpathentry kind="lib" path="framework/webapp/lib/json-lib-2.2.3-jdk15.jar"/> <classpathentry kind="lib" path="framework/webapp/lib/rome-0.9.jar"/> <classpathentry kind="lib" path="specialpurpose/googlecheckout/lib/checkout-sdk-0.8.8.jar"/> <classpathentry kind="lib" path="specialpurpose/ldap/lib/cas-server-core-3.3.jar"/> @@ -157,7 +157,6 @@ <classpathentry kind="src" path="applications/humanres/src"/> <classpathentry kind="src" path="applications/workeffort/src"/> <classpathentry kind="src" path="specialpurpose/appserver/src"/> - <classpathentry kind="src" path="framework/base/build/gen-src/javacc"/> <classpathentry excluding="org/ofbiz/base/config/CoberturaInstrumenter.java" kind="src" path="framework/base/src"/> <classpathentry kind="src" path="framework/bi/src"/> <classpathentry kind="src" path="specialpurpose/birt/src"/> @@ -172,7 +171,6 @@ <classpathentry kind="src" path="framework/security/src"/> <classpathentry kind="src" path="framework/service/src"/> <classpathentry kind="src" path="framework/sql/src"/> - <classpathentry kind="src" path="framework/sql/build/gen-src/javacc"/> <classpathentry kind="src" path="framework/start/src"/> <classpathentry kind="src" path="framework/testtools/src"/> <classpathentry excluding="org/ofbiz/webapp/view/JasperReportsPdfViewHandler.java|org/ofbiz/webapp/view/JasperReportsXmlViewHandler.java|org/ofbiz/webapp/view/JasperReportsJXlsViewHandler.java|org/ofbiz/webapp/view/JasperReportsPoiXlsViewHandler.java" kind="src" path="framework/webapp/src"/> Modified: ofbiz/branches/json-integration-refactoring/LICENSE URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/LICENSE?rev=1634459&r1=1634458&r2=1634459&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/LICENSE (original) +++ ofbiz/branches/json-integration-refactoring/LICENSE Mon Oct 27 07:13:36 2014 @@ -25,6 +25,7 @@ framework/base/lib/httpcore-4.2.1.jar framework/base/lib/ivy-2.2.0.jar framework/base/lib/jakarta-regexp-1.5.jar framework/base/lib/jpim-0.1.jar +framework/base/lib/json-lib-2.2.3-jdk15.jar framework/base/lib/juel-impl-2.2.7.jar framework/base/lib/juel-spi-2.2.7.jar framework/base/lib/log4j-1.2-api-2.0.1.jar @@ -92,7 +93,6 @@ framework/service/lib/neethi-2.0.4.jar framework/service/lib/XmlSchema-1.4.3.jar framework/webapp/lib/fop-1.1.jar framework/webapp/lib/xmlgraphics-commons-1.5.jar -framework/webapp/lib/json-lib-2.2.3-jdk15.jar framework/webapp/lib/ezmorph-0.9.1.jar framework/webapp/lib/rome-0.9.jar framework/webapp/lib/serializer-2.7.0.jar @@ -439,7 +439,6 @@ framework/base/lib/bsh-engine-modified.j framework/base/lib/hamcrest-all-1.2.jar framework/base/lib/httpunit-1.7.jar framework/base/lib/ical4j-1.0-rc2.jar -lib/build/javacc/javacc.jar (5.0) framework/base/lib/javolution-5.4.3.jar framework/base/lib/xpp3-1.1.4c.jar framework/base/lib/xstream-1.4.6.jar Modified: ofbiz/branches/json-integration-refactoring/NOTICE URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/NOTICE?rev=1634459&r1=1634458&r2=1634459&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/NOTICE (original) +++ ofbiz/branches/json-integration-refactoring/NOTICE Mon Oct 27 07:13:36 2014 @@ -253,12 +253,6 @@ jpim is released under a modified BSD st Java PIM Library (jpim) Copyright (c) 2001-2003 jpim development team. ========================================================================= -== JavaCC Notice == -========================================================================= - -This product includes software developed by the javacc team -(http://javacc.dev.java.net/). The included version is 4.1. -========================================================================= == XPP3 Notice == ========================================================================= Modified: ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java?rev=1634459&r1=1634458&r2=1634459&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java Mon Oct 27 07:13:36 2014 @@ -713,31 +713,6 @@ public class ImageManagementServices { return "success"; } - public static void toJsonObject(Map<String,Object> attrMap, HttpServletResponse response){ - JSONObject json = JSONObject.fromObject(attrMap); - String jsonStr = json.toString(); - if (jsonStr == null) { - Debug.logError("JSON Object was empty; fatal error!",module); - } - // set the X-JSON content type - response.setContentType("application/json"); - // jsonStr.length is not reliable for unicode characters - try { - response.setContentLength(jsonStr.getBytes("UTF8").length); - } catch (UnsupportedEncodingException e) { - Debug.logError("Problems with Json encoding",module); - } - // return the JSON String - Writer out; - try { - out = response.getWriter(); - out.write(jsonStr); - out.flush(); - } catch (IOException e) { - Debug.logError("Unable to get response writer",module); - } - } - public static void toJsonObjectList(List<Map<String,Object>> list, HttpServletResponse response) throws EventHandlerException { JSONObject json = null; List<JSONObject> jsonList = new ArrayList<JSONObject>(); Modified: ofbiz/branches/json-integration-refactoring/framework/base/build.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/framework/base/build.xml?rev=1634459&r1=1634458&r2=1634459&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/framework/base/build.xml (original) +++ ofbiz/branches/json-integration-refactoring/framework/base/build.xml Mon Oct 27 07:13:36 2014 @@ -51,6 +51,7 @@ under the License. <file name="org/ofbiz/base/conversion/test/TestBooleanConverters.java"/> <file name="org/ofbiz/base/conversion/test/DateTimeTests.java"/> <file name="org/ofbiz/base/conversion/test/MiscTests.java"/> + <file name="org/ofbiz/base/conversion/test/TestJSONConverters.java"/> <file name="org/ofbiz/base/util/test/UtilIOTests.java"/> <file name="org/ofbiz/base/test/BaseUnitTests.java"/> <file name="org/ofbiz/base/util/collections/test/GenericMapTest.java"/> @@ -80,20 +81,6 @@ under the License. </patternset> </target> - <target name="gen-src"> - <ofbiz-javacc dir="org/ofbiz/base/json" file="JSON"/> - </target> - - <target name="classes" depends="prepare,gen-src"> - <javac17> - <sourcepath> - <dirset dir="build/gen-src"> - <include name="javacc"/> - </dirset> - </sourcepath> - </javac17> - </target> - <target name="jar" depends="classes"> <main-jar> <main-elements> Added: ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/JSON.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/JSON.java?rev=1634459&view=auto ============================================================================== --- ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/JSON.java (added) +++ ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/JSON.java Mon Oct 27 07:13:36 2014 @@ -0,0 +1,82 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + *******************************************************************************/ +package org.ofbiz.base.conversion; + +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; + +import org.apache.commons.io.IOUtils; +import org.ofbiz.base.lang.ThreadSafe; +import org.ofbiz.base.util.Assert; + +/** A JSON object. */ +@ThreadSafe +public final class JSON { + + public static JSON from(InputStream inStream) throws IOException { + Assert.notNull("inStream", inStream); + String jsonString = IOUtils.toString(inStream, "UTF-8"); + return from(jsonString); + } + + public static JSON from(Object object) { + Assert.notNull("object", object); + // TODO: Finish implementation. + return null; + } + + public static JSON from(Reader reader) throws IOException { + Assert.notNull("reader", reader); + String jsonString = IOUtils.toString(reader); + return from(jsonString); + } + + public static JSON from(String jsonString) { + Assert.notNull("jsonString", jsonString); + // TODO: Validate String + return new JSON(jsonString); + } + + private final String jsonString; + + private JSON(String jsonString) { + this.jsonString = jsonString; + } + + @Override + public boolean equals(Object obj) { + return jsonString.equals(obj); + } + + @Override + public int hashCode() { + return jsonString.hashCode(); + } + + public <T> T toObject() { + // TODO: Finish implementation. + return null; + } + + @Override + public String toString() { + return jsonString.toString(); + } +} Modified: ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/JSONConverters.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/JSONConverters.java?rev=1634459&r1=1634458&r2=1634459&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/JSONConverters.java (original) +++ ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/JSONConverters.java Mon Oct 27 07:13:36 2014 @@ -18,124 +18,17 @@ *******************************************************************************/ package org.ofbiz.base.conversion; -import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.TreeSet; -import javolution.util.FastSet; - -import org.ofbiz.base.json.JSON; -import org.ofbiz.base.util.UtilGenerics; +import net.sf.json.JSON; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; /** JSON Converter classes. */ public class JSONConverters implements ConverterLoader { - public static class ObjectToJSONResultCreator<R extends JSONResult> implements ConverterCreator, ConverterLoader { - public void loadConverters() { - Converters.registerCreator(this); - } - - public <S, T> Converter<S, T> createConverter(Class<S> sourceClass, Class<T> targetClass) { - if (!JSONResult.class.isAssignableFrom(targetClass)) { - return null; - } - if (Collection.class.isAssignableFrom(sourceClass)) { - } else if (Map.class.isAssignableFrom(sourceClass)) { - } else if (Byte.class == sourceClass) { - } else if (Character.class == sourceClass) { - } else if (Double.class == sourceClass) { - } else if (Float.class == sourceClass) { - } else if (Integer.class == sourceClass) { - } else if (Long.class == sourceClass) { - } else if (Short.class == sourceClass) { - } else { - return null; - } - return UtilGenerics.cast(new ObjectToJSONWriterResult<S, JSONResult>(sourceClass, UtilGenerics.<Class<JSONResult>>cast(targetClass))); - } - } - - private static class ObjectToJSONWriterResult<S, T extends JSONResult> extends AbstractConverter<S, T> { - public ObjectToJSONWriterResult(Class<S> sourceClass, Class<T> targetClass) { - super(sourceClass, targetClass); - } - - public T convert(S obj) throws ConversionException { - try { - T result = UtilGenerics.<T>cast(getTargetClass().newInstance()); - result.getWriter().write(obj); - return result; - } catch (RuntimeException e) { - throw e; - } catch (Exception e) { - throw new ConversionException(e); - } - } - } - - public static class JSONToByte extends AbstractConverter<JSON, Byte> { - public JSONToByte() { - super(JSON.class, Byte.class); - } - - public Byte convert(JSON obj) throws ConversionException { - try { - return obj.JSONLong().byteValue(); - } catch (RuntimeException e) { - throw e; - } catch (Exception e) { - throw new ConversionException(e); - } - } - } - - public static class JSONToDouble extends AbstractConverter<JSON, Double> { - public JSONToDouble() { - super(JSON.class, Double.class); - } - - public Double convert(JSON obj) throws ConversionException { - try { - return obj.JSONFloat(); - } catch (RuntimeException e) { - throw e; - } catch (Exception e) { - throw new ConversionException(e); - } - } - } - - public static class JSONToFloat extends AbstractConverter<JSON, Float> { - public JSONToFloat() { - super(JSON.class, Float.class); - } - - public Float convert(JSON obj) throws ConversionException { - try { - return obj.JSONFloat().floatValue(); - } catch (RuntimeException e) { - throw e; - } catch (Exception e) { - throw new ConversionException(e); - } - } - } - - public static class JSONToInteger extends AbstractConverter<JSON, Integer> { - public JSONToInteger() { - super(JSON.class, Integer.class); - } - - public Integer convert(JSON obj) throws ConversionException { - try { - return obj.JSONLong().intValue(); - } catch (RuntimeException e) { - throw e; - } catch (Exception e) { - throw new ConversionException(e); - } - } - } public static class JSONToList extends AbstractConverter<JSON, List<Object>> { public JSONToList() { @@ -144,7 +37,7 @@ public class JSONConverters implements C public List<Object> convert(JSON obj) throws ConversionException { try { - return obj.JSONArray(); + return (List<Object>) JSONArray.toCollection((JSONArray)obj); } catch (RuntimeException e) { throw e; } catch (Exception e) { @@ -153,14 +46,14 @@ public class JSONConverters implements C } } - public static class JSONToLong extends AbstractConverter<JSON, Long> { - public JSONToLong() { - super(JSON.class, Long.class); + public static class JSONToMap extends AbstractConverter<JSON, Map<String, Object>> { + public JSONToMap() { + super(JSON.class, Map.class); } - public Long convert(JSON obj) throws ConversionException { + public Map<String, Object> convert(JSON obj) throws ConversionException { try { - return obj.JSONLong(); + return (Map<String, Object>) JSONObject.toBean((JSONObject)obj, Map.class); } catch (RuntimeException e) { throw e; } catch (Exception e) { @@ -169,14 +62,14 @@ public class JSONConverters implements C } } - public static class JSONToMap extends AbstractConverter<JSON, Map<String, Object>> { - public JSONToMap() { - super(JSON.class, Map.class); + public static class MapToJSON extends AbstractConverter<Map<String, Object>, JSON> { + public MapToJSON() { + super(Map.class, JSON.class); } - public Map<String, Object> convert(JSON obj) throws ConversionException { + public JSON convert(Map<String, Object> obj) throws ConversionException { try { - return obj.JSONObject(); + return JSONObject.fromObject(obj); } catch (RuntimeException e) { throw e; } catch (Exception e) { @@ -185,14 +78,14 @@ public class JSONConverters implements C } } - public static class JSONToShort extends AbstractConverter<JSON, Short> { - public JSONToShort() { - super(JSON.class, Short.class); + public static class ListToJSON extends AbstractConverter<List<Object>, JSON> { + public ListToJSON() { + super(List.class, JSON.class); } - public Short convert(JSON obj) throws ConversionException { + public JSON convert(List<Object> obj) throws ConversionException { try { - return obj.JSONLong().shortValue(); + return JSONArray.fromObject(obj); } catch (RuntimeException e) { throw e; } catch (Exception e) { @@ -208,8 +101,8 @@ public class JSONConverters implements C public Set<Object> convert(JSON obj) throws ConversionException { try { - Set<Object> set = FastSet.newInstance(); - set.addAll(obj.JSONArray()); + Set<Object> set = new TreeSet<Object>(); + set.addAll((JSONArray)obj); return set; } catch (RuntimeException e) { throw e; Modified: ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/test/MiscTests.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/test/MiscTests.java?rev=1634459&r1=1634458&r2=1634459&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/test/MiscTests.java (original) +++ ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/test/MiscTests.java Mon Oct 27 07:13:36 2014 @@ -21,7 +21,6 @@ package org.ofbiz.base.conversion.test; import java.math.BigDecimal; import java.net.URL; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -32,12 +31,10 @@ import javolution.util.FastMap; import org.ofbiz.base.conversion.Converter; import org.ofbiz.base.conversion.ConverterLoader; import org.ofbiz.base.conversion.Converters; -import org.ofbiz.base.conversion.JSONResult; import org.ofbiz.base.lang.SourceMonitored; import org.ofbiz.base.test.GenericTestCaseBase; import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilMisc; -import org.ofbiz.base.util.collections.LRUMap; @SourceMonitored public class MiscTests extends GenericTestCaseBase { @@ -46,12 +43,6 @@ public class MiscTests extends GenericTe super(name); } - private static <S, T extends JSONResult.Indenting> void assertConversion(String label, String wanted, Class<T> targetClass, Object source, Class<S> sourceClass) throws Exception { - Converter<S, T> converter = Converters.getConverter(sourceClass, targetClass); - assertTrue(label + " can convert", converter.canConvert(sourceClass, targetClass)); - assertEquals(label, wanted, converter.convert(UtilGenerics.<S>cast(source)).getResult()); - } - public void testStaticHelperClass() throws Exception { assertStaticHelperClass(Converters.class); } @@ -66,22 +57,6 @@ public class MiscTests extends GenericTe Converters.loadContainedConverters(MiscTests.class); } - public void testExtendsImplements() throws Exception { - List<String> arraysList = Arrays.asList("a", "b", "c"); - assertConversion("", "[\n \"a\",\n \"b\",\n \"c\"\n]", JSONResult.Indenting.class, arraysList, arraysList.getClass()); - Exception caught = null; - try { - Converters.getConverter(MiscTests.class, String.class); - } catch (ClassNotFoundException e) { - caught = e; - } finally { - assertNotNull("ClassNotFoundException thrown for MiscTests.class", caught); - } - LRUMap<String, String> map = new LRUMap<String, String>(); - map.put("a", "1"); - assertConversion("", "{\n \"a\": \"1\"\n}", JSONResult.Indenting.class, map, LRUMap.class); - } - public static <S> void assertPassThru(Object wanted, Class<S> sourceClass) throws Exception { assertPassThru(wanted, sourceClass, sourceClass); } Added: ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/test/TestJSONConverters.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/test/TestJSONConverters.java?rev=1634459&view=auto ============================================================================== --- ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/test/TestJSONConverters.java (added) +++ ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/test/TestJSONConverters.java Mon Oct 27 07:13:36 2014 @@ -0,0 +1,102 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + *******************************************************************************/ +package org.ofbiz.base.conversion.test; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import org.ofbiz.base.conversion.JSONConverters; +import org.ofbiz.base.conversion.Converter; +import org.ofbiz.base.conversion.ConverterLoader; +import org.ofbiz.base.conversion.Converters; + +import net.sf.json.JSON; +import junit.framework.TestCase; + +public class TestJSONConverters extends TestCase { + public TestJSONConverters(String name) { + super(name); + ConverterLoader loader = new JSONConverters(); + loader.loadConverters(); + } + + public void testJSONToMap() throws Exception { + Converter<JSON, Map> converter = Converters.getConverter(JSON.class, Map.class); + JSON json; + Map map, convertedMap; + map = new HashMap(); + map.put("field1", "value1"); + json = JSONObject.fromObject(map); + convertedMap = converter.convert(json); + assertEquals("JSON to Map", map, convertedMap); + } + + public void testJSONToList() throws Exception { + Converter<JSON, List> converter = Converters.getConverter(JSON.class, List.class); + JSON json; + List list, convertedList; + list = new ArrayList(); + list.add("field1"); + list.add("field2"); + json = JSONArray.fromObject(list); + convertedList = converter.convert(json); + assertEquals("JSON to List", list, convertedList); + } + + public void testJSONToSet() throws Exception { + Converter<JSON, Set> converter = Converters.getConverter(JSON.class, Set.class); + JSON json; + Set set, convertedSet; + set = new TreeSet(); + set.add("field1"); + set.add("field2"); + json = JSONArray.fromObject(set); + convertedSet = converter.convert(json); + assertEquals("JSON to Set", set, convertedSet); + } + + public void testMapToJSON() throws Exception { + Converter<Map, JSON> converter = Converters.getConverter(Map.class, JSON.class); + JSON json; + Map map = new LinkedHashMap(); + map.put("field1", "value1"); + map.put("field2", new BigDecimal("3.7")); + json = converter.convert(map); + assertEquals("Map to JSON", "{\"field1\":\"value1\",\"field2\":3.7}", json.toString()); + } + + public void testListToJSON() throws Exception { + Converter<List, JSON> converter = Converters.getConverter(List.class, JSON.class); + JSON json; + List list = new ArrayList(); + list.add("field1"); + list.add("field2"); + json = converter.convert(list); + assertEquals("List to JSON", "[\"field1\",\"field2\"]", json.toString()); + } +} + Propchange: ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/test/TestJSONConverters.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/test/TestJSONConverters.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/conversion/test/TestJSONConverters.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/util/UtilIO.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/util/UtilIO.java?rev=1634459&r1=1634458&r2=1634459&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/util/UtilIO.java (original) +++ ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/util/UtilIO.java Mon Oct 27 07:13:36 2014 @@ -19,34 +19,20 @@ package org.ofbiz.base.util; import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; -import java.io.PrintWriter; import java.io.Reader; -import java.io.Serializable; -import java.io.StringReader; -import java.io.StringWriter; import java.io.Writer; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.Charset; import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.StringUtils; -import org.ofbiz.base.conversion.Converter; -import org.ofbiz.base.conversion.Converters; -import org.ofbiz.base.json.JSON; -import org.ofbiz.base.json.JSONWriter; public final class UtilIO { public static final Charset UTF8 = Charset.forName("UTF-8"); @@ -329,141 +315,4 @@ public final class UtilIO { writer.write(value.substring(r)); writer.close(); } - - public static Object readObject(File file) throws ClassNotFoundException, IOException { - return readObject(new FileInputStream(file), false); - } - - public static Object readObject(File file, boolean allowJsonResolve) throws ClassNotFoundException, IOException { - return readObject(new FileInputStream(file), allowJsonResolve); - } - - public static Object readObject(InputStream in) throws ClassNotFoundException, IOException { - return readObject(in, false); - } - - public static Object readObject(InputStream in, boolean allowJsonResolve) throws ClassNotFoundException, IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - IOUtils.copy(in, baos); - in.close(); - byte[] bytes = baos.toByteArray(); - try { - char[] buffer = StringUtils.chomp(readString(bytes)).toCharArray(); - return parseObject(buffer, 0, buffer.length, allowJsonResolve); - } catch (Exception e) { - } - ObjectInputStream oin = new ObjectInputStream(new ByteArrayInputStream(bytes)); - Serializable value = (Serializable) oin.readObject(); - oin.close(); - return value; - } - - public static Object readObject(char[] buffer) throws ClassNotFoundException, IOException { - return parseObject(buffer, 0, buffer.length, false); - } - - public static Object readObject(char[] buffer, int offset, int length) throws ClassNotFoundException, IOException { - return parseObject(buffer, offset, length, false); - } - - private static <S, T> T convertObject(Class<S> sourceClass, S value, Class<T> targetClass) throws Exception { - Converter<S, T> converter = Converters.getConverter(sourceClass, targetClass); - return converter.convert(targetClass, value); - } - - private static Object parseObject(char[] buffer, int offset, int length, boolean allowJsonResolve) throws ClassNotFoundException, IOException { - try { - int i; - for (i = offset; i < length && buffer[i] != ':'; i++); - if (i > offset && i < length) { - String className = new String(buffer, offset, i); - Class<?> type = Class.forName(className); - if (buffer[length - 1] == '\n') { - length--; - } - if (buffer[length - 1] == '\r') { - length--; - } - return convertObject(String.class, new String(buffer, i + 1, length - i - 1), type); - } - } catch (Exception e) { - } - try { - return new JSON(new StringReader(new String(buffer, offset, length))).allowResolve(allowJsonResolve).JSONValue(); - } catch (Error e) { - } catch (Exception e) { - } - throw new IOException("Can't read (" + new String(buffer, offset, length) + ")"); - } - - public static void writeObject(File file, Object value) throws IOException { - writeObject(new FileOutputStream(file), value, false); - } - - public static void writeObject(File file, Object value, boolean allowJsonResolve) throws IOException { - writeObject(new FileOutputStream(file), value, allowJsonResolve); - } - - public static void writeObject(OutputStream out, Object value) throws IOException { - writeObject(out, value, false); - } - - public static void writeObject(OutputStream out, Object value, boolean allowJsonResolve) throws IOException { - try { - PrintWriter writer = new PrintWriter(new OutputStreamWriter(out, UTF8)); - if (encodeObject(writer, value, allowJsonResolve)) { - writer.println(); - writer.close(); - return; - } - } catch (Exception e) { - } - ObjectOutputStream oout = new ObjectOutputStream(out); - oout.writeObject(value); - oout.close(); - out.close(); - } - - private static <T> boolean encodeObject(Writer writer, T value, boolean allowJsonResolve) throws Exception { - Converter<T, String> converter = UtilGenerics.cast(Converters.getConverter(value.getClass(), String.class)); - if (converter != null) { - Class<?> clz = converter.getSourceClass(); - String str = converter.convert(value); - if (clz != null) { - writer.write(clz.getName()); - } else { - writer.write(value.getClass().getName()); - } - writer.write(':'); - writer.write(str); - return true; - } else { - StringWriter sw = new StringWriter(); - IndentingWriter indenting = new IndentingWriter(writer, true, false); - JSONWriter jsonWriter; - if (allowJsonResolve) { - jsonWriter = new JSONWriter(indenting, JSONWriter.ResolvingFallbackHandler); - } else { - jsonWriter = new JSONWriter(indenting); - } - jsonWriter.write(value); - writer.write(sw.toString()); - return true; - } - } - - public static void writeObject(StringBuilder sb, Object value) throws IOException { - writeObject(sb, value, false); - } - - public static void writeObject(StringBuilder sb, Object value, boolean allowJsonResolve) throws IOException { - try { - StringWriter writer = new StringWriter(); - if (encodeObject(writer, value, allowJsonResolve)) { - sb.append(writer.toString()); - return; - } - } catch (Exception e) {} //Empty catch because writeObject() calls encodeObject(), which *always* returns true, unless an error occurs. - throw new IOException("Can't write (" + value + ")"); - } } Modified: ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/util/test/UtilIOTests.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/util/test/UtilIOTests.java?rev=1634459&r1=1634458&r2=1634459&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/util/test/UtilIOTests.java (original) +++ ofbiz/branches/json-integration-refactoring/framework/base/src/org/ofbiz/base/util/test/UtilIOTests.java Mon Oct 27 07:13:36 2014 @@ -129,53 +129,4 @@ public class UtilIOTests extends Generic UtilIO.writeString(baos, UtilIO.UTF8, toWrite); assertEquals("writeString UTF8:" + label, wanted, baos.toByteArray()); } - - protected void checkBasicReadObject(Object value, String text) throws Exception { - byte[] bytes = text.getBytes("UTF-8"); - assertEquals("read bytes " + value.getClass().getName(), value, UtilIO.readObject(new ByteArrayInputStream(bytes))); - assertEquals("read chars " + value.getClass().getName(), value, UtilIO.readObject(text.toCharArray())); - assertEquals("read chars offset " + value.getClass().getName(), value, UtilIO.readObject(text.toCharArray(), 0, text.length())); - } - - protected void checkBasicReadWriteObject(Object value, String text) throws Exception { - String lineEnding = System.getProperty("line.separator"); - text = text.replaceAll("\n", lineEnding); - byte[] bytes = text.getBytes("UTF-8"); - assertEquals("read bytes " + value.getClass().getName(), value, UtilIO.readObject(new ByteArrayInputStream(bytes))); - assertEquals("read chars " + value.getClass().getName(), value, UtilIO.readObject(text.toCharArray())); - assertEquals("read chars offset " + value.getClass().getName(), value, UtilIO.readObject(text.toCharArray(), 0, text.length())); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - UtilIO.writeObject(baos, value); - assertEquals("write stream " + value.getClass().getName(), text, new String(baos.toByteArray(), "UTF-8")); - StringBuilder sb = new StringBuilder(); - UtilIO.writeObject(sb, value); - sb.append(lineEnding); - assertEquals("write builder " + value.getClass().getName(), text, sb.toString()); - } - - public void testReadWriteObject() throws Exception { - checkBasicReadWriteObject(Boolean.TRUE, "java.lang.Boolean:true\n"); - checkBasicReadWriteObject(Byte.valueOf("1"), "java.lang.Byte:1\n"); - checkBasicReadWriteObject(Double.valueOf("1.0"), "java.lang.Double:1.0\n"); - checkBasicReadWriteObject(Float.valueOf("1.0"), "java.lang.Float:1.0\n"); - checkBasicReadWriteObject(Integer.valueOf("1"), "java.lang.Integer:1\n"); - checkBasicReadWriteObject(Long.valueOf("1"), "java.lang.Long:1\n"); - checkBasicReadWriteObject(Short.valueOf("1"), "java.lang.Short:1\n"); - checkBasicReadWriteObject(BigDecimal.valueOf(500.5), "java.math.BigDecimal:500.5\n"); - checkBasicReadWriteObject(BigInteger.valueOf(500), "java.math.BigInteger:500\n"); - checkBasicReadWriteObject("1", "java.lang.String:1\n"); - checkBasicReadObject(Arrays.asList(new Object[] {"a", UtilMisc.toMap("b", Long.valueOf(1))}), "[\n \"a\",\n {\n \"b\": 1\n }\n]\n"); - checkBasicReadWriteObject(MemoryType.HEAP, "java.lang.management.MemoryType:HEAP\n"); - checkBasicReadWriteObject(MemoryType.NON_HEAP, "java.lang.management.MemoryType:NON_HEAP\n"); - checkBasicReadWriteObject(UtilIO.UTF8, "java.nio.charset.Charset:UTF-8\n"); - checkBasicReadWriteObject(InetAddress.getByAddress("localhost", new byte[] {127, 0, 0, 1}), "java.net.InetAddress:localhost\n"); - //checkBasicReadWriteObject(Pattern.compile("^([a-z]{3}.*?):$"), "java.util.regex.Pattern:^([a-z]{3}.*?):$\n"); - checkBasicReadWriteObject(Time.valueOf("12:34:56"), "java.sql.Time:12:34:56\n"); - //checkBasicReadWriteObject(new Timestamp(1234567890), "java.sql.Timestamp:1234567890 00:00:00\n"); - //checkBasicReadWriteObject(new java.util.Date(1234567890), "java.util.Date:1234567890\n"); - checkBasicReadWriteObject(UUID.fromString("c3241927-9f77-43e1-be16-bd71d245ef64"), "java.util.UUID:c3241927-9f77-43e1-be16-bd71d245ef64\n"); - checkBasicReadWriteObject(TimeZone.getTimeZone("America/Chicago"), "java.util.TimeZone:America/Chicago\n"); - checkBasicReadWriteObject(new SimpleDateFormat("MM/dd/yyyy hh:mm a"), "java.text.SimpleDateFormat:MM/dd/yyyy hh:mm a\n"); - checkBasicReadWriteObject(new Locale("en", "us"), "java.util.Locale:en_US\n"); - } } Modified: ofbiz/branches/json-integration-refactoring/framework/base/testdef/basetests.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/framework/base/testdef/basetests.xml?rev=1634459&r1=1634458&r2=1634459&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/framework/base/testdef/basetests.xml (original) +++ ofbiz/branches/json-integration-refactoring/framework/base/testdef/basetests.xml Mon Oct 27 07:13:36 2014 @@ -32,7 +32,8 @@ <junit-test-suite class-name="org.ofbiz.base.util.cache.test.UtilCacheTests"/> <junit-test-suite class-name="org.ofbiz.base.conversion.test.DateTimeTests"/> <junit-test-suite class-name="org.ofbiz.base.conversion.test.MiscTests"/> - <junit-test-suite class-name="org.ofbiz.base.json.test.JSONTests"/> + <junit-test-suite class-name="org.ofbiz.base.conversion.test.TestBooleanConverters"/> + <junit-test-suite class-name="org.ofbiz.base.conversion.test.TestJSONConverters"/> <!--junit-test-suite class-name="org.ofbiz.base.util.test.UtilIOTests"/--> <junit-test-suite class-name="org.ofbiz.base.test.BaseUnitTests"/> <junit-test-suite class-name="org.ofbiz.base.util.test.UtilPropertiesTests"/> Modified: ofbiz/branches/json-integration-refactoring/framework/common/src/org/ofbiz/common/CommonEvents.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/framework/common/src/org/ofbiz/common/CommonEvents.java?rev=1634459&r1=1634458&r2=1634459&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/framework/common/src/org/ofbiz/common/CommonEvents.java (original) +++ ofbiz/branches/json-integration-refactoring/framework/common/src/org/ofbiz/common/CommonEvents.java Mon Oct 27 07:13:36 2014 @@ -48,6 +48,8 @@ import net.sf.json.JSONSerializer; import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.lang.StringUtils; +import org.ofbiz.base.conversion.Converter; +import org.ofbiz.base.conversion.Converters; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.StringUtil; import org.ofbiz.base.util.UtilGenerics; @@ -288,11 +290,13 @@ public class CommonEvents { attrMap.remove(ignoreAttr); } } - - // create a JSON Object for return - JSONObject json = JSONObject.fromObject(attrMap); - writeJSONtoResponse(json, request.getMethod(), response); - + try { + Converter<Map, JSON> converter = Converters.getConverter(Map.class, JSON.class); + JSON json = converter.convert(attrMap); + writeJSONtoResponse(json, request.getMethod(), response); + } catch (Exception e) { + return "error"; + } return "success"; } Modified: ofbiz/branches/json-integration-refactoring/framework/sql/build.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/framework/sql/build.xml?rev=1634459&r1=1634458&r2=1634459&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/framework/sql/build.xml (original) +++ ofbiz/branches/json-integration-refactoring/framework/sql/build.xml Mon Oct 27 07:13:36 2014 @@ -45,11 +45,8 @@ under the License. <file name="org/ofbiz/sql/test/ValuesTest.java"/> <file name="org/ofbiz/sql/test/ConditionsTest.java"/> <file name="org/ofbiz/sql/test/SelectTest.java"/> - <file name="org/ofbiz/sql/test/SQLTest.java"/> </filelist> <patternset id="cobertura-src-dirs"> - <include name="build/gen-src/javacc"/> - <include name="build/gen-src/jjtree"/> <include name="src"/> </patternset> @@ -57,21 +54,6 @@ under the License. <!-- Compilation of the source files --> <!-- ================================================================== --> - <target name="gen-src"> - <ofbiz-javacc dir="org/ofbiz/sql" file="Parser"/> - </target> - - <target name="classes" depends="prepare,gen-src"> - <javac17> - <sourcepath> - <dirset dir="build/gen-src"> - <include name="javacc"/> - <include name="jjtree"/> - </dirset> - </sourcepath> - </javac17> - </target> - <target name="jar" depends="classes"> <main-jar/> <test-jar/> @@ -83,10 +65,6 @@ under the License. <target name="docs" depends="prepare-docs"> <default-javadoc> - <fileset dir="build/gen-src/javacc" defaultexcludes="yes"> - <patternset refid="src.inc.set"/> - <patternset refid="src.exc.set"/> - </fileset> <fileset dir="${src.dir}" defaultexcludes="yes"> <patternset refid="src.inc.set"/> <patternset refid="src.exc.set"/> Modified: ofbiz/branches/json-integration-refactoring/framework/sql/src/org/ofbiz/sql/test/SelectTest.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/framework/sql/src/org/ofbiz/sql/test/SelectTest.java?rev=1634459&r1=1634458&r2=1634459&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/framework/sql/src/org/ofbiz/sql/test/SelectTest.java (original) +++ ofbiz/branches/json-integration-refactoring/framework/sql/src/org/ofbiz/sql/test/SelectTest.java Mon Oct 27 07:13:36 2014 @@ -18,7 +18,6 @@ */ package org.ofbiz.sql.test; -import java.io.StringReader; import java.util.Collections; import java.util.Set; @@ -30,7 +29,6 @@ import org.ofbiz.sql.FieldDef; import org.ofbiz.sql.FieldValue; import org.ofbiz.sql.FunctionCall; import org.ofbiz.sql.OrderByItem; -import org.ofbiz.sql.Parser; import org.ofbiz.sql.StaticValue; import org.ofbiz.sql.Value; @@ -44,10 +42,6 @@ public class SelectTest extends GenericT super(name); } - private static Parser parser(Object v) { - return new Parser(new StringReader(v.toString())); - } - private static <V> void basicTest(String label, Class<V> clz, V v, V o, boolean matches) { assertNotEquals(label + ":not-equals-this", v, SelectTest.class); if (o != null) { @@ -62,7 +56,6 @@ public class SelectTest extends GenericT private static void fieldAllTest(String label, FieldAll v, String alias, Set<String> exclude, FieldAll o, boolean matches) throws Exception { assertEquals(label + ":alias", alias, v.getAlias()); assertEquals(label + ":exclude", exclude, set(v)); - assertEquals(label + ":parse", v, parser(v).parse_FieldAll()); basicTest(label, FieldAll.class, v, o, matches); } @@ -83,7 +76,6 @@ public class SelectTest extends GenericT assertEquals(label + ":value", value, v.getValue()); assertEquals(label + ":alias", alias, v.getAlias()); assertEquals(label + ":default-name", defaultName, v.getDefaultName()); - assertEquals(label + ":parse", v, parser(v).parse_FieldDef()); basicTest(label, FieldDef.class, v, o, matches); } @@ -104,7 +96,6 @@ public class SelectTest extends GenericT assertEquals(label + ":order", order, v.getOrder()); assertEquals(label + ":nulls", nulls, v.getNulls()); assertEquals(label + ":value", value, v.getValue()); - assertEquals(label + ":parse", v, parser(v).parse_OrderByItem()); basicTest(label, OrderByItem.class, v, o, matches); } Modified: ofbiz/branches/json-integration-refactoring/macros.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/macros.xml?rev=1634459&r1=1634458&r2=1634459&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/macros.xml (original) +++ ofbiz/branches/json-integration-refactoring/macros.xml Mon Oct 27 07:13:36 2014 @@ -186,32 +186,6 @@ under the License. <pathelement location="${ofbiz.home.dir}/framework/base/lib/ant/ant-contrib-1.0b3.jar"/> </classpath> </taskdef> - <macrodef name="ofbiz-javacc"> - <attribute name="dir"/> - <attribute name="file"/> - <attribute name="prefix" default=""/> - <sequential> - <if> - <not> - <uptodate - srcfile="@{prefix}src/@{dir}/@{file}.jj" - targetfile="@{prefix}build/gen-src/javacc/@{dir}/@{file}.java"/> - </not> - <then> - <delete dir="@{prefix}build/gen-src/javacc/@{dir}"/> - <mkdir dir="@{prefix}build/gen-src/javacc/@{dir}"/> - <javacc target="@{prefix}src/@{dir}/@{file}.jj" - javacchome="${ofbiz.home.dir}/lib/build/javacc" - outputdirectory="@{prefix}build/gen-src/javacc/@{dir}"/> - <replace token="public class" - value='@SuppressWarnings("all") public class' - dir="@{prefix}build/gen-src/javacc/@{dir}" - includes="*.java" /> - <delete dir="@{prefix}build/classes/@{dir}"/> - </then> - </if> - </sequential> - </macrodef> <presetdef name="externalsubant"> <subant inheritall="false">