From d8cb70194dc1dc82e12b1d1050505c9f8d2ced76 Mon Sep 17 00:00:00 2001 From: Haroon Khan Date: Mon, 17 Jan 2022 14:04:55 +0000 Subject: [PATCH] [JAVA-9421] Cleanup code present in stackify repo (#11709) --- guest/core-java-9/pom.xml | 35 -- .../main/java/com/stackify/optional/User.java | 28 -- .../src/main/resources/logback.xml | 13 - .../com/stackify/optional/OptionalTest.java | 41 -- guest/core-java/pom.xml | 29 -- .../java/com/stackify/optional/Address.java | 40 -- .../java/com/stackify/optional/Country.java | 29 -- .../main/java/com/stackify/optional/User.java | 51 -- .../stackify/optional/chaining/Address.java | 38 -- .../stackify/optional/chaining/Country.java | 28 -- .../com/stackify/optional/chaining/User.java | 50 -- .../stackify/optionalparams/MultiVitamin.java | 50 -- .../MultiVitaminAllowingNulls.java | 38 -- .../MultiVitaminOverloading.java | 56 --- .../MultiVitaminStaticFactoryMethods.java | 52 -- .../MultiVitaminWithBuilder.java | 77 --- .../java/com/stackify/stream/Employee.java | 46 -- .../stackify/stream/EmployeeRepository.java | 21 - guest/core-java/src/main/resources/log4j2.xml | 13 - .../com/stackify/optional/OptionalTest.java | 166 ------- .../chaining/OptionalChainingTest.java | 36 -- .../OptionalParamsUnitTest.java | 96 ---- .../com/stackify/stream/EmployeeTest.java | 455 ------------------ guest/core-java/src/test/resources/.keep | 0 guest/core-kotlin/.gitignore | 14 - guest/core-kotlin/pom.xml | 201 -------- .../kotlinvsjava/CompanionObjectTest.kt | 21 - .../baeldung/kotlinvsjava/ConstructorTest.kt | 18 - .../baeldung/kotlinvsjava/DataClassTest.kt | 33 -- .../baeldung/kotlinvsjava/DelegationTest.kt | 27 -- .../baeldung/kotlinvsjava/ExceptionsTest.kt | 34 -- .../kotlinvsjava/ExtensionFunctionsTest.kt | 30 -- .../baeldung/kotlinvsjava/FunctionsTest.kt | 70 --- .../baeldung/kotlinvsjava/IsOperatorTest.kt | 36 -- .../baeldung/kotlinvsjava/NullSafetyTest.kt | 67 --- .../kotlinvsjava/OperatorsOverloadingTest.kt | 61 --- .../baeldung/kotlinvsjava/PropertiesTest.kt | 32 -- guest/deep-jsf/README.md | 15 - guest/deep-jsf/pom.xml | 36 -- .../stackify/deepjsf/GreetControllerBean.java | 14 - .../stackify/deepjsf/PhaseListenerBean.java | 47 -- .../java/com/stackify/deepjsf/UserBean.java | 48 -- .../stackify/deepjsf/UserControllerBean.java | 14 - guest/deep-jsf/src/main/resources/logback.xml | 13 - .../src/main/webapp/WEB-INF/faces-config.xml | 15 - guest/deep-jsf/src/main/webapp/greet.xhtml | 11 - guest/deep-jsf/src/main/webapp/hello.xhtml | 10 - guest/deep-jsf/src/main/webapp/index.xhtml | 18 - guest/deep-jsf/src/main/webapp/register.xhtml | 31 -- guest/junit5-example/.gitignore | 4 - guest/junit5-example/pom.xml | 57 --- .../main/java/com/stackify/daos/UserDAO.java | 141 ------ .../main/java/com/stackify/models/User.java | 63 --- .../conditions/DisabledOnEnvironment.java | 15 - .../DisabledOnEnvironmentCondition.java | 38 -- .../com/stackify/utils/ConnectionUtil.java | 38 -- .../src/main/resources/application.properties | 1 - .../com/stackify/utils/jdbc.properties | 4 - .../src/main/resources/log4j2.xml | 13 - .../stackify/test/DatabaseConnectionTest.java | 19 - .../java/com/stackify/test/DynamicTests.java | 38 -- .../java/com/stackify/test/IncrementTest.java | 25 - .../java/com/stackify/test/TaggedTest.java | 16 - .../java/com/stackify/test/UsersTest.java | 155 ------ guest/log4j2-example/.gitignore | 4 - guest/log4j2-example/java.log | 3 - guest/log4j2-example/logs/app.log | 25 - guest/log4j2-example/pom.xml | 48 -- .../main/java/com/stackify/models/User.java | 43 -- .../java/com/stackify/services/MyService.java | 14 - .../src/main/resources/log4j2.xml | 62 --- .../stackify/services/MyServiceUnitTest.java | 81 ---- guest/logback-example/pom.xml | 28 -- .../stackify/logging/IgnoreLoggerFilter.java | 28 -- .../java/com/stackify/models/Employee.java | 43 -- .../stackify/services/EmployeeService.java | 11 - .../src/main/resources/application.properties | 1 - .../src/main/resources/logback.xml | 151 ------ .../services/EmployeeServiceUnitTest.java | 74 --- guest/remote-debugging/README.md | 16 - guest/remote-debugging/pom.xml | 44 -- .../debug/JavaRemoteDebuggingApplication.java | 12 - .../stackify/debug/config/WebInitializer.java | 12 - .../stackify/debug/rest/HelloController.java | 16 - .../src/main/resources/logback.xml | 13 - guest/slf4j/guide/pom.xml | 62 --- guest/slf4j/guide/slf4j-log4j/.gitignore | 25 - guest/slf4j/guide/slf4j-log4j/pom.xml | 42 -- .../com/stackify/slf4j/guide/Application.java | 12 - .../guide/controllers/SimpleController.java | 42 -- .../src/main/resources/application.properties | 0 .../slf4j-log4j/src/main/resources/log4j.xml | 17 - .../SimpleControllerIntegrationTest.java | 80 --- .../slf4j/guide/utils/ListAppender.java | 33 -- .../slf4j-log4j/src/test/resources/log4j.xml | 16 - guest/slf4j/guide/slf4j-log4j2/.gitignore | 25 - guest/slf4j/guide/slf4j-log4j2/pom.xml | 54 --- .../com/stackify/slf4j/guide/Application.java | 12 - .../guide/controllers/SimpleController.java | 42 -- .../src/main/resources/application.properties | 0 .../src/main/resources/log4j2-spring.xml | 28 -- .../SimpleControllerIntegrationTest.java | 81 ---- .../src/test/resources/log4j2-test.xml | 18 - guest/slf4j/guide/slf4j-logback/.gitignore | 25 - guest/slf4j/guide/slf4j-logback/pom.xml | 32 -- .../com/stackify/slf4j/guide/Application.java | 12 - .../guide/controllers/SimpleController.java | 133 ----- .../stackify/slf4j/guide/l10n/Messages.java | 11 - .../guide/xlogger/XLoggerController.java | 28 -- .../src/main/resources/application.properties | 0 .../src/main/resources/logback-spring.xml | 11 - .../main/resources/messages_en_US.properties | 3 - .../main/resources/messages_es_ES.properties | 3 - .../SimpleControllerIntegrationTest.java | 163 ------- .../slf4j/guide/utils/ListAppender.java | 25 - .../src/test/resources/logback-test.xml | 8 - guest/spring-boot-app/.gitignore | 4 - .../WebContent/META-INF/MANIFEST.MF | 2 - guest/spring-boot-app/docker/Dockerfile | 16 - guest/spring-boot-app/docker/logback.xml | 15 - guest/spring-boot-app/docker/run.sh | 4 - guest/spring-boot-app/pom.xml | 76 --- .../main/java/com/stackify/Application.java | 13 - .../stackify/config/PersistenceConfig.java | 21 - .../controller/EmployeeController.java | 34 -- .../java/com/stackify/model/Employee.java | 41 -- .../repository/EmployeeRepository.java | 9 - .../src/main/resources/application.properties | 5 - .../src/main/resources/logback.xml | 13 - .../src/main/resources/myData.sql | 1 - .../src/main/resources/mySchema.sql | 1 - .../test/EmployeeControllerUnitTest.java | 46 -- guest/spring-mvc/README.md | 17 - guest/spring-mvc/pom.xml | 35 -- .../guest/springmvc/Spring5Application.java | 15 - .../guest/springmvc/model/LoginData.java | 27 -- .../springmvc/web/InternalsController.java | 40 -- .../guest/springmvc/web/MyInputResource.java | 14 - .../guest/springmvc/web/MyOutputResource.java | 15 - .../web/RestfulWebServiceController.java | 14 - .../spring-mvc/src/main/resources/logback.xml | 13 - .../src/main/resources/templates/failure.html | 10 - .../src/main/resources/templates/login.html | 13 - .../src/main/resources/templates/success.html | 10 - guest/spring-security/README.md | 17 - guest/spring-security/pom.xml | 53 -- .../guest/springsecurity/Application.java | 15 - .../config/WebMvcConfiguration.java | 16 - .../config/WebSecurityConfig.java | 40 -- .../src/main/resources/data.sql | 2 - .../src/main/resources/logback.xml | 13 - .../src/main/resources/schema.sql | 10 - .../src/main/resources/static/css/styles.css | 3 - .../main/resources/templates/customLogin.html | 21 - .../src/main/resources/templates/index.html | 11 - guest/thread-pools/pom.xml | 17 - .../java/com/stackify/models/Employee.java | 28 -- .../stackify/services/EmployeeService.java | 9 - .../stackify/threadpools/FactorialTask.java | 64 --- .../threadpools/ThreadsApplication.java | 102 ---- .../src/main/resources/logback.xml | 13 - .../WebContent/META-INF/MANIFEST.MF | 3 - guest/tomcat-app/WebContent/WEB-INF/web.xml | 28 -- guest/tomcat-app/pom.xml | 73 --- .../com/stackify/ApplicationInitializer.java | 9 - .../main/java/com/stackify/daos/UserDAO.java | 67 --- .../main/java/com/stackify/models/User.java | 43 -- .../com/stackify/services/CorsFilter.java | 19 - .../com/stackify/services/UserService.java | 37 -- .../com/stackify/utils/ConnectionUtil.java | 38 -- .../tomcat-app/src/main/resources/logback.xml | 13 - .../WebContent/META-INF/MANIFEST.MF | 3 - guest/webservices/rest-client/pom.xml | 31 -- .../rest-client/rest-client/.angular-cli.json | 57 --- .../rest-client/rest-client/.editorconfig | 13 - .../rest-client/rest-client/.gitignore | 42 -- .../rest-client/rest-client/README.md | 28 -- .../rest-client/e2e/app.e2e-spec.ts | 14 - .../rest-client/rest-client/e2e/app.po.ts | 11 - .../rest-client/e2e/tsconfig.e2e.json | 12 - .../rest-client/rest-client/karma.conf.js | 33 -- .../rest-client/rest-client/package.json | 48 -- .../rest-client/protractor.conf.js | 28 -- .../rest-client/src/app/app.component.css | 0 .../rest-client/src/app/app.component.html | 13 - .../rest-client/src/app/app.component.spec.ts | 32 -- .../rest-client/src/app/app.component.ts | 10 - .../rest-client/src/app/app.module.ts | 25 - .../rest-client/src/app/app.service.ts | 36 -- .../rest-client/src/app/users.component.html | 15 - .../rest-client/src/app/users.component.ts | 39 -- .../rest-client/src/assets/.gitkeep | 0 .../src/environments/environment.prod.ts | 3 - .../src/environments/environment.ts | 8 - .../rest-client/rest-client/src/favicon.ico | Bin 5430 -> 0 bytes .../rest-client/rest-client/src/index.html | 14 - .../rest-client/rest-client/src/main.ts | 11 - .../rest-client/rest-client/src/polyfills.ts | 73 --- .../rest-client/rest-client/src/styles.css | 1 - .../rest-client/rest-client/src/test.ts | 32 -- .../rest-client/src/tsconfig.app.json | 13 - .../rest-client/src/tsconfig.spec.json | 20 - .../rest-client/rest-client/src/typings.d.ts | 5 - .../rest-client/rest-client/tsconfig.json | 20 - .../rest-client/rest-client/tslint.json | 135 ------ .../WebContent/META-INF/MANIFEST.MF | 3 - .../rest-server/WebContent/WEB-INF/web.xml | 20 - guest/webservices/rest-server/pom.xml | 54 --- .../com/stackify/ApplicationInitializer.java | 9 - .../main/java/com/stackify/models/User.java | 43 -- .../com/stackify/services/CorsFilter.java | 19 - .../com/stackify/services/UserService.java | 33 -- .../src/main/resources/logback.xml | 13 - .../services/UserServiceLiveTest.java | 34 -- .../main/java/com/stackify/JAXWSClient.java | 19 - .../services/DefaultUserImplService.java | 94 ---- .../com/stackify/services/ObjectFactory.java | 48 -- .../main/java/com/stackify/services/User.java | 87 ---- .../com/stackify/services/UserService.java | 47 -- .../java/com/stackify/services/Users.java | 69 --- .../com/stackify/services/package-info.java | 2 - .../src/main/resources/logback.xml | 13 - .../java/com/stackify/ServicePublisher.java | 11 - .../main/java/com/stackify/models/User.java | 32 -- .../main/java/com/stackify/models/Users.java | 16 - .../stackify/services/DefaultUserImpl.java | 27 -- .../com/stackify/services/UserService.java | 19 - .../src/main/resources/logback.xml | 13 - .../WebContent/META-INF/MANIFEST.MF | 3 - guest/webservices/spring-rest-service/pom.xml | 55 --- .../main/java/com/stackify/Application.java | 12 - .../com/stackify/config/SwaggerConfig.java | 22 - .../stackify/controllers/UserController.java | 52 -- .../main/java/com/stackify/models/User.java | 34 -- .../src/main/resources/logback.xml | 13 - 235 files changed, 7832 deletions(-) delete mode 100644 guest/core-java-9/pom.xml delete mode 100644 guest/core-java-9/src/main/java/com/stackify/optional/User.java delete mode 100644 guest/core-java-9/src/main/resources/logback.xml delete mode 100644 guest/core-java-9/src/test/java/com/stackify/optional/OptionalTest.java delete mode 100644 guest/core-java/pom.xml delete mode 100644 guest/core-java/src/main/java/com/stackify/optional/Address.java delete mode 100644 guest/core-java/src/main/java/com/stackify/optional/Country.java delete mode 100644 guest/core-java/src/main/java/com/stackify/optional/User.java delete mode 100644 guest/core-java/src/main/java/com/stackify/optional/chaining/Address.java delete mode 100644 guest/core-java/src/main/java/com/stackify/optional/chaining/Country.java delete mode 100644 guest/core-java/src/main/java/com/stackify/optional/chaining/User.java delete mode 100644 guest/core-java/src/main/java/com/stackify/optionalparams/MultiVitamin.java delete mode 100644 guest/core-java/src/main/java/com/stackify/optionalparams/MultiVitaminAllowingNulls.java delete mode 100644 guest/core-java/src/main/java/com/stackify/optionalparams/MultiVitaminOverloading.java delete mode 100644 guest/core-java/src/main/java/com/stackify/optionalparams/MultiVitaminStaticFactoryMethods.java delete mode 100644 guest/core-java/src/main/java/com/stackify/optionalparams/MultiVitaminWithBuilder.java delete mode 100644 guest/core-java/src/main/java/com/stackify/stream/Employee.java delete mode 100644 guest/core-java/src/main/java/com/stackify/stream/EmployeeRepository.java delete mode 100644 guest/core-java/src/main/resources/log4j2.xml delete mode 100644 guest/core-java/src/test/java/com/stackify/optional/OptionalTest.java delete mode 100644 guest/core-java/src/test/java/com/stackify/optional/chaining/OptionalChainingTest.java delete mode 100644 guest/core-java/src/test/java/com/stackify/optionalparams/OptionalParamsUnitTest.java delete mode 100644 guest/core-java/src/test/java/com/stackify/stream/EmployeeTest.java delete mode 100644 guest/core-java/src/test/resources/.keep delete mode 100644 guest/core-kotlin/.gitignore delete mode 100644 guest/core-kotlin/pom.xml delete mode 100644 guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/CompanionObjectTest.kt delete mode 100644 guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/ConstructorTest.kt delete mode 100644 guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/DataClassTest.kt delete mode 100644 guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/DelegationTest.kt delete mode 100644 guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/ExceptionsTest.kt delete mode 100644 guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/ExtensionFunctionsTest.kt delete mode 100644 guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/FunctionsTest.kt delete mode 100644 guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/IsOperatorTest.kt delete mode 100644 guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/NullSafetyTest.kt delete mode 100644 guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/OperatorsOverloadingTest.kt delete mode 100644 guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/PropertiesTest.kt delete mode 100644 guest/deep-jsf/README.md delete mode 100644 guest/deep-jsf/pom.xml delete mode 100644 guest/deep-jsf/src/main/java/com/stackify/deepjsf/GreetControllerBean.java delete mode 100644 guest/deep-jsf/src/main/java/com/stackify/deepjsf/PhaseListenerBean.java delete mode 100644 guest/deep-jsf/src/main/java/com/stackify/deepjsf/UserBean.java delete mode 100644 guest/deep-jsf/src/main/java/com/stackify/deepjsf/UserControllerBean.java delete mode 100644 guest/deep-jsf/src/main/resources/logback.xml delete mode 100644 guest/deep-jsf/src/main/webapp/WEB-INF/faces-config.xml delete mode 100644 guest/deep-jsf/src/main/webapp/greet.xhtml delete mode 100644 guest/deep-jsf/src/main/webapp/hello.xhtml delete mode 100644 guest/deep-jsf/src/main/webapp/index.xhtml delete mode 100644 guest/deep-jsf/src/main/webapp/register.xhtml delete mode 100644 guest/junit5-example/.gitignore delete mode 100644 guest/junit5-example/pom.xml delete mode 100644 guest/junit5-example/src/main/java/com/stackify/daos/UserDAO.java delete mode 100644 guest/junit5-example/src/main/java/com/stackify/models/User.java delete mode 100644 guest/junit5-example/src/main/java/com/stackify/test/conditions/DisabledOnEnvironment.java delete mode 100644 guest/junit5-example/src/main/java/com/stackify/test/conditions/DisabledOnEnvironmentCondition.java delete mode 100644 guest/junit5-example/src/main/java/com/stackify/utils/ConnectionUtil.java delete mode 100644 guest/junit5-example/src/main/resources/application.properties delete mode 100644 guest/junit5-example/src/main/resources/com/stackify/utils/jdbc.properties delete mode 100644 guest/junit5-example/src/main/resources/log4j2.xml delete mode 100644 guest/junit5-example/src/test/java/com/stackify/test/DatabaseConnectionTest.java delete mode 100644 guest/junit5-example/src/test/java/com/stackify/test/DynamicTests.java delete mode 100644 guest/junit5-example/src/test/java/com/stackify/test/IncrementTest.java delete mode 100644 guest/junit5-example/src/test/java/com/stackify/test/TaggedTest.java delete mode 100644 guest/junit5-example/src/test/java/com/stackify/test/UsersTest.java delete mode 100644 guest/log4j2-example/.gitignore delete mode 100644 guest/log4j2-example/java.log delete mode 100644 guest/log4j2-example/logs/app.log delete mode 100644 guest/log4j2-example/pom.xml delete mode 100644 guest/log4j2-example/src/main/java/com/stackify/models/User.java delete mode 100644 guest/log4j2-example/src/main/java/com/stackify/services/MyService.java delete mode 100644 guest/log4j2-example/src/main/resources/log4j2.xml delete mode 100644 guest/log4j2-example/src/test/java/com/stackify/services/MyServiceUnitTest.java delete mode 100644 guest/logback-example/pom.xml delete mode 100644 guest/logback-example/src/main/java/com/stackify/logging/IgnoreLoggerFilter.java delete mode 100644 guest/logback-example/src/main/java/com/stackify/models/Employee.java delete mode 100644 guest/logback-example/src/main/java/com/stackify/services/EmployeeService.java delete mode 100644 guest/logback-example/src/main/resources/application.properties delete mode 100644 guest/logback-example/src/main/resources/logback.xml delete mode 100644 guest/logback-example/src/test/java/com/stackify/services/EmployeeServiceUnitTest.java delete mode 100644 guest/remote-debugging/README.md delete mode 100644 guest/remote-debugging/pom.xml delete mode 100644 guest/remote-debugging/src/main/java/com/stackify/debug/JavaRemoteDebuggingApplication.java delete mode 100644 guest/remote-debugging/src/main/java/com/stackify/debug/config/WebInitializer.java delete mode 100644 guest/remote-debugging/src/main/java/com/stackify/debug/rest/HelloController.java delete mode 100644 guest/remote-debugging/src/main/resources/logback.xml delete mode 100644 guest/slf4j/guide/pom.xml delete mode 100644 guest/slf4j/guide/slf4j-log4j/.gitignore delete mode 100644 guest/slf4j/guide/slf4j-log4j/pom.xml delete mode 100644 guest/slf4j/guide/slf4j-log4j/src/main/java/com/stackify/slf4j/guide/Application.java delete mode 100644 guest/slf4j/guide/slf4j-log4j/src/main/java/com/stackify/slf4j/guide/controllers/SimpleController.java delete mode 100644 guest/slf4j/guide/slf4j-log4j/src/main/resources/application.properties delete mode 100644 guest/slf4j/guide/slf4j-log4j/src/main/resources/log4j.xml delete mode 100644 guest/slf4j/guide/slf4j-log4j/src/test/java/com/stackify/slf4j/guide/controllers/SimpleControllerIntegrationTest.java delete mode 100644 guest/slf4j/guide/slf4j-log4j/src/test/java/com/stackify/slf4j/guide/utils/ListAppender.java delete mode 100644 guest/slf4j/guide/slf4j-log4j/src/test/resources/log4j.xml delete mode 100644 guest/slf4j/guide/slf4j-log4j2/.gitignore delete mode 100644 guest/slf4j/guide/slf4j-log4j2/pom.xml delete mode 100644 guest/slf4j/guide/slf4j-log4j2/src/main/java/com/stackify/slf4j/guide/Application.java delete mode 100644 guest/slf4j/guide/slf4j-log4j2/src/main/java/com/stackify/slf4j/guide/controllers/SimpleController.java delete mode 100644 guest/slf4j/guide/slf4j-log4j2/src/main/resources/application.properties delete mode 100644 guest/slf4j/guide/slf4j-log4j2/src/main/resources/log4j2-spring.xml delete mode 100644 guest/slf4j/guide/slf4j-log4j2/src/test/java/com/stackify/slf4j/guide/controllers/SimpleControllerIntegrationTest.java delete mode 100644 guest/slf4j/guide/slf4j-log4j2/src/test/resources/log4j2-test.xml delete mode 100644 guest/slf4j/guide/slf4j-logback/.gitignore delete mode 100644 guest/slf4j/guide/slf4j-logback/pom.xml delete mode 100644 guest/slf4j/guide/slf4j-logback/src/main/java/com/stackify/slf4j/guide/Application.java delete mode 100644 guest/slf4j/guide/slf4j-logback/src/main/java/com/stackify/slf4j/guide/controllers/SimpleController.java delete mode 100644 guest/slf4j/guide/slf4j-logback/src/main/java/com/stackify/slf4j/guide/l10n/Messages.java delete mode 100644 guest/slf4j/guide/slf4j-logback/src/main/java/com/stackify/slf4j/guide/xlogger/XLoggerController.java delete mode 100644 guest/slf4j/guide/slf4j-logback/src/main/resources/application.properties delete mode 100644 guest/slf4j/guide/slf4j-logback/src/main/resources/logback-spring.xml delete mode 100644 guest/slf4j/guide/slf4j-logback/src/main/resources/messages_en_US.properties delete mode 100644 guest/slf4j/guide/slf4j-logback/src/main/resources/messages_es_ES.properties delete mode 100644 guest/slf4j/guide/slf4j-logback/src/test/java/com/stackify/slf4j/guide/controllers/SimpleControllerIntegrationTest.java delete mode 100644 guest/slf4j/guide/slf4j-logback/src/test/java/com/stackify/slf4j/guide/utils/ListAppender.java delete mode 100644 guest/slf4j/guide/slf4j-logback/src/test/resources/logback-test.xml delete mode 100644 guest/spring-boot-app/.gitignore delete mode 100644 guest/spring-boot-app/WebContent/META-INF/MANIFEST.MF delete mode 100644 guest/spring-boot-app/docker/Dockerfile delete mode 100644 guest/spring-boot-app/docker/logback.xml delete mode 100755 guest/spring-boot-app/docker/run.sh delete mode 100644 guest/spring-boot-app/pom.xml delete mode 100644 guest/spring-boot-app/src/main/java/com/stackify/Application.java delete mode 100644 guest/spring-boot-app/src/main/java/com/stackify/config/PersistenceConfig.java delete mode 100644 guest/spring-boot-app/src/main/java/com/stackify/controller/EmployeeController.java delete mode 100644 guest/spring-boot-app/src/main/java/com/stackify/model/Employee.java delete mode 100644 guest/spring-boot-app/src/main/java/com/stackify/repository/EmployeeRepository.java delete mode 100644 guest/spring-boot-app/src/main/resources/application.properties delete mode 100644 guest/spring-boot-app/src/main/resources/logback.xml delete mode 100644 guest/spring-boot-app/src/main/resources/myData.sql delete mode 100644 guest/spring-boot-app/src/main/resources/mySchema.sql delete mode 100644 guest/spring-boot-app/src/test/java/com/stackify/test/EmployeeControllerUnitTest.java delete mode 100644 guest/spring-mvc/README.md delete mode 100644 guest/spring-mvc/pom.xml delete mode 100644 guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/Spring5Application.java delete mode 100644 guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/model/LoginData.java delete mode 100644 guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/web/InternalsController.java delete mode 100644 guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/web/MyInputResource.java delete mode 100644 guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/web/MyOutputResource.java delete mode 100644 guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/web/RestfulWebServiceController.java delete mode 100644 guest/spring-mvc/src/main/resources/logback.xml delete mode 100644 guest/spring-mvc/src/main/resources/templates/failure.html delete mode 100644 guest/spring-mvc/src/main/resources/templates/login.html delete mode 100644 guest/spring-mvc/src/main/resources/templates/success.html delete mode 100644 guest/spring-security/README.md delete mode 100644 guest/spring-security/pom.xml delete mode 100644 guest/spring-security/src/main/java/com/stackify/guest/springsecurity/Application.java delete mode 100644 guest/spring-security/src/main/java/com/stackify/guest/springsecurity/config/WebMvcConfiguration.java delete mode 100644 guest/spring-security/src/main/java/com/stackify/guest/springsecurity/config/WebSecurityConfig.java delete mode 100644 guest/spring-security/src/main/resources/data.sql delete mode 100644 guest/spring-security/src/main/resources/logback.xml delete mode 100644 guest/spring-security/src/main/resources/schema.sql delete mode 100644 guest/spring-security/src/main/resources/static/css/styles.css delete mode 100644 guest/spring-security/src/main/resources/templates/customLogin.html delete mode 100644 guest/spring-security/src/main/resources/templates/index.html delete mode 100644 guest/thread-pools/pom.xml delete mode 100644 guest/thread-pools/src/main/java/com/stackify/models/Employee.java delete mode 100644 guest/thread-pools/src/main/java/com/stackify/services/EmployeeService.java delete mode 100644 guest/thread-pools/src/main/java/com/stackify/threadpools/FactorialTask.java delete mode 100644 guest/thread-pools/src/main/java/com/stackify/threadpools/ThreadsApplication.java delete mode 100644 guest/thread-pools/src/main/resources/logback.xml delete mode 100644 guest/tomcat-app/WebContent/META-INF/MANIFEST.MF delete mode 100644 guest/tomcat-app/WebContent/WEB-INF/web.xml delete mode 100644 guest/tomcat-app/pom.xml delete mode 100644 guest/tomcat-app/src/main/java/com/stackify/ApplicationInitializer.java delete mode 100644 guest/tomcat-app/src/main/java/com/stackify/daos/UserDAO.java delete mode 100644 guest/tomcat-app/src/main/java/com/stackify/models/User.java delete mode 100644 guest/tomcat-app/src/main/java/com/stackify/services/CorsFilter.java delete mode 100644 guest/tomcat-app/src/main/java/com/stackify/services/UserService.java delete mode 100644 guest/tomcat-app/src/main/java/com/stackify/utils/ConnectionUtil.java delete mode 100644 guest/tomcat-app/src/main/resources/logback.xml delete mode 100644 guest/webservices/rest-client/WebContent/META-INF/MANIFEST.MF delete mode 100644 guest/webservices/rest-client/pom.xml delete mode 100644 guest/webservices/rest-client/rest-client/.angular-cli.json delete mode 100644 guest/webservices/rest-client/rest-client/.editorconfig delete mode 100644 guest/webservices/rest-client/rest-client/.gitignore delete mode 100644 guest/webservices/rest-client/rest-client/README.md delete mode 100644 guest/webservices/rest-client/rest-client/e2e/app.e2e-spec.ts delete mode 100644 guest/webservices/rest-client/rest-client/e2e/app.po.ts delete mode 100644 guest/webservices/rest-client/rest-client/e2e/tsconfig.e2e.json delete mode 100644 guest/webservices/rest-client/rest-client/karma.conf.js delete mode 100644 guest/webservices/rest-client/rest-client/package.json delete mode 100644 guest/webservices/rest-client/rest-client/protractor.conf.js delete mode 100644 guest/webservices/rest-client/rest-client/src/app/app.component.css delete mode 100644 guest/webservices/rest-client/rest-client/src/app/app.component.html delete mode 100644 guest/webservices/rest-client/rest-client/src/app/app.component.spec.ts delete mode 100644 guest/webservices/rest-client/rest-client/src/app/app.component.ts delete mode 100644 guest/webservices/rest-client/rest-client/src/app/app.module.ts delete mode 100644 guest/webservices/rest-client/rest-client/src/app/app.service.ts delete mode 100644 guest/webservices/rest-client/rest-client/src/app/users.component.html delete mode 100644 guest/webservices/rest-client/rest-client/src/app/users.component.ts delete mode 100644 guest/webservices/rest-client/rest-client/src/assets/.gitkeep delete mode 100644 guest/webservices/rest-client/rest-client/src/environments/environment.prod.ts delete mode 100644 guest/webservices/rest-client/rest-client/src/environments/environment.ts delete mode 100644 guest/webservices/rest-client/rest-client/src/favicon.ico delete mode 100644 guest/webservices/rest-client/rest-client/src/index.html delete mode 100644 guest/webservices/rest-client/rest-client/src/main.ts delete mode 100644 guest/webservices/rest-client/rest-client/src/polyfills.ts delete mode 100644 guest/webservices/rest-client/rest-client/src/styles.css delete mode 100644 guest/webservices/rest-client/rest-client/src/test.ts delete mode 100644 guest/webservices/rest-client/rest-client/src/tsconfig.app.json delete mode 100644 guest/webservices/rest-client/rest-client/src/tsconfig.spec.json delete mode 100644 guest/webservices/rest-client/rest-client/src/typings.d.ts delete mode 100644 guest/webservices/rest-client/rest-client/tsconfig.json delete mode 100644 guest/webservices/rest-client/rest-client/tslint.json delete mode 100644 guest/webservices/rest-server/WebContent/META-INF/MANIFEST.MF delete mode 100644 guest/webservices/rest-server/WebContent/WEB-INF/web.xml delete mode 100644 guest/webservices/rest-server/pom.xml delete mode 100644 guest/webservices/rest-server/src/main/java/com/stackify/ApplicationInitializer.java delete mode 100644 guest/webservices/rest-server/src/main/java/com/stackify/models/User.java delete mode 100644 guest/webservices/rest-server/src/main/java/com/stackify/services/CorsFilter.java delete mode 100644 guest/webservices/rest-server/src/main/java/com/stackify/services/UserService.java delete mode 100644 guest/webservices/rest-server/src/main/resources/logback.xml delete mode 100644 guest/webservices/rest-server/src/test/java/com/stackify/services/UserServiceLiveTest.java delete mode 100644 guest/webservices/soap_client/src/main/java/com/stackify/JAXWSClient.java delete mode 100644 guest/webservices/soap_client/src/main/java/com/stackify/services/DefaultUserImplService.java delete mode 100644 guest/webservices/soap_client/src/main/java/com/stackify/services/ObjectFactory.java delete mode 100644 guest/webservices/soap_client/src/main/java/com/stackify/services/User.java delete mode 100644 guest/webservices/soap_client/src/main/java/com/stackify/services/UserService.java delete mode 100644 guest/webservices/soap_client/src/main/java/com/stackify/services/Users.java delete mode 100644 guest/webservices/soap_client/src/main/java/com/stackify/services/package-info.java delete mode 100644 guest/webservices/soap_client/src/main/resources/logback.xml delete mode 100644 guest/webservices/soap_example/src/main/java/com/stackify/ServicePublisher.java delete mode 100644 guest/webservices/soap_example/src/main/java/com/stackify/models/User.java delete mode 100644 guest/webservices/soap_example/src/main/java/com/stackify/models/Users.java delete mode 100644 guest/webservices/soap_example/src/main/java/com/stackify/services/DefaultUserImpl.java delete mode 100644 guest/webservices/soap_example/src/main/java/com/stackify/services/UserService.java delete mode 100644 guest/webservices/soap_example/src/main/resources/logback.xml delete mode 100644 guest/webservices/spring-rest-service/WebContent/META-INF/MANIFEST.MF delete mode 100644 guest/webservices/spring-rest-service/pom.xml delete mode 100644 guest/webservices/spring-rest-service/src/main/java/com/stackify/Application.java delete mode 100644 guest/webservices/spring-rest-service/src/main/java/com/stackify/config/SwaggerConfig.java delete mode 100644 guest/webservices/spring-rest-service/src/main/java/com/stackify/controllers/UserController.java delete mode 100644 guest/webservices/spring-rest-service/src/main/java/com/stackify/models/User.java delete mode 100644 guest/webservices/spring-rest-service/src/main/resources/logback.xml diff --git a/guest/core-java-9/pom.xml b/guest/core-java-9/pom.xml deleted file mode 100644 index 786f85ce86..0000000000 --- a/guest/core-java-9/pom.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - 4.0.0 - com.stackify - core-java-9 - 0.0.1-SNAPSHOT - core-java-9 - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - ../../ - - - - - - maven-compiler-plugin - ${maven-compiler-plugin.version} - - ${maven.compiler.source} - ${maven.compiler.target} - - - - - - - 1.9 - 1.9 - - - \ No newline at end of file diff --git a/guest/core-java-9/src/main/java/com/stackify/optional/User.java b/guest/core-java-9/src/main/java/com/stackify/optional/User.java deleted file mode 100644 index 903e75f6f6..0000000000 --- a/guest/core-java-9/src/main/java/com/stackify/optional/User.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.stackify.optional; - -public class User { - private String email; - private String password; - - public User(String email, String password) { - super(); - this.email = email; - this.password = password; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } -} diff --git a/guest/core-java-9/src/main/resources/logback.xml b/guest/core-java-9/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/guest/core-java-9/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/guest/core-java-9/src/test/java/com/stackify/optional/OptionalTest.java b/guest/core-java-9/src/test/java/com/stackify/optional/OptionalTest.java deleted file mode 100644 index 4c3503b811..0000000000 --- a/guest/core-java-9/src/test/java/com/stackify/optional/OptionalTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.stackify.optional; - -import org.junit.Test; -import java.util.Optional; -import java.util.List; - -import static org.junit.Assert.*; -import java.util.stream.Collectors; - -public class OptionalTest { - - private User user; - - @Test - public void whenEmptyOptional_thenGetValueFromOr() { - User result = Optional.ofNullable(user) - .or( () -> Optional.of(new User("default","1234"))).get(); - - assertEquals(result.getEmail(), "default"); - } - - @Test - public void whenIfPresentOrElse_thenOk() { - Optional.ofNullable(user) - .ifPresentOrElse( u -> System.out.println("User is:" + u.getEmail()), () -> System.out.println("User not found")); - } - - @Test - public void whenGetStream_thenOk() { - User user = new User("john@gmail.com", "1234"); - List emails = Optional.ofNullable(user) - .stream() - .filter(u -> u.getEmail() != null && u.getEmail().contains("@")) - .map( u -> u.getEmail()) - .collect(Collectors.toList()); - - assertTrue(emails.size() == 1); - assertEquals(emails.get(0), user.getEmail()); - } - -} diff --git a/guest/core-java/pom.xml b/guest/core-java/pom.xml deleted file mode 100644 index 2ab067ad40..0000000000 --- a/guest/core-java/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - 4.0.0 - com.stackify - core-java - 0.0.1-SNAPSHOT - core-java - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - ../../ - - - - - org.apache.logging.log4j - log4j-core - ${log4j2.version} - - - - - 2.8.2 - - - \ No newline at end of file diff --git a/guest/core-java/src/main/java/com/stackify/optional/Address.java b/guest/core-java/src/main/java/com/stackify/optional/Address.java deleted file mode 100644 index f54c999920..0000000000 --- a/guest/core-java/src/main/java/com/stackify/optional/Address.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.stackify.optional; - -public class Address { - private String addressLine; - private String city; - private Country country; - - public Address(String addressLine, String city, Country country) { - super(); - this.addressLine = addressLine; - this.city = city; - this.country = country; - } - - public String getAddressLine() { - return addressLine; - } - - public void setAddressLine(String addressLine) { - this.addressLine = addressLine; - } - - public String getCity() { - return city; - } - - public void setCity(String city) { - this.city = city; - } - - public Country getCountry() { - return country; - } - - public void setCountry(Country country) { - this.country = country; - } - - -} diff --git a/guest/core-java/src/main/java/com/stackify/optional/Country.java b/guest/core-java/src/main/java/com/stackify/optional/Country.java deleted file mode 100644 index bf97ef7b6d..0000000000 --- a/guest/core-java/src/main/java/com/stackify/optional/Country.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.stackify.optional; - -public class Country { - private String name; - private String isocode; - - public Country(String name, String isocode) { - super(); - this.name = name; - this.isocode = isocode; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getIsocode() { - return isocode; - } - - public void setIsocode(String isocode) { - this.isocode = isocode; - } - -} diff --git a/guest/core-java/src/main/java/com/stackify/optional/User.java b/guest/core-java/src/main/java/com/stackify/optional/User.java deleted file mode 100644 index 910f2605dd..0000000000 --- a/guest/core-java/src/main/java/com/stackify/optional/User.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.stackify.optional; - -import java.util.Optional; - -public class User { - private String email; - private String password; - - private Address address; - - private String position; - - public User(String email, String password) { - super(); - this.email = email; - this.password = password; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public Address getAddress() { - return address; - } - - public void setAddress(Address address) { - this.address = address; - } - - public Optional getPosition() { - return Optional.ofNullable(position); - } - - public void setPosition(String position) { - this.position = position; - } - -} diff --git a/guest/core-java/src/main/java/com/stackify/optional/chaining/Address.java b/guest/core-java/src/main/java/com/stackify/optional/chaining/Address.java deleted file mode 100644 index 1e10c67c39..0000000000 --- a/guest/core-java/src/main/java/com/stackify/optional/chaining/Address.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.stackify.optional.chaining; - -import java.util.Optional; - -public class Address { - private String addressLine; - private String city; - private Country country; - - public Address(String addressLine, String city) { - this.addressLine = addressLine; - this.city = city; - } - - public String getAddressLine() { - return addressLine; - } - - public void setAddressLine(String addressLine) { - this.addressLine = addressLine; - } - - public String getCity() { - return city; - } - - public void setCity(String city) { - this.city = city; - } - - public Optional getCountry() { - return Optional.ofNullable(country); - } - - public void setCountry(Country country) { - this.country = country; - } -} diff --git a/guest/core-java/src/main/java/com/stackify/optional/chaining/Country.java b/guest/core-java/src/main/java/com/stackify/optional/chaining/Country.java deleted file mode 100644 index 89e85a9b43..0000000000 --- a/guest/core-java/src/main/java/com/stackify/optional/chaining/Country.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.stackify.optional.chaining; - -public class Country { - private String name; - private String isocode; - - public Country(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getIsocode() { - return isocode; - } - - public void setIsocode(String isocode) { - this.isocode = isocode; - } - - -} \ No newline at end of file diff --git a/guest/core-java/src/main/java/com/stackify/optional/chaining/User.java b/guest/core-java/src/main/java/com/stackify/optional/chaining/User.java deleted file mode 100644 index 07eb398abe..0000000000 --- a/guest/core-java/src/main/java/com/stackify/optional/chaining/User.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.stackify.optional.chaining; - -import java.util.Optional; - -public class User { - private String email; - private String password; - - private Address address; - - private String position; - - public User(String email, String password) { - this.email = email; - this.password = password; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public Optional
getAddress() { - return Optional.ofNullable(address); - } - - public void setAddress(Address address) { - this.address = address; - } - - public Optional getPosition() { - return Optional.ofNullable(position); - } - - public void setPosition(String position) { - this.position = position; - } - -} diff --git a/guest/core-java/src/main/java/com/stackify/optionalparams/MultiVitamin.java b/guest/core-java/src/main/java/com/stackify/optionalparams/MultiVitamin.java deleted file mode 100644 index 90cb49b321..0000000000 --- a/guest/core-java/src/main/java/com/stackify/optionalparams/MultiVitamin.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.stackify.optionalparams; - -public class MultiVitamin { - - private String name; // required - private int vitaminA; // in mcg - private int vitaminC; // in mg - private int calcium; // in mg - private int iron; // in mg - - public MultiVitamin(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public int getVitaminA() { - return vitaminA; - } - - public void setVitaminA(int vitaminA) { - this.vitaminA = vitaminA; - } - - public int getVitaminC() { - return vitaminC; - } - - public void setVitaminC(int vitaminC) { - this.vitaminC = vitaminC; - } - - public int getCalcium() { - return calcium; - } - - public void setCalcium(int calcium) { - this.calcium = calcium; - } - - public int getIron() { - return iron; - } - - public void setIron(int iron) { - this.iron = iron; - } -} \ No newline at end of file diff --git a/guest/core-java/src/main/java/com/stackify/optionalparams/MultiVitaminAllowingNulls.java b/guest/core-java/src/main/java/com/stackify/optionalparams/MultiVitaminAllowingNulls.java deleted file mode 100644 index 1d2a61354d..0000000000 --- a/guest/core-java/src/main/java/com/stackify/optionalparams/MultiVitaminAllowingNulls.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.stackify.optionalparams; - -public class MultiVitaminAllowingNulls { - - private String name; // required - private Integer vitaminA; // in mcg - private Integer vitaminC; // in mg - private Integer calcium; // in mg - private Integer iron; // in mg - - public MultiVitaminAllowingNulls(String name, Integer vitaminA, Integer vitaminC, Integer calcium, Integer iron) { - this.name = name; - this.vitaminA = vitaminA; - this.vitaminC = vitaminC; - this.calcium = calcium; - this.iron = iron; - } - - public String getName() { - return name; - } - - public Integer getVitaminA() { - return vitaminA; - } - - public Integer getVitaminC() { - return vitaminC; - } - - public Integer getCalcium() { - return calcium; - } - - public Integer getIron() { - return iron; - } -} \ No newline at end of file diff --git a/guest/core-java/src/main/java/com/stackify/optionalparams/MultiVitaminOverloading.java b/guest/core-java/src/main/java/com/stackify/optionalparams/MultiVitaminOverloading.java deleted file mode 100644 index e9dcb2509b..0000000000 --- a/guest/core-java/src/main/java/com/stackify/optionalparams/MultiVitaminOverloading.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.stackify.optionalparams; - -public class MultiVitaminOverloading { - - static final int DEFAULT_IRON_AMOUNT = 20; - - private final String name; // required - private final int vitaminA; // in mcg - private final int vitaminC; // in mg - private final int calcium; // in mg - private final int iron; // in mg - - public MultiVitaminOverloading(String name) { - this(name, 0); - } - - public MultiVitaminOverloading(String name, int vitaminA) { - this(name, vitaminA, 0); - } - - public MultiVitaminOverloading(String name, int vitaminA, int vitaminC) { - this(name, vitaminA, vitaminC, 0); - } - - public MultiVitaminOverloading(String name, int vitaminA, int vitaminC, int calcium) { - this(name, vitaminA, vitaminC, calcium, DEFAULT_IRON_AMOUNT); - } - - public MultiVitaminOverloading(String name, int vitaminA, int vitaminC, int calcium, int iron) { - this.name = name; - this.vitaminA = vitaminA; - this.vitaminC = vitaminC; - this.calcium = calcium; - this.iron = iron; - } - - public String getName() { - return name; - } - - public int getVitaminA() { - return vitaminA; - } - - public int getVitaminC() { - return vitaminC; - } - - public int getCalcium() { - return calcium; - } - - public int getIron() { - return iron; - } -} \ No newline at end of file diff --git a/guest/core-java/src/main/java/com/stackify/optionalparams/MultiVitaminStaticFactoryMethods.java b/guest/core-java/src/main/java/com/stackify/optionalparams/MultiVitaminStaticFactoryMethods.java deleted file mode 100644 index 229a2f0004..0000000000 --- a/guest/core-java/src/main/java/com/stackify/optionalparams/MultiVitaminStaticFactoryMethods.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.stackify.optionalparams; - -public class MultiVitaminStaticFactoryMethods { - - static final int IRON_AMT_DEF = 20; - static final int IRON_AMT_MEN = 30; - - static final int CALCIUM_AMT_DEF = 100; - static final int CALCIUM_AMT_WOMEN = 120; - - private final String name; // required - private final int vitaminA; // in mcg - private final int vitaminC; // in mg - private final int calcium; // in mg - private final int iron; // in mg - - public static MultiVitaminStaticFactoryMethods forMen(String name) { - return new MultiVitaminStaticFactoryMethods(name, 5000, 60, CALCIUM_AMT_DEF, IRON_AMT_MEN); - } - - public static MultiVitaminStaticFactoryMethods forWomen(String name) { - return new MultiVitaminStaticFactoryMethods(name, 5000, 60, CALCIUM_AMT_WOMEN, IRON_AMT_DEF); - } - - private MultiVitaminStaticFactoryMethods(String name, int vitaminA, int vitaminC, int calcium, int iron) { - this.name = name; - this.vitaminA = vitaminA; - this.vitaminC = vitaminC; - this.calcium = calcium; - this.iron = iron; - } - - public String getName() { - return name; - } - - public int getVitaminA() { - return vitaminA; - } - - public int getVitaminC() { - return vitaminC; - } - - public int getCalcium() { - return calcium; - } - - public int getIron() { - return iron; - } -} \ No newline at end of file diff --git a/guest/core-java/src/main/java/com/stackify/optionalparams/MultiVitaminWithBuilder.java b/guest/core-java/src/main/java/com/stackify/optionalparams/MultiVitaminWithBuilder.java deleted file mode 100644 index 8097074b86..0000000000 --- a/guest/core-java/src/main/java/com/stackify/optionalparams/MultiVitaminWithBuilder.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.stackify.optionalparams; - -public class MultiVitaminWithBuilder { - - private final String name; // required - private final int vitaminA; // in mcg - private final int vitaminC; // in mg - private final int calcium; // in mg - private final int iron; // in mg - - private MultiVitaminWithBuilder(MultiVitaminBuilder builder) { - this.name = builder.name; - this.vitaminA = builder.vitaminA; - this.vitaminC = builder.vitaminC; - this.calcium = builder.calcium; - this.iron = builder.iron; - } - - public String getName() { - return name; - } - - public int getVitaminA() { - return vitaminA; - } - - public int getVitaminC() { - return vitaminC; - } - - public int getCalcium() { - return calcium; - } - - public int getIron() { - return iron; - } - - public static class MultiVitaminBuilder { - - private static final int ZERO = 0; - - private final String name; // required - private int vitaminA = ZERO; - private int vitaminC = ZERO; - private int calcium = ZERO; - private int iron = ZERO; - - public MultiVitaminBuilder(String name) { - this.name = name; - } - - public MultiVitaminBuilder withVitaminA(int vitaminA) { - this.vitaminA = vitaminA; - return this; - } - - public MultiVitaminBuilder withVitaminC(int vitaminC) { - this.vitaminC = vitaminC; - return this; - } - - public MultiVitaminBuilder withCalcium(int calcium) { - this.calcium = calcium; - return this; - } - - public MultiVitaminBuilder withIron(int iron) { - this.iron = iron; - return this; - } - - public MultiVitaminWithBuilder build() { - return new MultiVitaminWithBuilder(this); - } - } -} diff --git a/guest/core-java/src/main/java/com/stackify/stream/Employee.java b/guest/core-java/src/main/java/com/stackify/stream/Employee.java deleted file mode 100644 index 005990c863..0000000000 --- a/guest/core-java/src/main/java/com/stackify/stream/Employee.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.stackify.stream; - -public class Employee { - private Integer id; - private String name; - private Double salary; - - public Employee(Integer id, String name, Double salary) { - this.id = id; - this.name = name; - this.salary = salary; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Double getSalary() { - return salary; - } - - public void setSalary(Double salary) { - this.salary = salary; - } - - public void salaryIncrement(Double percentage) { - Double newSalary = salary + percentage * salary / 100; - setSalary(newSalary); - } - - public String toString() { - return "Id: " + id + " Name:" + name + " Price:" + salary; - } -} diff --git a/guest/core-java/src/main/java/com/stackify/stream/EmployeeRepository.java b/guest/core-java/src/main/java/com/stackify/stream/EmployeeRepository.java deleted file mode 100644 index 223fee5e26..0000000000 --- a/guest/core-java/src/main/java/com/stackify/stream/EmployeeRepository.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.stackify.stream; - -import java.util.List; - -public class EmployeeRepository { - private List empList; - - public EmployeeRepository(List empList) { - this.empList = empList; - - } - public Employee findById(Integer id) { - for (Employee emp : empList) { - if (emp.getId() == id) { - return emp; - } - } - - return null; - } -} diff --git a/guest/core-java/src/main/resources/log4j2.xml b/guest/core-java/src/main/resources/log4j2.xml deleted file mode 100644 index a67aae6aa6..0000000000 --- a/guest/core-java/src/main/resources/log4j2.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/guest/core-java/src/test/java/com/stackify/optional/OptionalTest.java b/guest/core-java/src/test/java/com/stackify/optional/OptionalTest.java deleted file mode 100644 index c6e6ddb15d..0000000000 --- a/guest/core-java/src/test/java/com/stackify/optional/OptionalTest.java +++ /dev/null @@ -1,166 +0,0 @@ -package com.stackify.optional; - -import static org.junit.Assert.*; - -import java.util.ArrayList; -import java.util.List; -import java.util.NoSuchElementException; -import java.util.Optional; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.junit.Test; - -public class OptionalTest { - - private User user; - - private Logger logger = LogManager.getLogger(OptionalTest.class); - - @Test(expected = NullPointerException.class) - public void testNull() { - String isocode = user.getAddress().getCountry().getIsocode().toUpperCase(); - } - - @Test - public void test() { - - if (user != null) { - Address address = user.getAddress(); - if (address != null) { - Country country = address.getCountry(); - if (country != null) { - String isocode = country.getIsocode(); - if (isocode != null) { - isocode = isocode.toUpperCase(); - } - } - } - } - - } - - @Test(expected = NoSuchElementException.class) - public void whenCreateEmptyOptional_thenNull() { - Optional emptyOpt = Optional.empty(); - emptyOpt.get(); - } - - @Test(expected = NullPointerException.class) - public void whenCreateOfEmptyOptional_thenNullPointerException() { - Optional opt = Optional.of(user); - } - - @Test - public void whenCreateOfNullableOptional_thenOk() { - String name = "John"; - Optional opt = Optional.ofNullable(name); - assertEquals("John", opt.get()); - } - - @Test - public void whenCheckIsPresent_thenOk() { - user = new User("john@gmail.com", "1234"); - Optional opt = Optional.ofNullable(user); - assertTrue(opt.isPresent()); - - assertEquals(user.getEmail(), opt.get().getEmail()); - } - - @Test - public void whenCheckIfPresent_thenOk() { - user = new User("john@gmail.com", "1234"); - Optional opt = Optional.ofNullable(user); - assertTrue(opt.isPresent()); - - opt.ifPresent(u -> assertEquals(user.getEmail(), u.getEmail())); - } - - @Test - public void whenEmptyValue_thenReturnDefault() { - User user = null; - User user2 = new User("anna@gmail.com", "1234"); - User result = Optional.ofNullable(user).orElse(user2); - - assertEquals("anna@gmail.com", result.getEmail()); - } - - @Test - public void whenValueNotNull_thenIgnoreDefault() { - User user = new User("john@gmail.com", "1234"); - User user2 = new User("anna@gmail.com", "1234"); - User result = Optional.ofNullable(user).orElse(user2); - - assertEquals("john@gmail.com", result.getEmail()); - } - - @Test - public void whenSetDefaultOrElseGet_thenOk() { - User user = null; - User user2 = new User("anna@gmail.com", "1234"); - User result = Optional.ofNullable(user).orElseGet(() -> user2); - - assertEquals("anna@gmail.com", result.getEmail()); - } - - @Test - public void givenPresentValue_whenCompare_thenOk() { - User user = new User("john@gmail.com", "1234"); - logger.info("Using orElse"); - User result = Optional.ofNullable(user).orElse(createNewUser()); - logger.info("Using orElseGet"); - User result2 = Optional.ofNullable(user).orElseGet(() -> createNewUser()); - } - - private User createNewUser() { - logger.info("Creating New User"); - return new User("extra@gmail.com", "1234"); - } - - @Test - public void givenEmptyValue_whenCompare_thenOk() { - User user = null; - logger.info("Using orElse"); - User result = Optional.ofNullable(user).orElse(createNewUser()); - logger.info("Using orElseGet"); - User result2 = Optional.ofNullable(user).orElseGet(() -> createNewUser()); - } - - @Test(expected = IllegalArgumentException.class) - public void whenThrowException_thenOk() { - User result = Optional.ofNullable(user).orElseThrow(() -> new IllegalArgumentException()); - } - - @Test - public void whenMap_thenOk() { - user = new User("anna@gmail.com", "1234"); - String email = Optional.ofNullable(user).map(u -> u.getEmail()).orElse("default@gmail.com"); - assertEquals(email, user.getEmail()); - - } - - @Test - public void whenFlatMap_thenOk() { - user = new User("anna@gmail.com", "1234"); - user.setPosition("Developer"); - String position = Optional.ofNullable(user).flatMap(u -> u.getPosition()).orElse("default"); - assertEquals(position, user.getPosition().get()); - - } - - @Test - public void whenFilter_thenOk() { - user = new User("anna@gmail.com", "1234"); - Optional result = Optional.ofNullable(user).filter(u -> u.getEmail() != null && u.getEmail().contains("@")); - - assertTrue(result.isPresent()); - } - - @Test - public void whenStream_thenOk() { - List users = new ArrayList<>(); - User user = users.stream().findFirst().orElse(new User("default", "1234")); - assertEquals(user.getEmail(), "default"); - } - -} diff --git a/guest/core-java/src/test/java/com/stackify/optional/chaining/OptionalChainingTest.java b/guest/core-java/src/test/java/com/stackify/optional/chaining/OptionalChainingTest.java deleted file mode 100644 index 660497c367..0000000000 --- a/guest/core-java/src/test/java/com/stackify/optional/chaining/OptionalChainingTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.stackify.optional.chaining; - -import static org.junit.Assert.*; - -import java.util.Optional; - -import org.junit.Test; - -public class OptionalChainingTest { - - @Test - public void whenChaining_thenOk() { - User user = new User("anna@gmail.com", "1234"); - - String result = Optional.ofNullable(user) - .flatMap(u -> u.getAddress()) - .flatMap(a -> a.getCountry()) - .map(c -> c.getIsocode()) - .orElse("default"); - - assertEquals(result, "default"); - } - - @Test - public void whenChainingWithMethodReferences_thenOk() { - User user = new User("anna@gmail.com", "1234"); - - String result = Optional.ofNullable(user) - .flatMap(User::getAddress) - .flatMap(Address::getCountry) - .map(Country::getIsocode) - .orElse("default"); - - assertEquals(result, "default"); - } -} diff --git a/guest/core-java/src/test/java/com/stackify/optionalparams/OptionalParamsUnitTest.java b/guest/core-java/src/test/java/com/stackify/optionalparams/OptionalParamsUnitTest.java deleted file mode 100644 index 947ce83a90..0000000000 --- a/guest/core-java/src/test/java/com/stackify/optionalparams/OptionalParamsUnitTest.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.stackify.optionalparams; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.math.BigDecimal; - -import org.assertj.core.util.Arrays; -import org.junit.Test; - -public class OptionalParamsUnitTest { - - @Test - public void whenCreateMultiVitaminWithOverloading_thenOk() { - MultiVitaminOverloading multiVitamin = new MultiVitaminOverloading("Default Multivitamin"); - - assertThat(multiVitamin.getName()).isEqualTo("Default Multivitamin"); - assertThat(multiVitamin.getVitaminA()).isEqualTo(0); - assertThat(multiVitamin.getVitaminC()).isEqualTo(0); - assertThat(multiVitamin.getCalcium()).isEqualTo(0); - assertThat(multiVitamin.getIron()).isEqualTo(MultiVitaminOverloading.DEFAULT_IRON_AMOUNT); - } - - @Test - public void whenCreateMultiVitaminWithStaticFactoryMethods_thenOk() { - MultiVitaminStaticFactoryMethods mensMultiVitamin = MultiVitaminStaticFactoryMethods.forMen("Complete for Men"); - - assertThat(mensMultiVitamin.getName()).isEqualTo("Complete for Men"); - assertThat(mensMultiVitamin.getCalcium()).isEqualTo(MultiVitaminStaticFactoryMethods.CALCIUM_AMT_DEF); - assertThat(mensMultiVitamin.getIron()).isEqualTo(MultiVitaminStaticFactoryMethods.IRON_AMT_MEN); - - MultiVitaminStaticFactoryMethods womensMultiVitamin = MultiVitaminStaticFactoryMethods.forWomen("Complete for Women"); - - assertThat(womensMultiVitamin.getName()).isEqualTo("Complete for Women"); - assertThat(womensMultiVitamin.getCalcium()).isEqualTo(MultiVitaminStaticFactoryMethods.CALCIUM_AMT_WOMEN); - assertThat(womensMultiVitamin.getIron()).isEqualTo(MultiVitaminStaticFactoryMethods.IRON_AMT_DEF); - } - - @Test - public void whenCreateMultiVitaminWithBuilder_thenOk() { - MultiVitaminWithBuilder vitamin = new MultiVitaminWithBuilder.MultiVitaminBuilder("Maximum Strength") - .withCalcium(100) - .withIron(200) - .withVitaminA(50) - .withVitaminC(1000) - .build(); - - assertThat(vitamin.getName()).isEqualTo("Maximum Strength"); - assertThat(vitamin.getCalcium()).isEqualTo(100); - assertThat(vitamin.getIron()).isEqualTo(200); - assertThat(vitamin.getVitaminA()).isEqualTo(50); - assertThat(vitamin.getVitaminC()).isEqualTo(1000); - } - - @Test - public void whenCreateMutliVitaminWithAccessors_thenOk() { - MultiVitamin vitamin = new MultiVitamin("Generic"); - vitamin.setVitaminA(50); - vitamin.setVitaminC(1000); - vitamin.setCalcium(100); - vitamin.setIron(200); - - assertThat(vitamin.getName()).isEqualTo("Generic"); - assertThat(vitamin.getCalcium()).isEqualTo(100); - assertThat(vitamin.getIron()).isEqualTo(200); - assertThat(vitamin.getVitaminA()).isEqualTo(50); - assertThat(vitamin.getVitaminC()).isEqualTo(1000); - } - - @Test - public void whenCreateMultiVitaminWithNulls_thenOk() { - MultiVitamin vitamin = new MultiVitamin(null); - - assertThat(vitamin.getName()).isNull(); - } - - public void varArgsDemo() { - Object[] args = Arrays.array(Long.valueOf(1), Integer.valueOf(2), BigDecimal.valueOf(3)); - - processVarArgsWithCastingAntiPattern(args); - } - - private void processVarArgsWithCastingAntiPattern(Object... args) { - String message = "processing %s as %s"; - - // never do this sort of thing - for (Object arg : args) { - if (arg instanceof Long) { - System.out.println(String.format(message, arg, "Long")); - } else if (arg instanceof Integer) { - System.out.println(String.format(message, arg, "Integer")); - } else if (arg instanceof BigDecimal) { - System.out.println(String.format(message, arg, "BigDecimal")); - } - } - } -} diff --git a/guest/core-java/src/test/java/com/stackify/stream/EmployeeTest.java b/guest/core-java/src/test/java/com/stackify/stream/EmployeeTest.java deleted file mode 100644 index cf988d035a..0000000000 --- a/guest/core-java/src/test/java/com/stackify/stream/EmployeeTest.java +++ /dev/null @@ -1,455 +0,0 @@ -package com.stackify.stream; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.beans.HasPropertyWithValue.hasProperty; -import static org.junit.Assert.assertEquals; - -import java.io.IOException; -import java.io.PrintWriter; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Collection; -import java.util.Comparator; -import java.util.DoubleSummaryStatistics; -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Optional; -import java.util.Set; -import java.util.Vector; -import java.util.function.BinaryOperator; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import org.junit.After; -import org.junit.Test; - -public class EmployeeTest { - private String fileName = "src/test/resources/test.txt"; - - private static Employee[] arrayOfEmps = { - new Employee(1, "Jeff Bezos", 100000.0), - new Employee(2, "Bill Gates", 200000.0), - new Employee(3, "Mark Zuckerberg", 300000.0) - }; - - private static List empList = Arrays.asList(arrayOfEmps); - private static EmployeeRepository employeeRepository = new EmployeeRepository(empList); - - @After - public void cleanup() throws IOException { - Files.deleteIfExists(Paths.get(fileName)); - } - - @Test - public void whenGetStreamFromList_ObtainStream() { - assert(empList.stream() instanceof Stream); - } - - @Test - public void whenGetStreamFromArray_ObtainStream() { - assert(Stream.of(arrayOfEmps) instanceof Stream); - } - - @Test - public void whenGetStreamFromElements_ObtainStream() { - assert(Stream.of(arrayOfEmps[0], arrayOfEmps[1], arrayOfEmps[2]) instanceof Stream); - } - - @Test - public void whenBuildStreamFromElements_ObtainStream() { - Stream.Builder empStreamBuilder = Stream.builder(); - - empStreamBuilder.accept(arrayOfEmps[0]); - empStreamBuilder.accept(arrayOfEmps[1]); - empStreamBuilder.accept(arrayOfEmps[2]); - - Stream empStream = empStreamBuilder.build(); - - assert(empStream instanceof Stream); - } - - @Test - public void whenIncrementSalaryForEachEmployee_thenApplyNewSalary() { - Employee[] arrayOfEmps = { - new Employee(1, "Jeff Bezos", 100000.0), - new Employee(2, "Bill Gates", 200000.0), - new Employee(3, "Mark Zuckerberg", 300000.0) - }; - - List empList = Arrays.asList(arrayOfEmps); - - empList.stream().forEach(e -> e.salaryIncrement(10.0)); - - assertThat(empList, contains( - hasProperty("salary", equalTo(110000.0)), - hasProperty("salary", equalTo(220000.0)), - hasProperty("salary", equalTo(330000.0)) - )); - } - - @Test - public void whenIncrementSalaryUsingPeek_thenApplyNewSalary() { - Employee[] arrayOfEmps = { - new Employee(1, "Jeff Bezos", 100000.0), - new Employee(2, "Bill Gates", 200000.0), - new Employee(3, "Mark Zuckerberg", 300000.0) - }; - - List empList = Arrays.asList(arrayOfEmps); - - empList.stream() - .peek(e -> e.salaryIncrement(10.0)) - .peek(System.out::println) - .collect(Collectors.toList()); - - assertThat(empList, contains( - hasProperty("salary", equalTo(110000.0)), - hasProperty("salary", equalTo(220000.0)), - hasProperty("salary", equalTo(330000.0)) - )); - } - - @Test - public void whenMapIdToEmployees_thenGetEmployeeStream() { - Integer[] empIds = { 1, 2, 3 }; - - List employees = Stream.of(empIds) - .map(employeeRepository::findById) - .collect(Collectors.toList()); - - assertEquals(employees.size(), empIds.length); - } - - @Test - public void whenFlatMapEmployeeNames_thenGetNameStream() { - List> namesNested = Arrays.asList( - Arrays.asList("Jeff", "Bezos"), - Arrays.asList("Bill", "Gates"), - Arrays.asList("Mark", "Zuckerberg")); - - List namesFlatStream = namesNested.stream() - .flatMap(Collection::stream) - .collect(Collectors.toList()); - - assertEquals(namesFlatStream.size(), namesNested.size() * 2); - } - - @Test - public void whenFilterEmployees_thenGetFilteredStream() { - Integer[] empIds = { 1, 2, 3, 4 }; - - List employees = Stream.of(empIds) - .map(employeeRepository::findById) - .filter(e -> e != null) - .filter(e -> e.getSalary() > 200000) - .collect(Collectors.toList()); - - assertEquals(Arrays.asList(arrayOfEmps[2]), employees); - } - - @Test - public void whenFindFirst_thenGetFirstEmployeeInStream() { - Integer[] empIds = { 1, 2, 3, 4 }; - - Employee employee = Stream.of(empIds) - .map(employeeRepository::findById) - .filter(e -> e != null) - .filter(e -> e.getSalary() > 100000) - .findFirst() - .orElse(null); - - assertEquals(employee.getSalary(), new Double(200000)); - } - - @Test - public void whenCollectStreamToList_thenGetList() { - List employees = empList.stream().collect(Collectors.toList()); - - assertEquals(empList, employees); - } - - @Test - public void whenStreamToArray_thenGetArray() { - Employee[] employees = empList.stream().toArray(Employee[]::new); - - assertThat(empList.toArray(), equalTo(employees)); - } - - @Test - public void whenStreamCount_thenGetElementCount() { - Long empCount = empList.stream() - .filter(e -> e.getSalary() > 200000) - .count(); - - assertEquals(empCount, new Long(1)); - } - - @Test - public void whenLimitInfiniteStream_thenGetFiniteElements() { - Stream infiniteStream = Stream.iterate(2, i -> i * 2); - - List collect = infiniteStream - .skip(3) - .limit(5) - .collect(Collectors.toList()); - - assertEquals(collect, Arrays.asList(16, 32, 64, 128, 256)); - } - - @Test - public void whenSortStream_thenGetSortedStream() { - List employees = empList.stream() - .sorted((e1, e2) -> e1.getName().compareTo(e2.getName())) - .collect(Collectors.toList()); - - assertEquals(employees.get(0).getName(), "Bill Gates"); - assertEquals(employees.get(1).getName(), "Jeff Bezos"); - assertEquals(employees.get(2).getName(), "Mark Zuckerberg"); - } - - - @Test - public void whenFindMin_thenGetMinElementFromStream() { - Employee firstEmp = empList.stream() - .min((e1, e2) -> e1.getId() - e2.getId()) - .orElseThrow(NoSuchElementException::new); - - assertEquals(firstEmp.getId(), new Integer(1)); - } - - @Test - public void whenFindMax_thenGetMaxElementFromStream() { - Employee maxSalEmp = empList.stream() - .max(Comparator.comparing(Employee::getSalary)) - .orElseThrow(NoSuchElementException::new); - - assertEquals(maxSalEmp.getSalary(), new Double(300000.0)); - } - - @Test - public void whenApplyDistinct_thenRemoveDuplicatesFromStream() { - List intList = Arrays.asList(2, 5, 3, 2, 4, 3); - List distinctIntList = intList.stream().distinct().collect(Collectors.toList()); - - assertEquals(distinctIntList, Arrays.asList(2, 5, 3, 4)); - } - - @Test - public void whenApplyMatch_thenReturnBoolean() { - List intList = Arrays.asList(2, 4, 5, 6, 8); - - boolean allEven = intList.stream().allMatch(i -> i % 2 == 0); - boolean oneEven = intList.stream().anyMatch(i -> i % 2 == 0); - boolean noneMultipleOfThree = intList.stream().noneMatch(i -> i % 3 == 0); - - assertEquals(allEven, false); - assertEquals(oneEven, true); - assertEquals(noneMultipleOfThree, false); - } - - @Test - public void whenFindMaxOnIntStream_thenGetMaxInteger() { - Integer latestEmpId = empList.stream() - .mapToInt(Employee::getId) - .max() - .orElseThrow(NoSuchElementException::new); - - assertEquals(latestEmpId, new Integer(3)); - } - - @Test - public void whenApplySumOnIntStream_thenGetSum() { - Double avgSal = empList.stream() - .mapToDouble(Employee::getSalary) - .average() - .orElseThrow(NoSuchElementException::new); - - assertEquals(avgSal, new Double(200000)); - } - - @Test - public void whenApplyReduceOnStream_thenGetValue() { - Double sumSal = empList.stream() - .map(Employee::getSalary) - .reduce(0.0, Double::sum); - - assertEquals(sumSal, new Double(600000)); - } - - @Test - public void whenCollectByJoining_thenGetJoinedString() { - String empNames = empList.stream() - .map(Employee::getName) - .collect(Collectors.joining(", ")) - .toString(); - - assertEquals(empNames, "Jeff Bezos, Bill Gates, Mark Zuckerberg"); - } - - @Test - public void whenCollectBySet_thenGetSet() { - Set empNames = empList.stream() - .map(Employee::getName) - .collect(Collectors.toSet()); - - assertEquals(empNames.size(), 3); - } - - @Test - public void whenToVectorCollection_thenGetVector() { - Vector empNames = empList.stream() - .map(Employee::getName) - .collect(Collectors.toCollection(Vector::new)); - - assertEquals(empNames.size(), 3); - } - - @Test - public void whenApplySummarizing_thenGetBasicStats() { - DoubleSummaryStatistics stats = empList.stream() - .collect(Collectors.summarizingDouble(Employee::getSalary)); - - assertEquals(stats.getCount(), 3); - assertEquals(stats.getSum(), 600000.0, 0); - assertEquals(stats.getMin(), 100000.0, 0); - assertEquals(stats.getMax(), 300000.0, 0); - assertEquals(stats.getAverage(), 200000.0, 0); - } - - @Test - public void whenApplySummaryStatistics_thenGetBasicStats() { - DoubleSummaryStatistics stats = empList.stream() - .mapToDouble(Employee::getSalary) - .summaryStatistics(); - - assertEquals(stats.getCount(), 3); - assertEquals(stats.getSum(), 600000.0, 0); - assertEquals(stats.getMin(), 100000.0, 0); - assertEquals(stats.getMax(), 300000.0, 0); - assertEquals(stats.getAverage(), 200000.0, 0); - } - - @Test - public void whenStreamPartition_thenGetMap() { - List intList = Arrays.asList(2, 4, 5, 6, 8); - Map> isEven = intList.stream().collect( - Collectors.partitioningBy(i -> i % 2 == 0)); - - assertEquals(isEven.get(true).size(), 4); - assertEquals(isEven.get(false).size(), 1); - } - - @Test - public void whenStreamGroupingBy_thenGetMap() { - Map> groupByAlphabet = empList.stream().collect( - Collectors.groupingBy(e -> new Character(e.getName().charAt(0)))); - - assertEquals(groupByAlphabet.get('B').get(0).getName(), "Bill Gates"); - assertEquals(groupByAlphabet.get('J').get(0).getName(), "Jeff Bezos"); - assertEquals(groupByAlphabet.get('M').get(0).getName(), "Mark Zuckerberg"); - } - - @Test - public void whenStreamMapping_thenGetMap() { - Map> idGroupedByAlphabet = empList.stream().collect( - Collectors.groupingBy(e -> new Character(e.getName().charAt(0)), - Collectors.mapping(Employee::getId, Collectors.toList()))); - - assertEquals(idGroupedByAlphabet.get('B').get(0), new Integer(2)); - assertEquals(idGroupedByAlphabet.get('J').get(0), new Integer(1)); - assertEquals(idGroupedByAlphabet.get('M').get(0), new Integer(3)); - } - - @Test - public void whenStreamReducing_thenGetValue() { - Double percentage = 10.0; - Double salIncrOverhead = empList.stream().collect(Collectors.reducing( - 0.0, e -> e.getSalary() * percentage / 100, (s1, s2) -> s1 + s2)); - - assertEquals(salIncrOverhead, 60000.0, 0); - } - - @Test - public void whenStreamGroupingAndReducing_thenGetMap() { - Comparator byNameLength = Comparator.comparing(Employee::getName); - - Map> longestNameByAlphabet = empList.stream().collect( - Collectors.groupingBy(e -> new Character(e.getName().charAt(0)), - Collectors.reducing(BinaryOperator.maxBy(byNameLength)))); - - assertEquals(longestNameByAlphabet.get('B').get().getName(), "Bill Gates"); - assertEquals(longestNameByAlphabet.get('J').get().getName(), "Jeff Bezos"); - assertEquals(longestNameByAlphabet.get('M').get().getName(), "Mark Zuckerberg"); - } - - @Test - public void whenParallelStream_thenPerformOperationsInParallel() { - Employee[] arrayOfEmps = { - new Employee(1, "Jeff Bezos", 100000.0), - new Employee(2, "Bill Gates", 200000.0), - new Employee(3, "Mark Zuckerberg", 300000.0) - }; - - List empList = Arrays.asList(arrayOfEmps); - - empList.stream().parallel().forEach(e -> e.salaryIncrement(10.0)); - - assertThat(empList, contains( - hasProperty("salary", equalTo(110000.0)), - hasProperty("salary", equalTo(220000.0)), - hasProperty("salary", equalTo(330000.0)) - )); - } - - @Test - public void whenGenerateStream_thenGetInfiniteStream() { - Stream.generate(Math::random) - .limit(5) - .forEach(System.out::println); - } - - @Test - public void whenIterateStream_thenGetInfiniteStream() { - Stream evenNumStream = Stream.iterate(2, i -> i * 2); - - List collect = evenNumStream - .limit(5) - .collect(Collectors.toList()); - - assertEquals(collect, Arrays.asList(2, 4, 8, 16, 32)); - } - - @Test - public void whenStreamToFile_thenGetFile() throws IOException { - String[] words = { - "hello", - "refer", - "world", - "level" - }; - - try (PrintWriter pw = new PrintWriter( - Files.newBufferedWriter(Paths.get(fileName)))) { - Stream.of(words).forEach(pw::println); - } - } - - private List getPalindrome(Stream stream, int length) { - return stream.filter(s -> s.length() == length) - .filter(s -> s.compareToIgnoreCase( - new StringBuilder(s).reverse().toString()) == 0) - .collect(Collectors.toList()); - } - - @Test - public void whenFileToStream_thenGetStream() throws IOException { - whenStreamToFile_thenGetFile(); - - List str = getPalindrome(Files.lines(Paths.get(fileName)), 5); - assertThat(str, contains("refer", "level")); - } -} diff --git a/guest/core-java/src/test/resources/.keep b/guest/core-java/src/test/resources/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/guest/core-kotlin/.gitignore b/guest/core-kotlin/.gitignore deleted file mode 100644 index 0c017e8f8c..0000000000 --- a/guest/core-kotlin/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -/bin/ - -#ignore gradle -.gradle/ - - -#ignore build and generated files -build/ -node/ -out/ - -#ignore installed node modules and package lock file -node_modules/ -package-lock.json diff --git a/guest/core-kotlin/pom.xml b/guest/core-kotlin/pom.xml deleted file mode 100644 index 91bc7fa170..0000000000 --- a/guest/core-kotlin/pom.xml +++ /dev/null @@ -1,201 +0,0 @@ - - - 4.0.0 - com.stackify - core-kotlin - 1.0-SNAPSHOT - core-kotlin - jar - - - - jcenter - http://jcenter.bintray.com - - - - - - org.junit.platform - junit-platform-runner - ${junit-platform.version} - test - - - org.jetbrains.kotlin - kotlin-stdlib - ${kotlin-stdlib.version} - - - org.jetbrains.kotlin - kotlin-stdlib-jdk8 - ${kotlin-stdlib.version} - - - org.jetbrains.kotlin - kotlin-test-junit - ${kotlin-test-junit.version} - test - - - org.jetbrains.kotlin - kotlin-reflect - ${kotlin-reflect.version} - - - org.jetbrains.spek - spek-api - ${spek.api.version} - test - - - org.jetbrains.spek - spek-subject-extension - ${spek.subject.version} - test - - - org.jetbrains.spek - spek-junit-platform-engine - ${spek.junit.version} - test - - - com.nhaarman - mockito-kotlin - ${mockito-kotlin.version} - test - - - org.assertj - assertj-core - ${assertj.version} - test - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - - org.apache.maven.plugins - maven-failsafe-plugin - ${maven-failsafe-plugin.version} - test - - - org.jetbrains.kotlin - kotlin-maven-plugin - ${kotlin-maven-plugin.version} - provided - - - - - - - org.jetbrains.kotlin - kotlin-maven-plugin - ${kotlin-maven-plugin.version} - - - compile - - compile - - - - ${project.basedir}/src/main/kotlin - - - - - test-compile - - test-compile - - - - ${project.basedir}/src/test/kotlin - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - ${java.version} - ${java.version} - - - - - default-compile - none - - - - default-testCompile - none - - - java-compile - compile - - compile - - - - - - maven-failsafe-plugin - ${maven-failsafe-plugin.version} - - - org.junit.platform - junit-platform-surefire-provider - ${junit-platform-surefire-provider.version} - - - - - junit5 - - integration-test - verify - - - - **/*Test5.java - - - - - - - - - - 2.22.0 - UTF-8 - 1.2.60 - 1.2.51 - 1.2.51 - 1.2.51 - 0.22.5 - 1.5.0 - 3.6.1 - 3.10.0 - 3.7.0 - 1.1.5 - 1.1.5 - 1.1.5 - - - diff --git a/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/CompanionObjectTest.kt b/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/CompanionObjectTest.kt deleted file mode 100644 index 69573fb75b..0000000000 --- a/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/CompanionObjectTest.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.kotlinvsjava - -import org.junit.Test -import kotlin.test.assertEquals - -class CompanionObjectTest { - - @Test - fun givenAClassWithCompanionObject_whenCallingMethodTheSameAsStaticOne_thenWeGetAResult() { - assertEquals("A", A.returnClassName()) - } - -} - -class A { - companion object { - fun returnClassName(): String { - return "A" - } - } -} \ No newline at end of file diff --git a/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/ConstructorTest.kt b/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/ConstructorTest.kt deleted file mode 100644 index fdb5d05db5..0000000000 --- a/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/ConstructorTest.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.baeldung.kotlinvsjava - -import org.junit.Test -import kotlin.test.assertEquals - -class ConstructorTests { - - @Test - fun givenAClassWithPrimaryConstructor_whenCreatingAnInstance_thenWeGetObject() { - var example = Example(1, "Example") - - assertEquals(1, example.id) - assertEquals("Example", example.name) - } - -} - -class Example constructor(val id: Int, var name: String) \ No newline at end of file diff --git a/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/DataClassTest.kt b/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/DataClassTest.kt deleted file mode 100644 index ad79538d3c..0000000000 --- a/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/DataClassTest.kt +++ /dev/null @@ -1,33 +0,0 @@ -package com.baeldung.kotlinvsjava - -import org.junit.Test -import kotlin.test.assertEquals -import kotlin.test.assertFalse - -class DataClassTest { - - @Test - fun givenASampleDataClass_whenCallingToStringMethod_thenItReturnsAllProperties() { - val student = Student(1, "John", "Smith") - - assertEquals(1, student.id) - assertEquals("John", student.name) - assertEquals("Smith", student.lastName) - assertEquals("Student(id=1, name=John, lastName=Smith)", student.toString()) - } - - @Test - fun givenASampleDataClass_whenCreatingACopyWithGeneratedFunction_thenItReturnsACopyWithRequestedChanges() { - val student = Student(1, "John", "Smith") - val student2 = student.copy(id = 2, name = "Anne") - - assertEquals(2, student2.id) - assertEquals("Anne", student2.name) - assertEquals("Smith", student2.lastName) - assertEquals("Student(id=2, name=Anne, lastName=Smith)", student2.toString()) - assertFalse(student.equals(student2)) - } - -} - -data class Student(val id: Int, val name: String, val lastName: String) \ No newline at end of file diff --git a/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/DelegationTest.kt b/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/DelegationTest.kt deleted file mode 100644 index 2da824c2db..0000000000 --- a/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/DelegationTest.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.baeldung.kotlinvsjava - -import org.junit.Test -import kotlin.test.assertEquals - -class DelegationTest { - - @Test - fun givenAClassWithDelegation_whenCallDelegatedMethod_thenWeGetAResultDefinedInPassedObject() { - val car = Car(V6Engine()) - - assertEquals("Vroom", car.makeSound()) - } - -} - -interface Engine { - fun makeSound(): String -} - -class V6Engine: Engine { - override fun makeSound(): String { - return "Vroom" - } -} - -class Car(e: Engine) : Engine by e \ No newline at end of file diff --git a/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/ExceptionsTest.kt b/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/ExceptionsTest.kt deleted file mode 100644 index 073c4dd890..0000000000 --- a/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/ExceptionsTest.kt +++ /dev/null @@ -1,34 +0,0 @@ -package com.baeldung.kotlinvsjava - -import java.io.IOException -import kotlin.test.Test -import kotlin.test.assertEquals - -class ExceptionsTest { - - @Test - fun givenATryExpression_whenReturning5InLastExpressionOfTryBlock_thenWeGet5() { - val value: Int = try { 5 } catch (e: IOException) { 6 } - - assertEquals(5, value) - } - - @Test - fun givenATryExpression_whenReturning6InLastExpressionOfCatchBlock_thenWeGet6() { - val value: Int = try { funThrowingException() } catch (e: IOException) { 6 } - - assertEquals(6, value) - } - - @org.junit.Test(expected = IllegalArgumentException::class) - fun givenANullString_whenUsingElvisOperator_thenExceptionIsThrown() { - val sampleString: String? = null - - sampleString?.length ?: throw IllegalArgumentException("String must not be null") - } - - private fun funThrowingException(): Nothing { - throw IOException() - } - -} \ No newline at end of file diff --git a/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/ExtensionFunctionsTest.kt b/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/ExtensionFunctionsTest.kt deleted file mode 100644 index 3db73b6d2d..0000000000 --- a/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/ExtensionFunctionsTest.kt +++ /dev/null @@ -1,30 +0,0 @@ -package com.baeldung.kotlinvsjava - -import org.junit.Test -import kotlin.test.assertEquals - -class ExtensionFunctionsTest { - - @Test - fun givenAStringWithAnExtensionFunction_whenCallingThatFunction_thenItConcatenatesStrings() { - val sampleString = "ABC" - val concatenatedString = sampleString.appendString("DEF") - - assertEquals("ABCDEF", concatenatedString) - } - - @Test - fun givenAStringWithAnExtensionProperty_whenReadingProperty_thenItReturnsLengthOfString() { - val sampleString = "ABC" - - assertEquals(3, sampleString.size) - } - - fun String.appendString(str : String): String { - return plus(str) - } - - val String.size: Int - get() = length - -} \ No newline at end of file diff --git a/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/FunctionsTest.kt b/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/FunctionsTest.kt deleted file mode 100644 index 6176478dfe..0000000000 --- a/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/FunctionsTest.kt +++ /dev/null @@ -1,70 +0,0 @@ -package com.baeldung.kotlinvsjava - -import org.junit.Test -import kotlin.test.assertEquals - -class FunctionsTest { - - @Test - fun givenALambdaExpressionConcatenatingString_whenUsingTheFunctionWithAAndBString_thenWeGetAB() { - val concat: (String, String) -> String = { a, b -> a + b } - - assertEquals("AB", concat("A","B")) - } - - @Test - fun givenAnAnonymousFunctionConcatenatingString_whenUsingTheFunctionWithAAndBString_thenWeGetAB() { - val concat: (String, String) -> String = fun(a: String, b: String): String { return a + b } - - assertEquals("AB", concat("A","B")) - } - - @Test - fun givenAnPlusMethodOfString_whenUsingTheFunctionWithAAndBString_thenWeGetAB() { - val concat = String::plus - - assertEquals("AB", concat("A","B")) - } - - @Test - fun givenAStringConstractorAssignedToFunction_whenUsingFunctionReference_thenWeGetNewString() { - val concat = ::String - - assertEquals("A", concat().plus("A")) - } - - @Test - fun givenAClassImplementingAFunctionType_whenUsingTheFunctionWithAAndBString_thenWeGetAB() { - val concat = StringConcatenation() - - assertEquals("AB", concat("A", "B")) - } - - @Test - fun givenALambdaExpressionWithReceiver_whenUsingTheFunctionWithReceiver_thenWeGetABC() { - val concat: String.(String, String) -> String = { a, b -> plus(a).plus(b) } - - assertEquals("ABC", "A".concat("B", "C")) - } - - @Test - fun givenALambdaExpressionWithinLambdaExpression_whenUsingTheFunction_thenWeGetAB() { - val concat: (String) -> ((String) -> String) = { a -> {b -> a + b} } - - assertEquals("AB", (concat("A")("B"))) - } - - @Test - fun given3NestedLambdaExpression_whenUsingTheFunction_thenWeGetABC() { - val concat: (String) -> (String) -> (String) -> String = { a -> {b -> { c -> a + b + c} } } - - assertEquals("ABC", concat("A")("B")("C")) - } - -} - -class StringConcatenation: (String, String) -> String { - override fun invoke(p1: String, p2: String): String { - return p1 + p2 - } -} \ No newline at end of file diff --git a/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/IsOperatorTest.kt b/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/IsOperatorTest.kt deleted file mode 100644 index 1817602cdf..0000000000 --- a/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/IsOperatorTest.kt +++ /dev/null @@ -1,36 +0,0 @@ -package com.baeldung.kotlinvsjava - -import org.junit.Test -import kotlin.math.absoluteValue -import kotlin.test.assertEquals -import kotlin.test.assertTrue - -class IsOperatorTest { - - @Test - fun givenSampleValue_whenUsingIsOperatorInIfStatement_thenItCastsAutomaticallyToString() { - val value: Any = "string" - - if(value is String) { - assertEquals(6, value.length) - } - } - - @Test - fun givenSampleValue_whenUsingIsOperatorWithAndOperator_thenItCastsAutomaticallyToString() { - val value: Any = "string" - - assertTrue(value is String && value.length == 6) - } - - @Test - fun givenSampleValue_whenUsingWithWhenOperator_thenItCastsAutomaticallyToString() { - val value: Any = "string" - - when(value) { - is String -> assertEquals(6, value.length) - is Int -> assertEquals(6, value.absoluteValue) - } - } - -} \ No newline at end of file diff --git a/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/NullSafetyTest.kt b/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/NullSafetyTest.kt deleted file mode 100644 index 8cb3cbc761..0000000000 --- a/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/NullSafetyTest.kt +++ /dev/null @@ -1,67 +0,0 @@ -package com.baeldung.kotlinvsjava - -import kotlin.test.Test -import java.lang.NullPointerException -import kotlin.test.assertEquals -import kotlin.test.assertNotNull -import kotlin.test.assertNull - -class NullSafetyTest { - - @Test - fun givenStringAndNull_whenUsingSafeCallOperatorWithLengthMethod_thenReturnsLengthForStringAndNullForNull() { - val stringValue: String? = "string" - val nullValue: String? = null - - assertNotNull(stringValue?.length) - assertNull(nullValue?.length) - } - - @Test(expected = NullPointerException::class) - fun givenNullReference_whenUsingTheNotNullAssertionOperator_thenItThrowsNullPointerException() { - val stringValue: String? = "string" - val nullValue: String? = null - - assertNotNull(stringValue!!.length) - nullValue!!.length - } - - @Test - fun givenStringAndNull_whenUsingElvisOperator_thenItTestsAgainstNullAndReturnsTheProperValue() { - val stringValue: String? = "string" - val nullValue: String? = null - - val shouldBeLength: Int = stringValue?.length ?: -1 - val souldBeMinusOne: Int = nullValue?.length ?: -1 - - assertEquals(6, shouldBeLength) - assertEquals(-1, souldBeMinusOne) - } - - @Test - fun givenString_whenCastingToInt_thenItReturnsNull() { - val stringValue: String? = "string" - - val intValue: Int? = stringValue as? Int - - assertNull(intValue) - } - - @Test - fun givenCollectionWithNulls_whenFilterNonNull_thenItReturnsCollectionWithoutNulls() { - val list: List = listOf("a", "b", null) - val nonNullList = list.filterNotNull() - - assertEquals(2, nonNullList.size) - assertEquals(nonNullList, listOf("a", "b")) - } - - @Test - fun givenCollectionWithNulls_whenLetWithSafeCallOperator_thenItOmitsNulls() { - val list: List = listOf("a", "b", null) - for(elem in list) { - elem?.let { assertNotNull(it) } - } - } - -} \ No newline at end of file diff --git a/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/OperatorsOverloadingTest.kt b/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/OperatorsOverloadingTest.kt deleted file mode 100644 index a28008da20..0000000000 --- a/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/OperatorsOverloadingTest.kt +++ /dev/null @@ -1,61 +0,0 @@ -package com.baeldung.kotlinvsjava - -import org.junit.Test -import kotlin.test.assertEquals -import kotlin.test.assertTrue - -class OperatorsOverloadingTest { - - @Test - fun givenThePlaneClassWithOverloadedIncrementationOperator_whenCallingTheOperator_thenItIncreasesSpeed(){ - var plane = Plane(0.0) - - plane++ - assertEquals(50.0, plane.currentSpeed) - } - - @Test - fun givenThePlaneClassWithOverloadedMinusOperator_whenCallingTheOperator_thenItDecreaseSpeed(){ - var plane = Plane(1000.0) - - plane - 500.0 - assertEquals(500.0, plane.currentSpeed) - } - - @Test - fun givenThePlaneClassWithOverloadedInvokeOperator_whenCallingTheOperator_thenItSetSpeed(){ - var plane = Plane(0.0) - - plane(150.0) - assertEquals(150.0, plane.currentSpeed) - } - - @Test - fun given2PlaneObjectWithOverloadedComparisonOperator_whenCallingTheOperator_thenItComparesSpeedValues(){ - var plane = Plane(0.0) - var plane2 = Plane(150.0) - - assertTrue(plane < (plane2)) - } - -} - -class Plane(var currentSpeed: Double) { - - operator fun inc(): Plane { - currentSpeed += 50.0 - return this - } - - operator fun minus(number: Double) { - currentSpeed = if(currentSpeed < number) 0.0 else currentSpeed - number - } - - operator fun invoke(speed: Double) { - currentSpeed = speed - } - - operator fun compareTo(plane: Plane): Int { - return currentSpeed.compareTo(plane.currentSpeed) - } -} \ No newline at end of file diff --git a/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/PropertiesTest.kt b/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/PropertiesTest.kt deleted file mode 100644 index 95abcd68a2..0000000000 --- a/guest/core-kotlin/src/test/kotlin/com/baeldung/kotlinvsjava/PropertiesTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.kotlinvsjava - -import org.junit.Test -import java.math.BigDecimal -import kotlin.test.assertEquals - -class PropertiesTest { - - @Test - fun givenASampleClassWithValAndVarProperties_whenSettingPrice_thenWeGetZeroOrOne() { - val product = Product() - product.price = BigDecimal(10) - - val product2 = Product() - product2.price = null - - assertEquals("empty", product.id) - assertEquals("empty", product2.id) - assertEquals(BigDecimal(10), product.price) - assertEquals(BigDecimal(1), product2.price) - } - -} - -class Product { - - val id: String? = "empty" - - var price: BigDecimal? = BigDecimal.ZERO - set(value) = if(value == null) { field = BigDecimal.ONE} else { field = value } - -} \ No newline at end of file diff --git a/guest/deep-jsf/README.md b/guest/deep-jsf/README.md deleted file mode 100644 index b5f532535b..0000000000 --- a/guest/deep-jsf/README.md +++ /dev/null @@ -1,15 +0,0 @@ -## Building - -To build the module, use Maven's `package` goal: - -``` -mvn clean package -``` - -The `war` file will be available at `target/deep-jsf.war` - -## Running - -The `war` application is deployed to a Java EE 7 compliant application server, for example, to GlassFish 4 or later. - -The example then will be accessible at http://localhost:8080/deep-jsf/index.xhtml \ No newline at end of file diff --git a/guest/deep-jsf/pom.xml b/guest/deep-jsf/pom.xml deleted file mode 100644 index 91cf567e73..0000000000 --- a/guest/deep-jsf/pom.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - 4.0.0 - com.stackify - deep-jsf - 0.0.1-SNAPSHOT - deep-jsf - war - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - ../../ - - - - - javax - javaee-api - ${javaee-api.version} - provided - - - - - deep-jsf - - - - false - 7.0 - - - \ No newline at end of file diff --git a/guest/deep-jsf/src/main/java/com/stackify/deepjsf/GreetControllerBean.java b/guest/deep-jsf/src/main/java/com/stackify/deepjsf/GreetControllerBean.java deleted file mode 100644 index 7f5cf99781..0000000000 --- a/guest/deep-jsf/src/main/java/com/stackify/deepjsf/GreetControllerBean.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.stackify.deepjsf; - -import javax.faces.bean.ManagedBean; -import javax.faces.bean.RequestScoped; - -@ManagedBean -@RequestScoped -public class GreetControllerBean { - - public String greet() { - return "greet"; - } - -} diff --git a/guest/deep-jsf/src/main/java/com/stackify/deepjsf/PhaseListenerBean.java b/guest/deep-jsf/src/main/java/com/stackify/deepjsf/PhaseListenerBean.java deleted file mode 100644 index d4f6a6e815..0000000000 --- a/guest/deep-jsf/src/main/java/com/stackify/deepjsf/PhaseListenerBean.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.stackify.deepjsf; - -import javax.faces.bean.ManagedBean; -import javax.faces.bean.RequestScoped; -import javax.faces.component.UIComponent; -import javax.faces.component.UIViewRoot; -import javax.faces.component.visit.VisitContext; -import javax.faces.component.visit.VisitResult; -import javax.faces.event.PhaseEvent; -import javax.faces.event.PhaseId; -import javax.servlet.http.HttpServletRequest; - -@ManagedBean -@RequestScoped -public class PhaseListenerBean { - - public void beforeListener(PhaseEvent event) { - if (!event.getPhaseId().equals(PhaseId.RENDER_RESPONSE)) { - return; - } - UIViewRoot root = event.getFacesContext().getViewRoot(); - - boolean showNewFeature = showNewFeatureForIp(event); - - processComponentTree(root, event, showNewFeature); - } - - private boolean showNewFeatureForIp(PhaseEvent event) { - HttpServletRequest request = (HttpServletRequest) event.getFacesContext() - .getExternalContext().getRequest(); - String ip = request.getRemoteAddr(); - return !ip.startsWith("127.0"); - } - - private void processComponentTree(UIComponent component, PhaseEvent event, boolean show) { - component.visitTree(VisitContext.createVisitContext(event.getFacesContext()), - (context, target) -> { - if (target.getId() != null - && target.getId().startsWith("new-feature-") - && !show) { - target.setRendered(false); - } - return VisitResult.ACCEPT; - }); - } - -} diff --git a/guest/deep-jsf/src/main/java/com/stackify/deepjsf/UserBean.java b/guest/deep-jsf/src/main/java/com/stackify/deepjsf/UserBean.java deleted file mode 100644 index f6c94e87b8..0000000000 --- a/guest/deep-jsf/src/main/java/com/stackify/deepjsf/UserBean.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.stackify.deepjsf; - -import javax.faces.bean.ManagedBean; -import javax.faces.bean.SessionScoped; -import javax.faces.event.ValueChangeEvent; - -@ManagedBean -@SessionScoped -public class UserBean { - - private String name = ""; - - private String lastName = ""; - - private String proposedLogin = ""; - - public void nameChanged(ValueChangeEvent event) { - this.proposedLogin = event.getNewValue() + "-" + lastName; - } - - public void lastNameChanged(ValueChangeEvent event) { - this.proposedLogin = name + "-" + event.getNewValue(); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getProposedLogin() { - return proposedLogin; - } - - public void setProposedLogin(String proposedLogin) { - this.proposedLogin = proposedLogin; - } -} diff --git a/guest/deep-jsf/src/main/java/com/stackify/deepjsf/UserControllerBean.java b/guest/deep-jsf/src/main/java/com/stackify/deepjsf/UserControllerBean.java deleted file mode 100644 index c2a46a019a..0000000000 --- a/guest/deep-jsf/src/main/java/com/stackify/deepjsf/UserControllerBean.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.stackify.deepjsf; - -import javax.faces.bean.ManagedBean; -import javax.faces.bean.RequestScoped; - -@ManagedBean -@RequestScoped -public class UserControllerBean { - - public String register() { - return "register-success"; - } - -} diff --git a/guest/deep-jsf/src/main/resources/logback.xml b/guest/deep-jsf/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/guest/deep-jsf/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/guest/deep-jsf/src/main/webapp/WEB-INF/faces-config.xml b/guest/deep-jsf/src/main/webapp/WEB-INF/faces-config.xml deleted file mode 100644 index 264e60065c..0000000000 --- a/guest/deep-jsf/src/main/webapp/WEB-INF/faces-config.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - /register.xhtml - - register-success - /hello.xhtml - - - - \ No newline at end of file diff --git a/guest/deep-jsf/src/main/webapp/greet.xhtml b/guest/deep-jsf/src/main/webapp/greet.xhtml deleted file mode 100644 index 50c79c64e1..0000000000 --- a/guest/deep-jsf/src/main/webapp/greet.xhtml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - diff --git a/guest/deep-jsf/src/main/webapp/hello.xhtml b/guest/deep-jsf/src/main/webapp/hello.xhtml deleted file mode 100644 index f9c3745dca..0000000000 --- a/guest/deep-jsf/src/main/webapp/hello.xhtml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - diff --git a/guest/deep-jsf/src/main/webapp/index.xhtml b/guest/deep-jsf/src/main/webapp/index.xhtml deleted file mode 100644 index de99b89815..0000000000 --- a/guest/deep-jsf/src/main/webapp/index.xhtml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/guest/deep-jsf/src/main/webapp/register.xhtml b/guest/deep-jsf/src/main/webapp/register.xhtml deleted file mode 100644 index ba1b8e0233..0000000000 --- a/guest/deep-jsf/src/main/webapp/register.xhtml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/guest/junit5-example/.gitignore b/guest/junit5-example/.gitignore deleted file mode 100644 index 60be5b80aa..0000000000 --- a/guest/junit5-example/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/target/ -.settings/ -.classpath -.project diff --git a/guest/junit5-example/pom.xml b/guest/junit5-example/pom.xml deleted file mode 100644 index cc52b0e3d7..0000000000 --- a/guest/junit5-example/pom.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - 4.0.0 - junit5-example - junit5-example - 0.0.1-SNAPSHOT - junit5-example - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - ../../ - - - - - org.junit.jupiter - junit-jupiter-params - ${junit-jupiter.version} - - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - - - com.h2database - h2 - ${h2.version} - - - org.apache.logging.log4j - log4j-core - ${log4j-core.version} - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - math - - - - - - - - 2.8.2 - - \ No newline at end of file diff --git a/guest/junit5-example/src/main/java/com/stackify/daos/UserDAO.java b/guest/junit5-example/src/main/java/com/stackify/daos/UserDAO.java deleted file mode 100644 index 091d077ef6..0000000000 --- a/guest/junit5-example/src/main/java/com/stackify/daos/UserDAO.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.stackify.daos; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.stackify.models.User; -import com.stackify.utils.ConnectionUtil; - -public class UserDAO { - - private Logger logger = LogManager.getLogger(UserDAO.class); - - public void createTable() { - try (Connection con = ConnectionUtil.getConnection()) { - String createQuery = "CREATE TABLE users(email varchar(50) primary key, name varchar(50))"; - PreparedStatement pstmt = con.prepareStatement(createQuery); - - pstmt.execute(); - } catch (SQLException exc) { - logger.error(exc.getMessage()); - } - - } - - public void add(User user) { - try (Connection con = ConnectionUtil.getConnection()) { - - String insertQuery = "INSERT INTO users(email,name) VALUES(?,?)"; - PreparedStatement pstmt = con.prepareStatement(insertQuery); - pstmt.setString(1, user.getEmail()); - pstmt.setString(2, user.getName()); - - pstmt.executeUpdate(); - } catch (SQLException exc) { - logger.error(exc.getMessage()); - } - } - - public void update(User user) { - try (Connection con = ConnectionUtil.getConnection()) { - - String updateQuery = "UPDATE users SET name=? WHERE email=?"; - PreparedStatement pstmt = con.prepareStatement(updateQuery); - pstmt.setString(1, user.getName()); - pstmt.setString(2, user.getEmail()); - - pstmt.executeUpdate(); - } catch (SQLException exc) { - logger.error(exc.getMessage()); - } - } - - public void delete(User user) { - try (Connection con = ConnectionUtil.getConnection()) { - - String deleteQuery = "DELETE FROM users WHERE email=?"; - PreparedStatement pstmt = con.prepareStatement(deleteQuery); - pstmt.setString(1, user.getEmail()); - - pstmt.executeUpdate(); - } catch (SQLException exc) { - logger.error(exc.getMessage()); - } - } - - public void delete(String email) { - try (Connection con = ConnectionUtil.getConnection()) { - - String deleteQuery = "DELETE FROM users WHERE email=?"; - PreparedStatement pstmt = con.prepareStatement(deleteQuery); - pstmt.setString(1, email); - - pstmt.executeUpdate(); - } catch (SQLException exc) { - logger.error(exc.getMessage()); - } - } - - public User findOne(String email) { - User user = null; - - try (Connection con = ConnectionUtil.getConnection()) { - String query = "SELECT * FROM users WHERE email=?"; - PreparedStatement pstmt = con.prepareStatement(query); - pstmt.setString(1, email); - - ResultSet rs = pstmt.executeQuery(); - while (rs.next()) { - user = new User(); - user.setEmail(rs.getString("email")); - user.setName(rs.getString("name")); - } - - } catch (SQLException exc) { - logger.error(exc.getMessage()); - } - - return user; - } - - public List findAll() { - List users = new ArrayList<>(); - - try (Connection con = ConnectionUtil.getConnection()) { - String query = "SELECT * FROM users"; - PreparedStatement pstmt = con.prepareStatement(query); - - ResultSet rs = pstmt.executeQuery(); - while (rs.next()) { - User user = new User(); - user.setEmail(rs.getString("email")); - user.setName(rs.getString("name")); - users.add(user); - } - } catch (SQLException exc) { - logger.error(exc.getMessage()); - } - - return users; - } - - public void deleteAll() { - try (Connection con = ConnectionUtil.getConnection()) { - - String deleteQuery = "DELETE FROM users"; - PreparedStatement pstmt = con.prepareStatement(deleteQuery); - - pstmt.executeUpdate(); - } catch (SQLException exc) { - logger.error(exc.getMessage()); - } - } - -} diff --git a/guest/junit5-example/src/main/java/com/stackify/models/User.java b/guest/junit5-example/src/main/java/com/stackify/models/User.java deleted file mode 100644 index d6951102a7..0000000000 --- a/guest/junit5-example/src/main/java/com/stackify/models/User.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.stackify.models; - -public class User { - private String email; - private String name; - - public User() { - } - - public User(String email, String name) { - super(); - this.email = email; - this.name = name; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((email == null) ? 0 : email.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - User other = (User) obj; - if (email == null) { - if (other.email != null) - return false; - } else if (!email.equals(other.email)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; - } - -} diff --git a/guest/junit5-example/src/main/java/com/stackify/test/conditions/DisabledOnEnvironment.java b/guest/junit5-example/src/main/java/com/stackify/test/conditions/DisabledOnEnvironment.java deleted file mode 100644 index 2c1fa80f2e..0000000000 --- a/guest/junit5-example/src/main/java/com/stackify/test/conditions/DisabledOnEnvironment.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.stackify.test.conditions; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.junit.jupiter.api.extension.ExtendWith; - -@Target({ ElementType.METHOD }) -@Retention(RetentionPolicy.RUNTIME) -@ExtendWith(DisabledOnEnvironmentCondition.class) -public @interface DisabledOnEnvironment { - String[] value(); -} \ No newline at end of file diff --git a/guest/junit5-example/src/main/java/com/stackify/test/conditions/DisabledOnEnvironmentCondition.java b/guest/junit5-example/src/main/java/com/stackify/test/conditions/DisabledOnEnvironmentCondition.java deleted file mode 100644 index adb9d9c09e..0000000000 --- a/guest/junit5-example/src/main/java/com/stackify/test/conditions/DisabledOnEnvironmentCondition.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.stackify.test.conditions; - -import java.io.IOException; -import java.util.Arrays; -import java.util.Optional; -import java.util.Properties; - -import org.junit.jupiter.api.extension.ConditionEvaluationResult; -import org.junit.jupiter.api.extension.TestExecutionCondition; -import org.junit.jupiter.api.extension.TestExtensionContext; -import org.junit.platform.commons.support.AnnotationSupport; - -import com.stackify.utils.ConnectionUtil; - -public class DisabledOnEnvironmentCondition implements TestExecutionCondition { - - @Override - public ConditionEvaluationResult evaluate(TestExtensionContext context) { - Properties props = new Properties(); - String env = ""; - try { - props.load(ConnectionUtil.class.getResourceAsStream("/application.properties")); - env = props.getProperty("env"); - } catch (IOException e) { - e.printStackTrace(); - } - Optional disabled = AnnotationSupport.findAnnotation(context.getElement().get(), DisabledOnEnvironment.class); - if (disabled.isPresent()) { - String[] envs = disabled.get().value(); - if (Arrays.asList(envs).contains(env)) { - return ConditionEvaluationResult.disabled("Disabled on environment " + env); - } - } - - return ConditionEvaluationResult.enabled("Enabled on environment "+env); - } - -} diff --git a/guest/junit5-example/src/main/java/com/stackify/utils/ConnectionUtil.java b/guest/junit5-example/src/main/java/com/stackify/utils/ConnectionUtil.java deleted file mode 100644 index bcfe5058a7..0000000000 --- a/guest/junit5-example/src/main/java/com/stackify/utils/ConnectionUtil.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.stackify.utils; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import java.util.Properties; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -public class ConnectionUtil { - - private static Logger logger = LogManager.getLogger(ConnectionUtil.class); - - public static Connection getConnection() { - try { - Properties props = new Properties(); - props.load(ConnectionUtil.class.getResourceAsStream("jdbc.properties")); - Class.forName(props.getProperty("jdbc.driver")); - Connection con = DriverManager.getConnection(props.getProperty("jdbc.url"), props.getProperty("jdbc.user"), props.getProperty("jdbc.password")); - return con; - } - - catch (FileNotFoundException exc) { - logger.error(exc.getMessage()); - } catch (IOException exc) { - logger.error(exc.getMessage()); - } catch (ClassNotFoundException exc) { - logger.error(exc.getMessage()); - } catch (SQLException exc) { - logger.error(exc.getMessage()); - } - return null; - } - -} diff --git a/guest/junit5-example/src/main/resources/application.properties b/guest/junit5-example/src/main/resources/application.properties deleted file mode 100644 index 601f964ff3..0000000000 --- a/guest/junit5-example/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -env=dev \ No newline at end of file diff --git a/guest/junit5-example/src/main/resources/com/stackify/utils/jdbc.properties b/guest/junit5-example/src/main/resources/com/stackify/utils/jdbc.properties deleted file mode 100644 index 2d9a39b157..0000000000 --- a/guest/junit5-example/src/main/resources/com/stackify/utils/jdbc.properties +++ /dev/null @@ -1,4 +0,0 @@ -jdbc.driver=org.h2.Driver -jdbc.url=jdbc:h2:mem:myDb;DB_CLOSE_DELAY=-1 -jdbc.user= -jdbc.password= \ No newline at end of file diff --git a/guest/junit5-example/src/main/resources/log4j2.xml b/guest/junit5-example/src/main/resources/log4j2.xml deleted file mode 100644 index 602b5ab490..0000000000 --- a/guest/junit5-example/src/main/resources/log4j2.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/guest/junit5-example/src/test/java/com/stackify/test/DatabaseConnectionTest.java b/guest/junit5-example/src/test/java/com/stackify/test/DatabaseConnectionTest.java deleted file mode 100644 index d8f13b5715..0000000000 --- a/guest/junit5-example/src/test/java/com/stackify/test/DatabaseConnectionTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.stackify.test; - -import java.sql.Connection; - -import org.junit.jupiter.api.Test; - -import com.stackify.utils.ConnectionUtil; - -import static org.junit.jupiter.api.Assertions.*; - -public interface DatabaseConnectionTest { - - @Test - default void testDatabaseConnection() { - Connection con = ConnectionUtil.getConnection(); - assertNotNull(con); - } - -} diff --git a/guest/junit5-example/src/test/java/com/stackify/test/DynamicTests.java b/guest/junit5-example/src/test/java/com/stackify/test/DynamicTests.java deleted file mode 100644 index 39b3b5aac5..0000000000 --- a/guest/junit5-example/src/test/java/com/stackify/test/DynamicTests.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.stackify.test; - -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.*; -import org.junit.jupiter.api.DynamicTest; -import org.junit.jupiter.api.TestFactory; -import org.junit.jupiter.api.function.ThrowingConsumer; - -import com.stackify.daos.UserDAO; -import com.stackify.models.User; - -public class DynamicTests { - - @TestFactory - public Collection dynamicTestCollection() { - return Arrays.asList(DynamicTest.dynamicTest("Dynamic Test", () -> assertTrue(1 == 1))); - } - - @TestFactory - public Stream dynamicUserTestCollection() { - List inputList = Arrays.asList(new User("john@yahoo.com", "John"), new User("ana@yahoo.com", "Ana")); - - Function displayNameGenerator = (input) -> "Saving user: " + input; - - UserDAO userDAO = new UserDAO(); - ThrowingConsumer testExecutor = (input) -> { - userDAO.add(input); - assertNotNull(userDAO.findOne(input.getEmail())); - }; - - return DynamicTest.stream(inputList.iterator(), displayNameGenerator, testExecutor); - } -} diff --git a/guest/junit5-example/src/test/java/com/stackify/test/IncrementTest.java b/guest/junit5-example/src/test/java/com/stackify/test/IncrementTest.java deleted file mode 100644 index a23a5bf20b..0000000000 --- a/guest/junit5-example/src/test/java/com/stackify/test/IncrementTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.stackify.test; - -import static org.junit.jupiter.api.Assertions.*; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.RepeatedTest; -import org.junit.jupiter.api.RepetitionInfo; - -public class IncrementTest { - - private static Logger logger = LogManager.getLogger(IncrementTest.class); - - @BeforeEach - public void increment() { - logger.info("Before Each Test"); - } - - @RepeatedTest(value = 3, name = RepeatedTest.SHORT_DISPLAY_NAME) - public void test(RepetitionInfo info) { - assertTrue(1 == 1); - logger.info("Repetition #" + info.getCurrentRepetition()); - } -} diff --git a/guest/junit5-example/src/test/java/com/stackify/test/TaggedTest.java b/guest/junit5-example/src/test/java/com/stackify/test/TaggedTest.java deleted file mode 100644 index db3c38ceac..0000000000 --- a/guest/junit5-example/src/test/java/com/stackify/test/TaggedTest.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.stackify.test; - -import static org.junit.jupiter.api.Assertions.*; -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; - -@Tag("math") -public class TaggedTest { - - @Test - @Tag("arithmetic") - public void testEquals() { - assertTrue(1 == 1); - } - -} diff --git a/guest/junit5-example/src/test/java/com/stackify/test/UsersTest.java b/guest/junit5-example/src/test/java/com/stackify/test/UsersTest.java deleted file mode 100644 index 88958a8232..0000000000 --- a/guest/junit5-example/src/test/java/com/stackify/test/UsersTest.java +++ /dev/null @@ -1,155 +0,0 @@ -package com.stackify.test; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; - -import static org.junit.jupiter.api.Assertions.*; -import static org.junit.jupiter.api.Assumptions.*; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import com.stackify.daos.UserDAO; -import com.stackify.models.User; - -import com.stackify.test.conditions.DisabledOnEnvironment; - -public class UsersTest implements DatabaseConnectionTest { - - private static UserDAO userDAO; - - private static Logger logger = LogManager.getLogger(UsersTest.class); - - @BeforeAll - public static void addData() { - userDAO = new UserDAO(); - userDAO.createTable(); - - User user1 = new User("john@gmail.com", "John"); - User user2 = new User("ana@gmail.com", "Ana"); - userDAO.add(user1); - userDAO.add(user2); - } - - @Test - @DisplayName("Test Get Users") - public void testGetUsersNumber() { - assertEquals(2, userDAO.findAll().size()); - - } - - @Test - @DisplayName("Test Get Users") - public void testGetUsersNumberWithInfo(TestInfo testInfo) { - assertEquals(2, userDAO.findAll().size()); - assertEquals("Test Get Users", testInfo.getDisplayName()); - assertEquals(UsersTest.class, testInfo.getTestClass().get()); - logger.info("Running test method:" + testInfo.getTestMethod().get().getName()); - } - - @Test - public void testGetUser() { - User user = userDAO.findOne("john@gmail.com"); - assertEquals("John", user.getName(), "User name:" + user.getName() + " incorrect"); - } - - @Test - public void testClassicAssertions() { - User user1 = userDAO.findOne("john@gmail.com"); - User user2 = userDAO.findOne("john@yahoo.com"); - - assertNotNull(user1); - assertNull(user2); - - user2 = new User("john@yahoo.com", "John"); - assertEquals(user1.getName(), user2.getName(), "Names are not equal"); - assertFalse(user1.getEmail().equals(user2.getEmail()), "Emails are equal"); - assertNotSame(user1, user2); - } - - @Test - @Disabled - public void testGroupedAssertions() { - User user = userDAO.findOne("john@gmail.com"); - assertAll("user", () -> assertEquals("Johnson", user.getName()), () -> assertEquals("johnson@gmail.com", user.getEmail())); - } - - @Test - public void testIterableEquals() { - User user1 = new User("john@gmail.com", "John"); - User user2 = new User("ana@gmail.com", "Ana"); - - List users = new ArrayList<>(); - users.add(user1); - users.add(user2); - - assertIterableEquals(users, userDAO.findAll()); - } - - @Test - public void testLinesMatch() { - List expectedLines = Collections.singletonList("(.*)@(.*)"); - List emails = Arrays.asList("john@gmail.com"); - assertLinesMatch(expectedLines, emails); - } - - @Test - void testThrows() { - User user = null; - Exception exception = assertThrows(NullPointerException.class, () -> user.getName()); - logger.info(exception.getMessage()); - } - - @Test - @DisabledOnEnvironment({ "dev", "prod") - void testFail() { - fail("this test fails"); - } - - @Test - void testAssumptions() { - List users = userDAO.findAll(); - assumeFalse(users == null); - assumeTrue(users.size() > 0); - - User user1 = new User("john@gmail.com", "John"); - - assumingThat(users.contains(user1), () -> assertTrue(users.size() > 1)); - } - - @ParameterizedTest - @ValueSource(strings = { "john@gmail.com", "ana@gmail.com" }) - public void testParameterized(String email) { - assertNotNull(userDAO.findOne(email)); - } - - @AfterAll - public static void removeData() { - userDAO.deleteAll(); - } - - @Nested - class DeleteUsersTest { - @Test - public void addUser() { - User user = new User("bob@gmail.com", "Bob"); - userDAO.add(user); - assertNotNull(userDAO.findOne("bob@gmail.com")); - - userDAO.delete("bob@gmail.com"); - assertNull(userDAO.findOne("bob@gmail.com")); - } - } - -} diff --git a/guest/log4j2-example/.gitignore b/guest/log4j2-example/.gitignore deleted file mode 100644 index 60be5b80aa..0000000000 --- a/guest/log4j2-example/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/target/ -.settings/ -.classpath -.project diff --git a/guest/log4j2-example/java.log b/guest/log4j2-example/java.log deleted file mode 100644 index 21e964d9ce..0000000000 --- a/guest/log4j2-example/java.log +++ /dev/null @@ -1,3 +0,0 @@ -14:00:35.258 INFO Programmatic Logger Message -14:03:51.178 INFO Programmatic Logger Message -14:04:11.753 INFO Programmatic Logger Message diff --git a/guest/log4j2-example/logs/app.log b/guest/log4j2-example/logs/app.log deleted file mode 100644 index 022f6fcea9..0000000000 --- a/guest/log4j2-example/logs/app.log +++ /dev/null @@ -1,25 +0,0 @@ -[ -{ - "timeMillis" : 1496315051753, - "thread" : "main", - "level" : "INFO", - "loggerName" : "RollingFileLogger", - "message" : "Json Message 1", - "endOfBatch" : false, - "loggerFqcn" : "org.apache.logging.log4j.spi.AbstractLogger", - "threadId" : 1, - "threadPriority" : 5 -} -, { - "timeMillis" : 1496315051862, - "thread" : "main", - "level" : "INFO", - "loggerName" : "RollingFileLogger", - "message" : "Json Messag 2", - "endOfBatch" : false, - "loggerFqcn" : "org.apache.logging.log4j.spi.AbstractLogger", - "threadId" : 1, - "threadPriority" : 5 -} - -] diff --git a/guest/log4j2-example/pom.xml b/guest/log4j2-example/pom.xml deleted file mode 100644 index a3284dbfe3..0000000000 --- a/guest/log4j2-example/pom.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - 4.0.0 - log4j2-example - log4j2-example - 0.0.1-SNAPSHOT - log4j2-example - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - ../../ - - - - - - org.apache.logging.log4j - log4j-core - ${log4j-core.version} - - - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - - - - - src/main/resources/ - - **/*.java - - - - - - - 2.8.2 - - - \ No newline at end of file diff --git a/guest/log4j2-example/src/main/java/com/stackify/models/User.java b/guest/log4j2-example/src/main/java/com/stackify/models/User.java deleted file mode 100644 index 1a53651292..0000000000 --- a/guest/log4j2-example/src/main/java/com/stackify/models/User.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.stackify.models; - -import java.time.LocalDate; - -public class User { - private String name; - private String email; - private LocalDate dateOfBirth; - - public User() { - } - - public User(String name, String email) { - super(); - this.name = name; - this.email = email; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public LocalDate getDateOfBirth() { - return dateOfBirth; - } - - public void setDateOfBirth(LocalDate dateOfBirth) { - this.dateOfBirth = dateOfBirth; - } - -} diff --git a/guest/log4j2-example/src/main/java/com/stackify/services/MyService.java b/guest/log4j2-example/src/main/java/com/stackify/services/MyService.java deleted file mode 100644 index 4b1dc0bf34..0000000000 --- a/guest/log4j2-example/src/main/java/com/stackify/services/MyService.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.stackify.services; - -import java.time.LocalDate; -import java.time.Period; - -import com.stackify.models.User; - -public class MyService { - - public int calculateUserAge(User user) { - return Period.between(user.getDateOfBirth(), LocalDate.now()).getYears(); - } - -} diff --git a/guest/log4j2-example/src/main/resources/log4j2.xml b/guest/log4j2-example/src/main/resources/log4j2.xml deleted file mode 100644 index 06f2ba5245..0000000000 --- a/guest/log4j2-example/src/main/resources/log4j2.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/guest/log4j2-example/src/test/java/com/stackify/services/MyServiceUnitTest.java b/guest/log4j2-example/src/test/java/com/stackify/services/MyServiceUnitTest.java deleted file mode 100644 index bd08225be4..0000000000 --- a/guest/log4j2-example/src/test/java/com/stackify/services/MyServiceUnitTest.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.stackify.services; - -import java.time.LocalDate; -import java.time.Month; - -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.core.Appender; -import org.apache.logging.log4j.core.LoggerContext; -import org.apache.logging.log4j.core.appender.FileAppender; -import org.apache.logging.log4j.core.config.AppenderRef; -import org.apache.logging.log4j.core.config.Configuration; -import org.apache.logging.log4j.core.config.LoggerConfig; -import org.apache.logging.log4j.core.layout.PatternLayout; -import org.junit.Test; - -import com.stackify.models.User; -import com.stackify.services.MyService; - -public class MyServiceUnitTest { - - private static final Logger logger = LogManager.getLogger(MyServiceUnitTest.class); - - @Test - public void testService() { - MyService myService = new MyService(); - User user = new User("John", "john@yahoo.com"); - user.setDateOfBirth(LocalDate.of(1980, Month.APRIL, 20)); - logger.info("Age of user {} is {}", () -> user.getName(), () -> myService.calculateUserAge(user)); - } - - @Test - public void testColoredLogger() { - logger.fatal("Fatal level message"); - logger.error("Error level message"); - logger.warn("Warn level message"); - logger.info("Info level message"); - logger.debug("Debug level message"); - } - - @Test - public void testRollingFileAppender() { - Logger rfLogger = LogManager.getLogger("RollingFileLogger"); - rfLogger.info("Json Message 1"); - rfLogger.info("Json Message 2"); - } - - @Test - public void testProgrammaticConfig() { - LoggerContext ctx = (LoggerContext) LogManager.getContext(false); - Configuration config = ctx.getConfiguration(); - - PatternLayout layout = PatternLayout.newBuilder().withConfiguration(config).withPattern("%d{HH:mm:ss.SSS} %level %msg%n").build(); - - Appender appender = FileAppender.newBuilder().setConfiguration(config).withName("programmaticFileAppender").withLayout(layout).withFileName("java.log").build(); - appender.start(); - config.addAppender(appender); - AppenderRef ref = AppenderRef.createAppenderRef("programmaticFileAppender", null, null); - AppenderRef[] refs = new AppenderRef[] { ref }; - - LoggerConfig loggerConfig = LoggerConfig.createLogger(false, Level.INFO, "programmaticLogger", "true", refs, null, config, null); - - loggerConfig.addAppender(appender, null, null); - config.addLogger("programmaticLogger", loggerConfig); - ctx.updateLoggers(); - - Logger pLogger = LogManager.getLogger("programmaticLogger"); - pLogger.info("Programmatic Logger Message"); - } - - @Test - public void testCustomLevel() { - Level myLevel = Level.forName("NEW_LEVEL", 350); - logger.log(myLevel, "Custom Level Message"); - - logger.log(Level.getLevel("NEW_XML_LEVEL"), "Custom XML Level Message"); - - } - -} diff --git a/guest/logback-example/pom.xml b/guest/logback-example/pom.xml deleted file mode 100644 index e7e83c743f..0000000000 --- a/guest/logback-example/pom.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - 4.0.0 - com.stackify - logback-example - 0.0.1-SNAPSHOT - logback-example - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - ../../ - - - - - org.codehaus.janino - janino - ${janino.version} - - - - - 3.0.7 - - \ No newline at end of file diff --git a/guest/logback-example/src/main/java/com/stackify/logging/IgnoreLoggerFilter.java b/guest/logback-example/src/main/java/com/stackify/logging/IgnoreLoggerFilter.java deleted file mode 100644 index c0eb414588..0000000000 --- a/guest/logback-example/src/main/java/com/stackify/logging/IgnoreLoggerFilter.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.stackify.logging; - -import org.slf4j.Marker; - -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.Logger; -import ch.qos.logback.classic.turbo.TurboFilter; -import ch.qos.logback.core.spi.FilterReply; - -public class IgnoreLoggerFilter extends TurboFilter { - - private String loggerName; - - @Override - public FilterReply decide(Marker marker, Logger logger, Level level, String format, Object[] params, Throwable t) { - if (loggerName == null) { - return FilterReply.NEUTRAL; - } else if (loggerName.equals(logger.getName())) { - return FilterReply.DENY; - } else - return FilterReply.NEUTRAL; - } - - public void setLoggerName(String loggerName) { - this.loggerName = loggerName; - } - -} diff --git a/guest/logback-example/src/main/java/com/stackify/models/Employee.java b/guest/logback-example/src/main/java/com/stackify/models/Employee.java deleted file mode 100644 index 1d040b372b..0000000000 --- a/guest/logback-example/src/main/java/com/stackify/models/Employee.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.stackify.models; - -public class Employee { - - private String email; - private String name; - - private double salary; - - public Employee() { - } - - public Employee(String email, String name, double salary) { - this.email = email; - this.name = name; - this.salary = salary; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public double getSalary() { - return salary; - } - - public void setSalary(double salary) { - this.salary = salary; - } - -} diff --git a/guest/logback-example/src/main/java/com/stackify/services/EmployeeService.java b/guest/logback-example/src/main/java/com/stackify/services/EmployeeService.java deleted file mode 100644 index 1795101f40..0000000000 --- a/guest/logback-example/src/main/java/com/stackify/services/EmployeeService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.stackify.services; - -import com.stackify.models.Employee; - -public class EmployeeService { - - public double calculateBonus(Employee user) { - return 0.1 * user.getSalary(); - } - -} diff --git a/guest/logback-example/src/main/resources/application.properties b/guest/logback-example/src/main/resources/application.properties deleted file mode 100644 index 601f964ff3..0000000000 --- a/guest/logback-example/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -env=dev \ No newline at end of file diff --git a/guest/logback-example/src/main/resources/logback.xml b/guest/logback-example/src/main/resources/logback.xml deleted file mode 100644 index d8ec24c7c3..0000000000 --- a/guest/logback-example/src/main/resources/logback.xml +++ /dev/null @@ -1,151 +0,0 @@ - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n - - System.out - - - - - - - - - log-%d{yyyy-MM-dd}.log - 30 - 3GB - - - 3MB - - - %d [%thread] %-5level %logger{50} - %msg%n - - - - - - userRole - ANONYMOUS - - - - ${userRole}.log - - %d [%thread] %level %mdc %logger{50} - %msg%n - - - - - - - - - %d %green([%thread]) %highlight(%level) %logger{50} - %msg%n - - - - - - - %thread%level%logger%msg - - - log.html - - - - - - ERROR - ACCEPT - DENY - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n - - System.err - - - - - WARN - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n - - - - - - - return (level > DEBUG && message.toLowerCase().contains("employee")); - - DENY - NEUTRAL - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n - - - - - - 2 - - - - ignoredColorLogger - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/guest/logback-example/src/test/java/com/stackify/services/EmployeeServiceUnitTest.java b/guest/logback-example/src/test/java/com/stackify/services/EmployeeServiceUnitTest.java deleted file mode 100644 index a3051f7087..0000000000 --- a/guest/logback-example/src/test/java/com/stackify/services/EmployeeServiceUnitTest.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.stackify.services; - -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; - -import com.stackify.models.Employee; - -import ch.qos.logback.classic.Level; - -public class EmployeeServiceUnitTest { - private static final Logger logger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); - - private EmployeeService employeeService = new EmployeeService(); - - @Test - public void testAppenders() { - Logger rollingFileLogger = LoggerFactory.getLogger("rollingFileLogger"); - rollingFileLogger.info("Testing rolling file logger"); - - MDC.put("userRole", "ADMIN"); - Logger siftingLogger = LoggerFactory.getLogger("roleSiftingLogger"); - siftingLogger.info("Admin Action"); - } - - @Test - public void testLayouts() { - Logger htmlLogger = LoggerFactory.getLogger("htmlLogger"); - htmlLogger.error("Employee Information Update Failed"); - htmlLogger.info("New Account Created"); - - Logger colorLogger = LoggerFactory.getLogger("colorLogger"); - colorLogger.error("Employee Information Update Failed"); - colorLogger.info("New Account Created"); - } - - @Test - public void testLogLevel() { - ch.qos.logback.classic.Logger rollingFileLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger("rollingFileLogger"); - rollingFileLogger.setLevel(Level.DEBUG); - rollingFileLogger.debug("Testing Log Level"); - } - - @Test - public void testParameter() { - Employee employee = new Employee("john@gmail.com", "John", 2000); - if (logger.isDebugEnabled()) { - logger.debug("The bonus for employee: " + employee.getName() + " is " + employeeService.calculateBonus(employee)); - } - logger.debug("The bonus for employee {} is {}", employee.getName(), employeeService.calculateBonus(employee)); - } - - @Test - public void testFilters() { - Logger levelFilterLogger = LoggerFactory.getLogger("levelFilterLogger"); - levelFilterLogger.error("Employee Information Update Failed"); - Logger thresholdFilterLogger = LoggerFactory.getLogger("thresholdFilterLogger"); - thresholdFilterLogger.trace("Employee record inserted"); - Logger evaluatorFilterLogger = LoggerFactory.getLogger("evaluatorFilterLogger"); - evaluatorFilterLogger.debug("Employee account deactivated"); - } - - @Test - public void testIgnoredLogger() { - Logger colorLogger = LoggerFactory.getLogger("ignoredColorLogger"); - colorLogger.info("Ignored Log Message"); - } - - @Test - public void testConditionalConfiguration() { - logger.trace("Employee record updated"); - } -} diff --git a/guest/remote-debugging/README.md b/guest/remote-debugging/README.md deleted file mode 100644 index cc63e7fd59..0000000000 --- a/guest/remote-debugging/README.md +++ /dev/null @@ -1,16 +0,0 @@ -## Building - -To build the module, use Maven's `package` goal: - -``` -mvn clean package -``` - -The `war` file will be available at `target/remote-debugging.war` - -## Running - -The `war` application is deployed to Apache Tomcat 8 or any other Java Web or Application server. -To deploy it to the Apache Tomcat 8 server, drop it in the `tomcat/webapps` directory. - -The service then will be accessible at http://localhost:8080/remote-debugging/hello?name=John \ No newline at end of file diff --git a/guest/remote-debugging/pom.xml b/guest/remote-debugging/pom.xml deleted file mode 100644 index 4541160e37..0000000000 --- a/guest/remote-debugging/pom.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - 4.0.0 - com.stackify - remote-debugging - 0.0.1-SNAPSHOT - remote-debugging - war - - - org.springframework.boot - spring-boot-starter-parent - 1.5.8.RELEASE - - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-tomcat - - - - - remote-debugging - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - UTF-8 - UTF-8 - - - diff --git a/guest/remote-debugging/src/main/java/com/stackify/debug/JavaRemoteDebuggingApplication.java b/guest/remote-debugging/src/main/java/com/stackify/debug/JavaRemoteDebuggingApplication.java deleted file mode 100644 index 9d1a632638..0000000000 --- a/guest/remote-debugging/src/main/java/com/stackify/debug/JavaRemoteDebuggingApplication.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.stackify.debug; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class JavaRemoteDebuggingApplication { - - public static void main(String[] args) { - SpringApplication.run(JavaRemoteDebuggingApplication.class, args); - } -} diff --git a/guest/remote-debugging/src/main/java/com/stackify/debug/config/WebInitializer.java b/guest/remote-debugging/src/main/java/com/stackify/debug/config/WebInitializer.java deleted file mode 100644 index b69e2b6c77..0000000000 --- a/guest/remote-debugging/src/main/java/com/stackify/debug/config/WebInitializer.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.stackify.debug.config; - -import com.stackify.debug.JavaRemoteDebuggingApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.web.support.SpringBootServletInitializer; - -public class WebInitializer extends SpringBootServletInitializer { - @Override - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { - return application.sources(JavaRemoteDebuggingApplication.class); - } -} diff --git a/guest/remote-debugging/src/main/java/com/stackify/debug/rest/HelloController.java b/guest/remote-debugging/src/main/java/com/stackify/debug/rest/HelloController.java deleted file mode 100644 index 8c614a36ec..0000000000 --- a/guest/remote-debugging/src/main/java/com/stackify/debug/rest/HelloController.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.stackify.debug.rest; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@RestController("/hello") -public class HelloController { - - @GetMapping - public String hello(@RequestParam("name") String name) { - String message = "Hello, " + name; - return message; - } - -} diff --git a/guest/remote-debugging/src/main/resources/logback.xml b/guest/remote-debugging/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/guest/remote-debugging/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/guest/slf4j/guide/pom.xml b/guest/slf4j/guide/pom.xml deleted file mode 100644 index 8b479a4ba7..0000000000 --- a/guest/slf4j/guide/pom.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - 4.0.0 - com.stackify.slf4j.guide - slf4j-parent-module - 1.0.0-SNAPSHOT - slf4j-parent-module - pom - - - org.springframework.boot - spring-boot-starter-parent - 2.0.6.RELEASE - - - - slf4j-logback - slf4j-log4j2 - slf4j-log4j - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-test - test - - - org.powermock - powermock-module-junit4 - ${powermock.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.version} - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - UTF-8 - UTF-8 - 1.8 - 2.0.0-beta.5 - - diff --git a/guest/slf4j/guide/slf4j-log4j/.gitignore b/guest/slf4j/guide/slf4j-log4j/.gitignore deleted file mode 100644 index 82eca336e3..0000000000 --- a/guest/slf4j/guide/slf4j-log4j/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -/target/ -!.mvn/wrapper/maven-wrapper.jar - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -/nbproject/private/ -/build/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ \ No newline at end of file diff --git a/guest/slf4j/guide/slf4j-log4j/pom.xml b/guest/slf4j/guide/slf4j-log4j/pom.xml deleted file mode 100644 index 70b93d8ab4..0000000000 --- a/guest/slf4j/guide/slf4j-log4j/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - 4.0.0 - slf4j-log4j - 0.0.1-SNAPSHOT - slf4j-log4j - jar - - - com.stackify.slf4j.guide - slf4j-parent-module - 1.0.0-SNAPSHOT - .. - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-logging - - - - - org.slf4j - slf4j-log4j12 - - - org.springframework.boot - spring-boot-starter-test - test - - - - - 1.7.25 - - diff --git a/guest/slf4j/guide/slf4j-log4j/src/main/java/com/stackify/slf4j/guide/Application.java b/guest/slf4j/guide/slf4j-log4j/src/main/java/com/stackify/slf4j/guide/Application.java deleted file mode 100644 index 01ccf519b3..0000000000 --- a/guest/slf4j/guide/slf4j-log4j/src/main/java/com/stackify/slf4j/guide/Application.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.stackify.slf4j.guide; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } -} diff --git a/guest/slf4j/guide/slf4j-log4j/src/main/java/com/stackify/slf4j/guide/controllers/SimpleController.java b/guest/slf4j/guide/slf4j-log4j/src/main/java/com/stackify/slf4j/guide/controllers/SimpleController.java deleted file mode 100644 index 14f4439545..0000000000 --- a/guest/slf4j/guide/slf4j-log4j/src/main/java/com/stackify/slf4j/guide/controllers/SimpleController.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.stackify.slf4j.guide.controllers; - -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class SimpleController { - - Logger logger = LoggerFactory.getLogger(SimpleController.class); - - @GetMapping("/slf4j-guide-request") - public String processList(List list) { - logger.info("Client requested process the following list: {}", list); - try { - logger.debug("Starting process"); - // ...processing list here... - Thread.sleep(500); - } catch (RuntimeException | InterruptedException e) { - logger.error("There was an issue processing the list.", e); - } finally { - logger.info("Finished processing"); - } - return "done"; - } - - @GetMapping("/slf4j-guide-mdc-request") - public String clientMDCRequest(@RequestHeader String clientId) throws InterruptedException { - MDC.put("clientId", clientId); - logger.info("Client {} has made a request", clientId); - logger.info("Starting request"); - Thread.sleep(500); - logger.info("Finished request"); - MDC.clear(); - return "finished"; - } -} diff --git a/guest/slf4j/guide/slf4j-log4j/src/main/resources/application.properties b/guest/slf4j/guide/slf4j-log4j/src/main/resources/application.properties deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/guest/slf4j/guide/slf4j-log4j/src/main/resources/log4j.xml b/guest/slf4j/guide/slf4j-log4j/src/main/resources/log4j.xml deleted file mode 100644 index ea432bff77..0000000000 --- a/guest/slf4j/guide/slf4j-log4j/src/main/resources/log4j.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/guest/slf4j/guide/slf4j-log4j/src/test/java/com/stackify/slf4j/guide/controllers/SimpleControllerIntegrationTest.java b/guest/slf4j/guide/slf4j-log4j/src/test/java/com/stackify/slf4j/guide/controllers/SimpleControllerIntegrationTest.java deleted file mode 100644 index 991a1e2686..0000000000 --- a/guest/slf4j/guide/slf4j-log4j/src/test/java/com/stackify/slf4j/guide/controllers/SimpleControllerIntegrationTest.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.stackify.slf4j.guide.controllers; - -import static org.powermock.api.mockito.PowerMockito.doNothing; -import static org.powermock.api.mockito.PowerMockito.spy; - -import java.util.Collections; - -import org.apache.log4j.Level; -import org.apache.log4j.spi.LoggingEvent; -import org.assertj.core.api.Condition; -import org.assertj.core.api.SoftAssertions; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.slf4j.MDC; - -import com.stackify.slf4j.guide.utils.ListAppender; - -@RunWith(PowerMockRunner.class) -@PrepareForTest(MDC.class) -public class SimpleControllerIntegrationTest { - - private SimpleController controller = new SimpleController(); - - @Before - public void clearLogList() { - ListAppender.clearEventList(); - } - - @Test - public void whenSimpleRequestMade_thenAllRegularMessagesLogged() { - String output = controller.processList(Collections.emptyList()); - - SoftAssertions errorCollector = new SoftAssertions(); - errorCollector.assertThat(ListAppender.getEvents()) - .haveAtLeastOne(eventContains("Client requested process the following list: []", Level.INFO)) - .haveAtLeastOne(eventContains("Starting process", Level.DEBUG)) - .haveAtLeastOne(eventContains("Finished processing", Level.INFO)) - .haveExactly(0, eventOfLevel(Level.ERROR)); - errorCollector.assertThat(output) - .isEqualTo("done"); - errorCollector.assertAll(); - } - - @Test - public void givenClientId_whenMDCRequestMade_thenMessagesWithClientIdLogged() throws Exception { - // We avoid cleaning the context so tht we can check it afterwards - spy(MDC.class); - doNothing().when(MDC.class); - MDC.clear(); - String clientId = "id-1234"; - - String output = controller.clientMDCRequest(clientId); - - SoftAssertions errorCollector = new SoftAssertions(); - errorCollector.assertThat(ListAppender.getEvents()) - .allMatch(entry -> { - return clientId.equals(entry.getMDC("clientId")); - }) - .haveAtLeastOne(eventContains("Client id-1234 has made a request", Level.INFO)) - .haveAtLeastOne(eventContains("Starting request", Level.INFO)) - .haveAtLeastOne(eventContains("Finished request", Level.INFO)); - errorCollector.assertThat(output) - .isEqualTo("finished"); - errorCollector.assertAll(); - - } - - private Condition eventOfLevel(Level level) { - return eventContains(null, level); - } - - private Condition eventContains(String substring, Level level) { - - return new Condition(entry -> (substring == null || (entry.getRenderedMessage() != null && entry.getRenderedMessage() - .contains(substring))) && (level == null || level.equals(entry.getLevel())), String.format("entry with message '%s', level %s", substring, level)); - } -} diff --git a/guest/slf4j/guide/slf4j-log4j/src/test/java/com/stackify/slf4j/guide/utils/ListAppender.java b/guest/slf4j/guide/slf4j-log4j/src/test/java/com/stackify/slf4j/guide/utils/ListAppender.java deleted file mode 100644 index 4ce9e73d6d..0000000000 --- a/guest/slf4j/guide/slf4j-log4j/src/test/java/com/stackify/slf4j/guide/utils/ListAppender.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.stackify.slf4j.guide.utils; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.AppenderSkeleton; -import org.apache.log4j.spi.LoggingEvent; - -public class ListAppender extends AppenderSkeleton { - public static List events = new ArrayList(); - - @Override - public void close() { - } - - @Override - public boolean requiresLayout() { - return false; - } - - @Override - protected void append(LoggingEvent event) { - events.add(event); - } - - public static List getEvents() { - return events; - } - - public static void clearEventList() { - events.clear(); - } -} diff --git a/guest/slf4j/guide/slf4j-log4j/src/test/resources/log4j.xml b/guest/slf4j/guide/slf4j-log4j/src/test/resources/log4j.xml deleted file mode 100644 index 10443e5eab..0000000000 --- a/guest/slf4j/guide/slf4j-log4j/src/test/resources/log4j.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/guest/slf4j/guide/slf4j-log4j2/.gitignore b/guest/slf4j/guide/slf4j-log4j2/.gitignore deleted file mode 100644 index 82eca336e3..0000000000 --- a/guest/slf4j/guide/slf4j-log4j2/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -/target/ -!.mvn/wrapper/maven-wrapper.jar - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -/nbproject/private/ -/build/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ \ No newline at end of file diff --git a/guest/slf4j/guide/slf4j-log4j2/pom.xml b/guest/slf4j/guide/slf4j-log4j2/pom.xml deleted file mode 100644 index 93a8d9e974..0000000000 --- a/guest/slf4j/guide/slf4j-log4j2/pom.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - 4.0.0 - slf4j-log4j2 - 0.0.1-SNAPSHOT - slf4j-log4j2 - jar - - - com.stackify.slf4j.guide - slf4j-parent-module - 1.0.0-SNAPSHOT - .. - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-logging - - - - - org.springframework.boot - spring-boot-starter-log4j2 - - - org.springframework.boot - spring-boot-starter-test - test - - - org.apache.logging.log4j - log4j-core - ${log4j.version} - test-jar - - - org.apache.logging.log4j - log4j-api - ${log4j.version} - test-jar - - - - - 2.11.0 - - diff --git a/guest/slf4j/guide/slf4j-log4j2/src/main/java/com/stackify/slf4j/guide/Application.java b/guest/slf4j/guide/slf4j-log4j2/src/main/java/com/stackify/slf4j/guide/Application.java deleted file mode 100644 index 01ccf519b3..0000000000 --- a/guest/slf4j/guide/slf4j-log4j2/src/main/java/com/stackify/slf4j/guide/Application.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.stackify.slf4j.guide; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } -} diff --git a/guest/slf4j/guide/slf4j-log4j2/src/main/java/com/stackify/slf4j/guide/controllers/SimpleController.java b/guest/slf4j/guide/slf4j-log4j2/src/main/java/com/stackify/slf4j/guide/controllers/SimpleController.java deleted file mode 100644 index 14f4439545..0000000000 --- a/guest/slf4j/guide/slf4j-log4j2/src/main/java/com/stackify/slf4j/guide/controllers/SimpleController.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.stackify.slf4j.guide.controllers; - -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class SimpleController { - - Logger logger = LoggerFactory.getLogger(SimpleController.class); - - @GetMapping("/slf4j-guide-request") - public String processList(List list) { - logger.info("Client requested process the following list: {}", list); - try { - logger.debug("Starting process"); - // ...processing list here... - Thread.sleep(500); - } catch (RuntimeException | InterruptedException e) { - logger.error("There was an issue processing the list.", e); - } finally { - logger.info("Finished processing"); - } - return "done"; - } - - @GetMapping("/slf4j-guide-mdc-request") - public String clientMDCRequest(@RequestHeader String clientId) throws InterruptedException { - MDC.put("clientId", clientId); - logger.info("Client {} has made a request", clientId); - logger.info("Starting request"); - Thread.sleep(500); - logger.info("Finished request"); - MDC.clear(); - return "finished"; - } -} diff --git a/guest/slf4j/guide/slf4j-log4j2/src/main/resources/application.properties b/guest/slf4j/guide/slf4j-log4j2/src/main/resources/application.properties deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/guest/slf4j/guide/slf4j-log4j2/src/main/resources/log4j2-spring.xml b/guest/slf4j/guide/slf4j-log4j2/src/main/resources/log4j2-spring.xml deleted file mode 100644 index 7d1494c7a6..0000000000 --- a/guest/slf4j/guide/slf4j-log4j2/src/main/resources/log4j2-spring.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - ???? - %5p - yyyy-MM-dd HH:mm:ss.SSS - %clr{%d{${LOG_DATEFORMAT_PATTERN}}}{faint} %clr{${LOG_LEVEL_PATTERN}} %clr{${sys:PID}}{magenta} - %clr{---}{faint} %clr{%X{clientId}}{red}%clr{@%15.15t}{faint} %clr{%-40.40c{1.}}{cyan} %clr{:}{faint} %m%n - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/guest/slf4j/guide/slf4j-log4j2/src/test/java/com/stackify/slf4j/guide/controllers/SimpleControllerIntegrationTest.java b/guest/slf4j/guide/slf4j-log4j2/src/test/java/com/stackify/slf4j/guide/controllers/SimpleControllerIntegrationTest.java deleted file mode 100644 index f41c857533..0000000000 --- a/guest/slf4j/guide/slf4j-log4j2/src/test/java/com/stackify/slf4j/guide/controllers/SimpleControllerIntegrationTest.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.stackify.slf4j.guide.controllers; - -import java.util.Collections; - -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.core.LogEvent; -import org.apache.logging.log4j.junit.LoggerContextRule; -import org.apache.logging.log4j.test.appender.ListAppender; -import org.assertj.core.api.Condition; -import org.assertj.core.api.SoftAssertions; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -public class SimpleControllerIntegrationTest { - - private static ListAppender appender; - private SimpleController controller = new SimpleController(); - - @ClassRule - public static LoggerContextRule init = new LoggerContextRule("log4j2-test.xml"); - - @BeforeClass - public static void setupLogging() { - appender = init.getListAppender("ListAppender"); - } - - @Before - public void clearAppender() { - appender.clear(); - } - - @Test - public void whenSimpleRequestMade_thenAllRegularMessagesLogged() { - String output = controller.processList(Collections.emptyList()); - - SoftAssertions errorCollector = new SoftAssertions(); - errorCollector.assertThat(appender.getEvents()) - .haveAtLeastOne(eventContains("Client requested process the following list: []", Level.INFO)) - .haveAtLeastOne(eventContains("Starting process", Level.DEBUG)) - .haveAtLeastOne(eventContains("Finished processing", Level.INFO)) - .haveExactly(0, eventOfLevel(Level.ERROR)); - errorCollector.assertThat(output) - .isEqualTo("done"); - errorCollector.assertAll(); - } - - @Test - public void givenClientId_whenMDCRequestMade_thenMessagesWithClientIdLogged() throws Exception { - String clientId = "id-1234"; - - String output = controller.clientMDCRequest(clientId); - - SoftAssertions errorCollector = new SoftAssertions(); - errorCollector.assertThat(appender.getEvents()) - .allMatch(entry -> { - return clientId.equals(entry.getContextData() - .getValue("clientId")); - }) - .haveAtLeastOne(eventContains("Client id-1234 has made a request", Level.INFO)) - .haveAtLeastOne(eventContains("Starting request", Level.INFO)) - .haveAtLeastOne(eventContains("Finished request", Level.INFO)); - errorCollector.assertThat(output) - .isEqualTo("finished"); - errorCollector.assertAll(); - } - - private Condition eventOfLevel(Level level) { - return eventContains(null, level); - } - - private Condition eventContains(String substring, Level level) { - - return new Condition(entry -> (substring == null || (entry.getMessage() - .getFormattedMessage() != null && entry.getMessage() - .getFormattedMessage() - .contains(substring))) - && (level == null || level.equals(entry.getLevel())), String.format("entry with message '%s', level %s", substring, level)); - } -} diff --git a/guest/slf4j/guide/slf4j-log4j2/src/test/resources/log4j2-test.xml b/guest/slf4j/guide/slf4j-log4j2/src/test/resources/log4j2-test.xml deleted file mode 100644 index 2ca386f7f6..0000000000 --- a/guest/slf4j/guide/slf4j-log4j2/src/test/resources/log4j2-test.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/guest/slf4j/guide/slf4j-logback/.gitignore b/guest/slf4j/guide/slf4j-logback/.gitignore deleted file mode 100644 index 82eca336e3..0000000000 --- a/guest/slf4j/guide/slf4j-logback/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -/target/ -!.mvn/wrapper/maven-wrapper.jar - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -/nbproject/private/ -/build/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ \ No newline at end of file diff --git a/guest/slf4j/guide/slf4j-logback/pom.xml b/guest/slf4j/guide/slf4j-logback/pom.xml deleted file mode 100644 index 74f4470bad..0000000000 --- a/guest/slf4j/guide/slf4j-logback/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - 4.0.0 - slf4j-logback - 0.0.1-SNAPSHOT - slf4j-logback - jar - - - com.stackify.slf4j.guide - slf4j-parent-module - 1.0.0-SNAPSHOT - .. - - - - - org.slf4j - slf4j-ext - - - ch.qos.cal10n - cal10n-api - ${cal10n.version} - - - - - 0.8.1 - - diff --git a/guest/slf4j/guide/slf4j-logback/src/main/java/com/stackify/slf4j/guide/Application.java b/guest/slf4j/guide/slf4j-logback/src/main/java/com/stackify/slf4j/guide/Application.java deleted file mode 100644 index 01ccf519b3..0000000000 --- a/guest/slf4j/guide/slf4j-logback/src/main/java/com/stackify/slf4j/guide/Application.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.stackify.slf4j.guide; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } -} diff --git a/guest/slf4j/guide/slf4j-logback/src/main/java/com/stackify/slf4j/guide/controllers/SimpleController.java b/guest/slf4j/guide/slf4j-logback/src/main/java/com/stackify/slf4j/guide/controllers/SimpleController.java deleted file mode 100644 index 1fab675c94..0000000000 --- a/guest/slf4j/guide/slf4j-logback/src/main/java/com/stackify/slf4j/guide/controllers/SimpleController.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.stackify.slf4j.guide.controllers; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Locale; -import java.util.UUID; -import java.util.concurrent.ThreadLocalRandom; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; -import org.slf4j.Marker; -import org.slf4j.MarkerFactory; -import org.slf4j.cal10n.LocLogger; -import org.slf4j.cal10n.LocLoggerFactory; -import org.slf4j.ext.EventData; -import org.slf4j.ext.EventLogger; -import org.slf4j.profiler.Profiler; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import com.stackify.slf4j.guide.l10n.Messages; - -import ch.qos.cal10n.IMessageConveyor; -import ch.qos.cal10n.MessageConveyor; - -@RestController -public class SimpleController { - - Logger logger = LoggerFactory.getLogger(SimpleController.class); - - @GetMapping("/slf4j-guide-request") - public String processList(List list) { - logger.info("Client requested process the following list: {}", list); - try { - logger.debug("Starting process"); - // ...processing list here... - Thread.sleep(500); - } catch (RuntimeException | InterruptedException e) { - logger.error("There was an issue processing the list.", e); - } finally { - logger.info("Finished processing"); - } - return "done"; - } - - @GetMapping("/slf4j-guide-mdc-request") - public String clientMDCRequest(@RequestHeader String clientId) throws InterruptedException { - MDC.put("clientId", clientId); - logger.info("Client {} has made a request", clientId); - logger.info("Starting request"); - Thread.sleep(500); - logger.info("Finished request"); - MDC.clear(); - return "finished"; - } - - @GetMapping("/slf4j-guide-marker-request") - public String clientMarkerRequest() throws InterruptedException { - logger.info("client has made a request"); - Marker myMarker = MarkerFactory.getMarker("MYMARKER"); - logger.info(myMarker, "Starting request"); - Thread.sleep(500); - logger.debug(myMarker, "Finished request"); - return "finished"; - } - - @GetMapping("/slf4j-guide-profiler-request") - public String clientProfilerRequest() { - logger.info("client has made a request"); - Profiler myProfiler = new Profiler("MYPROFILER"); - // Associate the logger to handle the output( for testing purposes here) - myProfiler.setLogger(logger); - - myProfiler.start("List generation process"); - List list = generateList(); - - myProfiler.start("List sorting process"); - Collections.sort(list); - - // Use the log() method instead of print() to use the logger (for testing purposes here) - myProfiler.stop() - .log(); - return "finished"; - } - - private List generateList() { - List generated = new ArrayList<>(); - for (int i = 0; i < 5000; i++) { - generated.add(ThreadLocalRandom.current() - .nextInt(2000)); - } - return generated; - } - - @GetMapping("/slf4j-guide-event-request") - public String clientEventRequest(@RequestParam("sender") String sender, @RequestParam("receiver") String receiver) { - logger.info("sending from {} to {}", sender, receiver); - - // ...sending process... - - EventData data = new EventData(); - data.setEventDateTime(new Date()); - data.setEventType("sending"); - String confirm = UUID.randomUUID() - .toString(); - data.setEventId(confirm); - data.put("from", sender); - data.put("to", receiver); - EventLogger.logEvent(data); - - return "finished"; - } - - @GetMapping("/slf4j-guide-locale-request") - public String clientLocaleRequest(@RequestHeader("Accept-Language") String localeHeader) { - List list = Locale.LanguageRange.parse(localeHeader); - Locale locale = Locale.lookup(list, Arrays.asList(Locale.getAvailableLocales())); - IMessageConveyor messageConveyor = new MessageConveyor(locale); - LocLoggerFactory llFactory = new LocLoggerFactory(messageConveyor); - LocLogger locLogger = llFactory.getLocLogger(this.getClass()); - locLogger.info(Messages.CLIENT_REQUEST, "parametrizedClientId", localeHeader); - locLogger.debug(Messages.REQUEST_STARTED); - locLogger.info(Messages.REQUEST_FINISHED); - return "finished"; - } - -} diff --git a/guest/slf4j/guide/slf4j-logback/src/main/java/com/stackify/slf4j/guide/l10n/Messages.java b/guest/slf4j/guide/slf4j-logback/src/main/java/com/stackify/slf4j/guide/l10n/Messages.java deleted file mode 100644 index e4aacaf3be..0000000000 --- a/guest/slf4j/guide/slf4j-logback/src/main/java/com/stackify/slf4j/guide/l10n/Messages.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.stackify.slf4j.guide.l10n; - -import ch.qos.cal10n.BaseName; -import ch.qos.cal10n.Locale; -import ch.qos.cal10n.LocaleData; - -@BaseName("messages") -@LocaleData({ @Locale("en_US"), @Locale("es_ES") }) -public enum Messages { - CLIENT_REQUEST, REQUEST_STARTED, REQUEST_FINISHED -} diff --git a/guest/slf4j/guide/slf4j-logback/src/main/java/com/stackify/slf4j/guide/xlogger/XLoggerController.java b/guest/slf4j/guide/slf4j-logback/src/main/java/com/stackify/slf4j/guide/xlogger/XLoggerController.java deleted file mode 100644 index 8690c0ebc9..0000000000 --- a/guest/slf4j/guide/slf4j-logback/src/main/java/com/stackify/slf4j/guide/xlogger/XLoggerController.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.stackify.slf4j.guide.xlogger; - -import org.slf4j.ext.XLogger; -import org.slf4j.ext.XLoggerFactory; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class XLoggerController { - - private XLogger logger = XLoggerFactory.getXLogger(XLoggerController.class); - - @GetMapping("/slf4j-guide-xlogger-request") - public Integer clientXLoggerRequest(@RequestParam("queryParam") Integer queryParam) { - logger.info("Starting process"); - logger.entry(queryParam); - Integer rest = 0; - try { - rest = queryParam % 3; - } catch (RuntimeException anyException) { - logger.catching(anyException); - } - logger.exit(rest); - return rest; - } - -} diff --git a/guest/slf4j/guide/slf4j-logback/src/main/resources/application.properties b/guest/slf4j/guide/slf4j-logback/src/main/resources/application.properties deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/guest/slf4j/guide/slf4j-logback/src/main/resources/logback-spring.xml b/guest/slf4j/guide/slf4j-logback/src/main/resources/logback-spring.xml deleted file mode 100644 index 112e79c340..0000000000 --- a/guest/slf4j/guide/slf4j-logback/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - %marker %d{yyyy-MM-dd HH:mm:ss.SSS} -%5p %X{clientId}@%15.15t %-40.40logger{39} : %m%n - - - - - - \ No newline at end of file diff --git a/guest/slf4j/guide/slf4j-logback/src/main/resources/messages_en_US.properties b/guest/slf4j/guide/slf4j-logback/src/main/resources/messages_en_US.properties deleted file mode 100644 index a35dd60da3..0000000000 --- a/guest/slf4j/guide/slf4j-logback/src/main/resources/messages_en_US.properties +++ /dev/null @@ -1,3 +0,0 @@ -CLIENT_REQUEST=Client {0} has made a request using locale {1} -REQUEST_STARTED=Request started -REQUEST_FINISHED=Request finished \ No newline at end of file diff --git a/guest/slf4j/guide/slf4j-logback/src/main/resources/messages_es_ES.properties b/guest/slf4j/guide/slf4j-logback/src/main/resources/messages_es_ES.properties deleted file mode 100644 index 6cdab09236..0000000000 --- a/guest/slf4j/guide/slf4j-logback/src/main/resources/messages_es_ES.properties +++ /dev/null @@ -1,3 +0,0 @@ -CLIENT_REQUEST=El cliente {0} ha realizado una solicitud usando locale {1} -REQUEST_STARTED=Solicitud iniciada -REQUEST_FINISHED=Solicitud finalizada \ No newline at end of file diff --git a/guest/slf4j/guide/slf4j-logback/src/test/java/com/stackify/slf4j/guide/controllers/SimpleControllerIntegrationTest.java b/guest/slf4j/guide/slf4j-logback/src/test/java/com/stackify/slf4j/guide/controllers/SimpleControllerIntegrationTest.java deleted file mode 100644 index b870cc9ebd..0000000000 --- a/guest/slf4j/guide/slf4j-logback/src/test/java/com/stackify/slf4j/guide/controllers/SimpleControllerIntegrationTest.java +++ /dev/null @@ -1,163 +0,0 @@ -package com.stackify.slf4j.guide.controllers; - -import static org.powermock.api.mockito.PowerMockito.doNothing; -import static org.powermock.api.mockito.PowerMockito.spy; - -import java.util.Collections; - -import org.assertj.core.api.Condition; -import org.assertj.core.api.SoftAssertions; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.slf4j.MDC; - -import com.stackify.slf4j.guide.utils.ListAppender; - -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.spi.ILoggingEvent; - -@RunWith(PowerMockRunner.class) -@PrepareForTest(MDC.class) -public class SimpleControllerIntegrationTest { - - SimpleController controller = new SimpleController(); - - @Before - public void clearLogList() { - ListAppender.clearEventList(); - } - - @Test - public void whenSimpleRequestMade_thenAllRegularMessagesLogged() { - String output = controller.processList(Collections.emptyList()); - - SoftAssertions errorCollector = new SoftAssertions(); - errorCollector.assertThat(ListAppender.getEvents()) - .haveAtLeastOne(eventContains("Client requested process the following list: []", Level.INFO)) - .haveAtLeastOne(eventContains("Starting process", Level.DEBUG)) - .haveAtLeastOne(eventContains("Finished processing", Level.INFO)) - .haveExactly(0, eventOfLevel(Level.ERROR)); - errorCollector.assertThat(output) - .isEqualTo("done"); - errorCollector.assertAll(); - } - - @Test - public void givenClientId_whenMDCRequestMade_thenMessagesWithClientIdLogged() throws Exception { - // We avoid cleaning the context so tht we can check it afterwards - spy(MDC.class); - doNothing().when(MDC.class); - MDC.clear(); - String clientId = "id-1234"; - - String output = controller.clientMDCRequest(clientId); - - SoftAssertions errorCollector = new SoftAssertions(); - errorCollector.assertThat(ListAppender.getEvents()) - .allMatch(entry -> { - return clientId.equals(entry.getMDCPropertyMap() - .get("clientId")); - }) - .haveAtLeastOne(eventContains("Client id-1234 has made a request", Level.INFO)) - .haveAtLeastOne(eventContains("Starting request", Level.INFO)) - .haveAtLeastOne(eventContains("Finished request", Level.INFO)); - errorCollector.assertThat(output) - .isEqualTo("finished"); - errorCollector.assertAll(); - } - - @Test - public void whenMarkerRequestMade_thenMessagesWithMarkerLogged() throws Exception { - String output = controller.clientMarkerRequest(); - - SoftAssertions errorCollector = new SoftAssertions(); - errorCollector.assertThat(ListAppender.getEvents()) - .haveAtLeastOne(eventContains("client has made a request", Level.INFO)) - .haveAtLeastOne(eventContains("Starting request", Level.INFO, "MYMARKER")) - .haveAtLeastOne(eventContains("Finished request", Level.DEBUG, "MYMARKER")) - .haveExactly(2, eventContains(null, null, "MYMARKER")); - errorCollector.assertThat(output) - .isEqualTo("finished"); - errorCollector.assertAll(); - } - - @Test - public void whenProfilerRequestMade_thenMessagesWithPerformanceLogged() throws Exception { - String output = controller.clientProfilerRequest(); - - SoftAssertions errorCollector = new SoftAssertions(); - errorCollector.assertThat(ListAppender.getEvents()) - .haveAtLeastOne(eventContains("client has made a request", Level.INFO)) - .haveAtLeastOne(eventContains("Profiler [MYPROFILER]", Level.DEBUG)); - errorCollector.assertThat(output) - .isEqualTo("finished"); - errorCollector.assertAll(); - } - - @Test - public void whenEventRequestMade_thenMessagesWithEventLogged() throws Exception { - String sender = "sender"; - String receiver = "receiver"; - String output = controller.clientEventRequest(sender, receiver); - - SoftAssertions errorCollector = new SoftAssertions(); - errorCollector.assertThat(ListAppender.getEvents()) - .haveAtLeastOne(eventContains("sending from sender to receiver", Level.INFO)) - .haveAtLeastOne(eventContains("", Level.INFO)) - .haveAtLeastOne(eventContains("sender", Level.INFO)) - .haveAtLeastOne(eventContains("receiver", Level.INFO)); - errorCollector.assertThat(output) - .isEqualTo("finished"); - errorCollector.assertAll(); - } - - @Test - public void givenESLocale_whenLocaleRequestMade_thenMessagesWithEventLogged() throws Exception { - String locale = "es-ES"; - String output = controller.clientLocaleRequest(locale); - - SoftAssertions errorCollector = new SoftAssertions(); - errorCollector.assertThat(ListAppender.getEvents()) - .haveAtLeastOne(eventContains("El cliente parametrizedClientId ha realizado una solicitud usando locale es-ES", Level.INFO)) - .haveAtLeastOne(eventContains("Solicitud iniciada", Level.DEBUG)) - .haveAtLeastOne(eventContains("Solicitud finalizada", Level.INFO)); - errorCollector.assertThat(output) - .isEqualTo("finished"); - errorCollector.assertAll(); - } - - @Test - public void givenENLocale_whenLocaleRequestMade_thenMessagesWithEventLogged() throws Exception { - String locale = "en-US"; - String output = controller.clientLocaleRequest(locale); - - SoftAssertions errorCollector = new SoftAssertions(); - errorCollector.assertThat(ListAppender.getEvents()) - .haveAtLeastOne(eventContains("Client parametrizedClientId has made a request using locale en-US", Level.INFO)) - .haveAtLeastOne(eventContains("Request started", Level.DEBUG)) - .haveAtLeastOne(eventContains("Request finished", Level.INFO)); - errorCollector.assertThat(output) - .isEqualTo("finished"); - errorCollector.assertAll(); - } - - private Condition eventContains(String substring, Level level) { - return eventContains(substring, level, null); - } - - private Condition eventOfLevel(Level level) { - return eventContains(null, level, null); - } - - private Condition eventContains(String substring, Level level, String markerName) { - - return new Condition(entry -> (substring == null || (entry.getFormattedMessage() != null && entry.getFormattedMessage() - .contains(substring))) && (level == null || level.equals(entry.getLevel())) && (markerName == null || (entry.getMarker() != null - && markerName.equals(entry.getMarker() - .getName()))), - String.format("entry with message '%s', level %s and marker %s", substring, level, markerName)); - } -} diff --git a/guest/slf4j/guide/slf4j-logback/src/test/java/com/stackify/slf4j/guide/utils/ListAppender.java b/guest/slf4j/guide/slf4j-logback/src/test/java/com/stackify/slf4j/guide/utils/ListAppender.java deleted file mode 100644 index e6d4e47fb2..0000000000 --- a/guest/slf4j/guide/slf4j-logback/src/test/java/com/stackify/slf4j/guide/utils/ListAppender.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.stackify.slf4j.guide.utils; - -import java.util.ArrayList; -import java.util.List; - -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.AppenderBase; - -public class ListAppender extends AppenderBase { - - static private List events = new ArrayList<>(); - - @Override - protected void append(ILoggingEvent eventObject) { - events.add(eventObject); - } - - public static List getEvents() { - return events; - } - - public static void clearEventList() { - events.clear(); - } -} diff --git a/guest/slf4j/guide/slf4j-logback/src/test/resources/logback-test.xml b/guest/slf4j/guide/slf4j-logback/src/test/resources/logback-test.xml deleted file mode 100644 index 90168a0fea..0000000000 --- a/guest/slf4j/guide/slf4j-logback/src/test/resources/logback-test.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/guest/spring-boot-app/.gitignore b/guest/spring-boot-app/.gitignore deleted file mode 100644 index 60be5b80aa..0000000000 --- a/guest/spring-boot-app/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/target/ -.settings/ -.classpath -.project diff --git a/guest/spring-boot-app/WebContent/META-INF/MANIFEST.MF b/guest/spring-boot-app/WebContent/META-INF/MANIFEST.MF deleted file mode 100644 index e3c07ab38a..0000000000 --- a/guest/spring-boot-app/WebContent/META-INF/MANIFEST.MF +++ /dev/null @@ -1,2 +0,0 @@ -Manifest-Version: 1.0 -Class-Path: diff --git a/guest/spring-boot-app/docker/Dockerfile b/guest/spring-boot-app/docker/Dockerfile deleted file mode 100644 index 211e8927a3..0000000000 --- a/guest/spring-boot-app/docker/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -# Alpine Linux with OpenJDK JRE -FROM openjdk:8-jre-alpine -RUN apk add --no-cache bash - -# copy fat WAR -COPY spring-boot-app-0.0.1-SNAPSHOT.war /app.war - -# copy fat WAR -COPY logback.xml /logback.xml - -COPY run.sh /run.sh - -# runs application -#CMD ["/usr/bin/java", "-jar", "-Dspring.profiles.active=default", "-Dlogging.config=/logback.xml", "/app.war"] - -ENTRYPOINT ["/run.sh"] diff --git a/guest/spring-boot-app/docker/logback.xml b/guest/spring-boot-app/docker/logback.xml deleted file mode 100644 index 7e03ddc827..0000000000 --- a/guest/spring-boot-app/docker/logback.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - /var/log/Application/application.log - true - - %-7d{yyyy-MM-dd HH:mm:ss:SSS} %m%n - - - - - - - diff --git a/guest/spring-boot-app/docker/run.sh b/guest/spring-boot-app/docker/run.sh deleted file mode 100755 index aeecc29371..0000000000 --- a/guest/spring-boot-app/docker/run.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -java -Dspring.profiles.active=$1 -Dlogging.config=/logback.xml -jar /app.war - diff --git a/guest/spring-boot-app/pom.xml b/guest/spring-boot-app/pom.xml deleted file mode 100644 index 6f9c8e8aa9..0000000000 --- a/guest/spring-boot-app/pom.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - 4.0.0 - spring-boot-app - spring-boot-app - 0.0.1-SNAPSHOT - spring-boot-app - war - - - org.springframework.boot - spring-boot-starter-parent - 1.5.3.RELEASE - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-data-jpa - - - com.h2database - h2 - - - org.springframework.boot - spring-boot-starter-actuator - - - org.springframework.boot - spring-boot-starter-test - - - - - - - maven-compiler-plugin - - - maven-war-plugin - - WebContent - - - - org.springframework.boot - spring-boot-maven-plugin - - - - repackage - - - com.stackify.Application - ${project.basedir}/docker - - - - - - - - - - 8.0.43 - UTF-8 - 1.8 - - - diff --git a/guest/spring-boot-app/src/main/java/com/stackify/Application.java b/guest/spring-boot-app/src/main/java/com/stackify/Application.java deleted file mode 100644 index de03fb6c81..0000000000 --- a/guest/spring-boot-app/src/main/java/com/stackify/Application.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.stackify; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} diff --git a/guest/spring-boot-app/src/main/java/com/stackify/config/PersistenceConfig.java b/guest/spring-boot-app/src/main/java/com/stackify/config/PersistenceConfig.java deleted file mode 100644 index dfbd964228..0000000000 --- a/guest/spring-boot-app/src/main/java/com/stackify/config/PersistenceConfig.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.stackify.config; - -import javax.sql.DataSource; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase; -import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; -import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; - -@Configuration -public class PersistenceConfig { - - @Bean - public DataSource dataSource() { - EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); - EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.H2).addScript("mySchema.sql").addScript("myData.sql").build(); - return db; - } - -} \ No newline at end of file diff --git a/guest/spring-boot-app/src/main/java/com/stackify/controller/EmployeeController.java b/guest/spring-boot-app/src/main/java/com/stackify/controller/EmployeeController.java deleted file mode 100644 index 44ad61fcfe..0000000000 --- a/guest/spring-boot-app/src/main/java/com/stackify/controller/EmployeeController.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.stackify.controller; - -import java.util.List; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.http.HttpStatus; - -import com.stackify.model.Employee; -import com.stackify.repository.EmployeeRepository; - -@RestController -public class EmployeeController { - - private EmployeeRepository employeeRepository; - - public EmployeeController(EmployeeRepository employeeRepository) { - this.employeeRepository = employeeRepository; - } - - @PostMapping("/employees") - @ResponseStatus(HttpStatus.CREATED) - public void addEmployee(@RequestBody Employee employee) { - employeeRepository.save(employee); - } - - @GetMapping("/employees") - public List getEmployees() { - return employeeRepository.findAll(); - } -} diff --git a/guest/spring-boot-app/src/main/java/com/stackify/model/Employee.java b/guest/spring-boot-app/src/main/java/com/stackify/model/Employee.java deleted file mode 100644 index 708a990166..0000000000 --- a/guest/spring-boot-app/src/main/java/com/stackify/model/Employee.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.stackify.model; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; - -@Entity -public class Employee { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private long id; - - private String name; - - public Employee() { - } - - public Employee(long id, String name) { - super(); - this.id = id; - this.name = name; - } - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - -} diff --git a/guest/spring-boot-app/src/main/java/com/stackify/repository/EmployeeRepository.java b/guest/spring-boot-app/src/main/java/com/stackify/repository/EmployeeRepository.java deleted file mode 100644 index 583fa21ab0..0000000000 --- a/guest/spring-boot-app/src/main/java/com/stackify/repository/EmployeeRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.stackify.repository; - -import org.springframework.data.jpa.repository.JpaRepository; - -import com.stackify.model.Employee; - -public interface EmployeeRepository extends JpaRepository { - -} diff --git a/guest/spring-boot-app/src/main/resources/application.properties b/guest/spring-boot-app/src/main/resources/application.properties deleted file mode 100644 index ac81442a1c..0000000000 --- a/guest/spring-boot-app/src/main/resources/application.properties +++ /dev/null @@ -1,5 +0,0 @@ -server.port=8081 -server.contextPath=/springbootapp -logging.level.org.springframework.web: INFO - -spring.jpa.hibernate.ddl-auto=update \ No newline at end of file diff --git a/guest/spring-boot-app/src/main/resources/logback.xml b/guest/spring-boot-app/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/guest/spring-boot-app/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/guest/spring-boot-app/src/main/resources/myData.sql b/guest/spring-boot-app/src/main/resources/myData.sql deleted file mode 100644 index abf63b6d5b..0000000000 --- a/guest/spring-boot-app/src/main/resources/myData.sql +++ /dev/null @@ -1 +0,0 @@ -insert into employee(name) values ('ana'); \ No newline at end of file diff --git a/guest/spring-boot-app/src/main/resources/mySchema.sql b/guest/spring-boot-app/src/main/resources/mySchema.sql deleted file mode 100644 index 48ba63d69f..0000000000 --- a/guest/spring-boot-app/src/main/resources/mySchema.sql +++ /dev/null @@ -1 +0,0 @@ -create table employee(id int identity primary key, name varchar(30)); \ No newline at end of file diff --git a/guest/spring-boot-app/src/test/java/com/stackify/test/EmployeeControllerUnitTest.java b/guest/spring-boot-app/src/test/java/com/stackify/test/EmployeeControllerUnitTest.java deleted file mode 100644 index 9808546e82..0000000000 --- a/guest/spring-boot-app/src/test/java/com/stackify/test/EmployeeControllerUnitTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.stackify.test; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.context.web.WebAppConfiguration; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.web.context.WebApplicationContext; - -import static org.hamcrest.Matchers.*; - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; - -import com.stackify.Application; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = Application.class) -@WebAppConfiguration -public class EmployeeControllerUnitTest { - - private static final String CONTENT_TYPE = "application/json;charset=UTF-8"; - - private MockMvc mockMvc; - - @Autowired - private WebApplicationContext webApplicationContext; - - @Before - public void setup() throws Exception { - this.mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build(); - } - - @Test - public void whenCreateGetEmployee_thenOk() throws Exception { - String employeeJson = "{\"name\":\"john\"}"; - - this.mockMvc.perform(post("/employees").contentType(CONTENT_TYPE).content(employeeJson)).andExpect(status().isCreated()); - - this.mockMvc.perform(get("/employees")).andExpect(status().isOk()).andExpect(content().contentType(CONTENT_TYPE)).andExpect(jsonPath("$", hasSize(2))).andExpect(jsonPath("$[0].name", is("ana"))).andExpect(jsonPath("$[1].name", is("john"))); - } -} diff --git a/guest/spring-mvc/README.md b/guest/spring-mvc/README.md deleted file mode 100644 index 9e5cd64a04..0000000000 --- a/guest/spring-mvc/README.md +++ /dev/null @@ -1,17 +0,0 @@ -## Building - -To build the module, use Maven's `package` goal: - -``` -mvn clean package -``` - -## Running - -To run the application, use Spring Boot's `run` goal: - -``` -mvn spring-boot:run -``` - -The application will be accessible at [http://localhost:8080/](http://localhost:8080/) diff --git a/guest/spring-mvc/pom.xml b/guest/spring-mvc/pom.xml deleted file mode 100644 index df08fa0595..0000000000 --- a/guest/spring-mvc/pom.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - 4.0.0 - com.stackify.guest - spring-mvc - 0.0.1-SNAPSHOT - spring-mvc - jar - Spring MVC sample project - - - org.springframework.boot - spring-boot-starter-parent - 2.0.0.RELEASE - - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - - - UTF-8 - UTF-8 - - - diff --git a/guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/Spring5Application.java b/guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/Spring5Application.java deleted file mode 100644 index 42d40fa02d..0000000000 --- a/guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/Spring5Application.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.stackify.guest.springmvc; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.boot.SpringApplication; - -@SpringBootApplication -@ComponentScan(basePackages = {"com.stackify.guest.springmvc"}) -public class Spring5Application { - - public static void main(String[] args) { - SpringApplication.run(Spring5Application.class, args); - } - -} diff --git a/guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/model/LoginData.java b/guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/model/LoginData.java deleted file mode 100644 index b1a0e86ef4..0000000000 --- a/guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/model/LoginData.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.stackify.guest.springmvc.model; - -public class LoginData { - - private String login; - - private String password; - - public LoginData() { - } - - public String getLogin() { - return login; - } - - public void setLogin(String login) { - this.login = login; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } -} diff --git a/guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/web/InternalsController.java b/guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/web/InternalsController.java deleted file mode 100644 index 0bd8570eed..0000000000 --- a/guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/web/InternalsController.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.stackify.guest.springmvc.web; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.servlet.ModelAndView; - -import com.stackify.guest.springmvc.model.LoginData; - -import java.util.Collections; - -@Controller -public class InternalsController { - - private static final String LOGIN = "jack"; - private static final String PASSWORD = "halloween"; - - @GetMapping("/") - public String hello() { - return "login"; - } - - @PostMapping("/login") - public ModelAndView login(LoginData loginData) { - if (LOGIN.equals(loginData.getLogin()) && PASSWORD.equals(loginData.getPassword())) { - return new ModelAndView("success", Collections.singletonMap("login", loginData.getLogin())); - } else { - return new ModelAndView("failure", Collections.singletonMap("login", loginData.getLogin())); - } - } - - @ResponseBody - @PostMapping("/message") - public MyOutputResource sendMessage(@RequestBody MyInputResource inputResource) { - return new MyOutputResource("Received: " + inputResource.getRequestMessage()); - } - -} diff --git a/guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/web/MyInputResource.java b/guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/web/MyInputResource.java deleted file mode 100644 index cf5815840a..0000000000 --- a/guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/web/MyInputResource.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.stackify.guest.springmvc.web; - -public class MyInputResource { - - private String requestMessage; - - public String getRequestMessage() { - return requestMessage; - } - - public void setRequestMessage(String requestMessage) { - this.requestMessage = requestMessage; - } -} diff --git a/guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/web/MyOutputResource.java b/guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/web/MyOutputResource.java deleted file mode 100644 index 2d0e174243..0000000000 --- a/guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/web/MyOutputResource.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.stackify.guest.springmvc.web; - -public class MyOutputResource { - - private String responseMessage; - - public MyOutputResource(String responseMessage) { - this.responseMessage = responseMessage; - } - - public String getResponseMessage() { - return responseMessage; - } - -} diff --git a/guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/web/RestfulWebServiceController.java b/guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/web/RestfulWebServiceController.java deleted file mode 100644 index edb35e6ecf..0000000000 --- a/guest/spring-mvc/src/main/java/com/stackify/guest/springmvc/web/RestfulWebServiceController.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.stackify.guest.springmvc.web; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class RestfulWebServiceController { - - @GetMapping("/message") - public MyOutputResource getMessage() { - return new MyOutputResource("Hello!"); - } - -} diff --git a/guest/spring-mvc/src/main/resources/logback.xml b/guest/spring-mvc/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/guest/spring-mvc/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/guest/spring-mvc/src/main/resources/templates/failure.html b/guest/spring-mvc/src/main/resources/templates/failure.html deleted file mode 100644 index f319652ede..0000000000 --- a/guest/spring-mvc/src/main/resources/templates/failure.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - Login Failure - -

- User with login not found, please try again. -

- \ No newline at end of file diff --git a/guest/spring-mvc/src/main/resources/templates/login.html b/guest/spring-mvc/src/main/resources/templates/login.html deleted file mode 100644 index d031ac8825..0000000000 --- a/guest/spring-mvc/src/main/resources/templates/login.html +++ /dev/null @@ -1,13 +0,0 @@ - - -Login Form - - -
- - - -
- - - \ No newline at end of file diff --git a/guest/spring-mvc/src/main/resources/templates/success.html b/guest/spring-mvc/src/main/resources/templates/success.html deleted file mode 100644 index 6966385f2e..0000000000 --- a/guest/spring-mvc/src/main/resources/templates/success.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - Login Success - -

- Hello, ! -

- \ No newline at end of file diff --git a/guest/spring-security/README.md b/guest/spring-security/README.md deleted file mode 100644 index 9e5cd64a04..0000000000 --- a/guest/spring-security/README.md +++ /dev/null @@ -1,17 +0,0 @@ -## Building - -To build the module, use Maven's `package` goal: - -``` -mvn clean package -``` - -## Running - -To run the application, use Spring Boot's `run` goal: - -``` -mvn spring-boot:run -``` - -The application will be accessible at [http://localhost:8080/](http://localhost:8080/) diff --git a/guest/spring-security/pom.xml b/guest/spring-security/pom.xml deleted file mode 100644 index 2ac8935c3c..0000000000 --- a/guest/spring-security/pom.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - 4.0.0 - com.stackify.guest - spring-security - 1.0-SNAPSHOT - spring-security - Spring Security Sample Project - - - org.springframework.boot - spring-boot-starter-parent - 2.0.0.RELEASE - - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - org.thymeleaf - thymeleaf-spring5 - ${thymeleaf-spring5.version} - - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.boot - spring-boot-starter-jdbc - - - com.h2database - h2 - runtime - - - - - UTF-8 - UTF-8 - 3.0.8.RELEASE - - - \ No newline at end of file diff --git a/guest/spring-security/src/main/java/com/stackify/guest/springsecurity/Application.java b/guest/spring-security/src/main/java/com/stackify/guest/springsecurity/Application.java deleted file mode 100644 index fbd0eee044..0000000000 --- a/guest/spring-security/src/main/java/com/stackify/guest/springsecurity/Application.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.stackify.guest.springsecurity; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"com.stackify.guest.springsecurity"}) -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} diff --git a/guest/spring-security/src/main/java/com/stackify/guest/springsecurity/config/WebMvcConfiguration.java b/guest/spring-security/src/main/java/com/stackify/guest/springsecurity/config/WebMvcConfiguration.java deleted file mode 100644 index b8dfe9050d..0000000000 --- a/guest/spring-security/src/main/java/com/stackify/guest/springsecurity/config/WebMvcConfiguration.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.stackify.guest.springsecurity.config; - -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -@Configuration -public class WebMvcConfiguration implements WebMvcConfigurer { - - @Override - public void addViewControllers(ViewControllerRegistry registry) { - registry.addViewController("/customLogin").setViewName("customLogin"); - registry.addViewController("/loginSuccess").setViewName("index"); - } - -} \ No newline at end of file diff --git a/guest/spring-security/src/main/java/com/stackify/guest/springsecurity/config/WebSecurityConfig.java b/guest/spring-security/src/main/java/com/stackify/guest/springsecurity/config/WebSecurityConfig.java deleted file mode 100644 index 164808d5b3..0000000000 --- a/guest/spring-security/src/main/java/com/stackify/guest/springsecurity/config/WebSecurityConfig.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.stackify.guest.springsecurity.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.provisioning.JdbcUserDetailsManager; - -import javax.sql.DataSource; - -@EnableWebSecurity -public class WebSecurityConfig extends WebSecurityConfigurerAdapter { - - @Bean - public UserDetailsService jdbcUserDetailsService(DataSource dataSource) { - JdbcUserDetailsManager manager = new JdbcUserDetailsManager(); - manager.setDataSource(dataSource); - return manager; - } - - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - } - - @Override - protected void configure(HttpSecurity http) throws Exception { - http.authorizeRequests() - .antMatchers("/css/**").permitAll() - .anyRequest().authenticated() - .and().formLogin() - .loginPage("/customLogin") - .defaultSuccessUrl("/loginSuccess", true) - .permitAll(); - } - -} \ No newline at end of file diff --git a/guest/spring-security/src/main/resources/data.sql b/guest/spring-security/src/main/resources/data.sql deleted file mode 100644 index b3f7db9105..0000000000 --- a/guest/spring-security/src/main/resources/data.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO users VALUES ('jill', '$2a$04$qUlqAEEYF1YvrpJMosodoewgL6aO.qgHytl2k5L7kdXEWnJsFdxvq', TRUE); -INSERT INTO authorities VALUES ('jill', 'USERS'); diff --git a/guest/spring-security/src/main/resources/logback.xml b/guest/spring-security/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/guest/spring-security/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/guest/spring-security/src/main/resources/schema.sql b/guest/spring-security/src/main/resources/schema.sql deleted file mode 100644 index 3de1b9a29f..0000000000 --- a/guest/spring-security/src/main/resources/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE users ( - username VARCHAR(256) PRIMARY KEY, - password VARCHAR(256), - enabled BOOLEAN -); - -CREATE TABLE authorities ( - username VARCHAR(256) REFERENCES users (username), - authority VARCHAR(256) -); diff --git a/guest/spring-security/src/main/resources/static/css/styles.css b/guest/spring-security/src/main/resources/static/css/styles.css deleted file mode 100644 index 72bcc4934f..0000000000 --- a/guest/spring-security/src/main/resources/static/css/styles.css +++ /dev/null @@ -1,3 +0,0 @@ -.bad-login { - color: red; -} \ No newline at end of file diff --git a/guest/spring-security/src/main/resources/templates/customLogin.html b/guest/spring-security/src/main/resources/templates/customLogin.html deleted file mode 100644 index c689c78514..0000000000 --- a/guest/spring-security/src/main/resources/templates/customLogin.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - -
-
- - - - -
- - - -
Log out successful.
-
- - \ No newline at end of file diff --git a/guest/spring-security/src/main/resources/templates/index.html b/guest/spring-security/src/main/resources/templates/index.html deleted file mode 100644 index 0769f9015f..0000000000 --- a/guest/spring-security/src/main/resources/templates/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - -

Hello, !

-
- - -
- \ No newline at end of file diff --git a/guest/thread-pools/pom.xml b/guest/thread-pools/pom.xml deleted file mode 100644 index 26809fccd8..0000000000 --- a/guest/thread-pools/pom.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - 4.0.0 - com.stackify - thread-pools - 0.0.1-SNAPSHOT - thread-pools - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - ../../ - - - \ No newline at end of file diff --git a/guest/thread-pools/src/main/java/com/stackify/models/Employee.java b/guest/thread-pools/src/main/java/com/stackify/models/Employee.java deleted file mode 100644 index 65661f38d5..0000000000 --- a/guest/thread-pools/src/main/java/com/stackify/models/Employee.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.stackify.models; - -public class Employee { - private String name; - private double salary; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public double getSalary() { - return salary; - } - - public void setSalary(double salary) { - this.salary = salary; - } - - public Employee(String name, double salary) { - super(); - this.name = name; - this.salary = salary; - } -} diff --git a/guest/thread-pools/src/main/java/com/stackify/services/EmployeeService.java b/guest/thread-pools/src/main/java/com/stackify/services/EmployeeService.java deleted file mode 100644 index 824f87a625..0000000000 --- a/guest/thread-pools/src/main/java/com/stackify/services/EmployeeService.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.stackify.services; - -import com.stackify.models.Employee; - -public class EmployeeService { - public double calculateBonus(Employee employee) { - return 0.1 * employee.getSalary(); - } -} diff --git a/guest/thread-pools/src/main/java/com/stackify/threadpools/FactorialTask.java b/guest/thread-pools/src/main/java/com/stackify/threadpools/FactorialTask.java deleted file mode 100644 index 2dd83d9b20..0000000000 --- a/guest/thread-pools/src/main/java/com/stackify/threadpools/FactorialTask.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.stackify.threadpools; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.concurrent.ForkJoinTask; -import java.util.concurrent.RecursiveTask; -import java.util.stream.IntStream; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class FactorialTask extends RecursiveTask { - - private static final Logger logger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); - - private static final long serialVersionUID = 1L; - - private int start = 1; - private int n; - - private static final int THRESHOLD = 20; - - public FactorialTask(int n) { - this.n = n; - } - - public FactorialTask(int start, int n) { - logger.info("New FactorialTask Created"); - this.start = start; - this.n = n; - } - - @Override - protected BigInteger compute() { - if ((n - start) >= THRESHOLD) { - return ForkJoinTask.invokeAll(createSubtasks()) - .stream() - .map(ForkJoinTask::join) - .reduce(BigInteger.ONE, BigInteger::multiply); - } else { - return calculate(start, n); - } - } - - private Collection createSubtasks() { - List dividedTasks = new ArrayList<>(); - - int mid = (start + n) / 2; - - dividedTasks.add(new FactorialTask(start, mid)); - dividedTasks.add(new FactorialTask(mid + 1, n)); - return dividedTasks; - } - - private BigInteger calculate(int start, int n) { - logger.info("Calculate factorial from " + start + " to " + n); - return IntStream.rangeClosed(start, n) - .mapToObj(BigInteger::valueOf) - .reduce(BigInteger.ONE, BigInteger::multiply); - } - -} diff --git a/guest/thread-pools/src/main/java/com/stackify/threadpools/ThreadsApplication.java b/guest/thread-pools/src/main/java/com/stackify/threadpools/ThreadsApplication.java deleted file mode 100644 index cc9048eee7..0000000000 --- a/guest/thread-pools/src/main/java/com/stackify/threadpools/ThreadsApplication.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.stackify.threadpools; - -import java.math.BigInteger; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ForkJoinPool; -import java.util.concurrent.Future; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.stackify.models.Employee; -import com.stackify.services.EmployeeService; - -public class ThreadsApplication { - - private static final Logger logger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); - - public static void main(String[] args) { - testExecutor(); - testExecutorService(); - testScheduledExecutorService(); - testThreadPoolExecutor(); - testForkJoinPool(); - } - - private static EmployeeService employeeService = new EmployeeService(); - - public static void testExecutor() { - Executor executor = Executors.newSingleThreadExecutor(); - executor.execute(() -> System.out.println("Single thread pool test")); - } - - public static void testExecutorService() { - - Employee employee = new Employee("John", 2000); - - ExecutorService executor = Executors.newFixedThreadPool(10); - - Callable callableTask = () -> { - return employeeService.calculateBonus(employee); - }; - Future future = executor.submit(callableTask); - - try { - if (future.isDone()) { - double result = future.get(); - System.out.println("Bonus is:" + result); - } - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - } - - executor.shutdown(); - } - - public static void testScheduledExecutorService() { - Employee employee = new Employee("John", 2000); - - ScheduledExecutorService executor = Executors.newScheduledThreadPool(10); - - Callable callableTask = () -> { - return employeeService.calculateBonus(employee); - }; - - Future futureScheduled = executor.schedule(callableTask, 2, TimeUnit.MILLISECONDS); - - try { - System.out.println("Bonus:" + futureScheduled.get()); - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - } - - executor.scheduleAtFixedRate(() -> System.out.println("Fixed Rate Scheduled"), 2, 2000, TimeUnit.MILLISECONDS); - executor.scheduleWithFixedDelay(() -> System.out.println("Fixed Delay Scheduled"), 2, 2000, TimeUnit.MILLISECONDS); - } - - public static void testThreadPoolExecutor() { - ThreadPoolExecutor fixedPoolExecutor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10); - ThreadPoolExecutor cachedPoolExecutor = (ThreadPoolExecutor) Executors.newCachedThreadPool(); - - ThreadPoolExecutor executor = new ThreadPoolExecutor(4, 6, 60, TimeUnit.SECONDS, new LinkedBlockingQueue()); - executor.setMaximumPoolSize(8); - - ScheduledThreadPoolExecutor scheduledExecutor = (ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(5); - } - - public static void testForkJoinPool() { - ForkJoinPool pool = ForkJoinPool.commonPool(); - logger.info("Thread Pool Created"); - BigInteger result = pool.invoke(new FactorialTask(100)); - System.out.println(result.toString()); - } -} diff --git a/guest/thread-pools/src/main/resources/logback.xml b/guest/thread-pools/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/guest/thread-pools/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/guest/tomcat-app/WebContent/META-INF/MANIFEST.MF b/guest/tomcat-app/WebContent/META-INF/MANIFEST.MF deleted file mode 100644 index 254272e1c0..0000000000 --- a/guest/tomcat-app/WebContent/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Class-Path: - diff --git a/guest/tomcat-app/WebContent/WEB-INF/web.xml b/guest/tomcat-app/WebContent/WEB-INF/web.xml deleted file mode 100644 index efc7c9ae0d..0000000000 --- a/guest/tomcat-app/WebContent/WEB-INF/web.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - tomcat-app - - tomcat-app - org.glassfish.jersey.servlet.ServletContainer - - javax.ws.rs.Application - com.stackify.ApplicationInitializer - - 1 - - - tomcat-app - /* - - - javamelody - net.bull.javamelody.MonitoringFilter - - gzip-compression-disabled - true - - - \ No newline at end of file diff --git a/guest/tomcat-app/pom.xml b/guest/tomcat-app/pom.xml deleted file mode 100644 index acdecc445c..0000000000 --- a/guest/tomcat-app/pom.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - 4.0.0 - com.stackify - tomcat-app - 0.0.1-SNAPSHOT - tomcat-app - war - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - ../../ - - - - - org.glassfish.jersey.containers - jersey-container-servlet - ${jersey-container-servlet.version} - - - org.glassfish.jersey.media - jersey-media-moxy - ${jersey-media-moxy.version} - - - io.rest-assured - rest-assured - ${rest-assured.version} - - - com.h2 - h2 - ${h2.version} - runtime - - - org.apache.logging.log4j - log4j-core - ${log4j-core.version} - - - net.bull.javamelody - javamelody-core - ${javamelody-core.version} - - - - - - - maven-war-plugin - ${maven-war-plugin.version} - - WebContent - - - - - - - 2.25.1 - 3.0.3 - 2.8.2 - 1.69.0 - 2.25.1 - 3.0.0 - - - \ No newline at end of file diff --git a/guest/tomcat-app/src/main/java/com/stackify/ApplicationInitializer.java b/guest/tomcat-app/src/main/java/com/stackify/ApplicationInitializer.java deleted file mode 100644 index 6d864e859e..0000000000 --- a/guest/tomcat-app/src/main/java/com/stackify/ApplicationInitializer.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.stackify; - -import org.glassfish.jersey.server.ResourceConfig; - -public class ApplicationInitializer extends ResourceConfig { - public ApplicationInitializer() { - packages("com.stackify.services"); - } -} diff --git a/guest/tomcat-app/src/main/java/com/stackify/daos/UserDAO.java b/guest/tomcat-app/src/main/java/com/stackify/daos/UserDAO.java deleted file mode 100644 index b57b230135..0000000000 --- a/guest/tomcat-app/src/main/java/com/stackify/daos/UserDAO.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.stackify.daos; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.stackify.models.User; -import com.stackify.utils.ConnectionUtil; - -public class UserDAO { - - private Logger logger = LogManager.getLogger(UserDAO.class); - - public void createTable() { - try (Connection con = ConnectionUtil.getConnection()) { - String createQuery = "CREATE TABLE IF NOT EXISTS users(email varchar(50) primary key, name varchar(50))"; - PreparedStatement pstmt = con.prepareStatement(createQuery); - - pstmt.execute(); - } catch (SQLException exc) { - logger.error(exc.getMessage()); - } - - } - - public void add(User user) { - try (Connection con = ConnectionUtil.getConnection()) { - - String insertQuery = "INSERT INTO users(email,name) VALUES(?,?)"; - PreparedStatement pstmt = con.prepareStatement(insertQuery); - pstmt.setString(1, user.getEmail()); - pstmt.setString(2, user.getName()); - - pstmt.executeUpdate(); - } catch (SQLException exc) { - logger.error(exc.getMessage()); - } - } - - public List findAll() { - List users = new ArrayList<>(); - - try (Connection con = ConnectionUtil.getConnection()) { - String query = "SELECT * FROM users"; - PreparedStatement pstmt = con.prepareStatement(query); - - ResultSet rs = pstmt.executeQuery(); - while (rs.next()) { - User user = new User(); - user.setEmail(rs.getString("email")); - user.setName(rs.getString("name")); - users.add(user); - } - } catch (SQLException exc) { - logger.error(exc.getMessage()); - } - - return users; - } - -} diff --git a/guest/tomcat-app/src/main/java/com/stackify/models/User.java b/guest/tomcat-app/src/main/java/com/stackify/models/User.java deleted file mode 100644 index 8c8073357d..0000000000 --- a/guest/tomcat-app/src/main/java/com/stackify/models/User.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.stackify.models; - -import javax.ws.rs.core.Link; - -public class User { - private String email; - private String name; - private Link link; - - public User() { - } - - public User(String email, String name) { - super(); - this.email = email; - this.name = name; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Link getLink() { - return link; - } - - public void setLink(Link link) { - this.link = link; - } - -} diff --git a/guest/tomcat-app/src/main/java/com/stackify/services/CorsFilter.java b/guest/tomcat-app/src/main/java/com/stackify/services/CorsFilter.java deleted file mode 100644 index 267aa6fd61..0000000000 --- a/guest/tomcat-app/src/main/java/com/stackify/services/CorsFilter.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.stackify.services; - -import java.io.IOException; - -import javax.ws.rs.container.ContainerRequestContext; -import javax.ws.rs.container.ContainerResponseContext; -import javax.ws.rs.container.ContainerResponseFilter; -import javax.ws.rs.ext.Provider; - -@Provider -public class CorsFilter implements ContainerResponseFilter { - - @Override - public void filter(final ContainerRequestContext requestContext, - final ContainerResponseContext response) throws IOException { - response.getHeaders().add("Access-Control-Allow-Origin", "*"); - response.getHeaders().add("Access-Control-Allow-Headers", "origin, content-type, accept"); - } -} diff --git a/guest/tomcat-app/src/main/java/com/stackify/services/UserService.java b/guest/tomcat-app/src/main/java/com/stackify/services/UserService.java deleted file mode 100644 index 6cdb3eb55f..0000000000 --- a/guest/tomcat-app/src/main/java/com/stackify/services/UserService.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.stackify.services; - -import java.util.List; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import com.stackify.daos.UserDAO; -import com.stackify.models.User; - -@Path("/users") -public class UserService { - private UserDAO userDao = new UserDAO(); - - public UserService (){ - userDao.createTable(); - } - - @POST - @Consumes(MediaType.APPLICATION_JSON) - public Response addUser(User user) { - userDao.add(user); - return Response.ok() - .build(); - } - - @GET - @Produces(MediaType.APPLICATION_JSON) - public List getUsers() { - return userDao.findAll(); - } -} diff --git a/guest/tomcat-app/src/main/java/com/stackify/utils/ConnectionUtil.java b/guest/tomcat-app/src/main/java/com/stackify/utils/ConnectionUtil.java deleted file mode 100644 index e7734f64a7..0000000000 --- a/guest/tomcat-app/src/main/java/com/stackify/utils/ConnectionUtil.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.stackify.utils; - -import java.sql.Connection; -import java.sql.SQLException; - -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import javax.sql.DataSource; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -public class ConnectionUtil { - - private static Logger logger = LogManager.getLogger(ConnectionUtil.class); - - public static Connection getConnection() { - try { - String jndiName = "java:/comp/env/jdbc/MyDataSource"; - - Context initialContext = new InitialContext(); - DataSource datasource = (DataSource)initialContext.lookup(jndiName); - if (datasource != null) { - return datasource.getConnection(); - } - else { - logger.error("Failed to lookup datasource."); - } - } - - catch (NamingException | SQLException exc) { - logger.error(exc.getMessage()); - } - return null; - } - -} diff --git a/guest/tomcat-app/src/main/resources/logback.xml b/guest/tomcat-app/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/guest/tomcat-app/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/guest/webservices/rest-client/WebContent/META-INF/MANIFEST.MF b/guest/webservices/rest-client/WebContent/META-INF/MANIFEST.MF deleted file mode 100644 index 254272e1c0..0000000000 --- a/guest/webservices/rest-client/WebContent/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Class-Path: - diff --git a/guest/webservices/rest-client/pom.xml b/guest/webservices/rest-client/pom.xml deleted file mode 100644 index b05e435c4c..0000000000 --- a/guest/webservices/rest-client/pom.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - 4.0.0 - com.stackify - rest-client - 0.0.1-SNAPSHOT - rest-client - war - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - ../../../ - - - - - - maven-war-plugin - ${maven-war-plugin.version} - - WebContent - false - - - - - - \ No newline at end of file diff --git a/guest/webservices/rest-client/rest-client/.angular-cli.json b/guest/webservices/rest-client/rest-client/.angular-cli.json deleted file mode 100644 index 5d1839d374..0000000000 --- a/guest/webservices/rest-client/rest-client/.angular-cli.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "$schema": "./node_modules/@angular/cli/lib/config/schema.json", - "project": { - "name": "rest-client" - }, - "apps": [ - { - "root": "src", - "outDir": "dist", - "assets": [ - "assets", - "favicon.ico" - ], - "index": "index.html", - "main": "main.ts", - "polyfills": "polyfills.ts", - "test": "test.ts", - "tsconfig": "tsconfig.app.json", - "testTsconfig": "tsconfig.spec.json", - "prefix": "app", - "styles": [ - "styles.css" - ], - "scripts": [], - "environmentSource": "environments/environment.ts", - "environments": { - "dev": "environments/environment.ts", - "prod": "environments/environment.prod.ts" - } - } - ], - "e2e": { - "protractor": { - "config": "./protractor.conf.js" - } - }, - "lint": [ - { - "project": "src/tsconfig.app.json" - }, - { - "project": "src/tsconfig.spec.json" - }, - { - "project": "e2e/tsconfig.e2e.json" - } - ], - "test": { - "karma": { - "config": "./karma.conf.js" - } - }, - "defaults": { - "styleExt": "css", - "component": {} - } -} diff --git a/guest/webservices/rest-client/rest-client/.editorconfig b/guest/webservices/rest-client/rest-client/.editorconfig deleted file mode 100644 index 6e87a003da..0000000000 --- a/guest/webservices/rest-client/rest-client/.editorconfig +++ /dev/null @@ -1,13 +0,0 @@ -# Editor configuration, see http://editorconfig.org -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 2 -insert_final_newline = true -trim_trailing_whitespace = true - -[*.md] -max_line_length = off -trim_trailing_whitespace = false diff --git a/guest/webservices/rest-client/rest-client/.gitignore b/guest/webservices/rest-client/rest-client/.gitignore deleted file mode 100644 index 54bfd2001e..0000000000 --- a/guest/webservices/rest-client/rest-client/.gitignore +++ /dev/null @@ -1,42 +0,0 @@ -# See http://help.github.com/ignore-files/ for more about ignoring files. - -# compiled output -/dist -/tmp -/out-tsc - -# dependencies -/node_modules - -# IDEs and editors -/.idea -.project -.classpath -.c9/ -*.launch -.settings/ -*.sublime-workspace - -# IDE - VSCode -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json - -# misc -/.sass-cache -/connect.lock -/coverage -/libpeerconnection.log -npm-debug.log -testem.log -/typings - -# e2e -/e2e/*.js -/e2e/*.map - -# System Files -.DS_Store -Thumbs.db diff --git a/guest/webservices/rest-client/rest-client/README.md b/guest/webservices/rest-client/rest-client/README.md deleted file mode 100644 index b33d171f3c..0000000000 --- a/guest/webservices/rest-client/rest-client/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# RestClient - -This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.1.3. - -## Development server - -Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. - -## Code scaffolding - -Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|module`. - -## Build - -Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build. - -## Running unit tests - -Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). - -## Running end-to-end tests - -Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). -Before running the tests make sure you are serving the app via `ng serve`. - -## Further help - -To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). diff --git a/guest/webservices/rest-client/rest-client/e2e/app.e2e-spec.ts b/guest/webservices/rest-client/rest-client/e2e/app.e2e-spec.ts deleted file mode 100644 index 2eb6dade08..0000000000 --- a/guest/webservices/rest-client/rest-client/e2e/app.e2e-spec.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { RestClientPage } from './app.po'; - -describe('rest-client App', () => { - let page: RestClientPage; - - beforeEach(() => { - page = new RestClientPage(); - }); - - it('should display welcome message', () => { - page.navigateTo(); - expect(page.getParagraphText()).toEqual('Welcome to app!!'); - }); -}); diff --git a/guest/webservices/rest-client/rest-client/e2e/app.po.ts b/guest/webservices/rest-client/rest-client/e2e/app.po.ts deleted file mode 100644 index 1e111a7ff6..0000000000 --- a/guest/webservices/rest-client/rest-client/e2e/app.po.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { browser, by, element } from 'protractor'; - -export class RestClientPage { - navigateTo() { - return browser.get('/'); - } - - getParagraphText() { - return element(by.css('app-root h1')).getText(); - } -} diff --git a/guest/webservices/rest-client/rest-client/e2e/tsconfig.e2e.json b/guest/webservices/rest-client/rest-client/e2e/tsconfig.e2e.json deleted file mode 100644 index e2a9a2fc77..0000000000 --- a/guest/webservices/rest-client/rest-client/e2e/tsconfig.e2e.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "outDir": "../out-tsc/e2e", - "module": "commonjs", - "target": "es5", - "types": [ - "jasmine", - "node" - ] - } -} diff --git a/guest/webservices/rest-client/rest-client/karma.conf.js b/guest/webservices/rest-client/rest-client/karma.conf.js deleted file mode 100644 index 4d9ab9d948..0000000000 --- a/guest/webservices/rest-client/rest-client/karma.conf.js +++ /dev/null @@ -1,33 +0,0 @@ -// Karma configuration file, see link for more information -// https://karma-runner.github.io/0.13/config/configuration-file.html - -module.exports = function (config) { - config.set({ - basePath: '', - frameworks: ['jasmine', '@angular/cli'], - plugins: [ - require('karma-jasmine'), - require('karma-chrome-launcher'), - require('karma-jasmine-html-reporter'), - require('karma-coverage-istanbul-reporter'), - require('@angular/cli/plugins/karma') - ], - client:{ - clearContext: false // leave Jasmine Spec Runner output visible in browser - }, - coverageIstanbulReporter: { - reports: [ 'html', 'lcovonly' ], - fixWebpackSourcePaths: true - }, - angularCli: { - environment: 'dev' - }, - reporters: ['progress', 'kjhtml'], - port: 9876, - colors: true, - logLevel: config.LOG_INFO, - autoWatch: true, - browsers: ['Chrome'], - singleRun: false - }); -}; diff --git a/guest/webservices/rest-client/rest-client/package.json b/guest/webservices/rest-client/rest-client/package.json deleted file mode 100644 index b10090830c..0000000000 --- a/guest/webservices/rest-client/rest-client/package.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "name": "rest-client", - "version": "0.0.0", - "license": "MIT", - "scripts": { - "ng": "ng", - "start": "ng serve", - "build": "ng build", - "test": "ng test", - "lint": "ng lint", - "e2e": "ng e2e" - }, - "private": true, - "dependencies": { - "@angular/animations": "^4.0.0", - "@angular/common": "^4.0.0", - "@angular/compiler": "^4.0.0", - "@angular/core": "^4.0.0", - "@angular/forms": "^4.0.0", - "@angular/http": "^4.0.0", - "@angular/platform-browser": "^4.0.0", - "@angular/platform-browser-dynamic": "^4.0.0", - "@angular/router": "^4.0.0", - "core-js": "^2.4.1", - "rxjs": "^5.1.0", - "zone.js": "^0.8.4" - }, - "devDependencies": { - "@angular/cli": "1.1.3", - "@angular/compiler-cli": "^4.0.0", - "@angular/language-service": "^4.0.0", - "@types/jasmine": "2.5.45", - "@types/node": "~6.0.60", - "codelyzer": "~3.0.1", - "jasmine-core": "~2.6.2", - "jasmine-spec-reporter": "~4.1.0", - "karma": "~1.7.0", - "karma-chrome-launcher": "~2.1.1", - "karma-cli": "~1.0.1", - "karma-coverage-istanbul-reporter": "^1.2.1", - "karma-jasmine": "~1.1.0", - "karma-jasmine-html-reporter": "^0.2.2", - "protractor": "~5.1.2", - "ts-node": "~3.0.4", - "tslint": "~5.3.2", - "typescript": "~2.3.3" - } -} diff --git a/guest/webservices/rest-client/rest-client/protractor.conf.js b/guest/webservices/rest-client/rest-client/protractor.conf.js deleted file mode 100644 index 7ee3b5ee86..0000000000 --- a/guest/webservices/rest-client/rest-client/protractor.conf.js +++ /dev/null @@ -1,28 +0,0 @@ -// Protractor configuration file, see link for more information -// https://github.com/angular/protractor/blob/master/lib/config.ts - -const { SpecReporter } = require('jasmine-spec-reporter'); - -exports.config = { - allScriptsTimeout: 11000, - specs: [ - './e2e/**/*.e2e-spec.ts' - ], - capabilities: { - 'browserName': 'chrome' - }, - directConnect: true, - baseUrl: 'http://localhost:4200/', - framework: 'jasmine', - jasmineNodeOpts: { - showColors: true, - defaultTimeoutInterval: 30000, - print: function() {} - }, - onPrepare() { - require('ts-node').register({ - project: 'e2e/tsconfig.e2e.json' - }); - jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); - } -}; diff --git a/guest/webservices/rest-client/rest-client/src/app/app.component.css b/guest/webservices/rest-client/rest-client/src/app/app.component.css deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/guest/webservices/rest-client/rest-client/src/app/app.component.html b/guest/webservices/rest-client/rest-client/src/app/app.component.html deleted file mode 100644 index 94dc25088b..0000000000 --- a/guest/webservices/rest-client/rest-client/src/app/app.component.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - Angular QuickStart - - - - - - - loading users component - - \ No newline at end of file diff --git a/guest/webservices/rest-client/rest-client/src/app/app.component.spec.ts b/guest/webservices/rest-client/rest-client/src/app/app.component.spec.ts deleted file mode 100644 index 7d2799ceb6..0000000000 --- a/guest/webservices/rest-client/rest-client/src/app/app.component.spec.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; - -import { AppComponent } from './app.component'; - -describe('AppComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], - }).compileComponents(); - })); - - it('should create the app', async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.debugElement.componentInstance; - expect(app).toBeTruthy(); - })); - - it(`should have as title 'app'`, async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.debugElement.componentInstance; - expect(app.title).toEqual('app'); - })); - - it('should render title in a h1 tag', async(() => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!!'); - })); -}); diff --git a/guest/webservices/rest-client/rest-client/src/app/app.component.ts b/guest/webservices/rest-client/rest-client/src/app/app.component.ts deleted file mode 100644 index 7b0f672831..0000000000 --- a/guest/webservices/rest-client/rest-client/src/app/app.component.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Component } from '@angular/core'; - -@Component({ - selector: 'app-root', - templateUrl: './app.component.html', - styleUrls: ['./app.component.css'] -}) -export class AppComponent { - title = 'app'; -} diff --git a/guest/webservices/rest-client/rest-client/src/app/app.module.ts b/guest/webservices/rest-client/rest-client/src/app/app.module.ts deleted file mode 100644 index fe90536b1e..0000000000 --- a/guest/webservices/rest-client/rest-client/src/app/app.module.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { BrowserModule } from '@angular/platform-browser'; -import { NgModule } from '@angular/core'; -import { HttpModule } from '@angular/http'; -import { FormsModule } from '@angular/forms'; - -import { AppComponent } from './app.component'; -import { UsersComponent } from './users.component'; -import { RouterModule } from '@angular/router'; - -@NgModule({ - declarations: [ - AppComponent, - UsersComponent - ], - imports: [ - BrowserModule, - HttpModule, - FormsModule, - RouterModule.forRoot([ - { path: '', component: AppComponent }, - { path: 'users', component: UsersComponent }])], - providers: [], - bootstrap: [AppComponent] -}) -export class AppModule { } diff --git a/guest/webservices/rest-client/rest-client/src/app/app.service.ts b/guest/webservices/rest-client/rest-client/src/app/app.service.ts deleted file mode 100644 index cf57aecbc9..0000000000 --- a/guest/webservices/rest-client/rest-client/src/app/app.service.ts +++ /dev/null @@ -1,36 +0,0 @@ -import {Injectable} from '@angular/core'; -import { Http, Response, Headers, RequestOptions } from '@angular/http'; -import 'rxjs/add/operator/map'; - -export class User { - constructor( - public email: string, - public name: string) { } -} - -@Injectable() -export class UserService { - constructor( - private _http: Http){} - - url = 'http://localhost:8080/rest-server/users'; - - addUser(user){ - let headers = new Headers({'Content-Type': 'application/json'}); - let options = new RequestOptions({ headers: headers}); - - return this._http.post(this.url, JSON.stringify(user), options) - .map( - (_response: Response) => { - return _response; - }, - err => alert('Error adding user')); - } - - getUsers() { - return this._http.get(this.url) - .map((_response: Response) => { - return _response.json(); - }); - } -} \ No newline at end of file diff --git a/guest/webservices/rest-client/rest-client/src/app/users.component.html b/guest/webservices/rest-client/rest-client/src/app/users.component.html deleted file mode 100644 index bbf9289080..0000000000 --- a/guest/webservices/rest-client/rest-client/src/app/users.component.html +++ /dev/null @@ -1,15 +0,0 @@ -
-Email:
-Name:
- -
- -
- - - - - -
{{user.email}} -{{user.name}}
- diff --git a/guest/webservices/rest-client/rest-client/src/app/users.component.ts b/guest/webservices/rest-client/rest-client/src/app/users.component.ts deleted file mode 100644 index 6c5a383848..0000000000 --- a/guest/webservices/rest-client/rest-client/src/app/users.component.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { Component } from '@angular/core'; -import {UserService, User} from './app.service'; - -@Component({ - selector: 'users-page', - providers: [UserService], - templateUrl: './users.component.html', - styleUrls: ['./app.component.css'] -}) -export class UsersComponent { - title = 'Users'; - - constructor( - private _service:UserService){} - - public user = {email: "", name: ""}; - public res=[]; - - addUser() { - this._service.addUser(this.user) - .subscribe( () => this.getUsers()); - } - - getUsers() { - this._service.getUsers() - .subscribe( - users => { - this.res=[]; - users.forEach(usr => { - this.res.push( - new User( - usr.email, - usr.name - ) - ) - }); - }); - } -} diff --git a/guest/webservices/rest-client/rest-client/src/assets/.gitkeep b/guest/webservices/rest-client/rest-client/src/assets/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/guest/webservices/rest-client/rest-client/src/environments/environment.prod.ts b/guest/webservices/rest-client/rest-client/src/environments/environment.prod.ts deleted file mode 100644 index 3612073bc3..0000000000 --- a/guest/webservices/rest-client/rest-client/src/environments/environment.prod.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const environment = { - production: true -}; diff --git a/guest/webservices/rest-client/rest-client/src/environments/environment.ts b/guest/webservices/rest-client/rest-client/src/environments/environment.ts deleted file mode 100644 index b7f639aeca..0000000000 --- a/guest/webservices/rest-client/rest-client/src/environments/environment.ts +++ /dev/null @@ -1,8 +0,0 @@ -// The file contents for the current environment will overwrite these during build. -// The build system defaults to the dev environment which uses `environment.ts`, but if you do -// `ng build --env=prod` then `environment.prod.ts` will be used instead. -// The list of which env maps to which file can be found in `.angular-cli.json`. - -export const environment = { - production: false -}; diff --git a/guest/webservices/rest-client/rest-client/src/favicon.ico b/guest/webservices/rest-client/rest-client/src/favicon.ico deleted file mode 100644 index 8081c7ceaf2be08bf59010158c586170d9d2d517..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5430 zcmc(je{54#6vvCoAI3i*G5%$U7!sA3wtMZ$fH6V9C`=eXGJb@R1%(I_{vnZtpD{6n z5Pl{DmxzBDbrB>}`90e12m8T*36WoeDLA&SD_hw{H^wM!cl_RWcVA!I+x87ee975; z@4kD^=bYPn&pmG@(+JZ`rqQEKxW<}RzhW}I!|ulN=fmjVi@x{p$cC`)5$a!)X&U+blKNvN5tg=uLvuLnuqRM;Yc*swiexsoh#XPNu{9F#c`G zQLe{yWA(Y6(;>y|-efAy11k<09(@Oo1B2@0`PtZSkqK&${ zgEY}`W@t{%?9u5rF?}Y7OL{338l*JY#P!%MVQY@oqnItpZ}?s z!r?*kwuR{A@jg2Chlf0^{q*>8n5Ir~YWf*wmsh7B5&EpHfd5@xVaj&gqsdui^spyL zB|kUoblGoO7G(MuKTfa9?pGH0@QP^b#!lM1yHWLh*2iq#`C1TdrnO-d#?Oh@XV2HK zKA{`eo{--^K&MW66Lgsktfvn#cCAc*(}qsfhrvOjMGLE?`dHVipu1J3Kgr%g?cNa8 z)pkmC8DGH~fG+dlrp(5^-QBeEvkOvv#q7MBVLtm2oD^$lJZx--_=K&Ttd=-krx(Bb zcEoKJda@S!%%@`P-##$>*u%T*mh+QjV@)Qa=Mk1?#zLk+M4tIt%}wagT{5J%!tXAE;r{@=bb%nNVxvI+C+$t?!VJ@0d@HIyMJTI{vEw0Ul ze(ha!e&qANbTL1ZneNl45t=#Ot??C0MHjjgY8%*mGisN|S6%g3;Hlx#fMNcL<87MW zZ>6moo1YD?P!fJ#Jb(4)_cc50X5n0KoDYfdPoL^iV`k&o{LPyaoqMqk92wVM#_O0l z09$(A-D+gVIlq4TA&{1T@BsUH`Bm=r#l$Z51J-U&F32+hfUP-iLo=jg7Xmy+WLq6_tWv&`wDlz#`&)Jp~iQf zZP)tu>}pIIJKuw+$&t}GQuqMd%Z>0?t%&BM&Wo^4P^Y z)c6h^f2R>X8*}q|bblAF?@;%?2>$y+cMQbN{X$)^R>vtNq_5AB|0N5U*d^T?X9{xQnJYeU{ zoZL#obI;~Pp95f1`%X3D$Mh*4^?O?IT~7HqlWguezmg?Ybq|7>qQ(@pPHbE9V?f|( z+0xo!#m@Np9PljsyxBY-UA*{U*la#8Wz2sO|48_-5t8%_!n?S$zlGe+NA%?vmxjS- zHE5O3ZarU=X}$7>;Okp(UWXJxI%G_J-@IH;%5#Rt$(WUX?6*Ux!IRd$dLP6+SmPn= z8zjm4jGjN772R{FGkXwcNv8GBcZI#@Y2m{RNF_w8(Z%^A*!bS*!}s6sh*NnURytky humW;*g7R+&|Ledvc- - - - - RestClient - - - - - - - - - diff --git a/guest/webservices/rest-client/rest-client/src/main.ts b/guest/webservices/rest-client/rest-client/src/main.ts deleted file mode 100644 index a9ca1caf8c..0000000000 --- a/guest/webservices/rest-client/rest-client/src/main.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { enableProdMode } from '@angular/core'; -import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; - -import { AppModule } from './app/app.module'; -import { environment } from './environments/environment'; - -if (environment.production) { - enableProdMode(); -} - -platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/guest/webservices/rest-client/rest-client/src/polyfills.ts b/guest/webservices/rest-client/rest-client/src/polyfills.ts deleted file mode 100644 index fd01cc9f1d..0000000000 --- a/guest/webservices/rest-client/rest-client/src/polyfills.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * This file includes polyfills needed by Angular and is loaded before the app. - * You can add your own extra polyfills to this file. - * - * This file is divided into 2 sections: - * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. - * 2. Application imports. Files imported after ZoneJS that should be loaded before your main - * file. - * - * The current setup is for so-called "evergreen" browsers; the last versions of browsers that - * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), - * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. - * - * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html - */ - -/*************************************************************************************************** - * BROWSER POLYFILLS - */ - -/** IE9, IE10 and IE11 requires all of the following polyfills. **/ -// import 'core-js/es6/symbol'; -// import 'core-js/es6/object'; -// import 'core-js/es6/function'; -// import 'core-js/es6/parse-int'; -// import 'core-js/es6/parse-float'; -// import 'core-js/es6/number'; -// import 'core-js/es6/math'; -// import 'core-js/es6/string'; -// import 'core-js/es6/date'; -// import 'core-js/es6/array'; -// import 'core-js/es6/regexp'; -// import 'core-js/es6/map'; -// import 'core-js/es6/weak-map'; -// import 'core-js/es6/set'; - -/** IE10 and IE11 requires the following for NgClass support on SVG elements */ -// import 'classlist.js'; // Run `npm install --save classlist.js`. - -/** IE10 and IE11 requires the following to support `@angular/animation`. */ -// import 'web-animations-js'; // Run `npm install --save web-animations-js`. - - -/** Evergreen browsers require these. **/ -import 'core-js/es6/reflect'; -import 'core-js/es7/reflect'; - - -/** ALL Firefox browsers require the following to support `@angular/animation`. **/ -// import 'web-animations-js'; // Run `npm install --save web-animations-js`. - - - -/*************************************************************************************************** - * Zone JS is required by Angular itself. - */ -import 'zone.js/dist/zone'; // Included with Angular CLI. - - - -/*************************************************************************************************** - * APPLICATION IMPORTS - */ - -/** - * Date, currency, decimal and percent pipes. - * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10 - */ -// import 'intl'; // Run `npm install --save intl`. -/** - * Need to import at least one locale-data with intl. - */ -// import 'intl/locale-data/jsonp/en'; diff --git a/guest/webservices/rest-client/rest-client/src/styles.css b/guest/webservices/rest-client/rest-client/src/styles.css deleted file mode 100644 index 90d4ee0072..0000000000 --- a/guest/webservices/rest-client/rest-client/src/styles.css +++ /dev/null @@ -1 +0,0 @@ -/* You can add global styles to this file, and also import other style files */ diff --git a/guest/webservices/rest-client/rest-client/src/test.ts b/guest/webservices/rest-client/rest-client/src/test.ts deleted file mode 100644 index cd612eeb0e..0000000000 --- a/guest/webservices/rest-client/rest-client/src/test.ts +++ /dev/null @@ -1,32 +0,0 @@ -// This file is required by karma.conf.js and loads recursively all the .spec and framework files - -import 'zone.js/dist/long-stack-trace-zone'; -import 'zone.js/dist/proxy.js'; -import 'zone.js/dist/sync-test'; -import 'zone.js/dist/jasmine-patch'; -import 'zone.js/dist/async-test'; -import 'zone.js/dist/fake-async-test'; -import { getTestBed } from '@angular/core/testing'; -import { - BrowserDynamicTestingModule, - platformBrowserDynamicTesting -} from '@angular/platform-browser-dynamic/testing'; - -// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. -declare const __karma__: any; -declare const require: any; - -// Prevent Karma from running prematurely. -__karma__.loaded = function () {}; - -// First, initialize the Angular testing environment. -getTestBed().initTestEnvironment( - BrowserDynamicTestingModule, - platformBrowserDynamicTesting() -); -// Then we find all the tests. -const context = require.context('./', true, /\.spec\.ts$/); -// And load the modules. -context.keys().map(context); -// Finally, start Karma to run the tests. -__karma__.start(); diff --git a/guest/webservices/rest-client/rest-client/src/tsconfig.app.json b/guest/webservices/rest-client/rest-client/src/tsconfig.app.json deleted file mode 100644 index 5e2507db58..0000000000 --- a/guest/webservices/rest-client/rest-client/src/tsconfig.app.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "outDir": "../out-tsc/app", - "module": "es2015", - "baseUrl": "", - "types": [] - }, - "exclude": [ - "test.ts", - "**/*.spec.ts" - ] -} diff --git a/guest/webservices/rest-client/rest-client/src/tsconfig.spec.json b/guest/webservices/rest-client/rest-client/src/tsconfig.spec.json deleted file mode 100644 index 510e3f1fda..0000000000 --- a/guest/webservices/rest-client/rest-client/src/tsconfig.spec.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "outDir": "../out-tsc/spec", - "module": "commonjs", - "target": "es5", - "baseUrl": "", - "types": [ - "jasmine", - "node" - ] - }, - "files": [ - "test.ts" - ], - "include": [ - "**/*.spec.ts", - "**/*.d.ts" - ] -} diff --git a/guest/webservices/rest-client/rest-client/src/typings.d.ts b/guest/webservices/rest-client/rest-client/src/typings.d.ts deleted file mode 100644 index ef5c7bd620..0000000000 --- a/guest/webservices/rest-client/rest-client/src/typings.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -/* SystemJS module definition */ -declare var module: NodeModule; -interface NodeModule { - id: string; -} diff --git a/guest/webservices/rest-client/rest-client/tsconfig.json b/guest/webservices/rest-client/rest-client/tsconfig.json deleted file mode 100644 index a35a8ee3a4..0000000000 --- a/guest/webservices/rest-client/rest-client/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compileOnSave": false, - "compilerOptions": { - "outDir": "./dist/out-tsc", - "baseUrl": "src", - "sourceMap": true, - "declaration": false, - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "target": "es5", - "typeRoots": [ - "node_modules/@types" - ], - "lib": [ - "es2016", - "dom" - ] - } -} diff --git a/guest/webservices/rest-client/rest-client/tslint.json b/guest/webservices/rest-client/rest-client/tslint.json deleted file mode 100644 index dd117b3871..0000000000 --- a/guest/webservices/rest-client/rest-client/tslint.json +++ /dev/null @@ -1,135 +0,0 @@ -{ - "rulesDirectory": [ - "node_modules/codelyzer" - ], - "rules": { - "arrow-return-shorthand": true, - "callable-types": true, - "class-name": true, - "comment-format": [ - true, - "check-space" - ], - "curly": true, - "eofline": true, - "forin": true, - "import-blacklist": [ - true, - "rxjs" - ], - "import-spacing": true, - "indent": [ - true, - "spaces" - ], - "interface-over-type-literal": true, - "label-position": true, - "max-line-length": [ - true, - 140 - ], - "member-access": false, - "member-ordering": [ - true, - "static-before-instance", - "variables-before-functions" - ], - "no-arg": true, - "no-bitwise": true, - "no-console": [ - true, - "debug", - "info", - "time", - "timeEnd", - "trace" - ], - "no-construct": true, - "no-debugger": true, - "no-duplicate-super": true, - "no-empty": false, - "no-empty-interface": true, - "no-eval": true, - "no-inferrable-types": [ - true, - "ignore-params" - ], - "no-misused-new": true, - "no-non-null-assertion": true, - "no-shadowed-variable": true, - "no-string-literal": false, - "no-string-throw": true, - "no-switch-case-fall-through": true, - "no-trailing-whitespace": true, - "no-unnecessary-initializer": true, - "no-unused-expression": true, - "no-use-before-declare": true, - "no-var-keyword": true, - "object-literal-sort-keys": false, - "one-line": [ - true, - "check-open-brace", - "check-catch", - "check-else", - "check-whitespace" - ], - "prefer-const": true, - "quotemark": [ - true, - "single" - ], - "radix": true, - "semicolon": [ - "always" - ], - "triple-equals": [ - true, - "allow-null-check" - ], - "typedef-whitespace": [ - true, - { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - } - ], - "typeof-compare": true, - "unified-signatures": true, - "variable-name": false, - "whitespace": [ - true, - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type" - ], - "directive-selector": [ - true, - "attribute", - "app", - "camelCase" - ], - "component-selector": [ - true, - "element", - "app", - "kebab-case" - ], - "use-input-property-decorator": true, - "use-output-property-decorator": true, - "use-host-property-decorator": true, - "no-input-rename": true, - "no-output-rename": true, - "use-life-cycle-interface": true, - "use-pipe-transform-interface": true, - "component-class-suffix": true, - "directive-class-suffix": true, - "no-access-missing-member": true, - "templates-use-public": true, - "invoke-injectable": true - } -} diff --git a/guest/webservices/rest-server/WebContent/META-INF/MANIFEST.MF b/guest/webservices/rest-server/WebContent/META-INF/MANIFEST.MF deleted file mode 100644 index 254272e1c0..0000000000 --- a/guest/webservices/rest-server/WebContent/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Class-Path: - diff --git a/guest/webservices/rest-server/WebContent/WEB-INF/web.xml b/guest/webservices/rest-server/WebContent/WEB-INF/web.xml deleted file mode 100644 index 46b173c59a..0000000000 --- a/guest/webservices/rest-server/WebContent/WEB-INF/web.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - rest-server - - rest-server - org.glassfish.jersey.servlet.ServletContainer - - javax.ws.rs.Application - com.stackify.ApplicationInitializer - - 1 - - - rest-server - /* - - \ No newline at end of file diff --git a/guest/webservices/rest-server/pom.xml b/guest/webservices/rest-server/pom.xml deleted file mode 100644 index ca81979b1e..0000000000 --- a/guest/webservices/rest-server/pom.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - 4.0.0 - com.stackify - rest-server - 0.0.1-SNAPSHOT - rest-server - war - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - ../../../ - - - - - org.glassfish.jersey.containers - jersey-container-servlet - ${jersey-container-servlet.version} - - - org.glassfish.jersey.media - jersey-media-moxy - ${jersey-media-moxy.version} - - - io.rest-assured - rest-assured - ${rest-assured.version} - - - - - - - maven-war-plugin - ${maven-war-plugin.version} - - WebContent - - - - - - - 2.25.1 - 3.0.3 - 2.25.1 - - - \ No newline at end of file diff --git a/guest/webservices/rest-server/src/main/java/com/stackify/ApplicationInitializer.java b/guest/webservices/rest-server/src/main/java/com/stackify/ApplicationInitializer.java deleted file mode 100644 index 6d864e859e..0000000000 --- a/guest/webservices/rest-server/src/main/java/com/stackify/ApplicationInitializer.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.stackify; - -import org.glassfish.jersey.server.ResourceConfig; - -public class ApplicationInitializer extends ResourceConfig { - public ApplicationInitializer() { - packages("com.stackify.services"); - } -} diff --git a/guest/webservices/rest-server/src/main/java/com/stackify/models/User.java b/guest/webservices/rest-server/src/main/java/com/stackify/models/User.java deleted file mode 100644 index 8c8073357d..0000000000 --- a/guest/webservices/rest-server/src/main/java/com/stackify/models/User.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.stackify.models; - -import javax.ws.rs.core.Link; - -public class User { - private String email; - private String name; - private Link link; - - public User() { - } - - public User(String email, String name) { - super(); - this.email = email; - this.name = name; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Link getLink() { - return link; - } - - public void setLink(Link link) { - this.link = link; - } - -} diff --git a/guest/webservices/rest-server/src/main/java/com/stackify/services/CorsFilter.java b/guest/webservices/rest-server/src/main/java/com/stackify/services/CorsFilter.java deleted file mode 100644 index 267aa6fd61..0000000000 --- a/guest/webservices/rest-server/src/main/java/com/stackify/services/CorsFilter.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.stackify.services; - -import java.io.IOException; - -import javax.ws.rs.container.ContainerRequestContext; -import javax.ws.rs.container.ContainerResponseContext; -import javax.ws.rs.container.ContainerResponseFilter; -import javax.ws.rs.ext.Provider; - -@Provider -public class CorsFilter implements ContainerResponseFilter { - - @Override - public void filter(final ContainerRequestContext requestContext, - final ContainerResponseContext response) throws IOException { - response.getHeaders().add("Access-Control-Allow-Origin", "*"); - response.getHeaders().add("Access-Control-Allow-Headers", "origin, content-type, accept"); - } -} diff --git a/guest/webservices/rest-server/src/main/java/com/stackify/services/UserService.java b/guest/webservices/rest-server/src/main/java/com/stackify/services/UserService.java deleted file mode 100644 index e78ed4627a..0000000000 --- a/guest/webservices/rest-server/src/main/java/com/stackify/services/UserService.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.stackify.services; - -import java.util.ArrayList; -import java.util.List; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import com.stackify.models.User; - -@Path("/users") -public class UserService { - private static List users = new ArrayList<>(); - - @POST - @Consumes(MediaType.APPLICATION_JSON) - public Response addUser(User user) { - users.add(user); - return Response.ok() - .build(); - } - - @GET - @Produces(MediaType.APPLICATION_JSON) - public List getUsers() { - return users; - } -} diff --git a/guest/webservices/rest-server/src/main/resources/logback.xml b/guest/webservices/rest-server/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/guest/webservices/rest-server/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/guest/webservices/rest-server/src/test/java/com/stackify/services/UserServiceLiveTest.java b/guest/webservices/rest-server/src/test/java/com/stackify/services/UserServiceLiveTest.java deleted file mode 100644 index be3992b7f7..0000000000 --- a/guest/webservices/rest-server/src/test/java/com/stackify/services/UserServiceLiveTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.stackify.services; - -import org.junit.Test; - -import io.restassured.RestAssured; -import static io.restassured.RestAssured.*; -import static org.hamcrest.CoreMatchers.*; - -public class UserServiceLiveTest { - @Test - public void whenAddUser_thenGetUserOk() { - RestAssured.baseURI = "http://localhost:8080/rest-server"; - - //@formatter:off - - String json = "{\"email\":\"john@gmail.com\",\"name\":\"John\"}"; - given() - .contentType("application/json") - .body(json) - .when() - .post("/users") - .then() - .statusCode(200); - - when() - .get("/users") - .then() - .contentType("application/json") - .body("name", hasItem("John")) - .body("email", hasItem("john@gmail.com")); - - //@formatter:on - } -} diff --git a/guest/webservices/soap_client/src/main/java/com/stackify/JAXWSClient.java b/guest/webservices/soap_client/src/main/java/com/stackify/JAXWSClient.java deleted file mode 100644 index 5542fbde20..0000000000 --- a/guest/webservices/soap_client/src/main/java/com/stackify/JAXWSClient.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.stackify; - -import com.stackify.services.DefaultUserImplService; -import com.stackify.services.User; -import com.stackify.services.UserService; -import com.stackify.services.Users; - -public class JAXWSClient { - public static void main(String[] args) { - DefaultUserImplService service = new DefaultUserImplService(); - User user = new User(); - user.setEmail("john@gmail.com"); - user.setName("John"); - UserService port = service.getDefaultUserImplPort(); - port.addUser(user); - Users users = port.getUsers(); - System.out.println(users.getUsers().iterator().next().getName()); - } -} diff --git a/guest/webservices/soap_client/src/main/java/com/stackify/services/DefaultUserImplService.java b/guest/webservices/soap_client/src/main/java/com/stackify/services/DefaultUserImplService.java deleted file mode 100644 index 821b969166..0000000000 --- a/guest/webservices/soap_client/src/main/java/com/stackify/services/DefaultUserImplService.java +++ /dev/null @@ -1,94 +0,0 @@ - -package com.stackify.services; - -import java.net.MalformedURLException; -import java.net.URL; -import javax.xml.namespace.QName; -import javax.xml.ws.Service; -import javax.xml.ws.WebEndpoint; -import javax.xml.ws.WebServiceClient; -import javax.xml.ws.WebServiceException; -import javax.xml.ws.WebServiceFeature; - - -/** - * This class was generated by the JAX-WS RI. - * JAX-WS RI 2.2.9-b130926.1035 - * Generated source version: 2.2 - * - */ -@WebServiceClient(name = "DefaultUserImplService", targetNamespace = "http://services.stackify.com/", wsdlLocation = "http://localhost:8080/users?wsdl") -public class DefaultUserImplService - extends Service -{ - - private final static URL DEFAULTUSERIMPLSERVICE_WSDL_LOCATION; - private final static WebServiceException DEFAULTUSERIMPLSERVICE_EXCEPTION; - private final static QName DEFAULTUSERIMPLSERVICE_QNAME = new QName("http://services.stackify.com/", "DefaultUserImplService"); - - static { - URL url = null; - WebServiceException e = null; - try { - url = new URL("http://localhost:8080/users?wsdl"); - } catch (MalformedURLException ex) { - e = new WebServiceException(ex); - } - DEFAULTUSERIMPLSERVICE_WSDL_LOCATION = url; - DEFAULTUSERIMPLSERVICE_EXCEPTION = e; - } - - public DefaultUserImplService() { - super(__getWsdlLocation(), DEFAULTUSERIMPLSERVICE_QNAME); - } - - public DefaultUserImplService(WebServiceFeature... features) { - super(__getWsdlLocation(), DEFAULTUSERIMPLSERVICE_QNAME, features); - } - - public DefaultUserImplService(URL wsdlLocation) { - super(wsdlLocation, DEFAULTUSERIMPLSERVICE_QNAME); - } - - public DefaultUserImplService(URL wsdlLocation, WebServiceFeature... features) { - super(wsdlLocation, DEFAULTUSERIMPLSERVICE_QNAME, features); - } - - public DefaultUserImplService(URL wsdlLocation, QName serviceName) { - super(wsdlLocation, serviceName); - } - - public DefaultUserImplService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) { - super(wsdlLocation, serviceName, features); - } - - /** - * - * @return - * returns UserService - */ - @WebEndpoint(name = "DefaultUserImplPort") - public UserService getDefaultUserImplPort() { - return super.getPort(new QName("http://services.stackify.com/", "DefaultUserImplPort"), UserService.class); - } - - /** - * - * @param features - * A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the features parameter will have their default values. - * @return - * returns UserService - */ - @WebEndpoint(name = "DefaultUserImplPort") - public UserService getDefaultUserImplPort(WebServiceFeature... features) { - return super.getPort(new QName("http://services.stackify.com/", "DefaultUserImplPort"), UserService.class, features); - } - - private static URL __getWsdlLocation() { - if (DEFAULTUSERIMPLSERVICE_EXCEPTION!= null) { - throw DEFAULTUSERIMPLSERVICE_EXCEPTION; - } - return DEFAULTUSERIMPLSERVICE_WSDL_LOCATION; - } - -} diff --git a/guest/webservices/soap_client/src/main/java/com/stackify/services/ObjectFactory.java b/guest/webservices/soap_client/src/main/java/com/stackify/services/ObjectFactory.java deleted file mode 100644 index d992521d9f..0000000000 --- a/guest/webservices/soap_client/src/main/java/com/stackify/services/ObjectFactory.java +++ /dev/null @@ -1,48 +0,0 @@ - -package com.stackify.services; - -import javax.xml.bind.annotation.XmlRegistry; - - -/** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the com.stackify.services package. - *

