Skip to content

Commit

Permalink
(#29) Corrected demo calls
Browse files Browse the repository at this point in the history
  • Loading branch information
svettwer committed Sep 6, 2019
1 parent aac411b commit 0dda9cd
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2006-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.consol.citrus.demo.controller;

import com.consol.citrus.demo.model.City;
Expand All @@ -10,7 +26,10 @@
import org.springframework.stereotype.Controller;
import org.springframework.util.LinkedCaseInsensitiveMap;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.CallableStatement;
import java.sql.JDBCType;
Expand Down Expand Up @@ -94,7 +113,7 @@ private List<SqlParameter> createParameters() {

private CallableStatementCreator createCallableStatement(final String name) {
return con ->{
final CallableStatement callableStatement = con.prepareCall("CALL findCityByName(?,?)");
final CallableStatement callableStatement = con.prepareCall("CALL findCityByName(?,:name)");
callableStatement.registerOutParameter(2, JDBCType.INTEGER);
callableStatement.setString("name", name);
return callableStatement;
Expand Down
18 changes: 17 additions & 1 deletion demo/src/test/java/com/consol/citrus/demo/DemoJdbcServer.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2006-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.consol.citrus.demo;

import com.consol.citrus.db.driver.json.JsonDataSetProducer;
Expand Down Expand Up @@ -43,7 +59,7 @@ public static void main(final String[] args) throws IOException, SQLException {

dbServer.when()
.statement()
.execute(Pattern.compile("CALL findCityByName\\(\\?,\\?\\) - \\(\\?,Munich\\)"))
.execute(Pattern.compile("CALL findCityByName\\(\\?,:name\\) - \\(\\?,Munich\\)"))
.thenReturn(new JsonDataSetProducer("[{ \"name\": \"Munich\", \"id\": 1 }]").produce());


Expand Down

0 comments on commit 0dda9cd

Please sign in to comment.