You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2013/12/22 04:44:48 UTC
[2/2] git commit: CAMEL-7080 Polished the code and fixed some CS
errors
CAMEL-7080 Polished the code and fixed some CS errors
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/39abbbf1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/39abbbf1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/39abbbf1
Branch: refs/heads/master
Commit: 39abbbf1ae1bfc24359f02f874d60c4d54b42a6c
Parents: 53b6dcc
Author: Willem Jiang <wi...@gmail.com>
Authored: Sun Dec 22 11:44:31 2013 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Sun Dec 22 11:44:31 2013 +0800
----------------------------------------------------------------------
components/camel-csv/pom.xml | 2 +-
.../camel/dataformat/csv/CsvDataFormat.java | 1 -
.../camel/dataformat/csv/CsvIterator.java | 26 ++++++++--
.../camel/dataformat/csv/CsvIteratorTest.java | 52 ++++++++++++--------
.../csv/CsvUnmarshalStreamSpringTest.java | 6 +--
.../dataformat/csv/CsvUnmarshalStreamTest.java | 6 +--
parent/pom.xml | 1 +
7 files changed, 60 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/39abbbf1/components/camel-csv/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-csv/pom.xml b/components/camel-csv/pom.xml
index a265c08..2904163 100644
--- a/components/camel-csv/pom.xml
+++ b/components/camel-csv/pom.xml
@@ -59,7 +59,7 @@
<dependency>
<groupId>com.googlecode.jmockit</groupId>
<artifactId>jmockit</artifactId>
- <version>1.5</version>
+ <version>${jmockit-version}</version>
<scope>test</scope>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/camel/blob/39abbbf1/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvDataFormat.java b/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvDataFormat.java
index 4ce6e7e..0396b83 100644
--- a/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvDataFormat.java
+++ b/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvDataFormat.java
@@ -24,7 +24,6 @@ import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
http://git-wip-us.apache.org/repos/asf/camel/blob/39abbbf1/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvIterator.java
----------------------------------------------------------------------
diff --git a/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvIterator.java b/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvIterator.java
index 68df9c4..e9d4c41 100644
--- a/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvIterator.java
+++ b/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvIterator.java
@@ -1,7 +1,21 @@
-package org.apache.camel.dataformat.csv;
+/**
+ * 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.
+ */
-import org.apache.camel.util.IOHelper;
-import org.apache.commons.csv.CSVParser;
+package org.apache.camel.dataformat.csv;
import java.io.Closeable;
import java.io.IOException;
@@ -11,6 +25,9 @@ import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
+import org.apache.camel.util.IOHelper;
+import org.apache.commons.csv.CSVParser;
+
/**
*/
public class CsvIterator implements Iterator<List<String>>, Closeable {
@@ -19,8 +36,7 @@ public class CsvIterator implements Iterator<List<String>>, Closeable {
private final InputStreamReader in;
private String[] line;
- public CsvIterator(CSVParser parser, InputStreamReader in)
- throws IOException
+ public CsvIterator(CSVParser parser, InputStreamReader in) throws IOException
{
this.parser = parser;
this.in = in;
http://git-wip-us.apache.org/repos/asf/camel/blob/39abbbf1/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvIteratorTest.java
----------------------------------------------------------------------
diff --git a/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvIteratorTest.java b/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvIteratorTest.java
index db60e9a..385123b 100644
--- a/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvIteratorTest.java
+++ b/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvIteratorTest.java
@@ -1,35 +1,47 @@
+/**
+ * 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.csv;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+import java.util.NoSuchElementException;
+
import mockit.Expectations;
import mockit.Injectable;
import org.apache.commons.csv.CSVParser;
import org.junit.Assert;
import org.junit.Test;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.Arrays;
-import java.util.NoSuchElementException;
-
-/**
- */
public class CsvIteratorTest {
public static final String HDD_CRASH = "HDD crash";
@Test
public void closeIfError(
- final @Injectable InputStreamReader reader,
- final @Injectable CSVParser parser)
- throws IOException
- {
+ @Injectable final InputStreamReader reader,
+ @Injectable final CSVParser parser) throws IOException {
new Expectations() {
{
parser.getLine();
- result = new String[] { "1" };
+ result = new String[] {"1"};
parser.getLine();
- result = new String[] { "2" };
+ result = new String[] {"2"};
parser.getLine();
result = new IOException(HDD_CRASH);
@@ -58,20 +70,19 @@ public class CsvIteratorTest {
} catch (NoSuchElementException e) {
// okay
}
+ iterator.close();
}
@Test
- public void normalCycle(final @Injectable InputStreamReader reader,
- final @Injectable CSVParser parser)
- throws IOException
- {
+ public void normalCycle(@Injectable final InputStreamReader reader,
+ @Injectable final CSVParser parser) throws IOException {
new Expectations() {
{
parser.getLine();
- result = new String[] { "1" };
+ result = new String[] {"1"};
parser.getLine();
- result = new String[] { "2" };
+ result = new String[] {"2"};
parser.getLine();
result = null;
@@ -79,7 +90,7 @@ public class CsvIteratorTest {
reader.close();
}
};
-
+
CsvIterator iterator = new CsvIterator(parser, reader);
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals(Arrays.asList("1"), iterator.next());
@@ -95,6 +106,7 @@ public class CsvIteratorTest {
} catch (NoSuchElementException e) {
// okay
}
+ iterator.close();
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/39abbbf1/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvUnmarshalStreamSpringTest.java
----------------------------------------------------------------------
diff --git a/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvUnmarshalStreamSpringTest.java b/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvUnmarshalStreamSpringTest.java
index 0727801..17465b6 100644
--- a/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvUnmarshalStreamSpringTest.java
+++ b/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvUnmarshalStreamSpringTest.java
@@ -16,6 +16,9 @@
*/
package org.apache.camel.dataformat.csv;
+import java.util.Arrays;
+import java.util.Iterator;
+
import org.apache.camel.EndpointInject;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.spring.CamelSpringTestSupport;
@@ -23,9 +26,6 @@ import org.junit.Test;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
-import java.util.Arrays;
-import java.util.Iterator;
-
public class CsvUnmarshalStreamSpringTest extends CamelSpringTestSupport {
public static final String MESSAGE = "message";
http://git-wip-us.apache.org/repos/asf/camel/blob/39abbbf1/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvUnmarshalStreamTest.java
----------------------------------------------------------------------
diff --git a/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvUnmarshalStreamTest.java b/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvUnmarshalStreamTest.java
index 21627b2..355cd1e 100644
--- a/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvUnmarshalStreamTest.java
+++ b/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvUnmarshalStreamTest.java
@@ -16,16 +16,14 @@
*/
package org.apache.camel.dataformat.csv;
+import java.util.List;
+
import org.apache.camel.EndpointInject;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
/**
* Spring based integration test for the <code>CsvDataFormat</code>
* @version
http://git-wip-us.apache.org/repos/asf/camel/blob/39abbbf1/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 68dad0c..9971e0f 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -228,6 +228,7 @@
<jing-bundle-version>20030619_5</jing-bundle-version>
<jing-version>20030619</jing-version>
<jline-version>0.9.94</jline-version>
+ <jmockit-version>1.5</jmockit-version>
<jodatime-bundle-version>1.6.2</jodatime-bundle-version>
<jodatime2-bundle-version>2.3</jodatime2-bundle-version>
<josql-bundle-version>1.5_5</josql-bundle-version>