├── README.md ├── .gitignore ├── WEB-JAVA-5 - Secure API using JWT ├── settings.gradle ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── org │ │ │ └── generation │ │ │ └── jwt │ │ │ ├── service │ │ │ ├── CourseService.java │ │ │ └── CourseServiceImpl.java │ │ │ ├── controller │ │ │ ├── dto │ │ │ │ ├── Token.java │ │ │ │ └── LoginDto.java │ │ │ ├── CourseController.java │ │ │ └── AuthController.java │ │ │ ├── model │ │ │ └── Course.java │ │ │ ├── JwtApplication.java │ │ │ └── config │ │ │ └── JwtFilter.java │ └── test │ │ └── java │ │ └── org │ │ └── generation │ │ └── jwt │ │ └── JwtApplicationTests.java ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── build.gradle ├── README.md ├── gradlew.bat └── gradlew ├── WEB-JAVA-4 - REST API with Spring Boot ├── settings.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── src │ ├── test │ │ └── java │ │ │ └── org │ │ │ └── generation │ │ │ └── Students │ │ │ └── StudentsApplicationTests.java │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── org │ │ └── generation │ │ └── Students │ │ ├── data │ │ ├── StudentsRepository.java │ │ └── entity │ │ │ └── Student.java │ │ ├── service │ │ ├── StudentService.java │ │ └── StudentServiceMySQL.java │ │ └── StudentsApplication.java ├── build.gradle ├── README.md ├── gradlew.bat └── gradlew ├── WEB-JAVA-3 - Spring Data JPA ├── jpa-mysql-sample │ ├── settings.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ └── application.properties │ │ │ └── java │ │ │ │ └── org │ │ │ │ └── generation │ │ │ │ └── jpamysqlsample │ │ │ │ ├── repository │ │ │ │ └── UserRepository.java │ │ │ │ ├── service │ │ │ │ ├── UserService.java │ │ │ │ └── UserServiceImpl.java │ │ │ │ ├── JpaMysqlSampleApplication.java │ │ │ │ ├── model │ │ │ │ └── User.java │ │ │ │ └── controller │ │ │ │ └── UserController.java │ │ └── test │ │ │ └── java │ │ │ └── org │ │ │ └── generation │ │ │ └── jpamysqlsample │ │ │ └── JpaMysqlSampleApplicationTests.java │ ├── build.gradle │ ├── gradlew.bat │ ├── README.md │ └── gradlew └── README.md ├── WEB-JAVA-6 - Unit Testing Web Components ├── Math Application │ ├── build │ │ ├── test-results │ │ │ └── test │ │ │ │ ├── binary │ │ │ │ ├── output.bin.idx │ │ │ │ └── results.bin │ │ │ │ └── TEST-MathApplicationTest.xml │ │ └── classes │ │ │ └── java │ │ │ ├── test │ │ │ ├── CalculatorTest.class │ │ │ ├── MathApplicationTest.class │ │ │ └── CalculatorTest$Calculator.class │ │ │ └── main │ │ │ ├── MathApplication.class │ │ │ └── CalculatorService.class │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── build.gradle │ └── gradlew ├── Portfolio_Mockito_Exercise │ ├── settings.gradle │ ├── src │ │ ├── main │ │ │ └── java │ │ │ │ ├── StockService.java │ │ │ │ ├── Stock.java │ │ │ │ └── Portfolio.java │ │ └── test │ │ │ └── java │ │ │ └── PortfolioTester.java │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── build │ │ └── classes │ │ │ └── java │ │ │ ├── main │ │ │ ├── Stock.class │ │ │ ├── Portfolio.class │ │ │ └── StockService.class │ │ │ └── test │ │ │ └── PortfolioTester.class │ ├── mockito_test_proj.properties │ ├── build.gradle │ ├── pom.xml │ ├── gradlew.bat │ ├── gradlew │ └── mockito_test_proj.xml └── README.md ├── WEB-JAVA-2 - Dependencies Injection using Spring Framework ├── DependenciesInjection │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ └── application.properties │ │ │ └── java │ │ │ │ └── org │ │ │ │ └── generation │ │ │ │ └── dependencies_injection │ │ │ │ ├── service │ │ │ │ └── StudentService.java │ │ │ │ ├── DependenciesInjectionApplication.java │ │ │ │ ├── controller │ │ │ │ └── StudentController.java │ │ │ │ └── model │ │ │ │ └── Student.java │ │ └── test │ │ │ └── java │ │ │ └── org │ │ │ └── generation │ │ │ └── dependencies_injection │ │ │ └── DependenciesInjectionApplicationTests.java │ ├── settings.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── build.gradle │ ├── gradlew.bat │ └── gradlew ├── UserServiceApplicaiton │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ └── application.properties │ │ │ └── java │ │ │ │ └── org │ │ │ │ └── generation │ │ │ │ └── MyFirstWebApp │ │ │ │ ├── service │ │ │ │ ├── UserService.java │ │ │ │ ├── UserServiceMap.java │ │ │ │ └── UserServiceArrayList.java │ │ │ │ ├── UserServiceApplication.java │ │ │ │ ├── model │ │ │ │ └── User.java │ │ │ │ └── controller │ │ │ │ └── UserController.java │ │ └── test │ │ │ └── java │ │ │ └── org │ │ │ └── generation │ │ │ └── MyFirstWebApp │ │ │ └── UserServiceApplicationTests.java │ ├── settings.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── build.gradle │ ├── gradlew.bat │ └── gradlew └── README.md ├── java-web final project ├── Todo app image.png └── README.md ├── WEB-JAVA-1 - Introduction to Web Development using Java and Spring Boot └── README.md └── WEB-JAVA-7 - Web Applications Build and Deploy ├── Docker Class Exercise ├── Dockerfile ├── Application.java └── README.md └── README.md /README.md: -------------------------------------------------------------------------------- 1 | # WEB-JAVA 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.gradle 2 | .gradle/ 3 | .idea/ 4 | build/ -------------------------------------------------------------------------------- /WEB-JAVA-5 - Secure API using JWT/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'jwt' 2 | -------------------------------------------------------------------------------- /WEB-JAVA-5 - Secure API using JWT/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /WEB-JAVA-4 - REST API with Spring Boot/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'Students' 2 | -------------------------------------------------------------------------------- /WEB-JAVA-3 - Spring Data JPA/jpa-mysql-sample/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'jpa-mysql-sample' 2 | -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Math Application/build/test-results/test/binary/output.bin.idx: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/DependenciesInjection/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/UserServiceApplicaiton/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Portfolio_Mockito_Exercise/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'Mockito Test Proj' 2 | 3 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/UserServiceApplicaiton/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'MyFirstWebApp' 2 | -------------------------------------------------------------------------------- /java-web final project/Todo app image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/generation-org/WEB-JAVA/HEAD/java-web final project/Todo app image.png -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/DependenciesInjection/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'dependencies_injection' 2 | -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Portfolio_Mockito_Exercise/src/main/java/StockService.java: -------------------------------------------------------------------------------- 1 | public interface StockService { 2 | public double getPrice(Stock stock); 3 | } -------------------------------------------------------------------------------- /WEB-JAVA-5 - Secure API using JWT/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/generation-org/WEB-JAVA/HEAD/WEB-JAVA-5 - Secure API using JWT/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /WEB-JAVA-4 - REST API with Spring Boot/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/generation-org/WEB-JAVA/HEAD/WEB-JAVA-4 - REST API with Spring Boot/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /WEB-JAVA-3 - Spring Data JPA/jpa-mysql-sample/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/generation-org/WEB-JAVA/HEAD/WEB-JAVA-3 - Spring Data JPA/jpa-mysql-sample/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Math Application/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/generation-org/WEB-JAVA/HEAD/WEB-JAVA-6 - Unit Testing Web Components/Math Application/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Math Application/build/classes/java/test/CalculatorTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/generation-org/WEB-JAVA/HEAD/WEB-JAVA-6 - Unit Testing Web Components/Math Application/build/classes/java/test/CalculatorTest.class -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Math Application/build/test-results/test/binary/results.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/generation-org/WEB-JAVA/HEAD/WEB-JAVA-6 - Unit Testing Web Components/Math Application/build/test-results/test/binary/results.bin -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Portfolio_Mockito_Exercise/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/generation-org/WEB-JAVA/HEAD/WEB-JAVA-6 - Unit Testing Web Components/Portfolio_Mockito_Exercise/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Math Application/build/classes/java/main/MathApplication.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/generation-org/WEB-JAVA/HEAD/WEB-JAVA-6 - Unit Testing Web Components/Math Application/build/classes/java/main/MathApplication.class -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Portfolio_Mockito_Exercise/build/classes/java/main/Stock.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/generation-org/WEB-JAVA/HEAD/WEB-JAVA-6 - Unit Testing Web Components/Portfolio_Mockito_Exercise/build/classes/java/main/Stock.class -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Math Application/build/classes/java/main/CalculatorService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/generation-org/WEB-JAVA/HEAD/WEB-JAVA-6 - Unit Testing Web Components/Math Application/build/classes/java/main/CalculatorService.class -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Math Application/build/classes/java/test/MathApplicationTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/generation-org/WEB-JAVA/HEAD/WEB-JAVA-6 - Unit Testing Web Components/Math Application/build/classes/java/test/MathApplicationTest.class -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Portfolio_Mockito_Exercise/build/classes/java/main/Portfolio.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/generation-org/WEB-JAVA/HEAD/WEB-JAVA-6 - Unit Testing Web Components/Portfolio_Mockito_Exercise/build/classes/java/main/Portfolio.class -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Portfolio_Mockito_Exercise/build/classes/java/main/StockService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/generation-org/WEB-JAVA/HEAD/WEB-JAVA-6 - Unit Testing Web Components/Portfolio_Mockito_Exercise/build/classes/java/main/StockService.class -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/DependenciesInjection/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/generation-org/WEB-JAVA/HEAD/WEB-JAVA-2 - Dependencies Injection using Spring Framework/DependenciesInjection/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Math Application/build/classes/java/test/CalculatorTest$Calculator.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/generation-org/WEB-JAVA/HEAD/WEB-JAVA-6 - Unit Testing Web Components/Math Application/build/classes/java/test/CalculatorTest$Calculator.class -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Portfolio_Mockito_Exercise/build/classes/java/test/PortfolioTester.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/generation-org/WEB-JAVA/HEAD/WEB-JAVA-6 - Unit Testing Web Components/Portfolio_Mockito_Exercise/build/classes/java/test/PortfolioTester.class -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/UserServiceApplicaiton/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/generation-org/WEB-JAVA/HEAD/WEB-JAVA-2 - Dependencies Injection using Spring Framework/UserServiceApplicaiton/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /WEB-JAVA-4 - REST API with Spring Boot/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /WEB-JAVA-3 - Spring Data JPA/jpa-mysql-sample/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.jpa.hibernate.ddl-auto=none 2 | spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/db_example 3 | spring.datasource.username=springuser 4 | spring.datasource.password=ThePassword 5 | spring.jpa.show-sql=true 6 | -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Math Application/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /WEB-JAVA-5 - Secure API using JWT/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Mar 17 10:39:36 COT 2020 2 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-all.zip 3 | distributionBase=GRADLE_USER_HOME 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Portfolio_Mockito_Exercise/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/DependenciesInjection/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /WEB-JAVA-3 - Spring Data JPA/jpa-mysql-sample/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Mar 05 17:14:07 COT 2020 2 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip 3 | distributionBase=GRADLE_USER_HOME 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/UserServiceApplicaiton/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /WEB-JAVA-5 - Secure API using JWT/src/test/java/org/generation/jwt/JwtApplicationTests.java: -------------------------------------------------------------------------------- 1 | package org.generation.jwt; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class JwtApplicationTests 8 | { 9 | 10 | @Test 11 | void contextLoads() 12 | { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Portfolio_Mockito_Exercise/mockito_test_proj.properties: -------------------------------------------------------------------------------- 1 | path.variable.kotlin_bundled=/Applications/IntelliJ IDEA CE.app/Contents/plugins/Kotlin/kotlinc 2 | path.variable.maven_repository=/Users/debbie/.m2/repository 3 | jdk.home.10=/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home 4 | javac2.instrumentation.includeJavaRuntime=false -------------------------------------------------------------------------------- /WEB-JAVA-4 - REST API with Spring Boot/src/test/java/org/generation/Students/StudentsApplicationTests.java: -------------------------------------------------------------------------------- 1 | package org.generation.Students; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class StudentsApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /WEB-JAVA-5 - Secure API using JWT/src/main/java/org/generation/jwt/service/CourseService.java: -------------------------------------------------------------------------------- 1 | package org.generation.jwt.service; 2 | 3 | import org.generation.jwt.model.Course; 4 | 5 | import java.util.List; 6 | 7 | public interface CourseService 8 | { 9 | 10 | List all(); 11 | 12 | void save( Course course ); 13 | 14 | void delete( String courseId ); 15 | } 16 | -------------------------------------------------------------------------------- /WEB-JAVA-3 - Spring Data JPA/jpa-mysql-sample/src/main/java/org/generation/jpamysqlsample/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package org.generation.jpamysqlsample.repository; 2 | 3 | import org.generation.jpamysqlsample.model.User; 4 | import org.springframework.data.repository.CrudRepository; 5 | 6 | public interface UserRepository 7 | extends CrudRepository 8 | { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /WEB-JAVA-3 - Spring Data JPA/jpa-mysql-sample/src/main/java/org/generation/jpamysqlsample/service/UserService.java: -------------------------------------------------------------------------------- 1 | package org.generation.jpamysqlsample.service; 2 | 3 | 4 | import org.generation.jpamysqlsample.model.User; 5 | 6 | public interface UserService 7 | { 8 | 9 | User getUser( String id ); 10 | 11 | User save( User user ); 12 | 13 | void delete( String id ); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /WEB-JAVA-3 - Spring Data JPA/jpa-mysql-sample/src/test/java/org/generation/jpamysqlsample/JpaMysqlSampleApplicationTests.java: -------------------------------------------------------------------------------- 1 | package org.generation.jpamysqlsample; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class JpaMysqlSampleApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /WEB-JAVA-4 - REST API with Spring Boot/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.jpa.hibernate.ddl-auto=none 2 | spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/db_example 3 | spring.datasource.username=root 4 | spring.datasource.password=1q2w3e4r@2020 5 | spring.jpa.show-sql=true 6 | spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl 7 | -------------------------------------------------------------------------------- /WEB-JAVA-4 - REST API with Spring Boot/src/main/java/org/generation/Students/data/StudentsRepository.java: -------------------------------------------------------------------------------- 1 | package org.generation.Students.data; 2 | 3 | import org.generation.Students.data.entity.Student; 4 | import org.springframework.data.repository.CrudRepository; 5 | 6 | public interface StudentsRepository 7 | extends CrudRepository 8 | { 9 | 10 | Student findById( int id ); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /WEB-JAVA-1 - Introduction to Web Development using Java and Spring Boot /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # WEB-JAVA-1 - Introduction to Web Development using Java and Spring Boot 4 | 5 | 6 |
7 |
8 | 9 | 10 | ## Part 1: 11 | -------------------------------------------------------------------------------- /WEB-JAVA-7 - Web Applications Build and Deploy/Docker Class Exercise/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM gradle:6.2.0-jdk8 as builder 2 | VOLUME /tmp 3 | RUN mkdir /work 4 | COPY . /work 5 | WORKDIR /work 6 | RUN gradle build 7 | RUN mv /work/build/libs/*.jar /work/app.jar 8 | FROM openjdk:8-jdk-alpine 9 | COPY --from=builder /work/app.jar /work/app.jar 10 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/work/app.jar"] 11 | -------------------------------------------------------------------------------- /WEB-JAVA-4 - REST API with Spring Boot/src/main/java/org/generation/Students/service/StudentService.java: -------------------------------------------------------------------------------- 1 | package org.generation.Students.service; 2 | 3 | import org.generation.Students.data.entity.Student; 4 | 5 | public interface StudentService 6 | { 7 | 8 | Iterable all(); 9 | 10 | Student get( int studentId ); 11 | 12 | void save( Student student ); 13 | 14 | void delete( int studentId ); 15 | } 16 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/UserServiceApplicaiton/src/test/java/org/generation/MyFirstWebApp/UserServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package org.generation.MyFirstWebApp; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class UserServiceApplicationTests 8 | { 9 | 10 | @Test 11 | void contextLoads() { 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /WEB-JAVA-5 - Secure API using JWT/src/main/java/org/generation/jwt/controller/dto/Token.java: -------------------------------------------------------------------------------- 1 | package org.generation.jwt.controller.dto; 2 | 3 | public class Token 4 | { 5 | 6 | private final String accessToken; 7 | 8 | public Token( String accessToken ) 9 | { 10 | this.accessToken = accessToken; 11 | } 12 | 13 | public String getAccessToken() 14 | { 15 | return accessToken; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Math Application/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | } 4 | 5 | group 'org.example' 6 | version '1.0-SNAPSHOT' 7 | 8 | sourceCompatibility = 1.8 9 | 10 | repositories { 11 | mavenCentral() 12 | } 13 | 14 | dependencies { 15 | testCompile group: 'junit', name: 'junit', version: '4.12' 16 | testCompile group: 'org.mockito', name: 'mockito-core', version: '2.23.4' 17 | } 18 | -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Portfolio_Mockito_Exercise/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | } 4 | 5 | group 'org.example' 6 | version '1.0-SNAPSHOT' 7 | 8 | sourceCompatibility = 1.8 9 | 10 | repositories { 11 | mavenCentral() 12 | } 13 | 14 | dependencies { 15 | testCompile group: 'junit', name: 'junit', version: '4.12' 16 | testCompile group: 'org.mockito', name: 'mockito-core', version: '2.23.4' 17 | } 18 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/DependenciesInjection/src/test/java/org/generation/dependencies_injection/DependenciesInjectionApplicationTests.java: -------------------------------------------------------------------------------- 1 | package org.generation.dependencies_injection; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class DependenciesInjectionApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /WEB-JAVA-3 - Spring Data JPA/jpa-mysql-sample/src/main/java/org/generation/jpamysqlsample/JpaMysqlSampleApplication.java: -------------------------------------------------------------------------------- 1 | package org.generation.jpamysqlsample; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class JpaMysqlSampleApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(JpaMysqlSampleApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/UserServiceApplicaiton/src/main/java/org/generation/MyFirstWebApp/service/UserService.java: -------------------------------------------------------------------------------- 1 | package org.generation.MyFirstWebApp.service; 2 | 3 | import org.generation.MyFirstWebApp.model.User; 4 | 5 | import java.util.List; 6 | 7 | public interface UserService 8 | { 9 | List getAll(); 10 | 11 | void add(User user); 12 | 13 | void remove(User user); 14 | 15 | int size(); 16 | 17 | User getUser(int position); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/DependenciesInjection/src/main/java/org/generation/dependencies_injection/service/StudentService.java: -------------------------------------------------------------------------------- 1 | package org.generation.dependencies_injection.service; 2 | 3 | import org.generation.dependencies_injection.model.Student; 4 | 5 | import java.util.List; 6 | 7 | public interface StudentService 8 | { 9 | void add( Student student ); 10 | 11 | void delete( Student student ); 12 | 13 | List all(); 14 | 15 | Student findById( String id ); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/UserServiceApplicaiton/src/main/java/org/generation/MyFirstWebApp/UserServiceApplication.java: -------------------------------------------------------------------------------- 1 | package org.generation.MyFirstWebApp; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class UserServiceApplication 8 | { 9 | 10 | public static void main(String[] args) { 11 | SpringApplication.run( UserServiceApplication.class, args); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/DependenciesInjection/src/main/java/org/generation/dependencies_injection/DependenciesInjectionApplication.java: -------------------------------------------------------------------------------- 1 | package org.generation.dependencies_injection; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DependenciesInjectionApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(DependenciesInjectionApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /WEB-JAVA-5 - Secure API using JWT/src/main/java/org/generation/jwt/controller/dto/LoginDto.java: -------------------------------------------------------------------------------- 1 | package org.generation.jwt.controller.dto; 2 | 3 | public class LoginDto 4 | { 5 | 6 | private final String username; 7 | 8 | private final String password; 9 | 10 | public LoginDto( String username, String password ) 11 | { 12 | this.username = username; 13 | this.password = password; 14 | } 15 | 16 | public String getUsername() 17 | { 18 | return username; 19 | } 20 | 21 | public String getPassword() 22 | { 23 | return password; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /java-web final project/README.md: -------------------------------------------------------------------------------- 1 | # Welcome to the assessment for the JAVA-WEB module 2 | 3 | In this assessment you will build a Spring MVC Todo management web application using Spring Boot, Spring MVC, Spring Security, JSP, JPA and MySQL as a database. 4 | 5 | Don't worry if some of those concepts are unfamiliar to you, you will be given ample information to complete the assessment. 6 | 7 | ![todo app preview](https://github.com/generation-org/WEB-JAVA/blob/master/java-web%20final%20project/Todo%20app%20image.png) 8 | 9 | (Link to tutorial)[https://www.javaguides.net/2018/09/mini-todo-management-project-using-spring-boot-springmvc-springsecurity-jsp-hibernate-mysql.html] 10 | -------------------------------------------------------------------------------- /WEB-JAVA-7 - Web Applications Build and Deploy/Docker Class Exercise/Application.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @SpringBootApplication 9 | @RestController 10 | public class Application { 11 | 12 | @RequestMapping("/") 13 | public String home() { 14 | return "Hello Docker World"; 15 | } 16 | 17 | public static void main(String[] args) { 18 | SpringApplication.run(Application.class, args); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/DependenciesInjection/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.2.5.RELEASE' 3 | id 'io.spring.dependency-management' version '1.0.9.RELEASE' 4 | id 'java' 5 | } 6 | 7 | group = 'org.generation' 8 | version = '0.0.1-SNAPSHOT' 9 | sourceCompatibility = '1.8' 10 | 11 | repositories { 12 | mavenCentral() 13 | } 14 | 15 | dependencies { 16 | implementation 'org.springframework.boot:spring-boot-starter-web' 17 | testImplementation('org.springframework.boot:spring-boot-starter-test') { 18 | exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' 19 | } 20 | } 21 | 22 | test { 23 | useJUnitPlatform() 24 | } 25 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/UserServiceApplicaiton/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.2.5.RELEASE' 3 | id 'io.spring.dependency-management' version '1.0.9.RELEASE' 4 | id 'java' 5 | } 6 | 7 | group = 'org.generation' 8 | version = '0.0.1-SNAPSHOT' 9 | sourceCompatibility = '1.8' 10 | 11 | repositories { 12 | mavenCentral() 13 | } 14 | 15 | dependencies { 16 | implementation 'org.springframework.boot:spring-boot-starter-web' 17 | testImplementation('org.springframework.boot:spring-boot-starter-test') { 18 | exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' 19 | } 20 | } 21 | 22 | test { 23 | useJUnitPlatform() 24 | } 25 | -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Portfolio_Mockito_Exercise/src/main/java/Stock.java: -------------------------------------------------------------------------------- 1 | public class Stock { 2 | private String stockId; 3 | private String name; 4 | private int quantity; 5 | 6 | public Stock(String stockId, String name, int quantity){ 7 | this.stockId = stockId; 8 | this.name = name; 9 | this.quantity = quantity; 10 | } 11 | 12 | public String getStockId() { 13 | return stockId; 14 | } 15 | 16 | public void setStockId(String stockId) { 17 | this.stockId = stockId; 18 | } 19 | 20 | public int getQuantity() { 21 | return quantity; 22 | } 23 | 24 | public String getTicker() { 25 | return name; 26 | } 27 | } -------------------------------------------------------------------------------- /WEB-JAVA-5 - Secure API using JWT/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.2.5.RELEASE' 3 | id 'io.spring.dependency-management' version '1.0.9.RELEASE' 4 | id 'java' 5 | } 6 | 7 | group = 'org.generation' 8 | version = '0.0.1-SNAPSHOT' 9 | sourceCompatibility = '1.8' 10 | 11 | repositories { 12 | mavenCentral() 13 | } 14 | 15 | dependencies { 16 | implementation 'org.springframework.boot:spring-boot-starter-web' 17 | implementation 'io.jsonwebtoken:jjwt:0.9.1' 18 | testImplementation('org.springframework.boot:spring-boot-starter-test') { 19 | exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' 20 | } 21 | } 22 | 23 | test { 24 | useJUnitPlatform() 25 | } 26 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/UserServiceApplicaiton/src/main/java/org/generation/MyFirstWebApp/model/User.java: -------------------------------------------------------------------------------- 1 | package org.generation.MyFirstWebApp.model; 2 | 3 | public class User 4 | { 5 | private final int id; 6 | 7 | private final String name; 8 | 9 | private final String lastName; 10 | 11 | public User( int id, String name, String lastName ) 12 | { 13 | this.id = id; 14 | this.name = name; 15 | this.lastName = lastName; 16 | } 17 | 18 | public int getId() 19 | { 20 | return id; 21 | } 22 | 23 | public String getName() 24 | { 25 | return name; 26 | } 27 | 28 | public String getLastName() 29 | { 30 | return lastName; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /WEB-JAVA-4 - REST API with Spring Boot/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.2.5.RELEASE' 3 | id 'io.spring.dependency-management' version '1.0.9.RELEASE' 4 | id 'java' 5 | } 6 | 7 | group = 'org.generation' 8 | version = '0.0.1-SNAPSHOT' 9 | sourceCompatibility = '1.8' 10 | 11 | repositories { 12 | mavenCentral() 13 | } 14 | 15 | dependencies { 16 | implementation 'org.springframework.boot:spring-boot-starter-web' 17 | implementation 'org.springframework.boot:spring-boot-starter-data-jpa' 18 | runtimeOnly 'mysql:mysql-connector-java' 19 | testImplementation('org.springframework.boot:spring-boot-starter-test') { 20 | exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' 21 | } 22 | } 23 | 24 | test { 25 | useJUnitPlatform() 26 | } 27 | -------------------------------------------------------------------------------- /WEB-JAVA-3 - Spring Data JPA/jpa-mysql-sample/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.2.5.RELEASE' 3 | id 'io.spring.dependency-management' version '1.0.9.RELEASE' 4 | id 'java' 5 | } 6 | 7 | group = 'org.generation' 8 | version = '0.0.1-SNAPSHOT' 9 | sourceCompatibility = '1.8' 10 | 11 | repositories { 12 | mavenCentral() 13 | } 14 | 15 | dependencies { 16 | implementation 'org.springframework.boot:spring-boot-starter-web' 17 | implementation 'org.springframework.boot:spring-boot-starter-data-jpa' 18 | runtimeOnly 'mysql:mysql-connector-java' 19 | testImplementation('org.springframework.boot:spring-boot-starter-test') { 20 | exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' 21 | } 22 | } 23 | 24 | test { 25 | useJUnitPlatform() 26 | } 27 | -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Portfolio_Mockito_Exercise/src/main/java/Portfolio.java: -------------------------------------------------------------------------------- 1 | import java.util.List; 2 | 3 | public class Portfolio { 4 | private StockService stockService; 5 | private List stocks; 6 | 7 | public StockService getStockService() { 8 | return stockService; 9 | } 10 | 11 | public void setStockService(StockService stockService) { 12 | this.stockService = stockService; 13 | } 14 | 15 | public List getStocks() { 16 | return stocks; 17 | } 18 | 19 | public void setStocks(List stocks) { 20 | this.stocks = stocks; 21 | } 22 | 23 | public double getMarketValue(){ 24 | double marketValue = 0.0; 25 | 26 | for(Stock stock:stocks){ 27 | marketValue += stockService.getPrice(stock) * stock.getQuantity(); 28 | } 29 | return marketValue; 30 | } 31 | } -------------------------------------------------------------------------------- /WEB-JAVA-5 - Secure API using JWT/src/main/java/org/generation/jwt/model/Course.java: -------------------------------------------------------------------------------- 1 | package org.generation.jwt.model; 2 | 3 | public class Course 4 | { 5 | 6 | final String id; 7 | 8 | final String name; 9 | 10 | final String objectives; 11 | 12 | 13 | public Course( String id, String name, String objectives ) 14 | { 15 | this.id = id; 16 | this.name = name; 17 | this.objectives = objectives; 18 | } 19 | 20 | public String getId() 21 | { 22 | return id; 23 | } 24 | 25 | public String getName() 26 | { 27 | return name; 28 | } 29 | 30 | public String getObjectives() 31 | { 32 | return objectives; 33 | } 34 | 35 | @Override 36 | public String toString() 37 | { 38 | return "Course{" + "id='" + id + '\'' + ", name='" + name + '\'' + ", objectives='" + objectives + '\'' + '}'; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Portfolio_Mockito_Exercise/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 1.0.0 5 | MockitoExample 6 | 0.0.1 7 | 8 | 9 | org.mockito 10 | mockito-core 11 | 2.23.0 12 | test 13 | 14 | 15 | junit 16 | junit 17 | 4.12 18 | test 19 | 20 | 21 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/UserServiceApplicaiton/src/main/java/org/generation/MyFirstWebApp/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package org.generation.MyFirstWebApp.controller; 2 | 3 | import org.generation.MyFirstWebApp.model.User; 4 | import org.generation.MyFirstWebApp.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | @RestController 10 | public class UserController 11 | { 12 | final UserService userService; 13 | 14 | public UserController( @Autowired UserService userService ) 15 | { 16 | this.userService = userService; 17 | userService.add( new User( 1, "Santiago", "Carrillo" ) ); 18 | } 19 | 20 | @GetMapping( "/user" ) 21 | public User getUser() 22 | { 23 | return userService.getUser( 0 ); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /WEB-JAVA-5 - Secure API using JWT/src/main/java/org/generation/jwt/controller/CourseController.java: -------------------------------------------------------------------------------- 1 | package org.generation.jwt.controller; 2 | 3 | 4 | import org.generation.jwt.model.Course; 5 | import org.generation.jwt.service.CourseService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.CrossOrigin; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | import java.util.List; 12 | 13 | @RestController 14 | public class CourseController 15 | { 16 | 17 | private final CourseService courseService; 18 | 19 | public CourseController( @Autowired CourseService courseService ) 20 | { 21 | this.courseService = courseService; 22 | } 23 | 24 | @CrossOrigin( "*" ) 25 | @GetMapping( "/api/courses" ) 26 | public List all() 27 | { 28 | return courseService.all(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /WEB-JAVA-5 - Secure API using JWT/src/main/java/org/generation/jwt/JwtApplication.java: -------------------------------------------------------------------------------- 1 | package org.generation.jwt; 2 | 3 | import org.generation.jwt.config.JwtFilter; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.web.servlet.FilterRegistrationBean; 7 | import org.springframework.context.annotation.Bean; 8 | 9 | @SpringBootApplication 10 | public class JwtApplication 11 | { 12 | 13 | public static void main( String[] args ) 14 | { 15 | SpringApplication.run( JwtApplication.class, args ); 16 | } 17 | 18 | @Bean 19 | public FilterRegistrationBean jwtFilter() 20 | { 21 | FilterRegistrationBean registrationBean = new FilterRegistrationBean<>(); 22 | registrationBean.setFilter( new JwtFilter() ); 23 | registrationBean.addUrlPatterns( "/api/*" ); 24 | return registrationBean; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/DependenciesInjection/src/main/java/org/generation/dependencies_injection/controller/StudentController.java: -------------------------------------------------------------------------------- 1 | package org.generation.dependencies_injection.controller; 2 | 3 | import org.generation.dependencies_injection.model.Student; 4 | import org.generation.dependencies_injection.service.StudentService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | @RestController 11 | public class StudentController 12 | { 13 | 14 | private final StudentService studentService; 15 | 16 | public StudentController( @Autowired StudentService studentService ) 17 | { 18 | this.studentService = studentService; 19 | } 20 | 21 | @GetMapping( "/student/{id}" ) 22 | Student findById( @PathVariable( "id" ) String id ) 23 | { 24 | return studentService.findById( id ); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /WEB-JAVA-3 - Spring Data JPA/jpa-mysql-sample/src/main/java/org/generation/jpamysqlsample/model/User.java: -------------------------------------------------------------------------------- 1 | package org.generation.jpamysqlsample.model; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.Id; 7 | 8 | 9 | @Entity(name = "Users") 10 | public class User 11 | { 12 | @Id 13 | @GeneratedValue 14 | private String id; 15 | 16 | private String name; 17 | 18 | @Column(name = "last_name") 19 | private String lastName; 20 | 21 | private String email; 22 | 23 | public User() 24 | { 25 | } 26 | 27 | public User( String name, String id ) 28 | { 29 | this.name = name; 30 | this.id = id; 31 | } 32 | 33 | public String getName() 34 | { 35 | return name; 36 | } 37 | 38 | public void setName( String name ) 39 | { 40 | this.name = name; 41 | } 42 | 43 | public String getId() 44 | { 45 | return id; 46 | } 47 | 48 | public void setId( String id ) 49 | { 50 | this.id = id; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /WEB-JAVA-3 - Spring Data JPA/jpa-mysql-sample/src/main/java/org/generation/jpamysqlsample/service/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.generation.jpamysqlsample.service; 2 | 3 | import org.generation.jpamysqlsample.model.User; 4 | import org.generation.jpamysqlsample.repository.UserRepository; 5 | import org.springframework.stereotype.Service; 6 | 7 | import java.util.Optional; 8 | 9 | 10 | @Service 11 | public class UserServiceImpl 12 | implements UserService 13 | { 14 | 15 | private final UserRepository userRepository; 16 | 17 | public UserServiceImpl( UserRepository userRepository ) 18 | { 19 | this.userRepository = userRepository; 20 | } 21 | 22 | @Override 23 | public User getUser( String id ) 24 | { 25 | Optional user = userRepository.findById( id ); 26 | return user.orElse( null ); 27 | } 28 | 29 | @Override 30 | public User save( User user ) 31 | { 32 | return userRepository.save( user ); 33 | } 34 | 35 | @Override 36 | public void delete( String id ) 37 | { 38 | userRepository.deleteById( id ); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/UserServiceApplicaiton/src/main/java/org/generation/MyFirstWebApp/service/UserServiceMap.java: -------------------------------------------------------------------------------- 1 | package org.generation.MyFirstWebApp.service; 2 | 3 | import org.generation.MyFirstWebApp.model.User; 4 | 5 | import java.util.HashMap; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | public class UserServiceMap 10 | implements UserService 11 | { 12 | final Map userMap = new HashMap<>(); 13 | 14 | @Override 15 | public List getAll() 16 | { 17 | //TODO implement this method 18 | return null; 19 | } 20 | 21 | @Override 22 | public void add( User user ) 23 | { 24 | //TODO implement this method 25 | } 26 | 27 | @Override 28 | public void remove( User user ) 29 | { 30 | //TODO implement this method 31 | } 32 | 33 | @Override 34 | public int size() 35 | { 36 | //TODO implement this method 37 | return 0; 38 | } 39 | 40 | @Override 41 | public User getUser( int position ) 42 | { 43 | //TODO implement this method 44 | return null; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/UserServiceApplicaiton/src/main/java/org/generation/MyFirstWebApp/service/UserServiceArrayList.java: -------------------------------------------------------------------------------- 1 | package org.generation.MyFirstWebApp.service; 2 | 3 | import org.generation.MyFirstWebApp.model.User; 4 | import org.springframework.stereotype.Service; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | @Service 10 | public class UserServiceArrayList 11 | implements UserService 12 | { 13 | 14 | private final List userList = new ArrayList<>(); 15 | 16 | public UserServiceArrayList() 17 | { 18 | 19 | } 20 | 21 | @Override 22 | public List getAll() 23 | { 24 | return userList; 25 | } 26 | 27 | @Override 28 | public void add( User user ) 29 | { 30 | userList.add( user ); 31 | } 32 | 33 | @Override 34 | public void remove( User user ) 35 | { 36 | userList.remove( user ); 37 | } 38 | 39 | @Override 40 | public int size() 41 | { 42 | return userList.size(); 43 | } 44 | 45 | @Override 46 | public User getUser( int position ) 47 | { 48 | return userList.get( position ); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /WEB-JAVA-4 - REST API with Spring Boot/src/main/java/org/generation/Students/data/entity/Student.java: -------------------------------------------------------------------------------- 1 | package org.generation.Students.data.entity; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.Id; 7 | import java.util.Date; 8 | 9 | @Entity( name = "Students" ) 10 | public class Student 11 | { 12 | 13 | @Id 14 | @GeneratedValue 15 | @Column( name = "idStudents" ) 16 | private int id; 17 | 18 | private String name; 19 | 20 | private String email; 21 | 22 | private String address; 23 | 24 | @Column( name = "birth_date" ) 25 | private Date birthDate; 26 | 27 | 28 | public Student() 29 | { 30 | } 31 | 32 | public Student( String name, String email, Date birthDate ) 33 | { 34 | this.name = name; 35 | this.email = email; 36 | this.birthDate = birthDate; 37 | } 38 | 39 | @Override 40 | public String toString() 41 | { 42 | return "Student{" + "id=" + id + ", name='" + name + '\'' + ", email='" + email + '\'' 43 | + ", address='" + address + '\'' + ", birthDate=" + birthDate + '}'; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /WEB-JAVA-4 - REST API with Spring Boot/src/main/java/org/generation/Students/service/StudentServiceMySQL.java: -------------------------------------------------------------------------------- 1 | package org.generation.Students.service; 2 | 3 | import org.generation.Students.data.StudentsRepository; 4 | import org.generation.Students.data.entity.Student; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | @Service 9 | public class StudentServiceMySQL 10 | implements StudentService 11 | { 12 | 13 | private final StudentsRepository studentsRepository; 14 | 15 | public StudentServiceMySQL( @Autowired StudentsRepository studentsRepository ) 16 | { 17 | this.studentsRepository = studentsRepository; 18 | } 19 | 20 | @Override 21 | public Iterable all() 22 | { 23 | return studentsRepository.findAll(); 24 | } 25 | 26 | @Override 27 | public Student get( int studentId ) 28 | { 29 | return studentsRepository.findById( studentId ); 30 | } 31 | 32 | @Override 33 | public void save( Student student ) 34 | { 35 | studentsRepository.save( student ); 36 | } 37 | 38 | @Override 39 | public void delete( int studentId ) 40 | { 41 | studentsRepository.deleteById( studentId ); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /WEB-JAVA-7 - Web Applications Build and Deploy/README.md: -------------------------------------------------------------------------------- 1 | # WEB-JAVA-7 - Web Applications Build and Deploy 2 | 3 | ## Practice Exercise 4 | Deploy the git repo: https://github.com/generation-org/spring-boot. 5 | 6 | Now that we have a working database for users, we want to store and be able to retrieve more information about people. 7 | The program should take in initials for a person and their age. 8 | You should also be able to lookup and retrieve the initials and age of a person. 9 | 10 | Make sure to write unit tests! 11 | 12 | Once you have tested your application, it is time to deploy. 13 | 1. Build a docker image. 14 | The Dockerfile will not have changed from: 15 | ``` 16 | FROM gradle:6.2.0-jdk8 as builder 17 | VOLUME /tmp 18 | RUN mkdir /work 19 | COPY . /work 20 | WORKDIR /work 21 | RUN gradle build 22 | RUN mv /work/build/libs/*.jar /work/app.jar 23 | FROM openjdk:8-jdk-alpine 24 | COPY --from=builder /work/app.jar /work/app.jar 25 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/work/app.jar"] 26 | ``` 27 | 2. Deploy on heroku using the following commands. Replace `${YOUR_APP_NAME}` with the name of your application. 28 | 29 | ``` 30 | heroku login 31 | heroku container:login 32 | heroku apps:create ${YOUR_APP_NAME} 33 | heroku container:push web --app ${YOUR_APP_NAME} 34 | heroku container:release web --app ${YOUR_APP_NAME} 35 | ``` 36 | 37 | Go to the heroku dashboard and see your hosted site! 38 | -------------------------------------------------------------------------------- /WEB-JAVA-5 - Secure API using JWT/src/main/java/org/generation/jwt/controller/AuthController.java: -------------------------------------------------------------------------------- 1 | package org.generation.jwt.controller; 2 | 3 | 4 | import io.jsonwebtoken.Jwts; 5 | import io.jsonwebtoken.SignatureAlgorithm; 6 | import org.generation.jwt.controller.dto.LoginDto; 7 | import org.generation.jwt.controller.dto.Token; 8 | import org.springframework.web.bind.annotation.PostMapping; 9 | import org.springframework.web.bind.annotation.RequestBody; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | import javax.servlet.ServletException; 13 | import java.util.Calendar; 14 | import java.util.Date; 15 | 16 | @RestController 17 | public class AuthController 18 | { 19 | 20 | @PostMapping( "/auth" ) 21 | public Token auth( @RequestBody LoginDto loginDto ) 22 | throws ServletException 23 | { 24 | if ( loginDto.getUsername().equals( "user@mail.com" ) && loginDto.getPassword().equals( "password" ) ) 25 | { 26 | return new Token( generateToken( loginDto.getUsername() ) ); 27 | } 28 | throw new ServletException( "Invalid login. Please check your email and password." ); 29 | } 30 | 31 | private String generateToken( String email ) 32 | { 33 | 34 | Calendar calendar = Calendar.getInstance(); 35 | calendar.add( Calendar.HOUR, 10 ); 36 | String secret = "this-secret-is-not-very-secret-99"; 37 | return Jwts.builder().setSubject( email ).claim( "role", "user" ).setIssuedAt( new Date() ).setExpiration( 38 | calendar.getTime() ).signWith( SignatureAlgorithm.HS256, secret ).compact(); 39 | } 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Portfolio_Mockito_Exercise/src/test/java/PortfolioTester.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | import java.util.List; 3 | 4 | import static org.mockito.Mockito.*; 5 | 6 | public class PortfolioTester { 7 | 8 | Portfolio portfolio; 9 | StockService stockService; 10 | 11 | 12 | public static void main(String[] args){ 13 | PortfolioTester tester = new PortfolioTester(); 14 | tester.setUp(); 15 | System.out.println(tester.testMarketValue()?"pass":"fail"); 16 | } 17 | 18 | public void setUp(){ 19 | //Create a portfolio object which is to be tested 20 | portfolio = new Portfolio(); 21 | 22 | //Create the mock object of stock service 23 | stockService = mock(StockService.class); 24 | 25 | //set the stockService to the portfolio 26 | portfolio.setStockService(stockService); 27 | } 28 | 29 | public boolean testMarketValue(){ 30 | 31 | //Creates a list of stocks to be added to the portfolio 32 | List stocks = new ArrayList(); 33 | Stock googleStock = new Stock("1","Google", 10); 34 | Stock microsoftStock = new Stock("2","Microsoft",100); 35 | 36 | stocks.add(googleStock); 37 | stocks.add(microsoftStock); 38 | 39 | //add stocks to the portfolio 40 | portfolio.setStocks(stocks); 41 | 42 | //mock the behavior of stock service to return the value of various stocks 43 | when(stockService.getPrice(googleStock)).thenReturn(50.00); 44 | when(stockService.getPrice(microsoftStock)).thenReturn(1000.00); 45 | 46 | double marketValue = portfolio.getMarketValue(); 47 | return marketValue == 100500.0; 48 | } 49 | } -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/DependenciesInjection/src/main/java/org/generation/dependencies_injection/model/Student.java: -------------------------------------------------------------------------------- 1 | package org.generation.dependencies_injection.model; 2 | 3 | import java.util.Date; 4 | 5 | public class Student 6 | { 7 | private final String idStudent; 8 | 9 | private final int idType; 10 | 11 | private final String name; 12 | 13 | private final String lastName; 14 | 15 | private final int nationality; 16 | 17 | private String address; 18 | 19 | private Date birthDate; 20 | 21 | public Student( String idStudent, int idType, String name, String lastName, int nationality ) 22 | { 23 | this.idStudent = idStudent; 24 | this.idType = idType; 25 | this.name = name; 26 | this.lastName = lastName; 27 | this.nationality = nationality; 28 | } 29 | 30 | public void setAddress( String address ) 31 | { 32 | this.address = address; 33 | } 34 | 35 | public void setBirthDate( Date birthDate ) 36 | { 37 | this.birthDate = birthDate; 38 | } 39 | 40 | public String getIdStudent() 41 | { 42 | return idStudent; 43 | } 44 | 45 | public int getIdType() 46 | { 47 | return idType; 48 | } 49 | 50 | public String getName() 51 | { 52 | return name; 53 | } 54 | 55 | public String getLastName() 56 | { 57 | return lastName; 58 | } 59 | 60 | public int getNationality() 61 | { 62 | return nationality; 63 | } 64 | 65 | public String getAddress() 66 | { 67 | return address; 68 | } 69 | 70 | public Date getBirthDate() 71 | { 72 | return birthDate; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/README.md: -------------------------------------------------------------------------------- 1 | # WEB-JAVA-6 - Unit Testing Web Components 2 | 3 | ### Download and Load Repo 4 | 1. Clone repo. 5 | 2. Import project Math Application into IntelliJ. 6 | 7 | ### Reading the repository 8 | 9 | 1. Take 15 minutes to understand the code in the repository. 10 | 2. Once you have a clear understanding, talk to a partner about what the code does and its structure. 11 | 12 | ### Writing Tests in MathApplicationTest.java 13 | 1. Write 3 additional test cases to test the `add` functionality. 14 | 15 | 2. Write test cases in a new method called `testSubtract()` that tests the subtract method. 16 | 17 | 3. Write 3 test cases that verify whether a mock method is being called with required arguments, 18 | i.e. 19 | ``` 20 | when(calcService.add(10.0,20.0)).thenReturn(30.00); 21 | 22 | verify(calcService).add(10.0, 20.0); 23 | ``` 24 | 25 | Add this import to the top of your program to be able to use `verify`. 26 | ``` 27 | import static org.mockito.Mockito.verify; 28 | ``` 29 | 30 | 4. Write test cases that check on the number of calls that can be made on a particular method (*Hint*: Use the times or never keyword). 31 | Add these imports to the top of the program to be able to use `times` or `never`. 32 | ``` 33 | import static org.mockito.Mockito.times; 34 | import static org.mockito.Mockito.never; 35 | ``` 36 | 37 | 5. Write test cases to cover when exceptions will be thrown. 38 | 39 | ### Writing Tests in CalculatorTest.java 40 | 41 | You are tasked with designing a calculator with basic functionalities (add, subtract, multiply, and divide). We want to be able to test all the calculator functionalities. Fill in the implementation of `Calculator` in `CalculatorTest` and test each method you have created. 42 | -------------------------------------------------------------------------------- /WEB-JAVA-3 - Spring Data JPA/jpa-mysql-sample/src/main/java/org/generation/jpamysqlsample/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package org.generation.jpamysqlsample.controller; 2 | 3 | 4 | import org.generation.jpamysqlsample.model.User; 5 | import org.generation.jpamysqlsample.service.UserService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.CrossOrigin; 8 | import org.springframework.web.bind.annotation.DeleteMapping; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.PostMapping; 12 | import org.springframework.web.bind.annotation.PutMapping; 13 | import org.springframework.web.bind.annotation.RequestBody; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | @CrossOrigin( "*" ) 17 | @RestController 18 | public class UserController 19 | { 20 | 21 | public UserController( @Autowired UserService userService ) 22 | { 23 | this.userService = userService; 24 | } 25 | 26 | private final UserService userService; 27 | 28 | @GetMapping( "/user/{id}" ) 29 | public User getUser( @PathVariable String id ) 30 | { 31 | return userService.getUser( id ); 32 | } 33 | 34 | @PostMapping( "/user" ) 35 | public User newUser( @RequestBody User user ) 36 | { 37 | return userService.save( user ); 38 | } 39 | 40 | @PutMapping( "/user" ) 41 | public User updateUser( @RequestBody User user ) 42 | { 43 | return userService.save( user ); 44 | } 45 | 46 | @DeleteMapping( "/user/{id}" ) 47 | public void deleteUser( @PathVariable String id ) 48 | { 49 | userService.delete( id ); 50 | } 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /WEB-JAVA-7 - Web Applications Build and Deploy/Docker Class Exercise/README.md: -------------------------------------------------------------------------------- 1 | # Docker Class Exercise - Hello World 2 | 3 | ## Creating your first Docker Image 4 | 5 | ### Step 1: Hello Docker World 6 | 1. `git clone https://github.com/spring-guides/gs-spring-boot-docker.git` 7 | 2. Import the project into IntelliJ. 8 | 3. Take the `Application.java` file from this folder and put it into the `src/` in your project. 9 | 4. In your terminal, go to `gs-spring-boot-docker/complete`. Run from the command line:`./mvnw package && java -jar target/gs-spring-boot-docker-0.1.0.jar` 10 | 5. Go to localhost:8080 to see your "Hello Docker World" message. 11 | 12 | ### Step 2: Containerize It 13 | 1. Put the `Dockerfile` in this folder into your application. 14 | 2. Run in the command line `$ mkdir -p build/dependency && (cd build/dependency; jar -xf ../libs/*.jar)` 15 | 3. Create your Docker image. 16 | `$ docker build --build-arg DEPENDENCY=build/dependency -t springio/gs-spring-boot-docker .` 17 | 4. Run on docker! 18 | `docker run -p 8080:8080 -t springio/gs-spring-boot-docker` 19 | 5. Check out your Docker World Application at http://localhost:8080. 20 | 21 | Congratulations! You’ve just created a Docker container for a Spring Boot app! 22 | 23 | ## Deploying your Docker Image to Heroku 24 | 25 | 1. Make sure you have a Heroku account. 26 | 2. Create your docker image from the steps above (Creating your first Docker Image). 27 | 3. Deploy on Heroku. Copy and paste each command - one at a time. 28 | ``` 29 | heroku login 30 | heroku container:login 31 | heroku apps:create ${YOUR_APP_NAME} 32 | heroku container:push web --app ${YOUR_APP_NAME} 33 | heroku container:release web --app ${YOUR_APP_NAME} 34 | ``` 35 | 36 | To see your app, go to your heroku dashboard OR on the command line: `heroku open --app ${YOUR_APP_NAME}` 37 | -------------------------------------------------------------------------------- /WEB-JAVA-4 - REST API with Spring Boot/src/main/java/org/generation/Students/StudentsApplication.java: -------------------------------------------------------------------------------- 1 | package org.generation.Students; 2 | 3 | import org.generation.Students.data.entity.Student; 4 | import org.generation.Students.service.StudentService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | 9 | import java.util.Calendar; 10 | 11 | @SpringBootApplication 12 | public class StudentsApplication 13 | { 14 | 15 | static StudentService studentService; 16 | 17 | public StudentsApplication( @Autowired StudentService studentService ) 18 | { 19 | StudentsApplication.studentService = studentService; 20 | } 21 | 22 | public static void main( String[] args ) 23 | { 24 | SpringApplication.run( StudentsApplication.class, args ); 25 | loadSampleData(); 26 | } 27 | 28 | private static void loadSampleData() 29 | { 30 | Calendar calendar = Calendar.getInstance(); 31 | calendar.set( Calendar.YEAR, 1986 ); 32 | studentService.save( new Student( "Carlos", "carlos@generation.org", calendar.getTime() ) ); 33 | studentService.save( new Student( "Santiago", "santiago@generation.org", calendar.getTime() ) ); 34 | studentService.save( new Student( "Debbie", "debbie@generation.org", calendar.getTime() ) ); 35 | studentService.save( new Student( "Camilo", "camilo@generation.org", calendar.getTime() ) ); 36 | studentService.save( new Student( "Cleon", "cleon@generation.org", calendar.getTime() ) ); 37 | studentService.save( new Student( "Maria", "maria@generation.org", calendar.getTime() ) ); 38 | studentService.save( new Student( "Peter", "peter@generation.org", calendar.getTime() ) ); 39 | Iterable students = studentService.all(); 40 | for ( Student student : students ) 41 | { 42 | System.out.println( student ); 43 | } 44 | 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /WEB-JAVA-5 - Secure API using JWT/src/main/java/org/generation/jwt/config/JwtFilter.java: -------------------------------------------------------------------------------- 1 | package org.generation.jwt.config; 2 | 3 | import io.jsonwebtoken.Claims; 4 | import io.jsonwebtoken.Jwts; 5 | import io.jsonwebtoken.MalformedJwtException; 6 | import io.jsonwebtoken.SignatureException; 7 | import org.springframework.web.filter.GenericFilterBean; 8 | 9 | import javax.servlet.FilterChain; 10 | import javax.servlet.ServletException; 11 | import javax.servlet.ServletRequest; 12 | import javax.servlet.ServletResponse; 13 | import javax.servlet.http.HttpServletRequest; 14 | import javax.servlet.http.HttpServletResponse; 15 | import java.io.IOException; 16 | 17 | public class JwtFilter 18 | extends GenericFilterBean 19 | { 20 | @Override 21 | public void doFilter( ServletRequest request, ServletResponse response, FilterChain filterChain ) 22 | throws IOException, ServletException 23 | { 24 | HttpServletRequest httpServletRequest = (HttpServletRequest) request; 25 | HttpServletResponse httpServletResponse = (HttpServletResponse) response; 26 | String authHeader = httpServletRequest.getHeader( "authorization" ); 27 | 28 | if ( "OPTIONS".equals( ( httpServletRequest.getMethod() ) ) ) 29 | { 30 | httpServletResponse.setStatus( HttpServletResponse.SC_OK ); 31 | } 32 | else 33 | { 34 | if ( authHeader == null || !authHeader.startsWith( "Bearer " ) ) 35 | { 36 | throw new ServletException( "Invalid Token!" ); 37 | } 38 | 39 | String token = authHeader.substring( 7 ); 40 | 41 | try 42 | { 43 | Claims claims = Jwts.parser().setSigningKey( "this-secret-is-not-very-secret-99" ).parseClaimsJws( 44 | token ).getBody(); 45 | request.setAttribute( "claims", claims ); 46 | } 47 | catch ( SignatureException | MalformedJwtException e ) 48 | { 49 | throw new ServletException( "Invalid Token!" ); 50 | } 51 | } 52 | filterChain.doFilter( request, response ); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /WEB-JAVA-5 - Secure API using JWT/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # WEB-JAVA-5 - Secure API using JWT 4 | 5 | 6 |
7 |
8 | 9 | 10 | ## Part 1: Implementing Courses Controller 11 | 12 | 1. Download the base project and import it as a gradle project into your favorite IDE. 13 | 2. Open the CourseController and implement the following methods: 14 | ```java 15 | 16 | 17 | @PostMapping( "/api/courses" ) 18 | public Course save( @RequestBody Course course ){ 19 | return null; 20 | } 21 | 22 | @DeleteMapping( "/api/courses/{courseId}" ) 23 | public void delete( @PathVariable String courseId ){ 24 | 25 | } 26 | ``` 27 | 3. Test your Controller using Postman (don't forget to generate a token and add it to the request as Authorization header). 28 | 29 | ## Part 2: Implementing Students Sercure API 30 | 1. Create a new model called *Student* inside the model package with the following information: 31 | * Id 32 | * Name 33 | * Email 34 | 35 | 2. Define a new interface inside the service package called *StudentService* with the following methods: 36 | ```java 37 | public interface StudentService 38 | { 39 | 40 | List all(); 41 | 42 | Student save(Student student); 43 | 44 | void delete(String studentId); 45 | 46 | } 47 | ``` 48 | 3. Create an implementation of the *StudentService* interface and annotate it with *@Service*. 49 | 4. Create a new controller inside the controller package called *StudentController*. 50 | 5. Inject the *StudentService* inside the *StudentController* via de constructor. 51 | 6. Implement the endpoints to handle each request to fulfill the services defined on the *StudentService* interface. 52 | 7. Make sure your endpoints start with "/api" so they can be secured by the JWT Filter interceptor. 53 | 8. Test your API using Postman. 54 | 55 | ## Challenge Yourself 56 | Implement an additional endpoint method and service to enroll a student into a course. 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # WEB-JAVA-2 - Dependencies Injection using Spring Framework 4 | 5 | 6 |
7 |
8 | 9 | 10 | ## Part 1: Implementing Student Service: ArrayList 11 | 1. Download and import the project inside the [DependenciesInjection folder.](https://github.com/generation-org/WEB-JAVA/tree/master/WEB-JAVA-2%20-%20Dependencies%20Injection%20using%20Spring%20Framework/DependenciesInjection) 12 | 2. Create a new Java class *StudentServiceImpl* that implements the *StudentService* interface. 13 | 3. Implement the methods of the *StudentService* interface using an ArrayList as the internal data structure: 14 | ```java 15 | public interface StudentService 16 | { 17 | void add( Student student ); 18 | 19 | void delete( Student student ); 20 | 21 | List all(); 22 | 23 | Student findById( String id ); 24 | 25 | } 26 | ``` 27 | 4. Annotate the *StudentServiceImpl* with the *@Service* annotation. 28 | 5. Add a method inside the *StudentServiceImpl* that is called inside the constructors that add some test students. 29 | 6. Start your server by running the project on the *main* on the *DependenciesInjectionApplication* class. 30 | 7. Verify that your implementations work by passing an existing id into the url and checking that student data is displayed in the browser. 31 | ```html 32 | http://localhost:8080/student/10 33 | ``` 34 | ## Part 2: Implementing Student Service: HasMap 35 | 1. Create a new Java class *StudentServiceImplMap* that implements the *StudentService* class. 36 | 2. Implement the methods of the *StudentService* interface using a HashMap as the internal data structure. 37 | 3. Move the *@Service* annotation from the *StudentServiceImpl* to the *StudentServiceImplMap* 38 | 4. Run your project and verify that your code is using the map configuration (you can use the debugger or just add a console message with System.our.println("message")). 39 | 40 | ## Challenge Yourself 41 | 1. Open the *DependenciesInjectionApplicationTests* class and write 3 unit tests for any of the service implementations. 42 | -------------------------------------------------------------------------------- /WEB-JAVA-3 - Spring Data JPA/jpa-mysql-sample/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/DependenciesInjection/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/UserServiceApplicaiton/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Portfolio_Mockito_Exercise/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS="-Xmx64m" 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /WEB-JAVA-4 - REST API with Spring Boot/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # WEB-JAVA-4 - REST API with Spring Boot 4 | 5 | 6 |
7 |
8 | 9 | 10 | ## Part 1: Create the Database Table 11 | 1. Run the following SQL scripts using MySQL Workbench: 12 | ```sql 13 | -- ----------------------------------------------------- 14 | -- Schema mydb 15 | -- ----------------------------------------------------- 16 | CREATE SCHEMA IF NOT EXISTS `db_example` DEFAULT CHARACTER SET utf8 ; 17 | USE `db_example` ; 18 | 19 | -- ----------------------------------------------------- 20 | -- Table `mydb`.`Students` 21 | -- ----------------------------------------------------- 22 | CREATE TABLE IF NOT EXISTS `db_example`.`Students` ( 23 | `idStudents` INT NOT NULL, 24 | `name` VARCHAR(100) NULL, 25 | `email` VARCHAR(100) NULL, 26 | `address` VARCHAR(100) NULL, 27 | `birth_date` DATETIME NULL, 28 | PRIMARY KEY (`idStudents`)) 29 | ``` 30 | 2. Download the project and import it as a Gradle project into your IDE. 31 | 3. Verify the connection properties in the *application.properties* file. 32 | 3. Run the application and verify that the sample data is created from the Web Application. 33 | 34 | ## Part 2: Implementing a REST API CRUD 35 | 1. Create a new package called *controller*. 36 | 2. Create a new class called *StudentsController*. 37 | 3. Annotate the *StudentsController* with the *@RestController*. 38 | 4. Inject the *StudentService* into the *StudentsController* via the constructor: 39 | ```java 40 | private StudentService studentService; 41 | 42 | public StudentsController( @Autowired StudentService studentService ) 43 | { 44 | StudentsApplication.studentService = studentService; 45 | } 46 | ``` 47 | 5. Define an endpoint for each of the CRUD methods as follows: 48 | 49 | | Method Name | HTTP Method | Endpoint Path | 50 | |--------------------------------------|-------------|---------------| 51 | | all() | GET | /student | 52 | | findById(@PathVariable String id) | GET | /student/{id} | 53 | | save(@RequestBody Student student) | POST | /student | 54 | | update(@RequestBody Student student) | PUT | /student | 55 | | delete(@PathVariable String id) | DELETE | /student/{id} | 56 | 57 | 6. Use Postman to test your REST API. Verify each of the CRUD operations: 58 | * Create a new Student 59 | * Find a Student by ID 60 | * Get All the Students List 61 | * Update a Student 62 | * Delete a Student 63 | 64 | ## Challenge Yourself 65 | 1. Create an additional endpoint that lets you find all the students whose name starts with a given query parameter. 66 | -------------------------------------------------------------------------------- /WEB-JAVA-3 - Spring Data JPA/jpa-mysql-sample/README.md: -------------------------------------------------------------------------------- 1 | # Spring Boot API Sample Project 2 | 3 | ### Part 1: Creating a Database user 4 | 1. Open the terminal and mysql as root user: 5 | ```bash 6 | sudo mysql --password 7 | ``` 8 | 2. To create a new database, run the following commands at the mysql prompt: 9 | ```bash 10 | mysql> create database db_example; -- Creates the new database 11 | mysql> create user 'springuser'@'%' identified by 'ThePassword'; -- Creates the user 12 | mysql> grant all on db_example.* to 'springuser'@'%'; -- Gives all privileges to the new user on the newly created database 13 | ``` 14 | 15 | ### Part 2: Creating the local database 16 | 17 | 1. Open MySQL Workbench. 18 | 19 | 2. Open the Local Instance 3306 in the *MySQL Connections*. 20 | 21 | 3. Create a new database running the following commands at MySQL Workbench: 22 | ```sql 23 | -- ----------------------------------------------------- 24 | -- Schema db_example 25 | -- ----------------------------------------------------- 26 | CREATE SCHEMA IF NOT EXISTS `db_example` DEFAULT CHARACTER SET utf8 ; 27 | USE `db_example` ; 28 | 29 | -- ----------------------------------------------------- 30 | -- Table `db_example`.`Users` 31 | -- ----------------------------------------------------- 32 | CREATE TABLE IF NOT EXISTS `db_example`.`Users` ( 33 | `id` INT NOT NULL, 34 | `name` VARCHAR(200) NULL, 35 | `last_name` VARCHAR(200) NULL, 36 | `email` VARCHAR(200) NULL, 37 | PRIMARY KEY (`idUsers`)) 38 | ``` 39 | 4. Insert some Users to the database: 40 | ```sql 41 | INSERT INTO `db_example`.`Users` (`idUsers`, `name`, `last_name`, `email`) VALUES ('1', 'Debbie', 'Ly', 'debbie@generation.org'); 42 | INSERT INTO `db_example`.`Users` (`idUsers`, `name`, `last_name`, `email`) VALUES ('2', 'Cleon', 'Grant', 'cleon@generation.org'); 43 | INSERT INTO `db_example`.`Users` (`idUsers`, `name`, `last_name`, `email`) VALUES ('3', 'Carlos', 'Echeverry', 'carlos@generation.org'); 44 | INSERT INTO `db_example`.`Users` (`idUsers`, `name`, `last_name`, `email`) VALUES ('4', 'Elise', 'Guimarães', 'elise@generation.org'); 45 | INSERT INTO `db_example`.`Users` (`idUsers`, `name`, `last_name`, `email`) VALUES ('5', 'Ian', 'Munene', 'ian@generation.org'); 46 | INSERT INTO `db_example`.`Users` (`idUsers`, `name`, `last_name`, `email`) VALUES ('6', 'Santiago', 'Carrillo', 'santiago@generation.org'); 47 | ``` 48 | 49 | ### Part 3: Testing your Database connection 50 | 1. Download the project and import it as a Gradle project into your IDE IntelliJ Idea. 51 | 2. Run the application class. 52 | 3. Test that the connection works by accessing the users data in the browser: 53 | ```bash 54 | http://localhost:8080/user/1 55 | ``` 56 | Should output: 57 | ```json 58 | {"id":"1","name":"Debbie"} 59 | ``` 60 | -------------------------------------------------------------------------------- /WEB-JAVA-5 - Secure API using JWT/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 34 | 35 | @rem Find java.exe 36 | if defined JAVA_HOME goto findJavaFromJavaHome 37 | 38 | set JAVA_EXE=java.exe 39 | %JAVA_EXE% -version >NUL 2>&1 40 | if "%ERRORLEVEL%" == "0" goto init 41 | 42 | echo. 43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 44 | echo. 45 | echo Please set the JAVA_HOME variable in your environment to match the 46 | echo location of your Java installation. 47 | 48 | goto fail 49 | 50 | :findJavaFromJavaHome 51 | set JAVA_HOME=%JAVA_HOME:"=% 52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 53 | 54 | if exist "%JAVA_EXE%" goto init 55 | 56 | echo. 57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 58 | echo. 59 | echo Please set the JAVA_HOME variable in your environment to match the 60 | echo location of your Java installation. 61 | 62 | goto fail 63 | 64 | :init 65 | @rem Get command-line arguments, handling Windows variants 66 | 67 | if not "%OS%" == "Windows_NT" goto win9xME_args 68 | 69 | :win9xME_args 70 | @rem Slurp the command line arguments. 71 | set CMD_LINE_ARGS= 72 | set _SKIP=2 73 | 74 | :win9xME_args_slurp 75 | if "x%~1" == "x" goto execute 76 | 77 | set CMD_LINE_ARGS=%* 78 | 79 | :execute 80 | @rem Setup the command line 81 | 82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 83 | 84 | @rem Execute Gradle 85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 86 | 87 | :end 88 | @rem End local scope for the variables with windows NT shell 89 | if "%ERRORLEVEL%"=="0" goto mainEnd 90 | 91 | :fail 92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 93 | rem the _cmd.exe /c_ return code! 94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 95 | exit /b 1 96 | 97 | :mainEnd 98 | if "%OS%"=="Windows_NT" endlocal 99 | 100 | :omega 101 | -------------------------------------------------------------------------------- /WEB-JAVA-4 - REST API with Spring Boot/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 34 | 35 | @rem Find java.exe 36 | if defined JAVA_HOME goto findJavaFromJavaHome 37 | 38 | set JAVA_EXE=java.exe 39 | %JAVA_EXE% -version >NUL 2>&1 40 | if "%ERRORLEVEL%" == "0" goto init 41 | 42 | echo. 43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 44 | echo. 45 | echo Please set the JAVA_HOME variable in your environment to match the 46 | echo location of your Java installation. 47 | 48 | goto fail 49 | 50 | :findJavaFromJavaHome 51 | set JAVA_HOME=%JAVA_HOME:"=% 52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 53 | 54 | if exist "%JAVA_EXE%" goto init 55 | 56 | echo. 57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 58 | echo. 59 | echo Please set the JAVA_HOME variable in your environment to match the 60 | echo location of your Java installation. 61 | 62 | goto fail 63 | 64 | :init 65 | @rem Get command-line arguments, handling Windows variants 66 | 67 | if not "%OS%" == "Windows_NT" goto win9xME_args 68 | 69 | :win9xME_args 70 | @rem Slurp the command line arguments. 71 | set CMD_LINE_ARGS= 72 | set _SKIP=2 73 | 74 | :win9xME_args_slurp 75 | if "x%~1" == "x" goto execute 76 | 77 | set CMD_LINE_ARGS=%* 78 | 79 | :execute 80 | @rem Setup the command line 81 | 82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 83 | 84 | @rem Execute Gradle 85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 86 | 87 | :end 88 | @rem End local scope for the variables with windows NT shell 89 | if "%ERRORLEVEL%"=="0" goto mainEnd 90 | 91 | :fail 92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 93 | rem the _cmd.exe /c_ return code! 94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 95 | exit /b 1 96 | 97 | :mainEnd 98 | if "%OS%"=="Windows_NT" endlocal 99 | 100 | :omega 101 | -------------------------------------------------------------------------------- /WEB-JAVA-3 - Spring Data JPA/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # WEB-JAVA-3 - Spring Data JPA 4 | 5 | 6 |
7 |
8 | 9 | 10 | ## Part 1: Creating the database 11 | 1. Open MySQL Workbench and create a new Database with the following tables: 12 | * Products (id, name, description, price) 13 | * Sales (id, description, total) 14 | 2. Add a many-to-one relationship from the *Sales* table to the *Products* table 15 | 3. Export your database and run the SQL scripts to create the tables in your localinstance of MySQL 16 | 4. Insert some sample data into each table 17 | 18 | ## Part 2: Create a Spring Boot project 19 | 1. Go to the [Spring Initializr](https://start.spring.io) and create a new Gradle project with Java. 20 | 2. Import the project into IntelliJ Idea and add the following dependencies to the *build.gradle* file: 21 | ```gradle 22 | implementation 'org.springframework.boot:spring-boot-starter-data-jpa' 23 | runtimeOnly 'mysql:mysql-connector-java' 24 | ``` 25 | 3. Create new package called data.entity and implement an Entity for each of the tables (Products and Sales). Use the following code to map the one-to-many relationship: 26 | ```java 27 | @OneToMany(mappedBy = "sale", fetch = FetchType.LAZY, 28 | cascade = CascadeType.ALL) 29 | private Set pages; 30 | ``` 31 | 4. Define a Repository interface for each Entity: 32 | 33 | ```java 34 | public interface ProductsRepository extends CrudRepository 35 | { 36 | } 37 | public interface SalesRepository extends CrudRepository 38 | { 39 | } 40 | ``` 41 | 5. Create a SalesService interface: 42 | ```java 43 | public interface SalesService 44 | { 45 | Sale getSale( int id ); 46 | } 47 | ``` 48 | 6. Create a SalesServiceImpl that implements the SalesService interface: 49 | ```java 50 | @Service 51 | public class SalesServiceImpl implements SalesService 52 | { 53 | private final SalesRepository salesRepository; 54 | 55 | public SalesServiceImpl( SalesRepository salesRepository ) 56 | { 57 | this.salesRepository = salesRepository; 58 | } 59 | 60 | @Override 61 | public Sale getSale( int id ) 62 | { 63 | Optional sale = salesRepository.findById( id ); 64 | return user.orElse( null ); 65 | } 66 | ``` 67 | 68 | 7. Create a controller package and create the SalesController: 69 | ```java 70 | @CrossOrigin( "*" ) 71 | @RestController 72 | public class SalesController 73 | { 74 | 75 | private final SalesService salesService; 76 | 77 | public SalesController( @Autowired SalesService salesService ) 78 | { 79 | this.salesService = salesService; 80 | } 81 | 82 | @GetMapping( "/sales/{id}" ) 83 | public Sale getSale( @PathVariable String id ) 84 | { 85 | return salesService.getSale( Integer.parseInt( id ) ); 86 | } 87 | 88 | ``` 89 | 90 | 7. Run your project and verify it works by opening the following URL into your browser: 91 | 92 | ```html 93 | http://localhost:8080/sales/1 94 | ``` 95 | 96 | ## Challenge Yourself 97 | 1. Create another method into the SalesService and SalesController to retrieve all the products that belong to a given sale ID. 98 | -------------------------------------------------------------------------------- /WEB-JAVA-5 - Secure API using JWT/src/main/java/org/generation/jwt/service/CourseServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.generation.jwt.service; 2 | 3 | import org.generation.jwt.model.Course; 4 | import org.springframework.stereotype.Service; 5 | 6 | import java.util.ArrayList; 7 | import java.util.HashMap; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | 12 | @Service 13 | public class CourseServiceImpl 14 | implements CourseService 15 | { 16 | 17 | private final Map courseList = new HashMap<>(); 18 | 19 | public CourseServiceImpl() 20 | { 21 | courseList.put( "INTRO-CS-1", new Course( "INTRO-CS-1", "Introduction to Computer Science", 22 | "-Explain the basics about how the internet works\n" 23 | + "-Explain the difference between a client and a server\n" 24 | + "-Explain the TCP/IP protocol on a basic level\n" 25 | + "-Explain the HTTP protocol\n" 26 | + "-Explain and use the HTTP methods GET / POST / PUT / DELETE\n" 27 | + "-Use HTTP methods GET and POST with an HTTP Client (Postman)\n" 28 | + "-Use developer tools\n" 29 | + "-Describe the difference between a Web Site and a Web Application\n" 30 | + "-Give examples of Web Applications and Web Sites" ) ); 31 | courseList.put( "INTRO-CS-2", new Course( "INTRO-CS-2", "Introduction to Algorithms", 32 | "-Explain what an algorithm is \n" 33 | + "-Explain the structure of an algorithm\n" 34 | + "-Explain what code comments are and how to write them in JavaScript\n" 35 | + "-Describe what reserved words in JavaScript are and give examples\n" 36 | + "-Use primitive types to create variables and algorithms\n" 37 | + "-Declare and use variables of different types\n" 38 | + "-Write simple and correct programs using JavaScript\n" 39 | + "-Use the Javascript prompt function to capture a user input" ) ); 40 | courseList.put( "INTRO-CS-3", new Course( "INTRO-CS-3", "Algorithm Design and Problem Solving - Introduction", 41 | "-Declare and use conditionals\n" 42 | + "-Define functions using JavaScript\n" 43 | + "-Write algorithms that solve matemathical problems\n" 44 | + "-Manipulate Strings with JavaScript\n" 45 | + "-Write algorithms that solve problems using String Functions\n" 46 | + "-Use the Web debugger for JavaScript code on the Browser\n" 47 | + "-Write algorithms that solve problems taking user inputs" ) ); 48 | courseList.put( "INTRO-CS-4", new Course( "INTRO-CS-4", "Algorithm Design and Problem Solving - Advanced", 49 | "-Define and use arrays for numeric values\n" 50 | + "-Define and use arrays for String values\n" 51 | + "-Write algorithms that solve mathematical problems using arrays\n" 52 | + "-Read, understand and fix code writen by someone else\n" 53 | + "-Write algorithms that solve problems using logical expresions \n" 54 | + "-Explain and do code refactoring to improve code\n" 55 | + "-Iterate arrays and modify its data\n" 56 | + "-Write algorithms that solve basic sorting algorithms using arrays" ) ); 57 | } 58 | 59 | @Override 60 | public List all() 61 | { 62 | return new ArrayList<>( courseList.values() ); 63 | } 64 | 65 | @Override 66 | public void save( Course course ) 67 | { 68 | courseList.put( course.getId(), course ); 69 | } 70 | 71 | @Override 72 | public void delete( String courseId ) 73 | { 74 | courseList.remove( courseId ); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Math Application/build/test-results/test/TEST-MathApplicationTest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Argument(s) are different! Wanted: 6 | calcService.add(11.0d, 20.0d); 7 | -> at MathApplicationTest.testAdd(MathApplicationTest.java:32) 8 | Actual invocation has different arguments: 9 | calcService.add(10.0d, 20.0d); 10 | -> at MathApplication.add(MathApplication.java:9) 11 | 12 | at MathApplicationTest.testAdd(MathApplicationTest.java:32) 13 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 14 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 15 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 16 | at java.base/java.lang.reflect.Method.invoke(Method.java:564) 17 | at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) 18 | at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) 19 | at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) 20 | at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) 21 | at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) 22 | at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) 23 | at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) 24 | at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) 25 | at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) 26 | at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) 27 | at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) 28 | at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) 29 | at org.junit.runners.ParentRunner.run(ParentRunner.java:363) 30 | at org.mockito.internal.runners.DefaultInternalRunner$1.run(DefaultInternalRunner.java:79) 31 | at org.mockito.internal.runners.DefaultInternalRunner.run(DefaultInternalRunner.java:85) 32 | at org.mockito.internal.runners.StrictRunner.run(StrictRunner.java:39) 33 | at org.mockito.junit.MockitoJUnitRunner.run(MockitoJUnitRunner.java:163) 34 | at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) 35 | at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) 36 | at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) 37 | at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) 38 | at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) 39 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 40 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 41 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 42 | at java.base/java.lang.reflect.Method.invoke(Method.java:564) 43 | at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) 44 | at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) 45 | at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) 46 | at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) 47 | at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) 48 | at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:118) 49 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 50 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 51 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 52 | at java.base/java.lang.reflect.Method.invoke(Method.java:564) 53 | at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) 54 | at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) 55 | at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:175) 56 | at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:157) 57 | at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404) 58 | at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) 59 | at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) 60 | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) 61 | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) 62 | at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) 63 | at java.base/java.lang.Thread.run(Thread.java:844) 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /WEB-JAVA-3 - Spring Data JPA/jpa-mysql-sample/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Math Application/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS='"-Xmx64m"' 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/DependenciesInjection/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Portfolio_Mockito_Exercise/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS='"-Xmx64m"' 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /WEB-JAVA-2 - Dependencies Injection using Spring Framework/UserServiceApplicaiton/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /WEB-JAVA-5 - Secure API using JWT/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin or MSYS, switch paths to Windows format before running java 129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=`expr $i + 1` 158 | done 159 | case $i in 160 | 0) set -- ;; 161 | 1) set -- "$args0" ;; 162 | 2) set -- "$args0" "$args1" ;; 163 | 3) set -- "$args0" "$args1" "$args2" ;; 164 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=`save "$@"` 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | exec "$JAVACMD" "$@" 184 | -------------------------------------------------------------------------------- /WEB-JAVA-4 - REST API with Spring Boot/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin or MSYS, switch paths to Windows format before running java 129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=`expr $i + 1` 158 | done 159 | case $i in 160 | 0) set -- ;; 161 | 1) set -- "$args0" ;; 162 | 2) set -- "$args0" "$args1" ;; 163 | 3) set -- "$args0" "$args1" "$args2" ;; 164 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=`save "$@"` 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | exec "$JAVACMD" "$@" 184 | -------------------------------------------------------------------------------- /WEB-JAVA-6 - Unit Testing Web Components/Portfolio_Mockito_Exercise/mockito_test_proj.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | --------------------------------------------------------------------------------