Author: davsclaus Date: Mon Dec 17 10:17:48 2012 New Revision: 1422827 URL: http://svn.apache.org/viewvc?rev=1422827&view=rev Log: CAMEL-5827: Added support for implied decimal values in camel-bindy. Thanks to Luca Burgazzoli for the patch.
Added: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/AbstractNumberFormat.java (with props) camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/implied/ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/implied/BindyImpliedTest.java (with props) camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/number/ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/number/BindyNumberTest.java (with props) camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/implied/ camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/implied/BindyImpliedTest-context.xml (with props) camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/number/ camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/number/BindyNumberTest-context.xml (with props) Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFixedLengthFactory.java camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyKeyValuePairFactory.java camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/FormatFactory.java camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/KeyValuePairField.java camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigDecimalFormat.java camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigIntegerFormat.java camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DoubleFormat.java camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/FloatFormat.java camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/IntegerFormat.java camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/LongFormat.java camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/ShortFormat.java camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyComplexCsvGenerateHeaderMarshallTest.java camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyComplexCsvMarshallTest.java Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java?rev=1422827&r1=1422826&r2=1422827&view=diff ============================================================================== --- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java (original) +++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java Mon Dec 17 10:17:48 2012 @@ -16,6 +16,7 @@ */ package org.apache.camel.dataformat.bindy; + import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; @@ -39,6 +40,7 @@ import org.apache.camel.util.ObjectHelpe import org.slf4j.Logger; import org.slf4j.LoggerFactory; + /** * The BindyCsvFactory is the class who allows to : Generate a model associated * to a CSV record, bind data from a record to the POJOs, export data of POJOs @@ -191,7 +193,7 @@ public class BindyCsvFactory extends Bin String pattern = dataField.pattern(); // Create format object to format the field - format = FormatFactory.getFormat(field.getType(), pattern, getLocale(), dataField.precision()); + format = FormatFactory.getFormat(field.getType(), getLocale(), dataField); // field object to be set Object modelField = model.get(field.getDeclaringClass().getName()); @@ -398,7 +400,7 @@ public class BindyCsvFactory extends Bin int precision = datafield.precision(); // Create format - Format<?> format = FormatFactory.getFormat(type, pattern, getLocale(), precision); + Format<?> format = FormatFactory.getFormat(type, getLocale(), datafield); // Get field value Object value = field.get(obj); @@ -589,8 +591,7 @@ public class BindyCsvFactory extends Bin Object modelField = model.get(field.getDeclaringClass().getName()); if (field.get(modelField) == null && !dataField.defaultValue().isEmpty()) { String pattern = dataField.pattern(); - Format<?> format = FormatFactory.getFormat(field.getType(), pattern, getLocale(), - dataField.precision()); + Format<?> format = FormatFactory.getFormat(field.getType(), getLocale(), dataField); Object value = format.parse(dataField.defaultValue()); field.set(modelField, value); } Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFixedLengthFactory.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFixedLengthFactory.java?rev=1422827&r1=1422826&r2=1422827&view=diff ============================================================================== --- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFixedLengthFactory.java (original) +++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFixedLengthFactory.java Mon Dec 17 10:17:48 2012 @@ -28,12 +28,14 @@ import java.util.Map; import java.util.Map.Entry; import java.util.TreeMap; + import org.apache.camel.dataformat.bindy.annotation.DataField; import org.apache.camel.dataformat.bindy.annotation.FixedLengthRecord; import org.apache.camel.dataformat.bindy.annotation.Link; import org.apache.camel.dataformat.bindy.format.FormatException; import org.apache.camel.spi.PackageScanClassResolver; import org.apache.camel.util.ObjectHelper; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -215,7 +217,7 @@ public class BindyFixedLengthFactory ext pattern = dataField.pattern(); // Create format object to format the field - format = FormatFactory.getFormat(field.getType(), pattern, getLocale(), dataField.precision()); + format = FormatFactory.getFormat(field.getType(), getLocale(), dataField); // field object to be set Object modelField = model.get(field.getDeclaringClass().getName()); @@ -320,7 +322,7 @@ public class BindyFixedLengthFactory ext // Create format - Format<?> format = FormatFactory.getFormat(type, pattern, getLocale(), precision); + Format<?> format = FormatFactory.getFormat(type, getLocale(), datafield); // Get field value Object value = field.get(obj); Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyKeyValuePairFactory.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyKeyValuePairFactory.java?rev=1422827&r1=1422826&r2=1422827&view=diff ============================================================================== --- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyKeyValuePairFactory.java (original) +++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyKeyValuePairFactory.java Mon Dec 17 10:17:48 2012 @@ -287,7 +287,7 @@ public class BindyKeyValuePairFactory ex String pattern = keyValuePairField.pattern(); // Create format object to format the field - Format<?> format = FormatFactory.getFormat(field.getType(), pattern, getLocale(), keyValuePairField.precision()); + Format<?> format = FormatFactory.getFormat(field.getType(), getLocale(), keyValuePairField); // format the value of the key received result = formatField(format, value, key, line); @@ -326,7 +326,7 @@ public class BindyKeyValuePairFactory ex String pattern = keyValuePairField.pattern(); // Create format object to format the field - Format<?> format = FormatFactory.getFormat(field.getType(), pattern, getLocale(), keyValuePairField.precision()); + Format<?> format = FormatFactory.getFormat(field.getType(), getLocale(), keyValuePairField); // format the value of the key received Object result = formatField(format, value, key, line); @@ -456,7 +456,7 @@ public class BindyKeyValuePairFactory ex // Create format @SuppressWarnings("unchecked") - Format<Object> format = (Format<Object>)FormatFactory.getFormat(type, pattern, getLocale(), precision); + Format<Object> format = (Format<Object>)FormatFactory.getFormat(type, getLocale(), keyValuePairField); // Get object to be formatted Object obj = model.get(field.getDeclaringClass().getName()); Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/FormatFactory.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/FormatFactory.java?rev=1422827&r1=1422826&r2=1422827&view=diff ============================================================================== --- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/FormatFactory.java (original) +++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/FormatFactory.java Mon Dec 17 10:17:48 2012 @@ -16,11 +16,14 @@ */ package org.apache.camel.dataformat.bindy; + import java.math.BigDecimal; import java.math.BigInteger; import java.util.Date; import java.util.Locale; +import org.apache.camel.dataformat.bindy.annotation.DataField; +import org.apache.camel.dataformat.bindy.annotation.KeyValuePairField; import org.apache.camel.dataformat.bindy.format.BigDecimalFormat; import org.apache.camel.dataformat.bindy.format.BigIntegerFormat; import org.apache.camel.dataformat.bindy.format.ByteFormat; @@ -38,6 +41,8 @@ import org.apache.camel.dataformat.bindy import org.apache.camel.dataformat.bindy.format.ShortFormat; import org.apache.camel.dataformat.bindy.format.ShortPatternFormat; import org.apache.camel.dataformat.bindy.format.StringFormat; +import org.apache.camel.util.ObjectHelper; + /** * Factory to return {@link Format} classes for a given type. @@ -54,48 +59,80 @@ public final class FormatFactory { * @param pattern is the pattern to be used during the formatting of the data * @param locale optional locale for NumberFormat and DateFormat parsing. * @param precision optional scale for BigDecimal parsing. + * @param impliedDecimalSeparator optional flag for floatign-point values * @return Format the formatter * @throws IllegalArgumentException if not suitable formatter is found */ - public static Format<?> getFormat(Class<?> clazz, String pattern, String locale, int precision) throws Exception { + private static Format<?> doGetFormat(Class<?> clazz, String pattern, String locale, int precision, boolean impliedDecimalSeparator) throws Exception { if (clazz == byte.class || clazz == Byte.class) { - return pattern != null ? new BytePatternFormat(pattern, getLocale(locale)) : new ByteFormat(); - + return ObjectHelper.isNotEmpty(pattern) + ? new BytePatternFormat(pattern, getLocale(locale)) + : new ByteFormat(); } else if (clazz == short.class || clazz == Short.class) { - return pattern != null ? new ShortPatternFormat(pattern, getLocale(locale)) : new ShortFormat(); - + return ObjectHelper.isNotEmpty(pattern) + ? new ShortPatternFormat(pattern, getLocale(locale)) + : new ShortFormat(); } else if (clazz == int.class || clazz == Integer.class) { - return pattern != null ? new IntegerPatternFormat(pattern, getLocale(locale)) : new IntegerFormat(); - + return ObjectHelper.isNotEmpty(pattern) + ? new IntegerPatternFormat(pattern, getLocale(locale)) + : new IntegerFormat(); } else if (clazz == long.class || clazz == Long.class) { - return pattern != null ? new LongPatternFormat(pattern, getLocale(locale)) : new LongFormat(); - + return ObjectHelper.isNotEmpty(pattern) + ? new LongPatternFormat(pattern, getLocale(locale)) + : new LongFormat(); } else if (clazz == float.class || clazz == Float.class) { - return pattern != null ? new FloatPatternFormat(pattern, getLocale(locale)) : new FloatFormat(); - + return ObjectHelper.isNotEmpty(pattern) + ? new FloatPatternFormat(pattern, getLocale(locale)) + : new FloatFormat(impliedDecimalSeparator, precision, getLocale(locale)); } else if (clazz == double.class || clazz == Double.class) { - return pattern != null ? new DoublePatternFormat(pattern, getLocale(locale)) : new DoubleFormat(); - + return ObjectHelper.isNotEmpty(pattern) + ? new DoublePatternFormat(pattern, getLocale(locale)) + : new DoubleFormat(impliedDecimalSeparator, precision, getLocale(locale)); } else if (clazz == BigDecimal.class) { - return new BigDecimalFormat(precision); - + return new BigDecimalFormat(impliedDecimalSeparator, precision, getLocale(locale)); } else if (clazz == BigInteger.class) { return new BigIntegerFormat(); - } else if (clazz == String.class) { return new StringFormat(); - } else if (clazz == Date.class) { return new DatePatternFormat(pattern, getLocale(locale)); - } else if (clazz == char.class || clazz == Character.class) { return new CharacterFormat(); - } else { throw new IllegalArgumentException("Can not find a suitable formatter for the type: " + clazz.getCanonicalName()); } } + /** + * Retrieves the format to use for the given type + * + * @param clazz represents the type of the format (String, Integer, Byte) + * @param locale optional locale for NumberFormat and DateFormat parsing. + * @return Format the formatter + * @throws IllegalArgumentException if not suitable formatter is found + */ + public static Format<?> getFormat(Class<?> clazz, String locale, DataField data) throws Exception { + String pattern = data.pattern(); + int precision = data.precision(); + + return doGetFormat(clazz, pattern, locale, precision, data.impliedDecimalSeparator()); + } + + /** + * Retrieves the format to use for the given type + * + * @param clazz represents the type of the format (String, Integer, Byte) + * @param locale optional locale for NumberFormat and DateFormat parsing. + * @return Format the formatter + * @throws IllegalArgumentException if not suitable formatter is found + */ + public static Format<?> getFormat(Class<?> clazz, String locale, KeyValuePairField data) throws Exception { + String pattern = data.pattern(); + int precision = data.precision(); + + return doGetFormat(clazz, pattern, locale, precision, data.impliedDecimalSeparator()); + } + private static Locale getLocale(String locale) { Locale answer = null; if (locale != null && !(locale.length() == 0)) { Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java?rev=1422827&r1=1422826&r2=1422827&view=diff ============================================================================== --- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java (original) +++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java Mon Dec 17 10:17:48 2012 @@ -101,4 +101,9 @@ public @interface DataField { * Field's default value in case no value is set */ String defaultValue() default ""; + + /** + * Indicates if there is a decimal point implied at a specified location + */ + boolean impliedDecimalSeparator() default false; } Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/KeyValuePairField.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/KeyValuePairField.java?rev=1422827&r1=1422826&r2=1422827&view=diff ============================================================================== --- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/KeyValuePairField.java (original) +++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/KeyValuePairField.java Mon Dec 17 10:17:48 2012 @@ -71,6 +71,13 @@ public @interface KeyValuePairField { */ int precision() default 0; + /** + * Indicates if the field is mandatory + */ boolean required() default false; + /** + * Indicates if there is a decimal point implied at a specified location + */ + boolean impliedDecimalSeparator() default false; } Added: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/AbstractNumberFormat.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/AbstractNumberFormat.java?rev=1422827&view=auto ============================================================================== --- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/AbstractNumberFormat.java (added) +++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/AbstractNumberFormat.java Mon Dec 17 10:17:48 2012 @@ -0,0 +1,83 @@ +/** + * 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.apache.camel.dataformat.bindy.format; + +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.util.Locale; + +import org.apache.camel.dataformat.bindy.Format; + +/** + * + */ +public abstract class AbstractNumberFormat<T extends Number> implements Format<T> { + private boolean impliedDecimalPosition; + private int precision; + private DecimalFormat format; + private int multiplier; + + /** + * + */ + public AbstractNumberFormat() { + this(false, 0, null); + } + + /** + * + */ + public AbstractNumberFormat(boolean impliedDecimalPosition, int precision, Locale locale) { + this.impliedDecimalPosition = impliedDecimalPosition; + this.precision = precision > 0 ? precision : 0; + this.format = null; + this.multiplier = 1; + + this.format = new DecimalFormat(); + this.format.setGroupingUsed(false); + this.format.setDecimalSeparatorAlwaysShown(false); + + if (locale != null) { + this.format.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(locale)); + } + + if (this.impliedDecimalPosition) { + this.format.setMinimumFractionDigits(0); + this.format.setMaximumFractionDigits(0); + this.multiplier = (int)Math.pow(10D, precision); + } else { + this.format.setMinimumFractionDigits(this.precision); + this.format.setMaximumFractionDigits(this.precision); + } + } + + protected boolean hasImpliedDecimalPosition() { + return this.impliedDecimalPosition; + } + + protected int getPrecision() { + return this.precision; + } + + protected DecimalFormat getFormat() { + return this.format; + } + + protected int getMultiplier() { + return multiplier; + } +} Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/AbstractNumberFormat.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/AbstractNumberFormat.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigDecimalFormat.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigDecimalFormat.java?rev=1422827&r1=1422826&r2=1422827&view=diff ============================================================================== --- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigDecimalFormat.java (original) +++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigDecimalFormat.java Mon Dec 17 10:17:48 2012 @@ -17,39 +17,30 @@ package org.apache.camel.dataformat.bindy.format; import java.math.BigDecimal; +import java.util.Locale; -import org.apache.camel.dataformat.bindy.Format; -public class BigDecimalFormat implements Format<BigDecimal> { +public class BigDecimalFormat extends AbstractNumberFormat<BigDecimal> { - private int precision = -1; - - public BigDecimalFormat(int precision) { - this.precision = precision; - } - - public BigDecimalFormat() { + public BigDecimalFormat(boolean impliedDecimalPosition, int precision, Locale locale) { + super(impliedDecimalPosition, precision, locale); } public String format(BigDecimal object) throws Exception { - return object.toString(); + return !super.hasImpliedDecimalPosition() + ? super.getFormat().format(object) + : super.getFormat().format(object.multiply(new BigDecimal(super.getMultiplier()))); } public BigDecimal parse(String string) throws Exception { - BigDecimal result = new BigDecimal(string); - // only set precision if defined - if (precision != -1) { - result = result.setScale(precision); + BigDecimal result = new BigDecimal(string.trim()); + if (super.hasImpliedDecimalPosition()) { + result = result.divide(new BigDecimal(super.getMultiplier())); + } + if (super.getPrecision() != -1) { + result = result.setScale(super.getPrecision()); } - return result; - } - - public int getPrecision() { - return precision; - } - public void setPrecision(int precision) { - this.precision = precision; + return result; } - } Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigIntegerFormat.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigIntegerFormat.java?rev=1422827&r1=1422826&r2=1422827&view=diff ============================================================================== --- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigIntegerFormat.java (original) +++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigIntegerFormat.java Mon Dec 17 10:17:48 2012 @@ -18,9 +18,7 @@ package org.apache.camel.dataformat.bind import java.math.BigInteger; -import org.apache.camel.dataformat.bindy.Format; - -public class BigIntegerFormat implements Format<BigInteger> { +public class BigIntegerFormat extends AbstractNumberFormat<BigInteger> { public String format(BigInteger object) throws Exception { return object.toString(); Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DoubleFormat.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DoubleFormat.java?rev=1422827&r1=1422826&r2=1422827&view=diff ============================================================================== --- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DoubleFormat.java (original) +++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DoubleFormat.java Mon Dec 17 10:17:48 2012 @@ -16,16 +16,31 @@ */ package org.apache.camel.dataformat.bindy.format; -import org.apache.camel.dataformat.bindy.Format; +import java.math.BigDecimal; +import java.util.Locale; -public class DoubleFormat implements Format<Double> { +public class DoubleFormat extends AbstractNumberFormat<Double> { + + public DoubleFormat(boolean impliedDecimalPosition, int precision, Locale locale) { + super(impliedDecimalPosition, precision, locale); + } public String format(Double object) throws Exception { - return object.toString(); + return !super.hasImpliedDecimalPosition() + ? super.getFormat().format(object) + : super.getFormat().format(object * super.getMultiplier()); } public Double parse(String string) throws Exception { - return new Double(string); - } + Double value = null; + if (!super.hasImpliedDecimalPosition()) { + value = Double.parseDouble(string.trim()); + } else { + BigDecimal tmp = new BigDecimal(string.trim()); + BigDecimal div = BigDecimal.valueOf(super.getMultiplier()); + value = tmp.divide(div).doubleValue(); + } + return value; + } } Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/FloatFormat.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/FloatFormat.java?rev=1422827&r1=1422826&r2=1422827&view=diff ============================================================================== --- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/FloatFormat.java (original) +++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/FloatFormat.java Mon Dec 17 10:17:48 2012 @@ -16,16 +16,31 @@ */ package org.apache.camel.dataformat.bindy.format; -import org.apache.camel.dataformat.bindy.Format; +import java.math.BigDecimal; +import java.util.Locale; -public class FloatFormat implements Format<Float> { +public class FloatFormat extends AbstractNumberFormat<Float> { + + public FloatFormat(boolean impliedDecimalPosition, int precision, Locale locale) { + super(impliedDecimalPosition, precision, locale); + } public String format(Float object) throws Exception { - return object.toString(); + return !super.hasImpliedDecimalPosition() + ? super.getFormat().format(object) + : super.getFormat().format(object * super.getMultiplier()); } public Float parse(String string) throws Exception { - return new Float(string); - } + Float value = null; + if (!super.hasImpliedDecimalPosition()) { + value = Float.parseFloat(string.trim()); + } else { + BigDecimal tmp = new BigDecimal(string.trim()); + BigDecimal div = BigDecimal.valueOf(super.getMultiplier()); + value = tmp.divide(div).floatValue(); + } + return value; + } } Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/IntegerFormat.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/IntegerFormat.java?rev=1422827&r1=1422826&r2=1422827&view=diff ============================================================================== --- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/IntegerFormat.java (original) +++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/IntegerFormat.java Mon Dec 17 10:17:48 2012 @@ -16,9 +16,8 @@ */ package org.apache.camel.dataformat.bindy.format; -import org.apache.camel.dataformat.bindy.Format; -public class IntegerFormat implements Format<Integer> { +public class IntegerFormat extends AbstractNumberFormat<Integer> { public String format(Integer object) throws Exception { return object.toString(); Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/LongFormat.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/LongFormat.java?rev=1422827&r1=1422826&r2=1422827&view=diff ============================================================================== --- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/LongFormat.java (original) +++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/LongFormat.java Mon Dec 17 10:17:48 2012 @@ -16,9 +16,8 @@ */ package org.apache.camel.dataformat.bindy.format; -import org.apache.camel.dataformat.bindy.Format; -public class LongFormat implements Format<Long> { +public class LongFormat extends AbstractNumberFormat<Long> { public String format(Long object) throws Exception { return object.toString(); Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/ShortFormat.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/ShortFormat.java?rev=1422827&r1=1422826&r2=1422827&view=diff ============================================================================== --- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/ShortFormat.java (original) +++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/ShortFormat.java Mon Dec 17 10:17:48 2012 @@ -16,9 +16,8 @@ */ package org.apache.camel.dataformat.bindy.format; -import org.apache.camel.dataformat.bindy.Format; -public class ShortFormat implements Format<Short> { +public class ShortFormat extends AbstractNumberFormat<Short> { public String format(Short object) throws Exception { return object.toString(); Modified: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyComplexCsvGenerateHeaderMarshallTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyComplexCsvGenerateHeaderMarshallTest.java?rev=1422827&r1=1422826&r2=1422827&view=diff ============================================================================== --- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyComplexCsvGenerateHeaderMarshallTest.java (original) +++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyComplexCsvGenerateHeaderMarshallTest.java Mon Dec 17 10:17:48 2012 @@ -41,7 +41,7 @@ public class BindyComplexCsvGenerateHead private List<Map<String, Object>> models = new ArrayList<Map<String, Object>>(); private String result = "Order Nr,Client Nr,First Name,Last Name,Instrument Code,Instrument Nr,Order Type,Instrument Type,amount,currency,Order Date\r\n" - + "10,A1,Julia,Roberts,ISIN,LU123456789,BUY,Share,150,USD,14-01-2009\r\n"; + + "10,A1,Julia,Roberts,ISIN,LU123456789,BUY,Share,150.00,USD,14-01-2009\r\n"; @Produce(uri = "direct:start") private ProducerTemplate template; Modified: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyComplexCsvMarshallTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyComplexCsvMarshallTest.java?rev=1422827&r1=1422826&r2=1422827&view=diff ============================================================================== --- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyComplexCsvMarshallTest.java (original) +++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyComplexCsvMarshallTest.java Mon Dec 17 10:17:48 2012 @@ -40,7 +40,7 @@ import org.springframework.test.context. public class BindyComplexCsvMarshallTest extends AbstractJUnit4SpringContextTests { private List<Map<String, Object>> models = new ArrayList<Map<String, Object>>(); - private String result = "10,A1,Julia,Roberts,ISIN,LU123456789,BUY,Share,150,USD,14-01-2009\r\n"; + private String result = "10,A1,Julia,Roberts,ISIN,LU123456789,BUY,Share,150.00,USD,14-01-2009\r\n"; @Produce(uri = "direct:start") private ProducerTemplate template; Added: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/implied/BindyImpliedTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/implied/BindyImpliedTest.java?rev=1422827&view=auto ============================================================================== --- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/implied/BindyImpliedTest.java (added) +++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/implied/BindyImpliedTest.java Mon Dec 17 10:17:48 2012 @@ -0,0 +1,214 @@ +/** + * 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.apache.camel.dataformat.bindy.fixed.implied; + +import java.math.BigDecimal; + +import org.apache.camel.EndpointInject; +import org.apache.camel.Exchange; +import org.apache.camel.Produce; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.dataformat.bindy.annotation.DataField; +import org.apache.camel.dataformat.bindy.annotation.FixedLengthRecord; +import org.apache.camel.model.dataformat.BindyType; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; + + + +@ContextConfiguration +public class BindyImpliedTest extends AbstractJUnit4SpringContextTests { + + public static final String URI_DIRECT_MARSHALL = "direct:marshall"; + public static final String URI_DIRECT_UNMARSHALL = "direct:unmarshall"; + public static final String URI_MOCK_MARSHALL_RESULT = "mock:marshall-result"; + public static final String URI_MOCK_UNMARSHALL_RESULT = "mock:unmarshall-result"; + + // ************************************************************************* + // + // ************************************************************************* + + @Produce(uri = URI_DIRECT_MARSHALL) + private ProducerTemplate mtemplate; + + @EndpointInject(uri = URI_MOCK_MARSHALL_RESULT) + private MockEndpoint mresult; + + @Produce(uri = URI_DIRECT_UNMARSHALL) + private ProducerTemplate utemplate; + + @EndpointInject(uri = URI_MOCK_UNMARSHALL_RESULT) + private MockEndpoint uresult; + + // ************************************************************************* + // TEST + // ************************************************************************* + + @Test + @DirtiesContext + public void testMarshall() throws Exception { + + Record rec = new Record(); + rec.setField1(123.45); + rec.setField2(67.89); + rec.setField3(11.24F); + rec.setField4(33.45F); + rec.setField5(new BigDecimal(60.52)); + rec.setField6(new BigDecimal(70.62)); + + mresult.expectedBodiesReceived("1234567.89 112433.45 605270.62\r\n"); + + mtemplate.sendBody(rec); + mresult.assertIsSatisfied(); + } + + @Test + @DirtiesContext + public void testUnMarshall() throws Exception { + + utemplate.sendBody("1234567.89 112433.45 605270.62"); + + uresult.expectedMessageCount(1); + uresult.assertIsSatisfied(); + + // check the model + Exchange exc = uresult.getReceivedExchanges().get(0); + Record data = exc.getIn().getBody(Record.class); + + Assert.assertEquals(123.45D, data.getField1(), 0D); + Assert.assertEquals(67.89D, data.getField2(), 0D); + Assert.assertEquals(11.24F, data.getField3(), 0.001); + Assert.assertEquals(33.45F, data.getField4(), 0.001); + Assert.assertEquals(60.52D, data.getField5().doubleValue(), 0.001); + Assert.assertEquals(70.62D, data.getField6().doubleValue(), 0.001); + } + + // ************************************************************************* + // ROUTES + // ************************************************************************* + + public static class ContextConfig extends RouteBuilder { + public void configure() { + from(URI_DIRECT_MARSHALL) + .marshal().bindy(BindyType.Fixed, Record.class) + .to(URI_MOCK_MARSHALL_RESULT); + from(URI_DIRECT_UNMARSHALL) + .unmarshal().bindy(BindyType.Fixed, Record.class) + .to(URI_MOCK_UNMARSHALL_RESULT); + } + } + + // ************************************************************************* + // DATA MODEL + // ************************************************************************* + + @FixedLengthRecord(length = 30, paddingChar = ' ') + public static class Record { + + @DataField(pos = 1, length = 5, precision = 2, impliedDecimalSeparator = true) + private Double field1; + + @DataField(pos = 6, length = 5, precision = 2) + private Double field2; + + @DataField(pos = 11, length = 5, precision = 2, impliedDecimalSeparator = true) + private Float field3; + + @DataField(pos = 16, length = 5, precision = 2) + private Float field4; + + @DataField(pos = 21, length = 5, precision = 2, impliedDecimalSeparator = true) + private BigDecimal field5; + + @DataField(pos = 26, length = 5, precision = 2) + private BigDecimal field6; + + + // ********************************************************************* + // GETTER/SETTERS + // ********************************************************************* + + public Double getField1() { + return field1; + } + + public void setField1(Double value) { + this.field1 = value; + } + + public Double getField2() { + return field2; + } + + public void setField2(Double value) { + this.field2 = value; + } + + public Float getField3() { + return field3; + } + + public void setField3(Float value) { + this.field3 = value; + } + + public Float getField4() { + return field4; + } + + public void setField4(Float value) { + this.field4 = value; + } + + public BigDecimal getField5() { + return field5; + } + + public void setField5(BigDecimal value) { + this.field5 = value; + } + + public BigDecimal getField6() { + return field6; + } + + public void setField6(BigDecimal value) { + this.field6 = value; + } + + // ********************************************************************* + // HELPERS + // ********************************************************************* + + @Override + public String toString() { + return "Record{" + + "field1=<" + field1 + ">" + + ", field2=<" + field2 + ">" + + ", field3=<" + field3 + ">" + + ", field4=<" + field4 + ">" + + ", field5=<" + field6 + ">" + + ", field6=<" + field6 + ">" + + "}"; + } + } +} Propchange: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/implied/BindyImpliedTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/implied/BindyImpliedTest.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/number/BindyNumberTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/number/BindyNumberTest.java?rev=1422827&view=auto ============================================================================== --- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/number/BindyNumberTest.java (added) +++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/number/BindyNumberTest.java Mon Dec 17 10:17:48 2012 @@ -0,0 +1,132 @@ +/** + * 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.apache.camel.dataformat.bindy.fixed.number; + +import java.math.BigDecimal; + +import org.apache.camel.EndpointInject; +import org.apache.camel.Exchange; +import org.apache.camel.Produce; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.dataformat.bindy.annotation.DataField; +import org.apache.camel.dataformat.bindy.annotation.FixedLengthRecord; +import org.apache.camel.model.dataformat.BindyType; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; + +@ContextConfiguration +public class BindyNumberTest extends AbstractJUnit4SpringContextTests { + + public static final String URI_DIRECT_MARSHALL = "direct:marshall"; + public static final String URI_DIRECT_UNMARSHALL = "direct:unmarshall"; + public static final String URI_MOCK_MARSHALL_RESULT = "mock:marshall-result"; + public static final String URI_MOCK_UNMARSHALL_RESULT = "mock:unmarshall-result"; + + // ************************************************************************* + // + // ************************************************************************* + + @Produce(uri = URI_DIRECT_MARSHALL) + private ProducerTemplate mtemplate; + + @EndpointInject(uri = URI_MOCK_MARSHALL_RESULT) + private MockEndpoint mresult; + + @Produce(uri = URI_DIRECT_UNMARSHALL) + private ProducerTemplate utemplate; + + @EndpointInject(uri = URI_MOCK_UNMARSHALL_RESULT) + private MockEndpoint uresult; + + // ************************************************************************* + // TEST + // ************************************************************************* + + @Test + @DirtiesContext + public void testMarshall() throws Exception { + DataModel rec = new DataModel(); + rec.field1 = new BigDecimal(123.45); + rec.field2 = new BigDecimal(10.00); + rec.field3 = new BigDecimal(10.00); + rec.field4 = new Double(10.00); + rec.field5 = new Double(10.00); + + mresult.expectedBodiesReceived("1234510.00 1010.00 10\r\n"); + + mtemplate.sendBody(rec); + mresult.assertIsSatisfied(); + } + + @Test + @DirtiesContext + public void testUnMarshall() throws Exception { + + utemplate.sendBody("1234510.00 1010.00 10"); + + uresult.expectedMessageCount(1); + uresult.assertIsSatisfied(); + + // check the model + Exchange exc = uresult.getReceivedExchanges().get(0); + DataModel data = exc.getIn().getBody(DataModel.class); + + Assert.assertEquals(123.45D, data.field1.doubleValue(), 0D); + Assert.assertEquals(10.00D, data.field2.doubleValue(), 0D); + Assert.assertEquals(10.00D, data.field3.doubleValue(), 0D); + Assert.assertEquals(10.00D, data.field4.doubleValue(), 0D); + Assert.assertEquals(10.00D, data.field5.doubleValue(), 0D); + } + + // ************************************************************************* + // ROUTES + // ************************************************************************* + + public static class ContextConfig extends RouteBuilder { + public void configure() { + from(URI_DIRECT_MARSHALL) + .marshal().bindy(BindyType.Fixed, DataModel.class) + .to(URI_MOCK_MARSHALL_RESULT); + from(URI_DIRECT_UNMARSHALL) + .unmarshal().bindy(BindyType.Fixed, DataModel.class) + .to(URI_MOCK_UNMARSHALL_RESULT); + } + } + + // ************************************************************************* + // DATA MODEL + // ************************************************************************* + + @FixedLengthRecord(length = 25, paddingChar = ' ') + public static class DataModel { + @DataField(pos = 1, length = 5, precision = 2, impliedDecimalSeparator = true) + public BigDecimal field1; + @DataField(pos = 6, length = 5, precision = 2) + public BigDecimal field2; + @DataField(pos = 11, length = 5) + public BigDecimal field3; + @DataField(pos = 16, length = 5, precision = 2) + public Double field4; + @DataField(pos = 21, length = 5) + public Double field5; + } +} Propchange: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/number/BindyNumberTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/number/BindyNumberTest.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/implied/BindyImpliedTest-context.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/implied/BindyImpliedTest-context.xml?rev=1422827&view=auto ============================================================================== --- camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/implied/BindyImpliedTest-context.xml (added) +++ camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/implied/BindyImpliedTest-context.xml Mon Dec 17 10:17:48 2012 @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://camel.apache.org/schema/spring + http://camel.apache.org/schema/spring/camel-spring.xsd"> + + <camelContext xmlns="http://camel.apache.org/schema/spring"> + <routeBuilder ref="myBuilder"/> + </camelContext> + + <bean id ="myBuilder" + class ="org.apache.camel.dataformat.bindy.fixed.implied.BindyImpliedTest$ContextConfig"/> + +</beans> \ No newline at end of file Propchange: camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/implied/BindyImpliedTest-context.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/implied/BindyImpliedTest-context.xml ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/implied/BindyImpliedTest-context.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/number/BindyNumberTest-context.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/number/BindyNumberTest-context.xml?rev=1422827&view=auto ============================================================================== --- camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/number/BindyNumberTest-context.xml (added) +++ camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/number/BindyNumberTest-context.xml Mon Dec 17 10:17:48 2012 @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://camel.apache.org/schema/spring + http://camel.apache.org/schema/spring/camel-spring.xsd"> + + <camelContext xmlns="http://camel.apache.org/schema/spring"> + <routeBuilder ref="myBuilder"/> + </camelContext> + + <bean id ="myBuilder" + class ="org.apache.camel.dataformat.bindy.fixed.number.BindyNumberTest$ContextConfig"/> + +</beans> \ No newline at end of file Propchange: camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/number/BindyNumberTest-context.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/number/BindyNumberTest-context.xml ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/number/BindyNumberTest-context.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml