camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r748572 - in /camel/trunk/components/camel-sql/src: main/java/org/apache/camel/component/sql/SqlConstants.java main/java/org/apache/camel/component/sql/SqlProducer.java test/java/org/apache/camel/component/sql/SqlRouteTest.java
Date Fri, 27 Feb 2009 16:22:43 GMT
Author: davsclaus
Date: Fri Feb 27 16:22:42 2009
New Revision: 748572

URL: http://svn.apache.org/viewvc?rev=748572&view=rev
Log:
CAMEL-1373: CamelCase

Added:
    camel/trunk/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConstants.java
  (with props)
Modified:
    camel/trunk/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
    camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlRouteTest.java

Added: camel/trunk/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConstants.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConstants.java?rev=748572&view=auto
==============================================================================
--- camel/trunk/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConstants.java
(added)
+++ camel/trunk/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConstants.java
Fri Feb 27 16:22:42 2009
@@ -0,0 +1,31 @@
+/**
+ * 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.component.sql;
+
+/**
+ * SQL Constants.
+ */
+public final class SqlConstants {
+
+    public static final String SQL_UPDATE_COUNT = "CamelSqlUpdateCount";
+
+    public static final String SQL_ROW_COUNT = "CamelSqlRowCount";
+
+    private SqlConstants() {
+        // Utility class
+    }
+}

Propchange: camel/trunk/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConstants.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java?rev=748572&r1=748571&r2=748572&view=diff
==============================================================================
--- camel/trunk/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
(original)
+++ camel/trunk/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
Fri Feb 27 16:22:42 2009
@@ -31,7 +31,6 @@
 import org.springframework.jdbc.core.RowMapperResultSetExtractor;
 
 public class SqlProducer extends DefaultProducer {
-    public static final String UPDATE_COUNT = "org.apache.camel.sql.update-count";
     private String query;
     private JdbcTemplate jdbcTemplate;
 
@@ -67,10 +66,11 @@
                     RowMapperResultSetExtractor mapper = new RowMapperResultSetExtractor(new
ColumnMapRowMapper());
                     List<?> result = (List<?>) mapper.extractData(ps.getResultSet());
                     exchange.getOut().setBody(result);
+                    exchange.getIn().setHeader(SqlConstants.SQL_ROW_COUNT, result.size());
                     // preserve headers
                     exchange.getOut().setHeaders(exchange.getIn().getHeaders());
                 } else {
-                    exchange.getIn().setHeader(UPDATE_COUNT, ps.getUpdateCount());
+                    exchange.getIn().setHeader(SqlConstants.SQL_UPDATE_COUNT, ps.getUpdateCount());
                 }
 
                 // data is set on exchange so return null

Modified: camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlRouteTest.java?rev=748572&r1=748571&r2=748572&view=diff
==============================================================================
--- camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlRouteTest.java
(original)
+++ camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlRouteTest.java
Fri Feb 27 16:22:42 2009
@@ -28,7 +28,6 @@
 import org.apache.camel.component.mock.MockEndpoint;
 import org.springframework.dao.DataAccessException;
 import org.springframework.dao.EmptyResultDataAccessException;
-import org.springframework.jdbc.UncategorizedSQLException;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.datasource.SingleConnectionDataSource;
 
@@ -88,6 +87,7 @@
     
     public void testListResult() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedHeaderReceived(SqlConstants.SQL_ROW_COUNT, "2");
         mock.expectedMessageCount(1);
         List<Object> body = new ArrayList<Object>();
         body.add("ASF");
@@ -121,16 +121,14 @@
         template.sendBody("direct:insert", new Object[] {10, "test", "test"});
         mock.assertIsSatisfied();
         try {
-            String projectName = (String)jdbcTemplate
-                .queryForObject("select project from projects where id = 10", String.class);
+            String projectName = (String)jdbcTemplate.queryForObject("select project from
projects where id = 10", String.class);
             assertEquals("test", projectName);
         } catch (EmptyResultDataAccessException e) {
             fail("no row inserted");
         }
 
-        Integer actualUpdateCount = mock.getExchanges().get(0).getIn().getHeader(SqlProducer.UPDATE_COUNT,
-                                                                                 Integer.class);
-        assertEquals((Integer)1, actualUpdateCount);
+        Integer actualUpdateCount = mock.getExchanges().get(0).getIn().getHeader(SqlConstants.SQL_UPDATE_COUNT,
Integer.class);
+        assertEquals((Integer) 1, actualUpdateCount);
     }
 
     public void testNoBody() throws Exception {



Mime
View raw message