diff --git a/pom.xml b/pom.xml index a05d534..5c1ea68 100644 --- a/pom.xml +++ b/pom.xml @@ -44,12 +44,16 @@ 6.0 provided - - + + + commons-dbcp + commons-dbcp + 1.2.2 + - com.h2database - h2 - 1.4.196 + com.microsoft.sqlserver + mssql-jdbc + 6.1.0.jre8 diff --git a/src/main/java/com/example/demo/DemoApplication.java b/src/main/java/com/example/demo/DemoApplication.java deleted file mode 100644 index e03ec75..0000000 --- a/src/main/java/com/example/demo/DemoApplication.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.example.demo; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class DemoApplication { - - public static void main(String[] args) { - SpringApplication.run(DemoApplication.class, args); - } -} diff --git a/src/main/java/com/rshka/mcs/configuration/DBConfiguration.java b/src/main/java/com/rshka/mcs/configuration/DBConfiguration.java index 21cd125..283c532 100644 --- a/src/main/java/com/rshka/mcs/configuration/DBConfiguration.java +++ b/src/main/java/com/rshka/mcs/configuration/DBConfiguration.java @@ -2,6 +2,7 @@ package com.rshka.mcs.configuration; import javax.sql.DataSource; +import org.apache.commons.dbcp.BasicDataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -15,14 +16,12 @@ public class DBConfiguration { @Bean public DataSource dataSource() { - return new EmbeddedDatabaseBuilder() - .generateUniqueName(false). - setName("testdb") - .setType(EmbeddedDatabaseType.H2) - .addDefaultScripts() - .setScriptEncoding("UTF-8") - .ignoreFailedDrops(true) - .build(); + BasicDataSource dataSource = new BasicDataSource(); + dataSource.setUsername("sa"); + dataSource.setPassword("YourStrong!Passw0rd"); + dataSource.setUrl("jdbc:sqlserver://localhost:1401;DatabaseName=demo_rshka"); + dataSource.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); + return dataSource; } @Bean diff --git a/src/main/java/com/rshka/mcs/configuration/WebApplicationInitializer.java b/src/main/java/com/rshka/mcs/configuration/WebApplicationInitializer.java deleted file mode 100644 index 78e9a1e..0000000 --- a/src/main/java/com/rshka/mcs/configuration/WebApplicationInitializer.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.rshka.mcs.configuration; - -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletRegistration; - -import org.h2.server.web.WebServlet; -import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; - -public class WebApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { - - @Override - protected Class[] getRootConfigClasses() { - return null; - } - - @Override - protected Class[] getServletConfigClasses() { - return new Class[] { AppConfiguration.class }; - } - - @Override - protected String[] getServletMappings() { - return new String[] { "/" }; - } - - @Override - public void onStartup(ServletContext servletContext) throws ServletException { - super.onStartup(servletContext); - ServletRegistration.Dynamic servlet = servletContext.addServlet("h2-console", new WebServlet()); - servlet.setLoadOnStartup(2); - servlet.addMapping("/console/*"); - } - -} diff --git a/src/main/java/com/rshka/mcs/controllers/CustomerController.java b/src/main/java/com/rshka/mcs/controllers/CustomerController.java index 658c0e8..4841b58 100644 --- a/src/main/java/com/rshka/mcs/controllers/CustomerController.java +++ b/src/main/java/com/rshka/mcs/controllers/CustomerController.java @@ -3,7 +3,6 @@ package com.rshka.mcs.controllers; import java.util.List; import java.util.logging.ErrorManager; -import org.h2.util.New; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; diff --git a/src/main/java/com/rshka/mcs/dao/CustomerDaoImpl.java b/src/main/java/com/rshka/mcs/dao/CustomerDaoImpl.java index 40b3589..c932dd0 100644 --- a/src/main/java/com/rshka/mcs/dao/CustomerDaoImpl.java +++ b/src/main/java/com/rshka/mcs/dao/CustomerDaoImpl.java @@ -90,7 +90,7 @@ public class CustomerDaoImpl implements CustomerDao { MapSqlParameterSource parameters = new MapSqlParameterSource(); parameters.addValue("name", customer.getName()); - parameters.addValue("document", customer.getDocument()); + parameters.addValue("document_number", customer.getDocument()); parameters.addValue("address", customer.getAddress()); parameters.addValue("phone", customer.getPhoneNumber()); Number id = insert.executeAndReturnKey(parameters); diff --git a/src/main/java/com/rshka/mcs/mapper/CustomerMapper.java b/src/main/java/com/rshka/mcs/mapper/CustomerMapper.java index 95194bd..454b1fd 100644 --- a/src/main/java/com/rshka/mcs/mapper/CustomerMapper.java +++ b/src/main/java/com/rshka/mcs/mapper/CustomerMapper.java @@ -13,7 +13,7 @@ public class CustomerMapper implements RowMapper { Customer customer = new Customer(); customer.setAddress(rs.getString("address")); - customer.setDocument(rs.getString("document")); + customer.setDocument(rs.getString("document_number")); customer.setName(rs.getString("name")); customer.setPhoneNumber(rs.getString("phone")); return customer; diff --git a/src/main/webapp/WEB-INF/mvc-config.xml b/src/main/webapp/WEB-INF/mvc-config.xml index a4a5187..6dc66ea 100644 --- a/src/main/webapp/WEB-INF/mvc-config.xml +++ b/src/main/webapp/WEB-INF/mvc-config.xml @@ -17,26 +17,4 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/test/java/com/example/demo/DemoApplicationTests.java b/src/test/java/com/example/demo/DemoApplicationTests.java deleted file mode 100644 index b76e7f2..0000000 --- a/src/test/java/com/example/demo/DemoApplicationTests.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.example.demo; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class DemoApplicationTests { - - @Test - public void contextLoads() { - } - -} diff --git a/target/classes/com/rshka/mcs/controllers/CustomerController.class b/target/classes/com/rshka/mcs/controllers/CustomerController.class index 43ab32a..c1cab4b 100644 Binary files a/target/classes/com/rshka/mcs/controllers/CustomerController.class and b/target/classes/com/rshka/mcs/controllers/CustomerController.class differ diff --git a/target/classes/com/rshka/mcs/dao/CustomerDaoImpl.class b/target/classes/com/rshka/mcs/dao/CustomerDaoImpl.class index 9564295..3e1e4e1 100644 Binary files a/target/classes/com/rshka/mcs/dao/CustomerDaoImpl.class and b/target/classes/com/rshka/mcs/dao/CustomerDaoImpl.class differ diff --git a/target/classes/com/rshka/mcs/mapper/CustomerMapper.class b/target/classes/com/rshka/mcs/mapper/CustomerMapper.class index 6ba351a..ea40501 100644 Binary files a/target/classes/com/rshka/mcs/mapper/CustomerMapper.class and b/target/classes/com/rshka/mcs/mapper/CustomerMapper.class differ diff --git a/target/m2e-wtp/web-resources/META-INF/maven/com.rshk.demo.mcs/demo_mcs/pom.properties b/target/m2e-wtp/web-resources/META-INF/maven/com.rshk.demo.mcs/demo_mcs/pom.properties index 31d7823..c5fc77a 100644 --- a/target/m2e-wtp/web-resources/META-INF/maven/com.rshk.demo.mcs/demo_mcs/pom.properties +++ b/target/m2e-wtp/web-resources/META-INF/maven/com.rshk.demo.mcs/demo_mcs/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven Integration for Eclipse -#Thu Jan 16 07:31:55 PYST 2020 +#Thu Jan 16 22:35:34 PYST 2020 version=0.0.1-SNAPSHOT groupId=com.rshk.demo.mcs m2e.projectName=demo_mcs diff --git a/target/m2e-wtp/web-resources/META-INF/maven/com.rshk.demo.mcs/demo_mcs/pom.xml b/target/m2e-wtp/web-resources/META-INF/maven/com.rshk.demo.mcs/demo_mcs/pom.xml index a05d534..5c1ea68 100644 --- a/target/m2e-wtp/web-resources/META-INF/maven/com.rshk.demo.mcs/demo_mcs/pom.xml +++ b/target/m2e-wtp/web-resources/META-INF/maven/com.rshk.demo.mcs/demo_mcs/pom.xml @@ -44,12 +44,16 @@ 6.0 provided - - + + + commons-dbcp + commons-dbcp + 1.2.2 + - com.h2database - h2 - 1.4.196 + com.microsoft.sqlserver + mssql-jdbc + 6.1.0.jre8 diff --git a/test/DemoRshka.postman_collection.json b/test/DemoRshka.postman_collection.json new file mode 100644 index 0000000..2a3353f --- /dev/null +++ b/test/DemoRshka.postman_collection.json @@ -0,0 +1,133 @@ +{ + "info": { + "_postman_id": "19110da6-d426-4589-af54-86d64163d7ef", + "name": "DemoRshka", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "/customers/list", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:8080/demo_mcs/customer/list", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "demo_mcs", + "customer", + "list" + ] + } + }, + "response": [] + }, + { + "name": "/api-customers/list", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:8080/demo_itau/api-customers/list", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "demo_itau", + "api-customers", + "list" + ] + } + }, + "response": [] + }, + { + "name": "/customer/save", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"customer_name\":\"Persona Apellido\",\n\t\"customer_document\":\"1231231\",\n\t\"customer_address\":\"Avenida 1\",\n\t\"customer_number\":\"12312 12123\"\n}" + }, + "url": { + "raw": "http://localhost:8080/demo_mcs/customer/save", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "demo_mcs", + "customer", + "save" + ] + } + }, + "response": [] + }, + { + "name": "/api-customer/save", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"customer_name\":\"Persona Apellido\",\n\t\"customer_document\":\"1231231\",\n\t\"customer_address\":\"Avenida 1\",\n\t\"customer_number\":\"12312 12123\"\n}" + }, + "url": { + "raw": "http://localhost:8080/demo_itau/api-customers/save", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "demo_itau", + "api-customers", + "save" + ] + } + }, + "response": [] + }, + { + "name": "/customer/{document}", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:8080/demo_mcs/customer/1231231", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "demo_mcs", + "customer", + "1231231" + ] + } + }, + "response": [] + } + ], + "protocolProfileBehavior": {} +} \ No newline at end of file