An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are - * provided in this class. - * - */ -@XmlRegistry -public class ObjectFactory { - - - /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.stackify.services - * - */ - public ObjectFactory() { - } - - /** - * Create an instance of {@link User } - * - */ - public User createUser() { - return new User(); - } - - /** - * Create an instance of {@link Users } - * - */ - public Users createUsers() { - return new Users(); - } - -} diff --git a/guest/webservices/soap_client/src/main/java/com/stackify/services/User.java b/guest/webservices/soap_client/src/main/java/com/stackify/services/User.java deleted file mode 100644 index d9d517f83d..0000000000 --- a/guest/webservices/soap_client/src/main/java/com/stackify/services/User.java +++ /dev/null @@ -1,87 +0,0 @@ - -package com.stackify.services; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for user complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="user">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="email" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="name" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "user", propOrder = { - "email", - "name" -}) -public class User { - - protected String email; - protected String name; - - /** - * Gets the value of the email property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getEmail() { - return email; - } - - /** - * Sets the value of the email property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setEmail(String value) { - this.email = value; - } - - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } - - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } - -} diff --git a/guest/webservices/soap_client/src/main/java/com/stackify/services/UserService.java b/guest/webservices/soap_client/src/main/java/com/stackify/services/UserService.java deleted file mode 100644 index 87ab1f2f75..0000000000 --- a/guest/webservices/soap_client/src/main/java/com/stackify/services/UserService.java +++ /dev/null @@ -1,47 +0,0 @@ - -package com.stackify.services; - -import javax.jws.WebMethod; -import javax.jws.WebParam; -import javax.jws.WebResult; -import javax.jws.WebService; -import javax.jws.soap.SOAPBinding; -import javax.xml.bind.annotation.XmlSeeAlso; -import javax.xml.ws.Action; - - -/** - * This class was generated by the JAX-WS RI. - * JAX-WS RI 2.2.9-b130926.1035 - * Generated source version: 2.2 - * - */ -@WebService(name = "UserService", targetNamespace = "http://services.stackify.com/") -@SOAPBinding(style = SOAPBinding.Style.RPC) -@XmlSeeAlso({ - ObjectFactory.class -}) -public interface UserService { - - - /** - * - * @param arg0 - */ - @WebMethod - @Action(input = "http://services.stackify.com/UserService/addUserRequest", output = "http://services.stackify.com/UserService/addUserResponse") - public void addUser( - @WebParam(name = "arg0", partName = "arg0") - User arg0); - - /** - * - * @return - * returns com.stackify.services.Users - */ - @WebMethod - @WebResult(partName = "return") - @Action(input = "http://services.stackify.com/UserService/getUsersRequest", output = "http://services.stackify.com/UserService/getUsersResponse") - public Users getUsers(); - -} diff --git a/guest/webservices/soap_client/src/main/java/com/stackify/services/Users.java b/guest/webservices/soap_client/src/main/java/com/stackify/services/Users.java deleted file mode 100644 index bde0e47b11..0000000000 --- a/guest/webservices/soap_client/src/main/java/com/stackify/services/Users.java +++ /dev/null @@ -1,69 +0,0 @@ - -package com.stackify.services; - -import java.util.ArrayList; -import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for users complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="users">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="users" type="{http://services.stackify.com/}user" maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "users", propOrder = { - "users" -}) -public class Users { - - @XmlElement(nillable = true) - protected List users; - - /** - * Gets the value of the users property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the users property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getUsers().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link User } - * - * - */ - public List getUsers() { - if (users == null) { - users = new ArrayList(); - } - return this.users; - } - -} diff --git a/guest/webservices/soap_client/src/main/java/com/stackify/services/package-info.java b/guest/webservices/soap_client/src/main/java/com/stackify/services/package-info.java deleted file mode 100644 index af6d2bc25e..0000000000 --- a/guest/webservices/soap_client/src/main/java/com/stackify/services/package-info.java +++ /dev/null @@ -1,2 +0,0 @@ -@javax.xml.bind.annotation.XmlSchema(namespace = "http://services.stackify.com/") -package com.stackify.services; diff --git a/guest/webservices/soap_client/src/main/resources/logback.xml b/guest/webservices/soap_client/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/guest/webservices/soap_client/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/guest/webservices/soap_example/src/main/java/com/stackify/ServicePublisher.java b/guest/webservices/soap_example/src/main/java/com/stackify/ServicePublisher.java deleted file mode 100644 index 3a10b6e285..0000000000 --- a/guest/webservices/soap_example/src/main/java/com/stackify/ServicePublisher.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.stackify; - -import javax.xml.ws.Endpoint; - -import com.stackify.services.DefaultUserImpl; - -public class ServicePublisher { - public static void main(String[] args) { - Endpoint.publish("http://localhost:8080/users", new DefaultUserImpl()); - } -} diff --git a/guest/webservices/soap_example/src/main/java/com/stackify/models/User.java b/guest/webservices/soap_example/src/main/java/com/stackify/models/User.java deleted file mode 100644 index 1a9741154d..0000000000 --- a/guest/webservices/soap_example/src/main/java/com/stackify/models/User.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.stackify.models; - -public class User { - private String email; - private String name; - - public User() { - } - - public User(String email, String name) { - super(); - this.email = email; - this.name = name; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - -} diff --git a/guest/webservices/soap_example/src/main/java/com/stackify/models/Users.java b/guest/webservices/soap_example/src/main/java/com/stackify/models/Users.java deleted file mode 100644 index 2323a74614..0000000000 --- a/guest/webservices/soap_example/src/main/java/com/stackify/models/Users.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.stackify.models; - -import java.util.List; - -public class Users { - List users; - - public List getUsers() { - return users; - } - - public void setUsers(List users) { - this.users = users; - } - -} diff --git a/guest/webservices/soap_example/src/main/java/com/stackify/services/DefaultUserImpl.java b/guest/webservices/soap_example/src/main/java/com/stackify/services/DefaultUserImpl.java deleted file mode 100644 index 87d7d646c1..0000000000 --- a/guest/webservices/soap_example/src/main/java/com/stackify/services/DefaultUserImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.stackify.services; - -import java.util.ArrayList; - -import javax.jws.WebService; - -import com.stackify.models.User; -import com.stackify.models.Users; - -@WebService(endpointInterface = "com.stackify.services.UserService") -public class DefaultUserImpl implements UserService { - - ArrayList usersList = new ArrayList<>(); - - @Override - public void addUser(User user) { - usersList.add(user); - } - - @Override - public Users getUsers() { - Users users = new Users(); - users.setUsers(usersList); - return users; - } - -} diff --git a/guest/webservices/soap_example/src/main/java/com/stackify/services/UserService.java b/guest/webservices/soap_example/src/main/java/com/stackify/services/UserService.java deleted file mode 100644 index 8c57fbd061..0000000000 --- a/guest/webservices/soap_example/src/main/java/com/stackify/services/UserService.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.stackify.services; - -import javax.jws.WebMethod; -import javax.jws.WebService; -import javax.jws.soap.SOAPBinding; - -import com.stackify.models.User; -import com.stackify.models.Users; - -@WebService -@SOAPBinding(style = SOAPBinding.Style.RPC) -public interface UserService { - - @WebMethod - public void addUser(User user); - - @WebMethod - public Users getUsers(); -} diff --git a/guest/webservices/soap_example/src/main/resources/logback.xml b/guest/webservices/soap_example/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/guest/webservices/soap_example/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/guest/webservices/spring-rest-service/WebContent/META-INF/MANIFEST.MF b/guest/webservices/spring-rest-service/WebContent/META-INF/MANIFEST.MF deleted file mode 100644 index 254272e1c0..0000000000 --- a/guest/webservices/spring-rest-service/WebContent/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Class-Path: - diff --git a/guest/webservices/spring-rest-service/pom.xml b/guest/webservices/spring-rest-service/pom.xml deleted file mode 100644 index 6243f09727..0000000000 --- a/guest/webservices/spring-rest-service/pom.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - 4.0.0 - com.stackify - spring-rest-service - 0.0.1-SNAPSHOT - spring-rest-service - war - - - org.springframework.boot - spring-boot-starter-parent - 1.5.4.RELEASE - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-hateoas - - - io.springfox - springfox-swagger2 - ${springfox-swagger2.version} - - - io.springfox - springfox-swagger-ui - ${springfox-swagger-ui.version} - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - UTF-8 - UTF-8 - 1.8 - 2.7.0 - 2.7.0 - - - \ No newline at end of file diff --git a/guest/webservices/spring-rest-service/src/main/java/com/stackify/Application.java b/guest/webservices/spring-rest-service/src/main/java/com/stackify/Application.java deleted file mode 100644 index b45ed8094f..0000000000 --- a/guest/webservices/spring-rest-service/src/main/java/com/stackify/Application.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.stackify; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } -} diff --git a/guest/webservices/spring-rest-service/src/main/java/com/stackify/config/SwaggerConfig.java b/guest/webservices/spring-rest-service/src/main/java/com/stackify/config/SwaggerConfig.java deleted file mode 100644 index 0e9567b452..0000000000 --- a/guest/webservices/spring-rest-service/src/main/java/com/stackify/config/SwaggerConfig.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.stackify.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@Configuration -@EnableSwagger2 -public class SwaggerConfig { - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2).select() - .apis(RequestHandlerSelectors.basePackage("com.stackify.controllers")) - .paths(PathSelectors.any()) - .build(); - } -} diff --git a/guest/webservices/spring-rest-service/src/main/java/com/stackify/controllers/UserController.java b/guest/webservices/spring-rest-service/src/main/java/com/stackify/controllers/UserController.java deleted file mode 100644 index 361dbde38d..0000000000 --- a/guest/webservices/spring-rest-service/src/main/java/com/stackify/controllers/UserController.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.stackify.controllers; - -import java.util.ArrayList; -import java.util.List; - -import org.springframework.hateoas.Link; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - -import com.stackify.models.User; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; - -@RestController -public class UserController { - - private static List users = new ArrayList<>(); - - @PostMapping(value = "/users", consumes = MediaType.APPLICATION_JSON_VALUE) - @ResponseStatus(HttpStatus.CREATED) - public void addUser(@RequestBody User user) { - users.add(user); - } - - @GetMapping("/users") - public List getUsers() { - users.forEach(user -> { - Link selfLink = linkTo(methodOn(UserController.class).getUsers()).slash(user.getEmail()) - .withSelfRel(); - user.getLinks().clear(); - user.add(selfLink); - }); - return users; - } - - @GetMapping("/users/{email}") - public User getUser(@PathVariable String email) { - User us = users.stream() - .filter(user -> !user.getEmail() - .equals(email)) - .findAny() - .orElse(null); - return us; - } - -} diff --git a/guest/webservices/spring-rest-service/src/main/java/com/stackify/models/User.java b/guest/webservices/spring-rest-service/src/main/java/com/stackify/models/User.java deleted file mode 100644 index b52e7f0f87..0000000000 --- a/guest/webservices/spring-rest-service/src/main/java/com/stackify/models/User.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.stackify.models; - -import org.springframework.hateoas.ResourceSupport; - -public class User extends ResourceSupport { - private String email; - private String name; - - public User() { - } - - public User(String email, String name) { - super(); - this.email = email; - this.name = name; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - -} diff --git a/guest/webservices/spring-rest-service/src/main/resources/logback.xml b/guest/webservices/spring-rest-service/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/guest/webservices/spring-rest-service/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file