├── .gitignore ├── .scripts ├── 3A-postgresql │ ├── postgresql-42.2.5.jar │ ├── postgresql-datasource-commands.cli │ ├── postgresql-module.xml │ └── startup.sh ├── 3B-mysql │ ├── mysql-connector-java-8.0.13.jar │ ├── mysql-datasource-commands.cli │ ├── mysql-module.xml │ └── startup.sh ├── 3C-sql │ ├── mssql-datasource-commands.cli │ ├── mssql-jdbc-7.2.1.jre8.jar │ ├── mssql-module.xml │ └── startup.sh ├── persistence-h2.xml ├── persistence-mysql.xml ├── persistence-postgresql.xml └── persistence-sql.xml ├── LICENSE ├── README-petstoreee7.md ├── README.md ├── pom.xml ├── setup-env-variables-template.sh ├── src ├── main │ ├── docker │ │ └── postgresql.yml │ ├── forge │ │ └── generate.fsh │ ├── java │ │ └── org │ │ │ └── agoncal │ │ │ └── application │ │ │ └── petstore │ │ │ ├── constraints │ │ │ ├── Email.java │ │ │ ├── Login.java │ │ │ ├── NotEmpty.java │ │ │ └── Price.java │ │ │ ├── exceptions │ │ │ └── ValidationException.java │ │ │ ├── model │ │ │ ├── Address.java │ │ │ ├── Category.java │ │ │ ├── Country.java │ │ │ ├── CreditCard.java │ │ │ ├── CreditCardConverter.java │ │ │ ├── CreditCardType.java │ │ │ ├── Customer.java │ │ │ ├── Item.java │ │ │ ├── OrderLine.java │ │ │ ├── Product.java │ │ │ ├── PurchaseOrder.java │ │ │ └── UserRole.java │ │ │ ├── rest │ │ │ ├── CategoryEndpoint.java │ │ │ ├── CountryEndpoint.java │ │ │ ├── CustomerEndpoint.java │ │ │ ├── ItemEndpoint.java │ │ │ ├── ProductEndpoint.java │ │ │ └── RestApplication.java │ │ │ ├── security │ │ │ ├── LoginContextProducer.java │ │ │ ├── SimpleCallbackHandler.java │ │ │ └── SimpleLoginModule.java │ │ │ ├── service │ │ │ ├── AbstractService.java │ │ │ ├── CatalogService.java │ │ │ ├── CategoryService.java │ │ │ ├── ComputablePurchaseOrder.java │ │ │ ├── CountryService.java │ │ │ ├── CustomerService.java │ │ │ ├── InventoryService.java │ │ │ ├── ItemService.java │ │ │ ├── OrderLineService.java │ │ │ ├── ProductService.java │ │ │ ├── PurchaseOrderDecorator.java │ │ │ ├── PurchaseOrderService.java │ │ │ ├── ShippingService.java │ │ │ └── StatisticService.java │ │ │ ├── util │ │ │ ├── ConfigProperty.java │ │ │ ├── ConfigPropertyProducer.java │ │ │ ├── DatabaseProducer.java │ │ │ ├── Discount.java │ │ │ ├── Loggable.java │ │ │ ├── LoggingInterceptor.java │ │ │ ├── LoggingProducer.java │ │ │ ├── NumberProducer.java │ │ │ └── Vat.java │ │ │ └── view │ │ │ ├── AbstractBean.java │ │ │ ├── CatchException.java │ │ │ ├── DebugBean.java │ │ │ ├── ExceptionInterceptor.java │ │ │ ├── LocaleBean.java │ │ │ ├── LoggedIn.java │ │ │ ├── ViewUtils.java │ │ │ ├── admin │ │ │ ├── CategoryBean.java │ │ │ ├── CountryBean.java │ │ │ ├── CustomerBean.java │ │ │ ├── ItemBean.java │ │ │ ├── OrderLineBean.java │ │ │ ├── ProductBean.java │ │ │ └── PurchaseOrderBean.java │ │ │ └── shopping │ │ │ ├── AccountBean.java │ │ │ ├── CatalogBean.java │ │ │ ├── CredentialsBean.java │ │ │ ├── ShoppingCartBean.java │ │ │ └── ShoppingCartItem.java │ ├── resources │ │ ├── META-INF │ │ │ ├── persistence.xml │ │ │ └── validation.xml │ │ ├── Messages.properties │ │ ├── ValidationMessages.properties │ │ ├── ValidationMessages_fr.properties │ │ ├── config.properties │ │ ├── init_db.sql │ │ ├── logging.properties │ │ ├── messages_fr.properties │ │ └── petstore-test.login │ └── webapp │ │ ├── WEB-INF │ │ ├── beans.xml │ │ ├── classes │ │ │ └── META-INF │ │ │ │ └── forge.taglib.xml │ │ ├── faces-config.xml │ │ └── web.xml │ │ ├── admin │ │ ├── category │ │ │ ├── create.xhtml │ │ │ ├── search.xhtml │ │ │ └── view.xhtml │ │ ├── country │ │ │ ├── create.xhtml │ │ │ ├── search.xhtml │ │ │ └── view.xhtml │ │ ├── customer │ │ │ ├── create.xhtml │ │ │ ├── search.xhtml │ │ │ └── view.xhtml │ │ ├── item │ │ │ ├── create.xhtml │ │ │ ├── search.xhtml │ │ │ └── view.xhtml │ │ ├── product │ │ │ ├── create.xhtml │ │ │ ├── search.xhtml │ │ │ └── view.xhtml │ │ └── purchaseOrder │ │ │ ├── search.xhtml │ │ │ └── view.xhtml │ │ ├── debug.xhtml │ │ ├── error.xhtml │ │ ├── index.html │ │ ├── resources │ │ ├── css │ │ │ ├── sticky-footer-navbar.css │ │ │ └── style.css │ │ ├── favicon.gif │ │ ├── icons │ │ │ ├── arrow_refresh.png │ │ │ ├── cart_add.png │ │ │ ├── cart_delete.png │ │ │ ├── cart_go.png │ │ │ ├── fr.gif │ │ │ ├── us.gif │ │ │ └── user_edit.png │ │ ├── images │ │ │ ├── bird1.jpg │ │ │ ├── bird2.jpg │ │ │ ├── cat1.jpg │ │ │ ├── cat2.jpg │ │ │ ├── dog1.jpg │ │ │ ├── dog2.jpg │ │ │ ├── dog3.jpg │ │ │ ├── dog4.jpg │ │ │ ├── dog5.jpg │ │ │ ├── dog6.jpg │ │ │ ├── fish1.jpg │ │ │ ├── fish2.jpg │ │ │ ├── fish3.jpg │ │ │ ├── fish4.jpg │ │ │ ├── lizard1.jpg │ │ │ ├── reptile1.jpg │ │ │ └── snake1.jpg │ │ ├── splash.gif │ │ └── templates │ │ │ ├── paginator.xhtml │ │ │ ├── template.xhtml │ │ │ ├── templateCRUD.xhtml │ │ │ └── templateShopping.xhtml │ │ ├── shopping │ │ ├── confirmorder.xhtml │ │ ├── createaccount.xhtml │ │ ├── main.xhtml │ │ ├── orderconfirmed.xhtml │ │ ├── searchresult.xhtml │ │ ├── showaccount.xhtml │ │ ├── showcart.xhtml │ │ ├── showitem.xhtml │ │ ├── showitems.xhtml │ │ ├── showproducts.xhtml │ │ ├── signon.xhtml │ │ └── updateaccount.xhtml │ │ └── swagger.json └── test │ ├── java │ └── org │ │ └── agoncal │ │ └── application │ │ └── petstore │ │ ├── model │ │ ├── AddressIT.java │ │ ├── AddressTest.java │ │ ├── CategoryIT.java │ │ ├── CategoryTest.java │ │ ├── CountryTest.java │ │ ├── CreditCardTest.java │ │ ├── CustomerIT.java │ │ ├── CustomerTest.java │ │ ├── ItemIT.java │ │ ├── ItemTest.java │ │ ├── OrderLineTest.java │ │ ├── ProductIT.java │ │ ├── ProductTest.java │ │ ├── PurchaseOrderIT.java │ │ └── PurchaseOrderTest.java │ │ ├── rest │ │ ├── CategoryEndpointTest.java │ │ ├── CountryEndpointTest.java │ │ ├── CustomerEndpointTest.java │ │ ├── ItemEndpointTest.java │ │ └── ProductEndpointTest.java │ │ ├── service │ │ ├── CategoryServiceTest.java │ │ ├── CountryServiceTest.java │ │ ├── CustomerServiceTest.java │ │ ├── ItemServiceTest.java │ │ ├── OrderLineServiceTest.java │ │ ├── ProductServiceTest.java │ │ └── PurchaseOrderServiceTest.java │ │ └── view │ │ └── admin │ │ ├── CategoryBeanTest.java │ │ ├── CountryBeanTest.java │ │ ├── CustomerBeanTest.java │ │ ├── ItemBeanTest.java │ │ ├── OrderLineBeanTest.java │ │ ├── ProductBeanTest.java │ │ └── PurchaseOrderBeanTest.java │ └── resources │ └── arquillian.xml ├── step-00-setup-your-environment └── README.md ├── step-01-deploy-java-ee-app-to-azure ├── README.md └── media │ └── YAPS-PetStore-H2.jpg ├── step-02-create-a-database ├── README.md ├── step-02A-create-a-postgresql-database │ └── README.md ├── step-02B-create-a-mysql-database │ └── README.md └── step-02C-create-a-sql-database │ └── README.md ├── step-03-bind-java-ee-app-to-database ├── README.md ├── step-03A-bind-app-to-postgresql │ └── README.md ├── step-03B-bind-app-to-mysql │ └── README.md └── step-03C-bind-app-to-sql-database │ └── README.md ├── step-04-monitor-java-ee-app ├── README.md └── media │ ├── Create-Application-Insights.jpg │ ├── app-service-ai-menu-sh.png │ ├── app-service-configure-ai-sh.png │ ├── app-service-enable-ai-sh.png │ ├── app-service-view-ai-sh.png │ ├── seattle-petstore-app-logs-in-log-analytics.jpg │ ├── seattle-petstore-application-map.jpg │ ├── seattle-petstore-end-to-end-transaction.jpg │ ├── seattle-petstore-live-metrics.jpg │ ├── seattle-petstore-operation-performance-in-log-analytics.jpg │ ├── seattle-petstore-performance.jpg │ └── seattle-petstore-sql-dependencies.jpg ├── step-05-setup-github-actions ├── README.md └── media │ ├── download_publish_profile.png │ ├── search_logs.png │ ├── set_github_secret.png │ └── view_logs.png └── step-99-conclusion └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Thumbs.db 3 | .idea 4 | *.log 5 | *.jdbc 6 | *.iml 7 | target 8 | *.class 9 | *.jar 10 | *.war 11 | *.ear 12 | *.rar 13 | *.ipr 14 | *.iws 15 | rebel.xml 16 | *DB 17 | *.dat 18 | .classpath 19 | .project 20 | .settings 21 | WebContent 22 | *.vpp~* 23 | *.vpdm 24 | vpproject 25 | .vpprefdata 26 | *dummy*.* 27 | *-soapui-project.xml 28 | .lock 29 | teamworkUser.xml 30 | projectFilesBackup* 31 | *.zip 32 | *.gzprojectFilesBackup* 33 | 34 | .scripts/setup-env-variables.sh 35 | apm/ 36 | -------------------------------------------------------------------------------- /.scripts/3A-postgresql/postgresql-42.2.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/.scripts/3A-postgresql/postgresql-42.2.5.jar -------------------------------------------------------------------------------- /.scripts/3A-postgresql/postgresql-datasource-commands.cli: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # ***** IMPORTANT : PATH should point to PostgreSQL Java driver and module XML file on App Service Linux ******* 4 | module add --name=org.postgres --resources=/home/site/libs/postgresql-42.2.5.jar --module-xml=/home/site/scripts/postgresql-module.xml 5 | # sample : module add --name=org.postgres --resources=/home/site/libs/postgresql-42.2.5.jar --module-xml=/home/site/scripts/postgres-module.xml 6 | /subsystem=datasources/jdbc-driver=postgres:add(driver-name="postgres",driver-module-name="org.postgres",driver-class-name=org.postgresql.Driver,driver-xa-datasource-class-name=org.postgresql.xa.PGXADataSource) 7 | data-source add --name=postgresDS --driver-name=postgres --jndi-name=java:jboss/datasources/postgresDS --connection-url=${POSTGRES_CONNECTION_URL,env.POSTGRES_CONNECTION_URL:jdbc:postgresql://db:5432/postgres} --user-name=${POSTGRES_SERVER_ADMIN_FULL_NAME,env.POSTGRES_SERVER_ADMIN_FULL_NAME:postgres} --password=${POSTGRES_SERVER_ADMIN_PASSWORD,env.POSTGRES_SERVER_ADMIN_PASSWORD:example} --use-ccm=true --max-pool-size=5 --blocking-timeout-wait-millis=5000 --enabled=true --driver-class=org.postgresql.Driver --exception-sorter-class-name=org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter --jta=true --use-java-context=true --valid-connection-checker-class-name=org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker -------------------------------------------------------------------------------- /.scripts/3A-postgresql/postgresql-module.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.scripts/3A-postgresql/startup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | /opt/eap/bin/jboss-cli.sh -c --file=/home/site/scripts/postgresql-datasource-commands.cli -------------------------------------------------------------------------------- /.scripts/3B-mysql/mysql-connector-java-8.0.13.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/.scripts/3B-mysql/mysql-connector-java-8.0.13.jar -------------------------------------------------------------------------------- /.scripts/3B-mysql/mysql-datasource-commands.cli: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # ************** IMPORTANT : REPLACE THE PLACEHOLDERS ***************** 4 | # https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html/configuration_guide/datasource_management 5 | # The following command will install the com.mysql module 6 | module add --name=com.mysql --resources=/home/site/libs/mysql-connector-java-8.0.13.jar --module-xml=/home/site/scripts/mysql-module.xml 7 | # install the JDBC driver using the above defined module 8 | /subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql,driver-module-name=com.mysql,driver-class-name=com.mysql.cj.jdbc.Driver) 9 | # install the data source by using the data-source shortcut command 10 | data-source add --name=mysqlDS --jndi-name=java:jboss/datasources/mysqlDS --connection-url=${MYSQL_CONNECTION_URL,env.MYSQL_CONNECTION_URL:jdbc:mysql://db:3306/petstore} --driver-name=mysql --user-name=${MYSQL_SERVER_ADMIN_FULL_NAME,env.MYSQL_SERVER_ADMIN_FULL_NAME:mysql} --password=${MYSQL_SERVER_ADMIN_PASSWORD,env.MYSQL_SERVER_ADMIN_PASSWORD:example} --use-ccm=true --max-pool-size=5 --blocking-timeout-wait-millis=5000 --enabled=true --driver-class=com.mysql.cj.jdbc.Driver --jta=true --use-java-context=true --exception-sorter-class-name=com.mysql.cj.jdbc.integration.jboss.ExtendedMysqlExceptionSorter -------------------------------------------------------------------------------- /.scripts/3B-mysql/mysql-module.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.scripts/3B-mysql/startup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | /opt/eap/bin/jboss-cli.sh -c --file=/home/site/scripts/mysql-datasource-commands.cli -------------------------------------------------------------------------------- /.scripts/3C-sql/mssql-datasource-commands.cli: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | batch 3 | # ***** IMPORTANT : PATH should point to SQL Java driver and module XML file on App Service Linux ******* 4 | echo "Configuring sqlDS ===================" 5 | echo "Installing MSSQL module" 6 | module add --name=com.microsoft --resources=/home/site/libs/mssql-jdbc-7.2.1.jre8.jar --module-xml=/home/site/scripts/mssql-module.xml 7 | echo "Installing MSSQL driver" 8 | /subsystem=datasources/jdbc-driver=sqlserver:add(driver-name="sqlserver",driver-module-name="com.microsoft",driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver,driver-datasource-class-name=com.microsoft.sqlserver.jdbc.SQLServerDataSource) 9 | echo "Installing MSSQL datasource" 10 | data-source add --name=sqlDS --jndi-name=java:jboss/datasources/sqlDS --driver-name=sqlserver --connection-url=${SQL_CONNECTION_URL,env.SQL_CONNECTION_URL:example} --validate-on-match=true --background-validation=false --valid-connection-checker-class-name=org.jboss.jca.adapters.jdbc.extensions.mssql.MSSQLValidConnectionChecker --exception-sorter-class-name=org.jboss.jca.adapters.jdbc.extensions.mssql.MSSQLExceptionSorter 11 | run-batch 12 | echo "Installed MSSQL datasource" -------------------------------------------------------------------------------- /.scripts/3C-sql/mssql-jdbc-7.2.1.jre8.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/.scripts/3C-sql/mssql-jdbc-7.2.1.jre8.jar -------------------------------------------------------------------------------- /.scripts/3C-sql/mssql-module.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.scripts/3C-sql/startup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | /opt/eap/bin/jboss-cli.sh -c --file=/home/site/scripts/mssql-datasource-commands.cli -------------------------------------------------------------------------------- /.scripts/persistence-h2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | java:jboss/datasources/ExampleDS 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.scripts/persistence-mysql.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | java:jboss/datasources/mysqlDS 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.scripts/persistence-postgresql.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | java:jboss/datasources/postgresDS 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.scripts/persistence-sql.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | java:jboss/datasources/sqlDS 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE -------------------------------------------------------------------------------- /setup-env-variables-template.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Azure Environment 4 | export SUBSCRIPTION=your-subscription-id # customize this 5 | export RESOURCE_GROUP=migrate-java-ee-app-to-azure # you may want to customize by supplying a Resource Group name 6 | export WEBAPP=your-web-app-name # customize this - say, seattle-petstore 7 | export REGION=westus 8 | 9 | export DATABASE_SERVER=your-database-server-name # customize this 10 | export DATABASE_ADMIN=selvasingh # customize this 11 | export DATABASE_ADMIN_PASSWORD=SuperS3cr3t # customize this 12 | 13 | # ======== DERIVED Environment Variable Values =========== 14 | 15 | # Composed secrets for PostgreSQL 16 | export POSTGRES_SERVER_NAME=postgres-${DATABASE_SERVER} 17 | export POSTGRES_SERVER_ADMIN_LOGIN_NAME=${DATABASE_ADMIN} 18 | export POSTGRES_SERVER_ADMIN_PASSWORD=${DATABASE_ADMIN_PASSWORD} 19 | export POSTGRES_DATABASE_NAME=postgres 20 | 21 | export POSTGRES_SERVER_FULL_NAME=${POSTGRES_SERVER_NAME}.postgres.database.azure.com 22 | export POSTGRES_CONNECTION_URL=jdbc:postgresql://${POSTGRES_SERVER_FULL_NAME}:5432/${POSTGRES_DATABASE_NAME}?ssl=true 23 | export POSTGRES_SERVER_ADMIN_FULL_NAME=${POSTGRES_SERVER_ADMIN_LOGIN_NAME}@${POSTGRES_SERVER_NAME} 24 | 25 | # Composed secrets for MySQL 26 | export MYSQL_SERVER_NAME=mysql-${DATABASE_SERVER} 27 | export MYSQL_SERVER_ADMIN_LOGIN_NAME=${DATABASE_ADMIN} 28 | export MYSQL_SERVER_ADMIN_PASSWORD=${DATABASE_ADMIN_PASSWORD} 29 | export MYSQL_DATABASE_NAME=petstore 30 | 31 | export MYSQL_SERVER_FULL_NAME=${MYSQL_SERVER_NAME}.mysql.database.azure.com 32 | export MYSQL_CONNECTION_URL=jdbc:mysql://${MYSQL_SERVER_FULL_NAME}:3306/${MYSQL_DATABASE_NAME}?ssl=true\&useLegacyDatetimeCode=false\&serverTimezone=GMT 33 | export MYSQL_SERVER_ADMIN_FULL_NAME=${MYSQL_SERVER_ADMIN_LOGIN_NAME}\@${MYSQL_SERVER_NAME} 34 | 35 | # Composed secrets for SQLServer 36 | export SQL_SERVER_NAME=sql-${DATABASE_SERVER} 37 | export SQL_SERVER_ADMIN_LOGIN_NAME=${DATABASE_ADMIN} 38 | export SQL_SERVER_ADMIN_PASSWORD=${DATABASE_ADMIN_PASSWORD} 39 | export SQL_DATABASE_NAME=petstore 40 | 41 | export SQL_SERVER_FULL_NAME=${SQL_SERVER_NAME}.database.windows.net 42 | export SQL_SERVER_ADMIN_FULL_NAME=${SQL_SERVER_ADMIN_LOGIN_NAME}@${SQL_SERVER_NAME} 43 | export SQL_CONNECTION_URL="jdbc:sqlserver://${SQL_SERVER_FULL_NAME}:1433;database=${SQL_DATABASE_NAME};user=${SQL_SERVER_ADMIN_FULL_NAME};password=${SQL_SERVER_ADMIN_PASSWORD};encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;" 44 | 45 | # Composed secrets for Azure Monitor, Log Analtyics and Application Insights 46 | export LOG_ANALYTICS=${WEBAPP} 47 | export LOG_ANALYTICS_RESOURCE_ID= # will be set by script 48 | export WEBAPP_RESOURCE_ID= # will be set by script 49 | export DIAGNOSTIC_SETTINGS=send-logs-and-metrics 50 | export APPLICATION_INSIGHTS=${WEBAPP} 51 | export APPLICATIONINSIGHTS_CONNECTION_STRING= # will be set by script 52 | 53 | # ======== Programmatically Set ========== 54 | 55 | #IPCONFIG 56 | export DEVBOX_IP_ADDRESS=$(curl ifconfig.me) 57 | -------------------------------------------------------------------------------- /src/main/docker/postgresql.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | sponsor-postgresql: 4 | image: postgres:9.6.5 5 | ports: 6 | - 5432:5432 7 | -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/constraints/Email.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.constraints; 2 | 3 | import javax.validation.Constraint; 4 | import javax.validation.Payload; 5 | import javax.validation.ReportAsSingleViolation; 6 | import javax.validation.constraints.Pattern; 7 | import javax.validation.constraints.Size; 8 | import java.lang.annotation.Documented; 9 | import java.lang.annotation.ElementType; 10 | import java.lang.annotation.Retention; 11 | import java.lang.annotation.RetentionPolicy; 12 | import java.lang.annotation.Target; 13 | 14 | /** 15 | * @author Antonio Goncalves 16 | * http://www.antoniogoncalves.org 17 | * -- 18 | */ 19 | 20 | @Constraint(validatedBy = {}) 21 | @Size(min = 5) 22 | @Pattern(regexp = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\." 23 | + "[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*" 24 | + "@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?") 25 | @ReportAsSingleViolation 26 | @Retention(RetentionPolicy.RUNTIME) 27 | @Target( {ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, 28 | ElementType.TYPE, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR}) 29 | @Documented 30 | public @interface Email 31 | { 32 | 33 | // ====================================== 34 | // = Attributes = 35 | // ====================================== 36 | 37 | String message() default "{org.agoncal.application.petstore.constraints.Email.message}"; 38 | 39 | Class[] groups() default {}; 40 | 41 | Class[] payload() default {}; 42 | 43 | // ====================================== 44 | // = Inner Annotation = 45 | // ====================================== 46 | 47 | @Retention(RetentionPolicy.RUNTIME) 48 | @Target( {ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, 49 | ElementType.TYPE, ElementType.ANNOTATION_TYPE, 50 | ElementType.CONSTRUCTOR}) 51 | public @interface List 52 | { 53 | Email[] value(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/constraints/Login.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.constraints; 2 | 3 | import javax.validation.Constraint; 4 | import javax.validation.Payload; 5 | import javax.validation.ReportAsSingleViolation; 6 | import javax.validation.constraints.NotNull; 7 | import javax.validation.constraints.Size; 8 | import java.lang.annotation.Documented; 9 | import java.lang.annotation.ElementType; 10 | import java.lang.annotation.Retention; 11 | import java.lang.annotation.RetentionPolicy; 12 | import java.lang.annotation.Target; 13 | 14 | /** 15 | * @author Antonio Goncalves 16 | * http://www.antoniogoncalves.org 17 | * -- 18 | */ 19 | 20 | @Constraint(validatedBy = {}) 21 | @NotNull 22 | @Size(min = 1, max = 10) 23 | @ReportAsSingleViolation 24 | @Retention(RetentionPolicy.RUNTIME) 25 | @Target( {ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, 26 | ElementType.TYPE, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR}) 27 | @Documented 28 | public @interface Login 29 | { 30 | 31 | // ====================================== 32 | // = Attributes = 33 | // ====================================== 34 | 35 | String message() default "{org.agoncal.application.petstore.constraints.Login.message}"; 36 | 37 | Class[] groups() default {}; 38 | 39 | Class[] payload() default {}; 40 | 41 | // ====================================== 42 | // = Inner Annotation = 43 | // ====================================== 44 | 45 | @Retention(RetentionPolicy.RUNTIME) 46 | @Target( {ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, 47 | ElementType.TYPE, ElementType.ANNOTATION_TYPE, 48 | ElementType.CONSTRUCTOR}) 49 | public @interface List 50 | { 51 | Login[] value(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/constraints/NotEmpty.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.constraints; 2 | 3 | import javax.validation.Constraint; 4 | import javax.validation.Payload; 5 | import javax.validation.ReportAsSingleViolation; 6 | import javax.validation.constraints.NotNull; 7 | import javax.validation.constraints.Size; 8 | import java.lang.annotation.Documented; 9 | import java.lang.annotation.ElementType; 10 | import java.lang.annotation.Retention; 11 | import java.lang.annotation.RetentionPolicy; 12 | import java.lang.annotation.Target; 13 | 14 | /** 15 | * @author Antonio Goncalves 16 | * http://www.antoniogoncalves.org 17 | * -- 18 | */ 19 | 20 | @Constraint(validatedBy = {}) 21 | @NotNull 22 | @Size(min = 1) 23 | @ReportAsSingleViolation 24 | @Retention(RetentionPolicy.RUNTIME) 25 | @Target( {ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, 26 | ElementType.TYPE, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR}) 27 | @Documented 28 | public @interface NotEmpty 29 | { 30 | 31 | // ====================================== 32 | // = Attributes = 33 | // ====================================== 34 | 35 | String message() default "{org.agoncal.application.petstore.constraints.NotEmpty.message}"; 36 | 37 | Class[] groups() default {}; 38 | 39 | Class[] payload() default {}; 40 | 41 | // ====================================== 42 | // = Inner Annotation = 43 | // ====================================== 44 | 45 | @Retention(RetentionPolicy.RUNTIME) 46 | @Target( {ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, 47 | ElementType.TYPE, ElementType.ANNOTATION_TYPE, 48 | ElementType.CONSTRUCTOR}) 49 | public @interface List 50 | { 51 | NotEmpty[] value(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/constraints/Price.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.constraints; 2 | 3 | import javax.validation.Constraint; 4 | import javax.validation.Payload; 5 | import javax.validation.ReportAsSingleViolation; 6 | import javax.validation.constraints.DecimalMin; 7 | import java.lang.annotation.Documented; 8 | import java.lang.annotation.ElementType; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | import java.lang.annotation.Target; 12 | 13 | /** 14 | * @author Antonio Goncalves 15 | * http://www.antoniogoncalves.org 16 | * -- 17 | */ 18 | 19 | @Constraint(validatedBy = {}) 20 | @DecimalMin("10") 21 | @ReportAsSingleViolation 22 | @Retention(RetentionPolicy.RUNTIME) 23 | @Target( {ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, 24 | ElementType.TYPE, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR}) 25 | @Documented 26 | public @interface Price 27 | { 28 | 29 | // ====================================== 30 | // = Attributes = 31 | // ====================================== 32 | 33 | String message() default "{org.agoncal.application.petstore.constraints.Price.message}"; 34 | 35 | Class[] groups() default {}; 36 | 37 | Class[] payload() default {}; 38 | 39 | // ====================================== 40 | // = Inner Annotation = 41 | // ====================================== 42 | 43 | @Retention(RetentionPolicy.RUNTIME) 44 | @Target( {ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, 45 | ElementType.TYPE, ElementType.ANNOTATION_TYPE, 46 | ElementType.CONSTRUCTOR}) 47 | public @interface List 48 | { 49 | Price[] value(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/exceptions/ValidationException.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.exceptions; 2 | 3 | /** 4 | * @author Antonio Goncalves 5 | * http://www.antoniogoncalves.org 6 | * -- 7 | * Thrown when data is not valid 8 | */ 9 | 10 | public class ValidationException extends RuntimeException 11 | { 12 | // ====================================== 13 | // = Constructors = 14 | // ====================================== 15 | 16 | public ValidationException() 17 | { 18 | super(); 19 | } 20 | 21 | public ValidationException(String message) 22 | { 23 | super(message); 24 | } 25 | } -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/model/CreditCardConverter.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.model; 2 | 3 | public class CreditCardConverter 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/model/CreditCardType.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.model; 2 | 3 | /** 4 | * @author Antonio Goncalves 5 | * http://www.antoniogoncalves.org 6 | * -- 7 | */ 8 | 9 | public enum CreditCardType 10 | { 11 | 12 | // ====================================== 13 | // = Constants = 14 | // ====================================== 15 | 16 | VISA, MASTER_CARD, AMERICAN_EXPRESS 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/model/OrderLine.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.model; 2 | 3 | import java.io.Serializable; 4 | import java.util.Objects; 5 | 6 | import javax.persistence.*; 7 | import javax.validation.constraints.Min; 8 | 9 | @Entity 10 | @Table(name = "order_line") 11 | public class OrderLine implements Serializable 12 | { 13 | 14 | // ====================================== 15 | // = Attributes = 16 | // ====================================== 17 | 18 | @Id 19 | @GeneratedValue(strategy = GenerationType.AUTO) 20 | @Column(name = "id", updatable = false, nullable = false) 21 | private Long id; 22 | @Version 23 | @Column(name = "version") 24 | private int version; 25 | 26 | @Column(nullable = false) 27 | @Min(1) 28 | private Integer quantity; 29 | 30 | @ManyToOne(cascade = CascadeType.PERSIST) 31 | @JoinColumn(name = "item_fk", nullable = false) 32 | private Item item; 33 | 34 | // ====================================== 35 | // = Constructors = 36 | // ====================================== 37 | 38 | public OrderLine() 39 | { 40 | } 41 | 42 | public OrderLine(Integer quantity, Item item) 43 | { 44 | this.quantity = quantity; 45 | this.item = item; 46 | } 47 | 48 | // ====================================== 49 | // = Business methods = 50 | // ====================================== 51 | 52 | public Float getSubTotal() 53 | { 54 | return item.getUnitCost() * quantity; 55 | } 56 | 57 | // ====================================== 58 | // = Getters & setters = 59 | // ====================================== 60 | 61 | public Long getId() 62 | { 63 | return this.id; 64 | } 65 | 66 | public void setId(final Long id) 67 | { 68 | this.id = id; 69 | } 70 | 71 | public int getVersion() 72 | { 73 | return this.version; 74 | } 75 | 76 | public void setVersion(final int version) 77 | { 78 | this.version = version; 79 | } 80 | 81 | public Integer getQuantity() 82 | { 83 | return quantity; 84 | } 85 | 86 | public void setQuantity(Integer quantity) 87 | { 88 | this.quantity = quantity; 89 | } 90 | 91 | public Item getItem() 92 | { 93 | return this.item; 94 | } 95 | 96 | public void setItem(final Item item) 97 | { 98 | this.item = item; 99 | } 100 | 101 | // ====================================== 102 | // = Methods hash, equals, toString = 103 | // ====================================== 104 | 105 | @Override 106 | public final boolean equals(Object o) 107 | { 108 | if (this == o) 109 | return true; 110 | if (!(o instanceof OrderLine)) 111 | return false; 112 | OrderLine orderLine = (OrderLine) o; 113 | return Objects.equals(quantity, orderLine.quantity) && 114 | Objects.equals(item, orderLine.item); 115 | } 116 | 117 | @Override 118 | public final int hashCode() 119 | { 120 | return Objects.hash(quantity, item); 121 | } 122 | 123 | @Override 124 | public String toString() 125 | { 126 | return "OrderLine{" + 127 | "id=" + id + 128 | ", version=" + version + 129 | ", quantity=" + quantity + 130 | ", item=" + item + 131 | '}'; 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/model/UserRole.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.model; 2 | 3 | /** 4 | * @author Antonio Goncalves - http://www.antoniogoncalves.org -- 5 | */ 6 | public enum UserRole 7 | { 8 | // ====================================== 9 | // = Attributes = 10 | // ====================================== 11 | 12 | USER, ADMIN 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/rest/RestApplication.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.rest; 2 | 3 | import javax.ws.rs.ApplicationPath; 4 | import javax.ws.rs.core.Application; 5 | import java.util.HashSet; 6 | import java.util.Set; 7 | 8 | /** 9 | * @author Antonio Goncalves 10 | * http://www.antoniogoncalves.org 11 | * -- 12 | */ 13 | 14 | @ApplicationPath("/rest") 15 | public class RestApplication extends Application 16 | { 17 | // ====================================== 18 | // = Business methods = 19 | // ====================================== 20 | 21 | // TODO Not sure this is still needed for portability in EE 7 22 | // @Override 23 | // public Set> getClasses() 24 | // { 25 | // Set> classes = new HashSet<>(); 26 | // classes.add(CategoryEndpoint.class); 27 | // classes.add(CountryEndpoint.class); 28 | // classes.add(CustomerEndpoint.class); 29 | // classes.add(ItemEndpoint.class); 30 | // classes.add(ProductEndpoint.class); 31 | // return classes; 32 | // } 33 | } -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/security/LoginContextProducer.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.security; 2 | 3 | import org.agoncal.application.petstore.util.ConfigProperty; 4 | 5 | import javax.enterprise.inject.Produces; 6 | import javax.inject.Inject; 7 | import javax.security.auth.login.LoginContext; 8 | import javax.security.auth.login.LoginException; 9 | import java.io.File; 10 | import java.net.URISyntaxException; 11 | 12 | /** 13 | * @author blep 14 | * Date: 16/02/12 15 | * Time: 07:28 16 | */ 17 | 18 | public class LoginContextProducer 19 | { 20 | 21 | // ====================================== 22 | // = Attributes = 23 | // ====================================== 24 | 25 | @Inject 26 | private SimpleCallbackHandler callbackHandler; 27 | 28 | // ====================================== 29 | // = Business methods = 30 | // ====================================== 31 | 32 | @Produces 33 | public LoginContext produceLoginContext(@ConfigProperty("loginConfigFile") String loginConfigFileName, 34 | @ConfigProperty("loginModuleName") String loginModuleName) throws LoginException, URISyntaxException 35 | { 36 | 37 | //System.setProperty("java.security.auth.login.config", new File(LoginContextProducer.class.getResource(loginConfigFileName).toURI()).getPath()); 38 | 39 | try 40 | { 41 | return new LoginContext(loginModuleName, callbackHandler); 42 | } 43 | catch (Exception e) 44 | { 45 | System.out.println("ouch!!!"); 46 | return null; 47 | } 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/security/SimpleCallbackHandler.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.security; 2 | 3 | import org.agoncal.application.petstore.view.shopping.CredentialsBean; 4 | 5 | import javax.enterprise.context.RequestScoped; 6 | import javax.inject.Inject; 7 | import javax.inject.Named; 8 | import javax.security.auth.callback.Callback; 9 | import javax.security.auth.callback.CallbackHandler; 10 | import javax.security.auth.callback.NameCallback; 11 | import javax.security.auth.callback.PasswordCallback; 12 | import javax.security.auth.callback.UnsupportedCallbackException; 13 | import java.io.IOException; 14 | 15 | /** 16 | * @author blep 17 | * Date: 12/02/12 18 | * Time: 12:29 19 | */ 20 | 21 | @Named 22 | public class SimpleCallbackHandler implements CallbackHandler 23 | { 24 | 25 | // ====================================== 26 | // = Attributes = 27 | // ====================================== 28 | 29 | @Inject 30 | //@RequestScoped 31 | private CredentialsBean credentials; 32 | 33 | // ====================================== 34 | // = Business methods = 35 | // ====================================== 36 | 37 | @Override 38 | public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException 39 | { 40 | for (Callback callback : callbacks) 41 | { 42 | if (callback instanceof NameCallback) 43 | { 44 | NameCallback nameCallback = (NameCallback) callback; 45 | nameCallback.setName(credentials.getLogin()); 46 | } 47 | else if (callback instanceof PasswordCallback) 48 | { 49 | PasswordCallback passwordCallback = (PasswordCallback) callback; 50 | passwordCallback.setPassword(credentials.getPassword().toCharArray()); 51 | } 52 | else 53 | { 54 | throw new UnsupportedCallbackException(callback); 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/service/CategoryService.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.service; 2 | 3 | import org.agoncal.application.petstore.model.Category; 4 | 5 | import javax.annotation.Resource; 6 | import javax.ejb.Stateless; 7 | import javax.ejb.LocalBean; 8 | import javax.persistence.criteria.CriteriaBuilder; 9 | import javax.persistence.criteria.Predicate; 10 | import javax.persistence.criteria.Root; 11 | import java.io.Serializable; 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | import org.agoncal.application.petstore.util.Loggable; 15 | 16 | @Stateless 17 | @LocalBean 18 | @Loggable 19 | public class CategoryService extends AbstractService implements Serializable 20 | { 21 | 22 | // ====================================== 23 | // = Constructors = 24 | // ====================================== 25 | 26 | public CategoryService() 27 | { 28 | super(Category.class); 29 | } 30 | 31 | // ====================================== 32 | // = Protected methods = 33 | // ====================================== 34 | 35 | @Override 36 | protected Predicate[] getSearchPredicates(Root root, Category example) 37 | { 38 | CriteriaBuilder builder = this.entityManager.getCriteriaBuilder(); 39 | List predicatesList = new ArrayList(); 40 | 41 | String name = example.getName(); 42 | if (name != null && !"".equals(name)) 43 | { 44 | predicatesList.add(builder.like(builder.lower(root. get("name")), '%' + name.toLowerCase() + '%')); 45 | } 46 | String description = example.getDescription(); 47 | if (description != null && !"".equals(description)) 48 | { 49 | predicatesList.add(builder.like(builder.lower(root. get("description")), '%' + description.toLowerCase() + '%')); 50 | } 51 | 52 | return predicatesList.toArray(new Predicate[predicatesList.size()]); 53 | } 54 | } -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/service/ComputablePurchaseOrder.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.service; 2 | 3 | public interface ComputablePurchaseOrder 4 | { 5 | } -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/service/CountryService.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.service; 2 | 3 | import org.agoncal.application.petstore.model.Country; 4 | 5 | import javax.ejb.Stateless; 6 | import javax.ejb.LocalBean; 7 | import javax.persistence.criteria.CriteriaBuilder; 8 | import javax.persistence.criteria.Predicate; 9 | import javax.persistence.criteria.Root; 10 | import java.io.Serializable; 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | import org.agoncal.application.petstore.util.Loggable; 14 | 15 | @Stateless 16 | @LocalBean 17 | @Loggable 18 | public class CountryService extends AbstractService implements Serializable 19 | { 20 | 21 | // ====================================== 22 | // = Constructors = 23 | // ====================================== 24 | 25 | public CountryService() 26 | { 27 | super(Country.class); 28 | } 29 | 30 | // ====================================== 31 | // = Protected methods = 32 | // ====================================== 33 | 34 | @Override 35 | protected Predicate[] getSearchPredicates(Root root, Country example) 36 | { 37 | CriteriaBuilder builder = this.entityManager.getCriteriaBuilder(); 38 | List predicatesList = new ArrayList(); 39 | 40 | String isoCode = example.getIsoCode(); 41 | if (isoCode != null && !"".equals(isoCode)) 42 | { 43 | predicatesList.add(builder.like(builder.lower(root. get("isoCode")), '%' + isoCode.toLowerCase() + '%')); 44 | } 45 | String name = example.getName(); 46 | if (name != null && !"".equals(name)) 47 | { 48 | predicatesList.add(builder.like(builder.lower(root. get("name")), '%' + name.toLowerCase() + '%')); 49 | } 50 | String printableName = example.getPrintableName(); 51 | if (printableName != null && !"".equals(printableName)) 52 | { 53 | predicatesList.add(builder.like(builder.lower(root. get("printableName")), '%' + printableName.toLowerCase() + '%')); 54 | } 55 | String iso3 = example.getIso3(); 56 | if (iso3 != null && !"".equals(iso3)) 57 | { 58 | predicatesList.add(builder.like(builder.lower(root. get("iso3")), '%' + iso3.toLowerCase() + '%')); 59 | } 60 | String numcode = example.getNumcode(); 61 | if (numcode != null && !"".equals(numcode)) 62 | { 63 | predicatesList.add(builder.like(builder.lower(root. get("numcode")), '%' + numcode.toLowerCase() + '%')); 64 | } 65 | 66 | return predicatesList.toArray(new Predicate[predicatesList.size()]); 67 | } 68 | } -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/service/InventoryService.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.service; 2 | 3 | import org.agoncal.application.petstore.util.Loggable; 4 | 5 | @Loggable 6 | public class InventoryService 7 | { 8 | } -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/service/ItemService.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.service; 2 | 3 | import org.agoncal.application.petstore.model.Item; 4 | import org.agoncal.application.petstore.model.Product; 5 | 6 | import javax.ejb.Stateless; 7 | import javax.ejb.LocalBean; 8 | import javax.persistence.criteria.CriteriaBuilder; 9 | import javax.persistence.criteria.Predicate; 10 | import javax.persistence.criteria.Root; 11 | import java.io.Serializable; 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | import org.agoncal.application.petstore.util.Loggable; 15 | 16 | @Stateless 17 | @LocalBean 18 | @Loggable 19 | public class ItemService extends AbstractService implements Serializable 20 | { 21 | 22 | 23 | // ====================================== 24 | // = Constructors = 25 | // ====================================== 26 | 27 | public ItemService() 28 | { 29 | super(Item.class); 30 | } 31 | 32 | // ====================================== 33 | // = Protected methods = 34 | // ====================================== 35 | 36 | @Override 37 | protected Predicate[] getSearchPredicates(Root root, Item example) 38 | { 39 | CriteriaBuilder builder = this.entityManager.getCriteriaBuilder(); 40 | List predicatesList = new ArrayList(); 41 | 42 | String name = example.getName(); 43 | if (name != null && !"".equals(name)) 44 | { 45 | predicatesList.add(builder.like(builder.lower(root. get("name")), '%' + name.toLowerCase() + '%')); 46 | } 47 | String description = example.getDescription(); 48 | if (description != null && !"".equals(description)) 49 | { 50 | predicatesList.add(builder.like(builder.lower(root. get("description")), '%' + description.toLowerCase() + '%')); 51 | } 52 | String imagePath = example.getImagePath(); 53 | if (imagePath != null && !"".equals(imagePath)) 54 | { 55 | predicatesList.add(builder.like(builder.lower(root. get("imagePath")), '%' + imagePath.toLowerCase() + '%')); 56 | } 57 | Product product = example.getProduct(); 58 | if (product != null) 59 | { 60 | predicatesList.add(builder.equal(root.get("product"), product)); 61 | } 62 | 63 | return predicatesList.toArray(new Predicate[predicatesList.size()]); 64 | } 65 | } -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/service/OrderLineService.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.service; 2 | 3 | import org.agoncal.application.petstore.model.Item; 4 | import org.agoncal.application.petstore.model.OrderLine; 5 | 6 | import javax.ejb.Stateless; 7 | import javax.ejb.LocalBean; 8 | import javax.persistence.criteria.CriteriaBuilder; 9 | import javax.persistence.criteria.Predicate; 10 | import javax.persistence.criteria.Root; 11 | import java.io.Serializable; 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | import org.agoncal.application.petstore.util.Loggable; 15 | 16 | @Stateless 17 | @LocalBean 18 | @Loggable 19 | public class OrderLineService extends AbstractService implements Serializable 20 | { 21 | 22 | // ====================================== 23 | // = Constructors = 24 | // ====================================== 25 | 26 | public OrderLineService() 27 | { 28 | super(OrderLine.class); 29 | } 30 | 31 | // ====================================== 32 | // = Protected methods = 33 | // ====================================== 34 | 35 | @Override 36 | protected Predicate[] getSearchPredicates(Root root, OrderLine example) 37 | { 38 | CriteriaBuilder builder = this.entityManager.getCriteriaBuilder(); 39 | List predicatesList = new ArrayList(); 40 | 41 | Integer quantity = example.getQuantity(); 42 | if (quantity != null && quantity.intValue() != 0) 43 | { 44 | predicatesList.add(builder.equal(root.get("quantity"), quantity)); 45 | } 46 | Item item = example.getItem(); 47 | if (item != null) 48 | { 49 | predicatesList.add(builder.equal(root.get("item"), item)); 50 | } 51 | 52 | return predicatesList.toArray(new Predicate[predicatesList.size()]); 53 | } 54 | } -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.service; 2 | 3 | import org.agoncal.application.petstore.model.Category; 4 | import org.agoncal.application.petstore.model.Product; 5 | 6 | import javax.ejb.Stateless; 7 | import javax.ejb.LocalBean; 8 | import javax.persistence.criteria.CriteriaBuilder; 9 | import javax.persistence.criteria.Predicate; 10 | import javax.persistence.criteria.Root; 11 | import java.io.Serializable; 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | import org.agoncal.application.petstore.util.Loggable; 15 | 16 | @Stateless 17 | @LocalBean 18 | @Loggable 19 | public class ProductService extends AbstractService implements Serializable 20 | { 21 | 22 | // ====================================== 23 | // = Constructors = 24 | // ====================================== 25 | 26 | public ProductService() 27 | { 28 | super(Product.class); 29 | } 30 | 31 | // ====================================== 32 | // = Protected methods = 33 | // ====================================== 34 | 35 | @Override 36 | protected Predicate[] getSearchPredicates(Root root, Product example) 37 | { 38 | CriteriaBuilder builder = this.entityManager.getCriteriaBuilder(); 39 | List predicatesList = new ArrayList(); 40 | 41 | String name = example.getName(); 42 | if (name != null && !"".equals(name)) 43 | { 44 | predicatesList.add(builder.like(builder.lower(root. get("name")), '%' + name.toLowerCase() + '%')); 45 | } 46 | String description = example.getDescription(); 47 | if (description != null && !"".equals(description)) 48 | { 49 | predicatesList.add(builder.like(builder.lower(root. get("description")), '%' + description.toLowerCase() + '%')); 50 | } 51 | Category category = example.getCategory(); 52 | if (category != null) 53 | { 54 | predicatesList.add(builder.equal(root.get("category"), category)); 55 | } 56 | 57 | return predicatesList.toArray(new Predicate[predicatesList.size()]); 58 | } 59 | } -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/service/PurchaseOrderDecorator.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.service; 2 | 3 | import org.agoncal.application.petstore.service.ComputablePurchaseOrder; 4 | import javax.decorator.Decorator; 5 | import javax.inject.Inject; 6 | import javax.decorator.Delegate; 7 | 8 | @Decorator 9 | public abstract class PurchaseOrderDecorator implements ComputablePurchaseOrder 10 | { 11 | 12 | @Inject 13 | @Delegate 14 | private ComputablePurchaseOrder delegate; 15 | } -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/service/ShippingService.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.service; 2 | 3 | import org.agoncal.application.petstore.util.Loggable; 4 | 5 | @Loggable 6 | public class ShippingService 7 | { 8 | } -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/service/StatisticService.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.service; 2 | 3 | import org.agoncal.application.petstore.util.Loggable; 4 | 5 | @Loggable 6 | public class StatisticService 7 | { 8 | } -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/util/ConfigProperty.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.util; 2 | 3 | import javax.enterprise.util.Nonbinding; 4 | import javax.inject.Qualifier; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | import java.lang.annotation.ElementType; 9 | import java.lang.annotation.Documented; 10 | 11 | @Qualifier 12 | @Retention(RetentionPolicy.RUNTIME) 13 | @Target({ ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, 14 | ElementType.TYPE }) 15 | @Documented 16 | public @interface ConfigProperty { 17 | @Nonbinding String value() default ""; 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/util/ConfigPropertyProducer.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.util; 2 | 3 | import javax.enterprise.inject.Produces; 4 | import javax.enterprise.inject.spi.InjectionPoint; 5 | import java.io.IOException; 6 | import java.util.Properties; 7 | 8 | /** 9 | * @author blep 10 | * Date: 16/02/12 11 | * Time: 20:56 12 | */ 13 | 14 | public class ConfigPropertyProducer { 15 | 16 | // ====================================== 17 | // = Attributes = 18 | // ====================================== 19 | 20 | private static Properties props; 21 | 22 | static { 23 | props = new Properties(); 24 | try { 25 | props.load(ConfigPropertyProducer.class.getResourceAsStream("/config.properties")); 26 | } catch (IOException e) { 27 | e.printStackTrace(); 28 | } 29 | } 30 | 31 | // ====================================== 32 | // = Business methods = 33 | // ====================================== 34 | 35 | @Produces 36 | @ConfigProperty 37 | public static String produceConfigProperty(InjectionPoint ip) { 38 | String key = ip.getAnnotated().getAnnotation(ConfigProperty.class).value(); 39 | 40 | return props.getProperty(key); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/util/DatabaseProducer.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.util; 2 | 3 | import javax.enterprise.inject.Produces; 4 | import javax.persistence.EntityManager; 5 | import javax.persistence.PersistenceContext; 6 | 7 | /** 8 | * @author Antonio Goncalves 9 | * http://www.antoniogoncalves.org 10 | * -- 11 | */ 12 | 13 | public class DatabaseProducer 14 | { 15 | 16 | // ====================================== 17 | // = Attributes = 18 | // ====================================== 19 | 20 | @Produces 21 | @PersistenceContext(unitName = "applicationPetstorePU") 22 | private EntityManager em; 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/util/Discount.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.util; 2 | 3 | import javax.inject.Qualifier; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Documented; 9 | 10 | @Qualifier 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target({ ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, 13 | ElementType.TYPE }) 14 | @Documented 15 | public @interface Discount 16 | { 17 | } -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/util/Loggable.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.util; 2 | 3 | import javax.interceptor.InterceptorBinding; 4 | import java.lang.annotation.*; 5 | 6 | import static java.lang.annotation.ElementType.METHOD; 7 | import static java.lang.annotation.ElementType.TYPE; 8 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 9 | 10 | /** 11 | * @author Antonio Goncalves 12 | * http://www.antoniogoncalves.org 13 | * -- 14 | */ 15 | 16 | @InterceptorBinding 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Target({ ElementType.METHOD, ElementType.TYPE }) 19 | @Documented 20 | public @interface Loggable 21 | { 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/util/LoggingInterceptor.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.util; 2 | 3 | import javax.inject.Inject; 4 | import javax.interceptor.AroundInvoke; 5 | import javax.interceptor.Interceptor; 6 | import javax.interceptor.InvocationContext; 7 | import java.io.Serializable; 8 | import java.util.logging.Logger; 9 | 10 | /** 11 | * @author Antonio Goncalves 12 | * http://www.antoniogoncalves.org 13 | * -- 14 | * This interceptor implements Serializable because it's used on a Stateful Session Bean who has 15 | * passivation and activation lifecycle. 16 | */ 17 | 18 | @Loggable 19 | @Interceptor 20 | public class LoggingInterceptor implements Serializable 21 | { 22 | 23 | // ====================================== 24 | // = Attributes = 25 | // ====================================== 26 | 27 | @Inject 28 | private transient Logger logger; 29 | 30 | // ====================================== 31 | // = Business methods = 32 | // ====================================== 33 | 34 | @AroundInvoke 35 | private Object intercept(InvocationContext ic) throws Exception 36 | { 37 | logger.entering(ic.getTarget().getClass().getName(), ic.getMethod().getName()); 38 | logger.info(">>> " + ic.getTarget().getClass().getName() + "-" + ic.getMethod().getName()); 39 | try 40 | { 41 | return ic.proceed(); 42 | } 43 | finally 44 | { 45 | logger.exiting(ic.getTarget().getClass().getName(), ic.getMethod().getName()); 46 | logger.info("<<< " + ic.getTarget().getClass().getName() + "-" + ic.getMethod().getName()); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/util/LoggingProducer.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.util; 2 | 3 | import javax.enterprise.inject.Produces; 4 | import javax.enterprise.inject.spi.InjectionPoint; 5 | import java.util.logging.Logger; 6 | 7 | /** 8 | * @author Antonio Goncalves 9 | * http://www.antoniogoncalves.org 10 | * -- 11 | */ 12 | 13 | public class LoggingProducer { 14 | 15 | // ====================================== 16 | // = Business methods = 17 | // ====================================== 18 | 19 | @Produces 20 | public Logger produceLogger(InjectionPoint injectionPoint) { 21 | return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/util/NumberProducer.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.util; 2 | 3 | import javax.enterprise.inject.Produces; 4 | import org.agoncal.application.petstore.util.Vat; 5 | import javax.inject.Named; 6 | import org.agoncal.application.petstore.util.Discount; 7 | 8 | public class NumberProducer 9 | { 10 | 11 | @Produces 12 | @Vat 13 | @Named 14 | private Float vatRate; 15 | @Produces 16 | @Discount 17 | @Named 18 | private Float discountRate; 19 | } -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/util/Vat.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.util; 2 | 3 | import javax.inject.Qualifier; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Documented; 9 | 10 | @Qualifier 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target({ ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, 13 | ElementType.TYPE }) 14 | @Documented 15 | public @interface Vat 16 | { 17 | } -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/view/AbstractBean.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.view; 2 | 3 | import org.agoncal.application.petstore.util.Loggable; 4 | 5 | import javax.faces.application.FacesMessage; 6 | import javax.faces.context.FacesContext; 7 | import javax.inject.Inject; 8 | import java.text.MessageFormat; 9 | import java.util.Locale; 10 | import java.util.Map; 11 | import java.util.ResourceBundle; 12 | import java.util.logging.Logger; 13 | 14 | /** 15 | * @author Antonio Goncalves 16 | * http://www.antoniogoncalves.org 17 | * -- 18 | */ 19 | 20 | @Loggable 21 | public abstract class AbstractBean { 22 | 23 | // ====================================== 24 | // = Attributes = 25 | // ====================================== 26 | 27 | @Inject 28 | private transient Logger logger; 29 | 30 | // ====================================== 31 | // = Protected Methods = 32 | // ====================================== 33 | 34 | private String getMessage(FacesContext facesContext, String msgKey, Object... args) { 35 | Locale locale = facesContext.getViewRoot().getLocale(); 36 | ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); 37 | ResourceBundle bundle = ResourceBundle.getBundle("Messages", locale, classLoader); 38 | String msgValue = bundle.getString(msgKey); 39 | return MessageFormat.format(msgValue, args); 40 | } 41 | 42 | protected void addInformationMessage(String message, Object... args) { 43 | FacesContext context = FacesContext.getCurrentInstance(); 44 | context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, getMessage(context, message, args), null)); 45 | } 46 | 47 | protected void addWarningMessage(String message, Object... args) { 48 | FacesContext context = FacesContext.getCurrentInstance(); 49 | context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, getMessage(context, message, args), null)); 50 | } 51 | 52 | protected void addErrorMessage(String message, Object... args) { 53 | FacesContext context = FacesContext.getCurrentInstance(); 54 | context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, getMessage(context, message, args), null)); 55 | } 56 | 57 | protected String getParam(String param) { 58 | FacesContext context = FacesContext.getCurrentInstance(); 59 | Map map = context.getExternalContext().getRequestParameterMap(); 60 | return map.get(param); 61 | } 62 | 63 | protected Long getParamId(String param) { 64 | return Long.valueOf(getParam(param)); 65 | } 66 | } -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/view/CatchException.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.view; 2 | 3 | import javax.interceptor.InterceptorBinding; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.Target; 6 | 7 | import static java.lang.annotation.ElementType.METHOD; 8 | import static java.lang.annotation.ElementType.TYPE; 9 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 10 | 11 | /** 12 | * @author Antonio Goncalves 13 | * http://www.antoniogoncalves.org 14 | * -- 15 | * Any JSF backing bean using this interceptor binding will catch and display exceptions on the JSF page 16 | */ 17 | 18 | @InterceptorBinding 19 | @Target({METHOD, TYPE}) 20 | @Retention(RUNTIME) 21 | public @interface CatchException { 22 | } -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/view/DebugBean.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.view; 2 | 3 | import org.agoncal.application.petstore.util.Loggable; 4 | 5 | import javax.faces.bean.RequestScoped; 6 | import javax.inject.Named; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /** 11 | * @author Antonio Goncalves 12 | * http://www.antoniogoncalves.org 13 | * -- 14 | */ 15 | 16 | @Named 17 | @RequestScoped 18 | @Loggable 19 | @CatchException 20 | public class DebugBean extends AbstractBean { 21 | 22 | // ====================================== 23 | // = Public Methods = 24 | // ====================================== 25 | 26 | public List getThreadStack() { 27 | StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); 28 | List elements = new ArrayList<>(); 29 | for (StackTraceElement stackTraceElement : stackTraceElements) { 30 | elements.add(stackTraceElement.getClassName() + "." + 31 | stackTraceElement.getMethodName() + 32 | "(" + stackTraceElement.getFileName() + ":" + stackTraceElement.getLineNumber() + ")"); 33 | } 34 | return elements; 35 | } 36 | 37 | public String getWorkingDirectory() { 38 | return new java.io.File(".").getAbsolutePath(); 39 | } 40 | 41 | public String getTotalMemory() { 42 | return String.valueOf(Runtime.getRuntime().totalMemory()); 43 | } 44 | 45 | public String getFreeMemory() { 46 | return String.valueOf(Runtime.getRuntime().freeMemory()); 47 | } 48 | } -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/view/ExceptionInterceptor.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.view; 2 | 3 | import javax.faces.application.FacesMessage; 4 | import javax.faces.context.FacesContext; 5 | import javax.inject.Inject; 6 | import javax.interceptor.AroundInvoke; 7 | import javax.interceptor.Interceptor; 8 | import javax.interceptor.InvocationContext; 9 | import java.io.Serializable; 10 | import java.util.logging.Logger; 11 | 12 | /** 13 | * @author Antonio Goncalves 14 | * http://www.antoniogoncalves.org 15 | * -- 16 | * This interceptor catches exception and displayes them in a JSF page 17 | */ 18 | 19 | @Interceptor 20 | @CatchException 21 | public class ExceptionInterceptor implements Serializable { 22 | 23 | @Inject 24 | private Logger log; 25 | 26 | @AroundInvoke 27 | public Object catchException(InvocationContext ic) throws Exception { 28 | try { 29 | return ic.proceed(); 30 | } catch (Exception e) { 31 | addErrorMessage(e.getMessage()); 32 | log.severe("/!\\ " + ic.getTarget().getClass().getName() + " - " + ic.getMethod().getName() + " - " + e.getMessage()); 33 | e.printStackTrace(); 34 | } 35 | return null; 36 | } 37 | 38 | // TODO to refactor with Controller methods 39 | protected void addErrorMessage(String message) { 40 | FacesContext context = FacesContext.getCurrentInstance(); 41 | context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, message, null)); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/view/LocaleBean.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.view; 2 | 3 | import org.agoncal.application.petstore.util.Loggable; 4 | 5 | import javax.enterprise.context.SessionScoped; 6 | import javax.enterprise.inject.Produces; 7 | import javax.faces.context.FacesContext; 8 | import javax.inject.Named; 9 | import java.io.Serializable; 10 | import java.util.Locale; 11 | 12 | /** 13 | * @author Antonio Goncalves 14 | * http://www.antoniogoncalves.org 15 | * -- 16 | */ 17 | 18 | @Named 19 | @SessionScoped 20 | @Loggable 21 | public class LocaleBean implements Serializable { 22 | 23 | @Produces 24 | private Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale(); 25 | 26 | // ====================================== 27 | // = Business methods = 28 | // ====================================== 29 | 30 | public Locale getLocale() { 31 | return locale; 32 | } 33 | 34 | public String getLanguage() { 35 | return locale.getLanguage(); 36 | } 37 | 38 | public void setLanguage(String language) { 39 | locale = new Locale(language); 40 | FacesContext.getCurrentInstance().getViewRoot().setLocale(locale); 41 | } 42 | } -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/view/LoggedIn.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.view; 2 | 3 | import javax.inject.Qualifier; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.Target; 6 | 7 | import static java.lang.annotation.ElementType.*; 8 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 9 | 10 | /** 11 | * @author Antonio Goncalves 12 | * http://www.antoniogoncalves.org 13 | * -- 14 | */ 15 | 16 | @Qualifier 17 | @Retention(RUNTIME) 18 | @Target({FIELD, TYPE, METHOD}) 19 | public @interface LoggedIn { 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/view/ViewUtils.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.view; 2 | 3 | import javax.persistence.Id; 4 | import java.beans.PropertyDescriptor; 5 | import java.lang.reflect.Field; 6 | import java.lang.reflect.Method; 7 | import java.util.ArrayList; 8 | import java.util.Collection; 9 | import java.util.List; 10 | 11 | /** 12 | * Utilities for working with Java Server Faces views. 13 | */ 14 | 15 | public final class ViewUtils 16 | { 17 | 18 | public static List asList(Collection collection) 19 | { 20 | 21 | if (collection == null) 22 | { 23 | return null; 24 | } 25 | 26 | return new ArrayList(collection); 27 | } 28 | 29 | public static String display(Object object) 30 | { 31 | 32 | if (object == null) 33 | { 34 | return null; 35 | } 36 | 37 | try 38 | { 39 | // Invoke toString if declared in the class. If not found, the NoSuchMethodException is caught and handled 40 | object.getClass().getDeclaredMethod("toString"); 41 | return object.toString(); 42 | } 43 | catch (NoSuchMethodException noMethodEx) 44 | { 45 | try 46 | { 47 | for (Field field : object.getClass().getDeclaredFields()) 48 | { 49 | // Find the primary key field and display it 50 | if (field.getAnnotation(Id.class) != null) 51 | { 52 | // Find a matching getter and invoke it to display the key 53 | for (Method method : object.getClass().getDeclaredMethods()) 54 | { 55 | if (method.equals(new PropertyDescriptor(field.getName(), object.getClass()).getReadMethod())) 56 | { 57 | return method.invoke(object).toString(); 58 | } 59 | } 60 | } 61 | } 62 | for (Method method : object.getClass().getDeclaredMethods()) 63 | { 64 | // Find the primary key as a property instead of a field, and display it 65 | if (method.getAnnotation(Id.class) != null) 66 | { 67 | return method.invoke(object).toString(); 68 | } 69 | } 70 | } 71 | catch (Exception ex) 72 | { 73 | // Unlikely, but abort and stop view generation if any exception is thrown 74 | throw new RuntimeException(ex); 75 | } 76 | } 77 | 78 | return null; 79 | } 80 | 81 | private ViewUtils() 82 | { 83 | 84 | // Can never be called 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/view/shopping/CredentialsBean.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.view.shopping; 2 | 3 | import javax.enterprise.context.SessionScoped; 4 | import javax.inject.Named; 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author Antonio Goncalves 9 | * http://www.antoniogoncalves.org 10 | * -- 11 | */ 12 | 13 | @Named 14 | @SessionScoped 15 | public class CredentialsBean implements Serializable { 16 | 17 | // ====================================== 18 | // = Attributes = 19 | // ====================================== 20 | 21 | private String login; 22 | private String password; 23 | private String password2; 24 | 25 | // ====================================== 26 | // = Getters & setters = 27 | // ====================================== 28 | 29 | public String getLogin() { 30 | return login; 31 | } 32 | 33 | public void setLogin(String login) { 34 | this.login = login; 35 | } 36 | 37 | public String getPassword() { 38 | return password; 39 | } 40 | 41 | public void setPassword(String password) { 42 | this.password = password; 43 | } 44 | 45 | public String getPassword2() { 46 | return password2; 47 | } 48 | 49 | public void setPassword2(String password2) { 50 | this.password2 = password2; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/agoncal/application/petstore/view/shopping/ShoppingCartItem.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.view.shopping; 2 | 3 | import org.agoncal.application.petstore.model.Item; 4 | 5 | import javax.validation.constraints.Min; 6 | import javax.validation.constraints.NotNull; 7 | 8 | /** 9 | * @author Antonio Goncalves 10 | * http://www.antoniogoncalves.org 11 | * -- 12 | */ 13 | 14 | public class ShoppingCartItem 15 | { 16 | 17 | // ====================================== 18 | // = Attributes = 19 | // ====================================== 20 | 21 | @NotNull 22 | private Item item; 23 | @NotNull 24 | @Min(1) 25 | private Integer quantity; 26 | 27 | // ====================================== 28 | // = Constructors = 29 | // ====================================== 30 | 31 | public ShoppingCartItem(Item item, Integer quantity) 32 | { 33 | this.item = item; 34 | this.quantity = quantity; 35 | } 36 | 37 | // ====================================== 38 | // = Public Methods = 39 | // ====================================== 40 | 41 | public Float getSubTotal() 42 | { 43 | return item.getUnitCost() * quantity; 44 | } 45 | 46 | // ====================================== 47 | // = Getters & setters = 48 | // ====================================== 49 | 50 | public Item getItem() 51 | { 52 | return item; 53 | } 54 | 55 | public void setItem(Item item) 56 | { 57 | this.item = item; 58 | } 59 | 60 | public Integer getQuantity() 61 | { 62 | return quantity; 63 | } 64 | 65 | public void setQuantity(Integer quantity) 66 | { 67 | this.quantity = quantity; 68 | } 69 | 70 | // ====================================== 71 | // = Methods hash, equals, toString = 72 | // ====================================== 73 | 74 | @Override 75 | public boolean equals(Object o) 76 | { 77 | if (this == o) return true; 78 | if (o == null || getClass() != o.getClass()) return false; 79 | 80 | ShoppingCartItem cartItem = (ShoppingCartItem) o; 81 | 82 | if (!item.equals(cartItem.item)) return false; 83 | if (!quantity.equals(cartItem.quantity)) return false; 84 | 85 | return true; 86 | } 87 | 88 | @Override 89 | public int hashCode() 90 | { 91 | int result = item.hashCode(); 92 | result = 31 * result + quantity.hashCode(); 93 | return result; 94 | } 95 | 96 | @Override 97 | public String toString() 98 | { 99 | final StringBuilder sb = new StringBuilder(); 100 | sb.append("CartItem"); 101 | sb.append("{item='").append(item).append('\''); 102 | sb.append(", quantity='").append(quantity).append('\''); 103 | sb.append('}'); 104 | return sb.toString(); 105 | } 106 | } -------------------------------------------------------------------------------- /src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | java:jboss/datasources/sqlDS 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/validation.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/main/resources/Messages.properties: -------------------------------------------------------------------------------- 1 | #common 2 | yes=Yes. 3 | no=No. 4 | logIn=Log in 5 | logOut=Log out 6 | again=again 7 | creditCard=Credit Card 8 | noItemsFound=No Items Found 9 | update=Update 10 | remove=Remove 11 | welcome=Welcome 12 | search=Search 13 | submit=Submit 14 | checkout=Checkout 15 | 16 | #signon page 17 | signon_signIn=Sign In 18 | signon_returningCustomer=You are a returning customer 19 | signon_signup=You would like to sign up for an account 20 | signon_passwordRepeate=Password (Repeat): 21 | signon_new=Create new account 22 | login_exists=Login already exists 23 | been_loggedout=You've been logged out 24 | id_filled=User id has to be filled 25 | pwd_filled=User password has to be filled 26 | id_pwd_filled=Id and passwords have to be filled 27 | both_pwd_same=Both entered passwords have to be the same 28 | account_updated=Your account has been updated 29 | 30 | #Entities 31 | accounts=Accounts 32 | address=Address 33 | items=Items 34 | products=Products 35 | address_street1=Street1 36 | address_street2=Street2 37 | address_city=City 38 | address_state=State 39 | address_zipcode=Zipcode 40 | address_country=Country 41 | category_id=Id 42 | category_name=Name 43 | category_description=Description 44 | category_products=products 45 | creditCard_creditCardNumber=Credit Card Number 46 | creditCard_creditCardType=Type 47 | creditCard_creditCardExpDate=Expiry date 48 | customer_id=Id 49 | customer_login=Loggin 50 | customer_password=Password 51 | customer_firstName=Firstname 52 | customer_lastName=Lastname 53 | customer_telephone=Telephone 54 | customer_email=Email 55 | customer_dateOfBirth=Date Of Birth 56 | customer_age=Age 57 | item_id=Id 58 | item_name=Name 59 | item_description=Description 60 | item_unitCost=Unit cost 61 | item_imagePath=Image path 62 | item_product=Product 63 | order_id=Id 64 | order_orderDate=Order Date 65 | order_customer=Customer 66 | order_orderLines=Order lines 67 | order_deliveryAddress=Delivery address 68 | order_creditCard=Credit card 69 | orderLine_id=Id; 70 | orderLine_quantity=Quantity 71 | orderLine_item=Item 72 | product_id=Id 73 | product_description=Description 74 | product_category=Category 75 | product_items=Items 76 | product_noProductFound=No products found 77 | 78 | #Confirm order 79 | confirmorder_confimOrder=Confirm Order 80 | confirmorder_personalInformation=Personal information 81 | confirmorder_firstName=*Firstname : 82 | confirmorder_deliveryAddress=Delivery Address 83 | 84 | 85 | #Create Account 86 | createAccount_createYourAccount=Create Your Account 87 | createAccount_personalInformation=Personal information 88 | 89 | #Order Confirmed 90 | orderConfirmed_yourOrderIsComplete=Your Order is Complete 91 | orderConfirmed_yourOrderIdIs=Your order id is 92 | orderConfirmed_msg1=You will receive shortly an email confirming your order 93 | orderConfirmed_msg2=Thank you for shopping with the YAPS Pet Store 94 | 95 | #Search Result 96 | searchResult_searchFor=Search for 97 | searchResult_addToCart=Add to Cart 98 | 99 | #Show account 100 | showAccount_edit=Edit Your Account Information 101 | 102 | #Shopping Cart 103 | shoppingCart=Shopping Cart 104 | shoppingCart_empty=The Shopping Cart is empty 105 | 106 | #Show Items 107 | showItems_itemForProduct=Items for product 108 | 109 | #Show Products 110 | showProducts_productForCategory=Products for category 111 | 112 | #Update account 113 | updateYourAccount=Update your account 114 | 115 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /src/main/resources/ValidationMessages.properties: -------------------------------------------------------------------------------- 1 | org.agoncal.application.petstore.constraints.Email.message=Invalid email format 2 | org.agoncal.application.petstore.constraints.Login.message=Invalid login 3 | org.agoncal.application.petstore.constraints.NotEmpty.message=Not be empty 4 | org.agoncal.application.petstore.constraints.Price.message=Invalid price 5 | -------------------------------------------------------------------------------- /src/main/resources/ValidationMessages_fr.properties: -------------------------------------------------------------------------------- 1 | org.agoncal.application.petstore.constraints.Email.message=Format email invalide 2 | org.agoncal.application.petstore.constraints.Login.message=Login invalide 3 | org.agoncal.application.petstore.constraints.NotEmpty.message=Ne doit pas \u00EAtre vide 4 | org.agoncal.application.petstore.constraints.Price.message=Prix invalide 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/config.properties: -------------------------------------------------------------------------------- 1 | loginModuleName=SimpleLoginModule 2 | loginConfigFile=/petstore-test.login -------------------------------------------------------------------------------- /src/main/resources/logging.properties: -------------------------------------------------------------------------------- 1 | ############################################################ 2 | # Default Logging Configuration File 3 | # 4 | # You can use a different file by specifying a filename 5 | # with the java.util.logging.config.file system property. 6 | # For example java -Djava.util.logging.config.file=myfile 7 | ############################################################ 8 | 9 | ############################################################ 10 | # Global properties 11 | ############################################################ 12 | 13 | # "handlers" specifies a comma separated list of log Handler 14 | # classes. These handlers will be installed during VM startup. 15 | # Note that these classes must be on the system classpath. 16 | # By default we only configure a ConsoleHandler, which will only 17 | # show messages at the INFO and above levels. 18 | handlers= java.util.logging.ConsoleHandler, java.util.logging.FileHandler 19 | 20 | # To also add the FileHandler, use the following line instead. 21 | #handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler 22 | 23 | # Default global logging level. 24 | # This specifies which kinds of events are logged across 25 | # all loggers. For any given facility this global level 26 | # can be overriden by a facility specific level 27 | # Note that the ConsoleHandler also has a separate level 28 | # setting to limit messages printed to the console. 29 | .level= FINEST 30 | 31 | ############################################################ 32 | # Handler specific properties. 33 | # Describes specific configuration info for Handlers. 34 | ############################################################ 35 | 36 | # default file output is in customer's home directory. 37 | java.util.logging.FileHandler.pattern = %h/java%u.log 38 | java.util.logging.FileHandler.level = FINEST 39 | java.util.logging.FileHandler.limit = 50000 40 | java.util.logging.FileHandler.count = 1 41 | java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter 42 | 43 | # Limit the message that are printed on the console to INFO and above. 44 | java.util.logging.ConsoleHandler.level = FINEST 45 | java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter 46 | 47 | 48 | ############################################################ 49 | # Facility specific properties. 50 | # Provides extra control for each logger. 51 | ############################################################ 52 | 53 | # For example, set the com.xyz.foo logger to only log SEVERE 54 | # messages: 55 | org.agoncal.petstore.level = FINEST 56 | -------------------------------------------------------------------------------- /src/main/resources/petstore-test.login: -------------------------------------------------------------------------------- 1 | SimpleLoginModule{ 2 | org.agoncal.application.petstore.security.SimpleLoginModule required; 3 | } ; -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | org.agoncal.application.petstore.util.LoggingInterceptor 6 | org.agoncal.application.petstore.view.ExceptionInterceptor 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/classes/META-INF/forge.taglib.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | http://jboss.org/forge/view 5 | 6 | 7 | asList 8 | org.agoncal.application.petstore.view.ViewUtils 9 | 10 | java.util.List asList(java.util.Collection) 11 | 12 | 13 | 14 | 15 | display 16 | org.agoncal.application.petstore.view.ViewUtils 17 | 18 | java.lang.String display(java.lang.Object) 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/faces-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | en 7 | 8 | 9 | Messages 10 | i18n 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | agoncal-application-petstore-ee7 8 | 9 | 30 10 | 11 | 12 | ico 13 | image/x-icon 14 | 15 | 16 | javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE 17 | true 18 | 19 | 20 | 21 | 22 | Faces Servlet 23 | javax.faces.webapp.FacesServlet 24 | 1 25 | 26 | 27 | Faces Servlet 28 | *.xhtml 29 | 30 | 31 | 32 | 33 | primefaces.THEME 34 | bootstrap 35 | 36 | 37 | primefaces.FONT_AWESOME 38 | true 39 | 40 | 41 | 42 | index.html 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/main/webapp/admin/category/create.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | Category 19 | 20 | 21 | 22 | 23 | 24 | Edit existing Category 25 | 26 | 27 | Create a new Category 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 | -------------------------------------------------------------------------------- /src/main/webapp/admin/category/search.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Category 18 | 19 | 20 | 21 | Search Category entities 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 | -------------------------------------------------------------------------------- /src/main/webapp/admin/category/view.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Category 18 | 19 | 20 | 21 | View existing Category 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
35 | 36 | 37 | 38 |
39 |
40 | 41 |
-------------------------------------------------------------------------------- /src/main/webapp/admin/country/view.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Country 18 | 19 | 20 | 21 | View existing Country 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 |
-------------------------------------------------------------------------------- /src/main/webapp/admin/item/view.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Item 18 | 19 | 20 | 21 | View existing Item 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 |
-------------------------------------------------------------------------------- /src/main/webapp/admin/product/create.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Product 20 | 21 | 22 | 23 | 24 | 25 | Edit existing Product 26 | 27 | 28 | Create a new Product 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 | -------------------------------------------------------------------------------- /src/main/webapp/admin/product/view.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Product 18 | 19 | 20 | 21 | View existing Product 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 |
-------------------------------------------------------------------------------- /src/main/webapp/error.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | Oops 11 | 12 | 13 | 14 | That's going to leave a mark! 15 | 16 | 17 | 18 |

19 | JBoss and JBoss Community 22 |
To replace this page edit 'src/main/webapp/error.xhtml', or 23 | keep Forging! 24 |

25 |
26 | 27 |
28 | -------------------------------------------------------------------------------- /src/main/webapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Redirect... 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/main/webapp/resources/css/sticky-footer-navbar.css: -------------------------------------------------------------------------------- 1 | /* Sticky footer styles 2 | -------------------------------------------------- */ 3 | 4 | html, 5 | body { 6 | height: 100%; 7 | /* The html and body elements cannot have any padding or margin. */ 8 | } 9 | 10 | /* Wrapper for page content to push down footer */ 11 | #wrap { 12 | min-height: 100%; 13 | height: auto; 14 | /* Negative indent footer by its height */ 15 | margin: 0 auto -60px; 16 | /* Pad bottom by footer height */ 17 | padding: 0 0 60px; 18 | } 19 | 20 | /* Set the fixed height of the footer here */ 21 | #footer { 22 | height: 60px; 23 | background-color: #f5f5f5; 24 | } 25 | 26 | 27 | /* Custom page CSS 28 | -------------------------------------------------- */ 29 | /* Not required for template or sticky footer method. */ 30 | 31 | #wrap > .container { 32 | padding: 60px 15px 0; 33 | } 34 | .container .credit { 35 | margin: 20px 0; 36 | } 37 | 38 | #footer > .container { 39 | padding-left: 15px; 40 | padding-right: 15px; 41 | } 42 | 43 | code { 44 | font-size: 80%; 45 | } 46 | -------------------------------------------------------------------------------- /src/main/webapp/resources/css/style.css: -------------------------------------------------------------------------------- 1 | .centered-text { 2 | text-align: center 3 | } 4 | 5 | .menu-fr { 6 | background: transparent url("#{resource['icons/fr.gif']}") no-repeat center left; 7 | padding: 5px 5px 5px 20px; 8 | } 9 | 10 | .menu-en { 11 | background: transparent url("#{resource['icons/us.gif']}") no-repeat center left; 12 | padding: 5px 5px 5px 20px; 13 | } 14 | 15 | .add-to-cart { 16 | background: transparent url("#{resource['icons/cart_add.png']}") no-repeat center left; 17 | padding: 5px 5px 5px 20px; 18 | } 19 | 20 | .remove-from-cart { 21 | background: transparent url("#{resource['icons/cart_delete.png']}") no-repeat center left; 22 | padding: 5px 5px 5px 20px; 23 | } 24 | 25 | .checkout-cart { 26 | background: transparent url("#{resource['icons/cart_go.png']}") no-repeat center left; 27 | padding: 5px 5px 5px 20px; 28 | } 29 | 30 | .user-edit { 31 | background: transparent url("#{resource['icons/user_edit.png']}") no-repeat center left; 32 | padding: 5px 5px 5px 20px; 33 | } 34 | 35 | .arrow_refresh { 36 | background: transparent url("#{resource['icons/arrow_refresh.png']}") no-repeat center left; 37 | padding: 5px 5px 5px 20px; 38 | } 39 | -------------------------------------------------------------------------------- /src/main/webapp/resources/favicon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/favicon.gif -------------------------------------------------------------------------------- /src/main/webapp/resources/icons/arrow_refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/icons/arrow_refresh.png -------------------------------------------------------------------------------- /src/main/webapp/resources/icons/cart_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/icons/cart_add.png -------------------------------------------------------------------------------- /src/main/webapp/resources/icons/cart_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/icons/cart_delete.png -------------------------------------------------------------------------------- /src/main/webapp/resources/icons/cart_go.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/icons/cart_go.png -------------------------------------------------------------------------------- /src/main/webapp/resources/icons/fr.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/icons/fr.gif -------------------------------------------------------------------------------- /src/main/webapp/resources/icons/us.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/icons/us.gif -------------------------------------------------------------------------------- /src/main/webapp/resources/icons/user_edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/icons/user_edit.png -------------------------------------------------------------------------------- /src/main/webapp/resources/images/bird1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/images/bird1.jpg -------------------------------------------------------------------------------- /src/main/webapp/resources/images/bird2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/images/bird2.jpg -------------------------------------------------------------------------------- /src/main/webapp/resources/images/cat1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/images/cat1.jpg -------------------------------------------------------------------------------- /src/main/webapp/resources/images/cat2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/images/cat2.jpg -------------------------------------------------------------------------------- /src/main/webapp/resources/images/dog1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/images/dog1.jpg -------------------------------------------------------------------------------- /src/main/webapp/resources/images/dog2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/images/dog2.jpg -------------------------------------------------------------------------------- /src/main/webapp/resources/images/dog3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/images/dog3.jpg -------------------------------------------------------------------------------- /src/main/webapp/resources/images/dog4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/images/dog4.jpg -------------------------------------------------------------------------------- /src/main/webapp/resources/images/dog5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/images/dog5.jpg -------------------------------------------------------------------------------- /src/main/webapp/resources/images/dog6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/images/dog6.jpg -------------------------------------------------------------------------------- /src/main/webapp/resources/images/fish1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/images/fish1.jpg -------------------------------------------------------------------------------- /src/main/webapp/resources/images/fish2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/images/fish2.jpg -------------------------------------------------------------------------------- /src/main/webapp/resources/images/fish3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/images/fish3.jpg -------------------------------------------------------------------------------- /src/main/webapp/resources/images/fish4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/images/fish4.jpg -------------------------------------------------------------------------------- /src/main/webapp/resources/images/lizard1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/images/lizard1.jpg -------------------------------------------------------------------------------- /src/main/webapp/resources/images/reptile1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/images/reptile1.jpg -------------------------------------------------------------------------------- /src/main/webapp/resources/images/snake1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/images/snake1.jpg -------------------------------------------------------------------------------- /src/main/webapp/resources/splash.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/src/main/webapp/resources/splash.gif -------------------------------------------------------------------------------- /src/main/webapp/resources/templates/paginator.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 11 | 12 | 13 | < Previous 14 | 15 | 16 | 17 | 18 | Next > 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/webapp/resources/templates/templateCRUD.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 |
11 | 19 |
20 |
21 |
-------------------------------------------------------------------------------- /src/main/webapp/resources/templates/templateShopping.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 |
12 | 39 |
40 |
41 |
-------------------------------------------------------------------------------- /src/main/webapp/shopping/main.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | Birds 14 | Fish 15 | Dogs 16 | Reptiles 18 | Cats 19 | Birds 20 | 21 | Welcome to YAPS PetStore 23 |
24 |
25 |
26 | -------------------------------------------------------------------------------- /src/main/webapp/shopping/orderconfirmed.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 | 11 | 12 | #{i18n.orderConfirmed_yourOrderIsComplete} 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 |
24 | 25 | 26 | 27 | 28 | x 29 | 30 | $ 31 | 32 | 33 | = 34 | 35 | $ 36 | 37 |
38 |
39 | 40 |
41 | Total $ #{shoppingCartBean.order.total} 42 |
43 |
44 | 45 | #{i18n.orderConfirmed_yourOrderIdIs} : #{shoppingCartBean.order.id} 46 | 47 |

#{i18n.orderConfirmed_msg1}

48 | 49 |

#{i18n.orderConfirmed_msg2}

50 | 51 |
52 |
53 | -------------------------------------------------------------------------------- /src/main/webapp/shopping/searchresult.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | #{i18n.searchResult_searchFor} : #{catalogBean.keyword} 19 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 28 | 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 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/main/webapp/shopping/showcart.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 | 12 | 13 | #{i18n.shoppingCart} 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 | x 43 | $ 44 | 45 | 46 | = $ 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |
55 | 56 |
57 | 58 |
59 | Total $ 60 | 61 | 63 |
64 |
65 | 66 |
67 |
68 | 69 | -------------------------------------------------------------------------------- /src/main/webapp/shopping/showitem.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | #{catalogBean.item.product.name} - #{catalogBean.item.name} 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 36 | $ 37 | 38 | 39 | 40 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/main/webapp/shopping/showitems.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | #{i18n.showItems_itemForProduct} : #{catalogBean.product.name} 19 | 20 | 21 | 22 | 23 | 25 | 26 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | $ 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/main/webapp/shopping/showproducts.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | #{i18n.showProducts_productForCategory} : #{catalogBean.categoryName} 19 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 28 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/main/webapp/shopping/signon.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 11 | 12 | 13 | #{i18n.signon_signIn} 14 | 15 | 16 | 17 | 18 |
19 |
20 |

#{i18n.signon_returningCustomer}

21 |
22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 35 | 36 |
37 |
38 | 39 |
40 |
41 |

#{i18n.signon_signup}

42 |
43 |
44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 54 | 55 | 56 |
57 |
58 | 59 |
60 |
61 | -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/model/AddressIT.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.model; 2 | 3 | import org.jboss.arquillian.container.test.api.Deployment; 4 | import org.jboss.arquillian.junit.Arquillian; 5 | import org.jboss.shrinkwrap.api.ShrinkWrap; 6 | import org.jboss.shrinkwrap.api.asset.EmptyAsset; 7 | import org.jboss.shrinkwrap.api.spec.JavaArchive; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import javax.inject.Inject; 12 | import javax.validation.Validator; 13 | 14 | import static org.junit.Assert.assertEquals; 15 | 16 | /** 17 | * @author Antonio Goncalves 18 | */ 19 | @RunWith(Arquillian.class) 20 | public class AddressIT { 21 | 22 | // ====================================== 23 | // = Attributes = 24 | // ====================================== 25 | 26 | @Inject 27 | private Validator validator; 28 | 29 | // ====================================== 30 | // = Lifecycle Methods = 31 | // ====================================== 32 | 33 | @Deployment 34 | public static JavaArchive jar() { 35 | return ShrinkWrap.create(JavaArchive.class) 36 | .addClass(Address.class) 37 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); 38 | } 39 | 40 | // ====================================== 41 | // = Methods = 42 | // ====================================== 43 | 44 | @Test 45 | public void shouldCreateAValidAddress() { 46 | 47 | // Creates an object 48 | Country country = new Country("DV", "Dummy value", "Dummy value", "DMV", "DMV"); 49 | Address address = new Address("Street1", "City", "Zipcode", country); 50 | 51 | // Checks the object is valid 52 | assertEquals("Should have not constraint violation", 0, validator.validate(address).size()); 53 | } 54 | } -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/model/AddressTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.model; 2 | 3 | import nl.jqno.equalsverifier.EqualsVerifier; 4 | import nl.jqno.equalsverifier.Warning; 5 | import org.junit.Test; 6 | 7 | /** 8 | * @author Antonio Goncalves 9 | */ 10 | public class AddressTest { 11 | 12 | // ====================================== 13 | // = Methods = 14 | // ====================================== 15 | 16 | @Test 17 | public void shouldCheckEqualsAndHashCode() { 18 | 19 | // Checks equals and hashCode is valid 20 | EqualsVerifier.forClass(Address.class).suppress(Warning.NONFINAL_FIELDS).verify(); 21 | } 22 | } -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/model/CategoryIT.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.model; 2 | 3 | import org.jboss.arquillian.container.test.api.Deployment; 4 | import org.jboss.arquillian.junit.Arquillian; 5 | import org.jboss.shrinkwrap.api.ShrinkWrap; 6 | import org.jboss.shrinkwrap.api.asset.EmptyAsset; 7 | import org.jboss.shrinkwrap.api.spec.JavaArchive; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import javax.inject.Inject; 12 | import javax.validation.Validator; 13 | import javax.xml.bind.JAXBContext; 14 | import javax.xml.bind.Marshaller; 15 | import java.io.StringWriter; 16 | 17 | import static org.junit.Assert.assertEquals; 18 | 19 | /** 20 | * @author Antonio Goncalves 21 | */ 22 | @RunWith(Arquillian.class) 23 | public class CategoryIT { 24 | 25 | // ====================================== 26 | // = Attributes = 27 | // ====================================== 28 | 29 | @Inject 30 | private Validator validator; 31 | 32 | // ====================================== 33 | // = Lifecycle Methods = 34 | // ====================================== 35 | 36 | @Deployment 37 | public static JavaArchive jar() { 38 | return ShrinkWrap.create(JavaArchive.class) 39 | .addClass(Category.class) 40 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); 41 | } 42 | 43 | // ====================================== 44 | // = Methods = 45 | // ====================================== 46 | 47 | @Test 48 | public void shouldCreateAValidCategory() { 49 | 50 | // Creates an object 51 | Category category = new Category("Fish", "Any of numerous cold-blooded aquatic vertebrates characteristically having fins, gills, and a streamlined body"); 52 | 53 | // Checks the object is valid 54 | assertEquals("Should have not constraint violation", 0, validator.validate(category).size()); 55 | } 56 | 57 | @Test 58 | public void shouldBeAbleToMarshallAndUnmarchallIntoXML() throws Exception { 59 | 60 | // Creates an object 61 | Category category = new Category("Fish", "Any of numerous cold-blooded aquatic vertebrates characteristically having fins, gills, and a streamlined body"); 62 | 63 | // Marshalls it to XML 64 | StringWriter writer = new StringWriter(); 65 | JAXBContext context = JAXBContext.newInstance(Category.class); 66 | Marshaller m = context.createMarshaller(); 67 | m.marshal(category, writer); 68 | } 69 | } -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/model/CategoryTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.model; 2 | 3 | import nl.jqno.equalsverifier.EqualsVerifier; 4 | import nl.jqno.equalsverifier.Warning; 5 | import org.junit.Test; 6 | 7 | /** 8 | * @author Antonio Goncalves 9 | */ 10 | public class CategoryTest { 11 | 12 | // ====================================== 13 | // = Methods = 14 | // ====================================== 15 | 16 | @Test 17 | public void shouldCheckEqualsAndHashCode() { 18 | 19 | // Checks equals and hashCode is valid 20 | EqualsVerifier.forClass(Category.class).suppress(Warning.NONFINAL_FIELDS).verify(); 21 | } 22 | } -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/model/CountryTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.model; 2 | 3 | import nl.jqno.equalsverifier.EqualsVerifier; 4 | import nl.jqno.equalsverifier.Warning; 5 | import org.junit.Test; 6 | 7 | /** 8 | * @author Antonio Goncalves 9 | */ 10 | public class CountryTest { 11 | 12 | // ====================================== 13 | // = Methods = 14 | // ====================================== 15 | 16 | @Test 17 | public void shouldCheckEqualsAndHashCode() { 18 | 19 | // Checks equals and hashCode is valid 20 | EqualsVerifier.forClass(Country.class).suppress(Warning.NONFINAL_FIELDS).verify(); 21 | } 22 | } -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/model/CreditCardTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.model; 2 | 3 | import nl.jqno.equalsverifier.EqualsVerifier; 4 | import nl.jqno.equalsverifier.Warning; 5 | import org.junit.Test; 6 | 7 | /** 8 | * @author Antonio Goncalves 9 | */ 10 | public class CreditCardTest { 11 | 12 | // ====================================== 13 | // = Methods = 14 | // ====================================== 15 | 16 | @Test 17 | public void shouldCheckEqualsAndHashCode() { 18 | 19 | // Checks equals and hashCode is valid 20 | EqualsVerifier.forClass(CreditCard.class).suppress(Warning.NONFINAL_FIELDS).verify(); 21 | } 22 | } -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/model/CustomerIT.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.model; 2 | 3 | import org.jboss.arquillian.container.test.api.Deployment; 4 | import org.jboss.arquillian.junit.Arquillian; 5 | import org.jboss.shrinkwrap.api.ShrinkWrap; 6 | import org.jboss.shrinkwrap.api.asset.EmptyAsset; 7 | import org.jboss.shrinkwrap.api.spec.JavaArchive; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import javax.inject.Inject; 12 | import javax.validation.Validator; 13 | 14 | import static org.junit.Assert.assertEquals; 15 | 16 | /** 17 | * @author Antonio Goncalves 18 | */ 19 | @RunWith(Arquillian.class) 20 | public class CustomerIT { 21 | 22 | // ====================================== 23 | // = Attributes = 24 | // ====================================== 25 | 26 | @Inject 27 | private Validator validator; 28 | 29 | // ====================================== 30 | // = Lifecycle Methods = 31 | // ====================================== 32 | 33 | @Deployment 34 | public static JavaArchive jar() { 35 | return ShrinkWrap.create(JavaArchive.class) 36 | .addClasses(Category.class, Address.class) 37 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); 38 | } 39 | 40 | // ====================================== 41 | // = Methods = 42 | // ====================================== 43 | 44 | @Test 45 | public void shouldCreateAValidCustomer() { 46 | 47 | // Creates an object 48 | Country country = new Country("DV", "Dummy value", "Dummy value", "DMV", "DMV"); 49 | Address address = new Address("78 Gnu Rd", "Texas", "666", country); 50 | Customer customer = new Customer("Paul", "Mc Cartney", "pmac", "pmac", "paul@beales.com", address); 51 | 52 | // Checks the object is valid 53 | assertEquals("Should have not constraint violation", 0, validator.validate(customer).size()); 54 | } 55 | } -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/model/CustomerTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.model; 2 | 3 | import nl.jqno.equalsverifier.EqualsVerifier; 4 | import nl.jqno.equalsverifier.Warning; 5 | import org.junit.Test; 6 | 7 | /** 8 | * @author Antonio Goncalves 9 | */ 10 | public class CustomerTest { 11 | 12 | // ====================================== 13 | // = Methods = 14 | // ====================================== 15 | 16 | @Test 17 | public void shouldCheckEqualsAndHashCode() { 18 | 19 | // Checks equals and hashCode is valid 20 | EqualsVerifier.forClass(Customer.class).suppress(Warning.NONFINAL_FIELDS).verify(); 21 | } 22 | } -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/model/ItemIT.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.model; 2 | 3 | import org.jboss.arquillian.container.test.api.Deployment; 4 | import org.jboss.arquillian.junit.Arquillian; 5 | import org.jboss.shrinkwrap.api.ShrinkWrap; 6 | import org.jboss.shrinkwrap.api.asset.EmptyAsset; 7 | import org.jboss.shrinkwrap.api.spec.JavaArchive; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import javax.inject.Inject; 12 | import javax.validation.Validator; 13 | import javax.xml.bind.JAXBContext; 14 | import javax.xml.bind.Marshaller; 15 | import java.io.StringWriter; 16 | 17 | import static org.junit.Assert.assertEquals; 18 | 19 | /** 20 | * @author Antonio Goncalves 21 | */ 22 | @RunWith(Arquillian.class) 23 | public class ItemIT { 24 | 25 | // ====================================== 26 | // = Attributes = 27 | // ====================================== 28 | 29 | @Inject 30 | private Validator validator; 31 | 32 | // ====================================== 33 | // = Lifecycle Methods = 34 | // ====================================== 35 | 36 | @Deployment 37 | public static JavaArchive jar() { 38 | return ShrinkWrap.create(JavaArchive.class) 39 | .addClasses(Category.class, Product.class, Item.class) 40 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); 41 | } 42 | 43 | // ====================================== 44 | // = Methods = 45 | // ====================================== 46 | 47 | @Test 48 | public void shouldCreateAValidItem() { 49 | 50 | // Creates an object 51 | Category category = new Category("Fish", "Any of numerous cold-blooded aquatic vertebrates characteristically having fins, gills, and a streamlined body"); 52 | Product product = new Product("Bulldog", "Friendly dog from England", category); 53 | Item item = new Item("Thootless fish", 10f, "fish1.gif", "desc", product); 54 | 55 | // Checks the object is valid 56 | assertEquals("Should have not constraint violation", 0, validator.validate(item).size()); 57 | } 58 | 59 | @Test 60 | public void shouldBeAbleToMarshallAndUnmarchallIntoXML() throws Exception { 61 | 62 | // Creates an object 63 | Category category = new Category("Fish", "Any of numerous cold-blooded aquatic vertebrates characteristically having fins, gills, and a streamlined body"); 64 | Product product = new Product("Bulldog", "Friendly dog from England", category); 65 | Item item = new Item("Thootless fish", 10f, "fish1.gif", "desc", product); 66 | 67 | // Marshalls it to XML 68 | StringWriter writer = new StringWriter(); 69 | JAXBContext context = JAXBContext.newInstance(Item.class); 70 | Marshaller m = context.createMarshaller(); 71 | m.marshal(item, writer); 72 | } 73 | } -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/model/ItemTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.model; 2 | 3 | import nl.jqno.equalsverifier.EqualsVerifier; 4 | import nl.jqno.equalsverifier.Warning; 5 | import org.junit.Test; 6 | 7 | /** 8 | * @author Antonio Goncalves 9 | */ 10 | public class ItemTest { 11 | 12 | // ====================================== 13 | // = Methods = 14 | // ====================================== 15 | 16 | @Test 17 | public void shouldCheckEqualsAndHashCode() { 18 | 19 | // Checks equals and hashCode is valid 20 | EqualsVerifier.forClass(Item.class).suppress(Warning.NONFINAL_FIELDS).verify(); 21 | } 22 | } -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/model/OrderLineTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.model; 2 | 3 | import nl.jqno.equalsverifier.EqualsVerifier; 4 | import nl.jqno.equalsverifier.Warning; 5 | import org.junit.Test; 6 | 7 | /** 8 | * @author Antonio Goncalves 9 | */ 10 | public class OrderLineTest { 11 | 12 | // ====================================== 13 | // = Methods = 14 | // ====================================== 15 | 16 | @Test 17 | public void shouldCheckEqualsAndHashCode() { 18 | 19 | // Checks equals and hashCode is valid 20 | EqualsVerifier.forClass(OrderLine.class).suppress(Warning.NONFINAL_FIELDS).verify(); 21 | } 22 | } -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/model/ProductIT.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.model; 2 | 3 | import org.jboss.arquillian.container.test.api.Deployment; 4 | import org.jboss.arquillian.junit.Arquillian; 5 | import org.jboss.shrinkwrap.api.ShrinkWrap; 6 | import org.jboss.shrinkwrap.api.asset.EmptyAsset; 7 | import org.jboss.shrinkwrap.api.spec.JavaArchive; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import javax.inject.Inject; 12 | import javax.validation.Validator; 13 | import javax.xml.bind.JAXBContext; 14 | import javax.xml.bind.Marshaller; 15 | import java.io.StringWriter; 16 | 17 | import static org.junit.Assert.assertEquals; 18 | 19 | /** 20 | * @author Antonio Goncalves 21 | */ 22 | @RunWith(Arquillian.class) 23 | public class ProductIT { 24 | 25 | // ====================================== 26 | // = Attributes = 27 | // ====================================== 28 | 29 | @Inject 30 | private Validator validator; 31 | 32 | // ====================================== 33 | // = Lifecycle Methods = 34 | // ====================================== 35 | 36 | @Deployment 37 | public static JavaArchive jar() { 38 | return ShrinkWrap.create(JavaArchive.class) 39 | .addClasses(Category.class, Product.class) 40 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); 41 | } 42 | 43 | // ====================================== 44 | // = Methods = 45 | // ====================================== 46 | 47 | @Test 48 | public void shouldCreateAValidProduct() { 49 | 50 | // Creates an object 51 | Category category = new Category("Fish", "Any of numerous cold-blooded aquatic vertebrates characteristically having fins, gills, and a streamlined body"); 52 | Product product = new Product("Bulldog", "Friendly dog from England", category); 53 | 54 | // Checks the object is valid 55 | assertEquals("Should have not constraint violation", 0, validator.validate(product).size()); 56 | } 57 | 58 | @Test 59 | public void shouldBeAbleToMarshallAndUnmarchallIntoXML() throws Exception { 60 | 61 | // Creates an object 62 | Category category = new Category("Fish", "Any of numerous cold-blooded aquatic vertebrates characteristically having fins, gills, and a streamlined body"); 63 | Product product = new Product("Bulldog", "Friendly dog from England", category); 64 | 65 | // Marshalls it to XML 66 | StringWriter writer = new StringWriter(); 67 | JAXBContext context = JAXBContext.newInstance(Product.class); 68 | Marshaller m = context.createMarshaller(); 69 | m.marshal(product, writer); 70 | } 71 | } -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/model/ProductTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.model; 2 | 3 | import nl.jqno.equalsverifier.EqualsVerifier; 4 | import nl.jqno.equalsverifier.Warning; 5 | import org.junit.Test; 6 | 7 | /** 8 | * @author Antonio Goncalves 9 | */ 10 | public class ProductTest { 11 | 12 | // ====================================== 13 | // = Methods = 14 | // ====================================== 15 | 16 | @Test 17 | public void shouldCheckEqualsAndHashCode() { 18 | 19 | // Checks equals and hashCode is valid 20 | EqualsVerifier.forClass(Product.class).suppress(Warning.NONFINAL_FIELDS).verify(); 21 | } 22 | } -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/model/PurchaseOrderIT.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.model; 2 | 3 | import org.jboss.arquillian.container.test.api.Deployment; 4 | import org.jboss.arquillian.junit.Arquillian; 5 | import org.jboss.shrinkwrap.api.ShrinkWrap; 6 | import org.jboss.shrinkwrap.api.asset.EmptyAsset; 7 | import org.jboss.shrinkwrap.api.spec.JavaArchive; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import javax.inject.Inject; 12 | import javax.validation.Validator; 13 | 14 | import static org.junit.Assert.assertEquals; 15 | 16 | /** 17 | * @author Antonio Goncalves 18 | */ 19 | @RunWith(Arquillian.class) 20 | public class PurchaseOrderIT { 21 | 22 | // ====================================== 23 | // = Attributes = 24 | // ====================================== 25 | 26 | @Inject 27 | private Validator validator; 28 | 29 | // ====================================== 30 | // = Lifecycle Methods = 31 | // ====================================== 32 | 33 | @Deployment 34 | public static JavaArchive jar() { 35 | return ShrinkWrap.create(JavaArchive.class) 36 | .addClasses(Address.class, Customer.class, CreditCard.class, PurchaseOrder.class) 37 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); 38 | } 39 | 40 | // ====================================== 41 | // = Methods = 42 | // ====================================== 43 | 44 | @Test 45 | public void shouldCreateAValidOrder() { 46 | 47 | // Creates an object 48 | Country country = new Country("DV", "Dummy value", "Dummy value", "DMV", "DMV"); 49 | Address address = new Address("78 Gnu Rd", "Texas", "666", country); 50 | Customer customer = new Customer("Paul", "Mc Cartney", "pmac", "pmac", "paul@beales.com", address); 51 | CreditCard creditCard = new CreditCard("123456789", CreditCardType.VISA, "12/45"); 52 | PurchaseOrder order = new PurchaseOrder(customer, creditCard, address); 53 | 54 | // Checks the object is valid 55 | assertEquals("Should have not constraint violation", 0, validator.validate(order).size()); 56 | } 57 | } -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/model/PurchaseOrderTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.model; 2 | 3 | import nl.jqno.equalsverifier.EqualsVerifier; 4 | import nl.jqno.equalsverifier.Warning; 5 | import org.junit.Test; 6 | 7 | /** 8 | * @author Antonio Goncalves 9 | */ 10 | public class PurchaseOrderTest { 11 | 12 | // ====================================== 13 | // = Methods = 14 | // ====================================== 15 | 16 | @Test 17 | public void shouldCheckEqualsAndHashCode() { 18 | 19 | // Checks equals and hashCode is valid 20 | EqualsVerifier.forClass(PurchaseOrder.class).suppress(Warning.NONFINAL_FIELDS).verify(); 21 | } 22 | } -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/rest/CategoryEndpointTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.rest; 2 | 3 | import org.agoncal.application.petstore.model.Category; 4 | import org.jboss.arquillian.container.test.api.Deployment; 5 | import org.jboss.arquillian.container.test.api.RunAsClient; 6 | import org.jboss.arquillian.junit.Arquillian; 7 | import org.jboss.arquillian.test.api.ArquillianResource; 8 | import org.jboss.shrinkwrap.api.ShrinkWrap; 9 | import org.jboss.shrinkwrap.api.asset.EmptyAsset; 10 | import org.jboss.shrinkwrap.api.spec.WebArchive; 11 | import org.junit.Assert; 12 | import org.junit.Test; 13 | import org.junit.runner.RunWith; 14 | 15 | import javax.ws.rs.client.Client; 16 | import javax.ws.rs.client.ClientBuilder; 17 | import javax.ws.rs.client.WebTarget; 18 | import javax.ws.rs.core.MediaType; 19 | import javax.ws.rs.core.Response; 20 | import java.net.URI; 21 | 22 | import static org.junit.Assert.assertEquals; 23 | 24 | @RunWith(Arquillian.class) 25 | @RunAsClient 26 | public class CategoryEndpointTest 27 | { 28 | 29 | // ====================================== 30 | // = Attributes = 31 | // ====================================== 32 | 33 | @ArquillianResource 34 | private URI baseURL; 35 | 36 | // ====================================== 37 | // = Deployment = 38 | // ====================================== 39 | 40 | @Deployment(testable = false) 41 | public static WebArchive createDeployment() 42 | { 43 | return ShrinkWrap.create(WebArchive.class) 44 | .addClass(RestApplication.class) 45 | .addClass(CategoryEndpoint.class) 46 | .addClass(Category.class) 47 | .addAsResource("META-INF/persistence.xml", "META-INF/persistence.xml") 48 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); 49 | } 50 | 51 | // ====================================== 52 | // = Test Cases = 53 | // ====================================== 54 | 55 | @Test 56 | public void should_be_deployed() 57 | { 58 | Client client = ClientBuilder.newClient(); 59 | WebTarget target = client.target(baseURL).path("rest").path("categories"); 60 | assertEquals(Response.Status.OK.getStatusCode(), target.request(MediaType.APPLICATION_XML).get().getStatus()); 61 | } 62 | 63 | @Test 64 | public void should_produce_json() 65 | { 66 | Client client = ClientBuilder.newClient(); 67 | WebTarget target = client.target(baseURL).path("rest").path("categories"); 68 | assertEquals(Response.Status.OK.getStatusCode(), target.request(MediaType.APPLICATION_JSON).get().getStatus()); 69 | } 70 | 71 | @Test 72 | public void should_produce_xml() 73 | { 74 | Client client = ClientBuilder.newClient(); 75 | WebTarget target = client.target(baseURL).path("rest").path("categories"); 76 | assertEquals(Response.Status.OK.getStatusCode(), target.request(MediaType.APPLICATION_XML).get().getStatus()); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/rest/CountryEndpointTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.rest; 2 | 3 | import org.agoncal.application.petstore.model.Country; 4 | import org.jboss.arquillian.container.test.api.Deployment; 5 | import org.jboss.arquillian.container.test.api.RunAsClient; 6 | import org.jboss.arquillian.junit.Arquillian; 7 | import org.jboss.arquillian.test.api.ArquillianResource; 8 | import org.jboss.shrinkwrap.api.ShrinkWrap; 9 | import org.jboss.shrinkwrap.api.asset.EmptyAsset; 10 | import org.jboss.shrinkwrap.api.spec.WebArchive; 11 | import org.junit.Assert; 12 | import org.junit.Test; 13 | import org.junit.runner.RunWith; 14 | 15 | import javax.ws.rs.client.Client; 16 | import javax.ws.rs.client.ClientBuilder; 17 | import javax.ws.rs.client.WebTarget; 18 | import javax.ws.rs.core.MediaType; 19 | import javax.ws.rs.core.Response; 20 | import java.net.URI; 21 | 22 | import static org.junit.Assert.assertEquals; 23 | 24 | @RunWith(Arquillian.class) 25 | @RunAsClient 26 | public class CountryEndpointTest 27 | { 28 | 29 | // ====================================== 30 | // = Attributes = 31 | // ====================================== 32 | 33 | @ArquillianResource 34 | private URI baseURL; 35 | 36 | // ====================================== 37 | // = Deployment = 38 | // ====================================== 39 | 40 | @Deployment(testable = false) 41 | public static WebArchive createDeployment() 42 | { 43 | return ShrinkWrap.create(WebArchive.class) 44 | .addClass(RestApplication.class) 45 | .addClass(CountryEndpoint.class) 46 | .addClass(Country.class) 47 | .addAsResource("META-INF/persistence.xml", "META-INF/persistence.xml") 48 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); 49 | } 50 | 51 | // ====================================== 52 | // = Test Cases = 53 | // ====================================== 54 | 55 | @Test 56 | public void should_be_deployed() 57 | { 58 | Client client = ClientBuilder.newClient(); 59 | WebTarget target = client.target(baseURL).path("rest").path("countries"); 60 | assertEquals(Response.Status.OK.getStatusCode(), target.request(MediaType.APPLICATION_XML).get().getStatus()); 61 | } 62 | 63 | @Test 64 | public void should_produce_json() 65 | { 66 | Client client = ClientBuilder.newClient(); 67 | WebTarget target = client.target(baseURL).path("rest").path("countries"); 68 | assertEquals(Response.Status.OK.getStatusCode(), target.request(MediaType.APPLICATION_JSON).get().getStatus()); 69 | } 70 | 71 | @Test 72 | public void should_produce_xml() 73 | { 74 | Client client = ClientBuilder.newClient(); 75 | WebTarget target = client.target(baseURL).path("rest").path("countries"); 76 | assertEquals(Response.Status.OK.getStatusCode(), target.request(MediaType.APPLICATION_XML).get().getStatus()); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/rest/CustomerEndpointTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.rest; 2 | 3 | import org.agoncal.application.petstore.exceptions.ValidationException; 4 | import org.agoncal.application.petstore.model.Address; 5 | import org.agoncal.application.petstore.model.Country; 6 | import org.agoncal.application.petstore.model.Customer; 7 | import org.agoncal.application.petstore.model.UserRole; 8 | import org.jboss.arquillian.container.test.api.Deployment; 9 | import org.jboss.arquillian.container.test.api.RunAsClient; 10 | import org.jboss.arquillian.junit.Arquillian; 11 | import org.jboss.arquillian.test.api.ArquillianResource; 12 | import org.jboss.shrinkwrap.api.ShrinkWrap; 13 | import org.jboss.shrinkwrap.api.asset.EmptyAsset; 14 | import org.jboss.shrinkwrap.api.spec.WebArchive; 15 | import org.junit.Test; 16 | import org.junit.runner.RunWith; 17 | 18 | import javax.ws.rs.client.Client; 19 | import javax.ws.rs.client.ClientBuilder; 20 | import javax.ws.rs.client.WebTarget; 21 | import javax.ws.rs.core.MediaType; 22 | import javax.ws.rs.core.Response; 23 | import java.net.URI; 24 | 25 | import static org.junit.Assert.assertEquals; 26 | 27 | @RunWith(Arquillian.class) 28 | @RunAsClient 29 | public class CustomerEndpointTest 30 | { 31 | 32 | // ====================================== 33 | // = Attributes = 34 | // ====================================== 35 | 36 | @ArquillianResource 37 | private URI baseURL; 38 | 39 | // ====================================== 40 | // = Deployment = 41 | // ====================================== 42 | 43 | @Deployment(testable = false) 44 | public static WebArchive createDeployment() 45 | { 46 | return ShrinkWrap.create(WebArchive.class) 47 | .addClass(RestApplication.class) 48 | .addClass(CustomerEndpoint.class) 49 | .addClass(Customer.class) 50 | .addClass(Address.class) 51 | .addClass(Country.class) 52 | .addClass(UserRole.class) 53 | .addClass(ValidationException.class) 54 | .addAsResource("META-INF/persistence.xml", "META-INF/persistence.xml") 55 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); 56 | } 57 | 58 | // ====================================== 59 | // = Test Cases = 60 | // ====================================== 61 | 62 | @Test 63 | public void should_be_deployed() 64 | { 65 | Client client = ClientBuilder.newClient(); 66 | WebTarget target = client.target(baseURL).path("rest").path("customers"); 67 | assertEquals(Response.Status.OK.getStatusCode(), target.request(MediaType.APPLICATION_XML).get().getStatus()); 68 | } 69 | 70 | @Test 71 | public void should_produce_json() 72 | { 73 | Client client = ClientBuilder.newClient(); 74 | WebTarget target = client.target(baseURL).path("rest").path("customers"); 75 | assertEquals(Response.Status.OK.getStatusCode(), target.request(MediaType.APPLICATION_JSON).get().getStatus()); 76 | } 77 | 78 | @Test 79 | public void should_produce_xml() 80 | { 81 | Client client = ClientBuilder.newClient(); 82 | WebTarget target = client.target(baseURL).path("rest").path("customers"); 83 | assertEquals(Response.Status.OK.getStatusCode(), target.request(MediaType.APPLICATION_XML).get().getStatus()); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/rest/ItemEndpointTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.rest; 2 | 3 | import org.agoncal.application.petstore.model.Category; 4 | import org.agoncal.application.petstore.model.Item; 5 | import org.agoncal.application.petstore.model.Product; 6 | import org.jboss.arquillian.container.test.api.Deployment; 7 | import org.jboss.arquillian.junit.Arquillian; 8 | import org.jboss.arquillian.test.api.ArquillianResource; 9 | import org.jboss.shrinkwrap.api.ShrinkWrap; 10 | import org.jboss.shrinkwrap.api.asset.EmptyAsset; 11 | import org.jboss.shrinkwrap.api.spec.WebArchive; 12 | import org.junit.Assert; 13 | import org.junit.Test; 14 | import org.junit.runner.RunWith; 15 | 16 | import javax.ws.rs.client.Client; 17 | import javax.ws.rs.client.ClientBuilder; 18 | import javax.ws.rs.client.WebTarget; 19 | import javax.ws.rs.core.MediaType; 20 | import javax.ws.rs.core.Response; 21 | import java.net.URI; 22 | 23 | import static org.junit.Assert.assertEquals; 24 | 25 | @RunWith(Arquillian.class) 26 | public class ItemEndpointTest 27 | { 28 | 29 | // ====================================== 30 | // = Attributes = 31 | // ====================================== 32 | 33 | @ArquillianResource 34 | private URI baseURL; 35 | 36 | // ====================================== 37 | // = Deployment = 38 | // ====================================== 39 | 40 | @Deployment(testable = false) 41 | public static WebArchive createDeployment() 42 | { 43 | return ShrinkWrap.create(WebArchive.class) 44 | .addClass(RestApplication.class) 45 | .addClass(ItemEndpoint.class) 46 | .addClass(Item.class) 47 | .addClass(Product.class) 48 | .addClass(Category.class) 49 | .addAsResource("META-INF/persistence.xml", "META-INF/persistence.xml") 50 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); 51 | } 52 | 53 | // ====================================== 54 | // = Test Cases = 55 | // ====================================== 56 | 57 | @Test 58 | public void should_be_deployed() 59 | { 60 | Client client = ClientBuilder.newClient(); 61 | WebTarget target = client.target(baseURL).path("rest").path("items"); 62 | assertEquals(Response.Status.OK.getStatusCode(), target.request(MediaType.APPLICATION_XML).get().getStatus()); 63 | } 64 | 65 | @Test 66 | public void should_produce_json() 67 | { 68 | Client client = ClientBuilder.newClient(); 69 | WebTarget target = client.target(baseURL).path("rest").path("items"); 70 | assertEquals(Response.Status.OK.getStatusCode(), target.request(MediaType.APPLICATION_JSON).get().getStatus()); 71 | } 72 | 73 | @Test 74 | public void should_produce_xml() 75 | { 76 | Client client = ClientBuilder.newClient(); 77 | WebTarget target = client.target(baseURL).path("rest").path("items"); 78 | assertEquals(Response.Status.OK.getStatusCode(), target.request(MediaType.APPLICATION_XML).get().getStatus()); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/rest/ProductEndpointTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.rest; 2 | 3 | import org.agoncal.application.petstore.model.Category; 4 | import org.agoncal.application.petstore.model.Product; 5 | import org.jboss.arquillian.container.test.api.Deployment; 6 | import org.jboss.arquillian.container.test.api.RunAsClient; 7 | import org.jboss.arquillian.junit.Arquillian; 8 | import org.jboss.arquillian.test.api.ArquillianResource; 9 | import org.jboss.shrinkwrap.api.ShrinkWrap; 10 | import org.jboss.shrinkwrap.api.asset.EmptyAsset; 11 | import org.jboss.shrinkwrap.api.spec.WebArchive; 12 | import org.junit.Assert; 13 | import org.junit.Test; 14 | import org.junit.runner.RunWith; 15 | 16 | import javax.ws.rs.client.Client; 17 | import javax.ws.rs.client.ClientBuilder; 18 | import javax.ws.rs.client.WebTarget; 19 | import javax.ws.rs.core.MediaType; 20 | import javax.ws.rs.core.Response; 21 | import java.net.URI; 22 | 23 | import static org.junit.Assert.assertEquals; 24 | 25 | @RunWith(Arquillian.class) 26 | @RunAsClient 27 | public class ProductEndpointTest 28 | { 29 | 30 | // ====================================== 31 | // = Attributes = 32 | // ====================================== 33 | 34 | @ArquillianResource 35 | private URI baseURL; 36 | 37 | // ====================================== 38 | // = Deployment = 39 | // ====================================== 40 | 41 | @Deployment(testable = false) 42 | public static WebArchive createDeployment() 43 | { 44 | return ShrinkWrap.create(WebArchive.class) 45 | .addClass(RestApplication.class) 46 | .addClass(ProductEndpoint.class) 47 | .addClass(Product.class) 48 | .addClass(Category.class) 49 | .addAsResource("META-INF/persistence.xml", "META-INF/persistence.xml") 50 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); 51 | } 52 | 53 | // ====================================== 54 | // = Test Cases = 55 | // ====================================== 56 | 57 | @Test 58 | public void should_be_deployed() 59 | { 60 | Client client = ClientBuilder.newClient(); 61 | WebTarget target = client.target(baseURL).path("rest").path("products"); 62 | assertEquals(Response.Status.OK.getStatusCode(), target.request(MediaType.APPLICATION_XML).get().getStatus()); 63 | } 64 | 65 | @Test 66 | public void should_produce_json() 67 | { 68 | Client client = ClientBuilder.newClient(); 69 | WebTarget target = client.target(baseURL).path("rest").path("products"); 70 | assertEquals(Response.Status.OK.getStatusCode(), target.request(MediaType.APPLICATION_JSON).get().getStatus()); 71 | } 72 | 73 | @Test 74 | public void should_produce_xml() 75 | { 76 | Client client = ClientBuilder.newClient(); 77 | WebTarget target = client.target(baseURL).path("rest").path("products"); 78 | assertEquals(Response.Status.OK.getStatusCode(), target.request(MediaType.APPLICATION_XML).get().getStatus()); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/service/CategoryServiceTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.service; 2 | 3 | import org.agoncal.application.petstore.model.Category; 4 | import org.jboss.arquillian.container.test.api.Deployment; 5 | import org.jboss.arquillian.junit.Arquillian; 6 | import org.jboss.shrinkwrap.api.ShrinkWrap; 7 | import org.jboss.shrinkwrap.api.asset.EmptyAsset; 8 | import org.jboss.shrinkwrap.api.spec.JavaArchive; 9 | import org.junit.Assert; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | 13 | import javax.inject.Inject; 14 | 15 | import static org.junit.Assert.assertEquals; 16 | import static org.junit.Assert.assertNotNull; 17 | 18 | @RunWith(Arquillian.class) 19 | public class CategoryServiceTest 20 | { 21 | 22 | // ====================================== 23 | // = Attributes = 24 | // ====================================== 25 | 26 | @Inject 27 | private CategoryService categoryservice; 28 | 29 | // ====================================== 30 | // = Deployment = 31 | // ====================================== 32 | 33 | @Deployment 34 | public static JavaArchive createDeployment() 35 | { 36 | return ShrinkWrap.create(JavaArchive.class) 37 | .addClass(AbstractService.class) 38 | .addClass(CategoryService.class) 39 | .addClass(Category.class) 40 | .addAsManifestResource("META-INF/persistence.xml", "persistence.xml") 41 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); 42 | } 43 | 44 | // ====================================== 45 | // = Test Cases = 46 | // ====================================== 47 | 48 | @Test 49 | public void should_be_deployed() 50 | { 51 | Assert.assertNotNull(categoryservice); 52 | } 53 | 54 | @Test 55 | public void should_crud() 56 | { 57 | // Gets all the objects 58 | int initialSize = categoryservice.listAll().size(); 59 | 60 | // Creates an object 61 | Category category = new Category(); 62 | category.setName("Dummy value"); 63 | category.setDescription("Dummy value"); 64 | 65 | // Inserts the object into the database 66 | category = categoryservice.persist(category); 67 | assertNotNull(category.getId()); 68 | assertEquals(initialSize + 1, categoryservice.listAll().size()); 69 | 70 | // Finds the object from the database and checks it's the right one 71 | category = categoryservice.findById(category.getId()); 72 | assertEquals("Dummy value", category.getName()); 73 | 74 | // Updates the object 75 | category.setName("A new value"); 76 | category = categoryservice.merge(category); 77 | 78 | // Finds the object from the database and checks it has been updated 79 | category = categoryservice.findById(category.getId()); 80 | assertEquals("A new value", category.getName()); 81 | 82 | // Deletes the object from the database and checks it's not there anymore 83 | categoryservice.remove(category); 84 | assertEquals(initialSize, categoryservice.listAll().size()); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/service/CountryServiceTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.service; 2 | 3 | import org.agoncal.application.petstore.model.Country; 4 | import javax.inject.Inject; 5 | 6 | import org.jboss.arquillian.container.test.api.Deployment; 7 | import org.jboss.arquillian.junit.Arquillian; 8 | import org.jboss.shrinkwrap.api.ShrinkWrap; 9 | import org.jboss.shrinkwrap.api.spec.JavaArchive; 10 | import org.jboss.shrinkwrap.api.asset.EmptyAsset; 11 | import org.junit.Assert; 12 | import org.junit.Test; 13 | import org.junit.runner.RunWith; 14 | import static org.junit.Assert.*; 15 | 16 | @RunWith(Arquillian.class) 17 | public class CountryServiceTest 18 | { 19 | 20 | // ====================================== 21 | // = Attributes = 22 | // ====================================== 23 | 24 | @Inject 25 | private CountryService countryservice; 26 | 27 | // ====================================== 28 | // = Deployment = 29 | // ====================================== 30 | 31 | @Deployment 32 | public static JavaArchive createDeployment() 33 | { 34 | return ShrinkWrap.create(JavaArchive.class) 35 | .addClass(AbstractService.class) 36 | .addClass(CountryService.class) 37 | .addClass(Country.class) 38 | .addAsManifestResource("META-INF/persistence.xml", "persistence.xml") 39 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); 40 | } 41 | 42 | // ====================================== 43 | // = Test Cases = 44 | // ====================================== 45 | 46 | @Test 47 | public void should_be_deployed() 48 | { 49 | Assert.assertNotNull(countryservice); 50 | } 51 | 52 | @Test 53 | public void should_crud() 54 | { 55 | // Gets all the objects 56 | int initialSize = countryservice.listAll().size(); 57 | 58 | // Creates an object 59 | Country country = new Country("DV", "Dummy value", "Dummy value", "DMV", "DMV"); 60 | 61 | // Inserts the object into the database 62 | country = countryservice.persist(country); 63 | assertNotNull(country.getId()); 64 | assertEquals(initialSize + 1, countryservice.listAll().size()); 65 | 66 | // Finds the object from the database and checks it's the right one 67 | country = countryservice.findById(country.getId()); 68 | assertEquals("Dummy value", country.getName()); 69 | 70 | // Updates the object 71 | country.setName("A new value"); 72 | country = countryservice.merge(country); 73 | 74 | // Finds the object from the database and checks it has been updated 75 | country = countryservice.findById(country.getId()); 76 | assertEquals("A new value", country.getName()); 77 | 78 | // Deletes the object from the database and checks it's not there anymore 79 | countryservice.remove(country); 80 | assertEquals(initialSize, countryservice.listAll().size()); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/service/ItemServiceTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.service; 2 | 3 | import org.agoncal.application.petstore.model.Category; 4 | import org.agoncal.application.petstore.model.Item; 5 | import org.agoncal.application.petstore.model.Product; 6 | import javax.inject.Inject; 7 | 8 | import org.jboss.arquillian.container.test.api.Deployment; 9 | import org.jboss.arquillian.junit.Arquillian; 10 | import org.jboss.shrinkwrap.api.ShrinkWrap; 11 | import org.jboss.shrinkwrap.api.spec.JavaArchive; 12 | import org.jboss.shrinkwrap.api.asset.EmptyAsset; 13 | import org.junit.Assert; 14 | import org.junit.Test; 15 | import org.junit.runner.RunWith; 16 | import static org.junit.Assert.*; 17 | 18 | @RunWith(Arquillian.class) 19 | public class ItemServiceTest 20 | { 21 | 22 | // ====================================== 23 | // = Attributes = 24 | // ====================================== 25 | 26 | @Inject 27 | private ItemService itemservice; 28 | 29 | // ====================================== 30 | // = Deployment = 31 | // ====================================== 32 | 33 | @Deployment 34 | public static JavaArchive createDeployment() 35 | { 36 | return ShrinkWrap.create(JavaArchive.class) 37 | .addClass(AbstractService.class) 38 | .addClass(ItemService.class) 39 | .addClass(Item.class) 40 | .addClass(Product.class) 41 | .addClass(Category.class) 42 | .addAsManifestResource("META-INF/persistence.xml", "persistence.xml") 43 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); 44 | } 45 | 46 | // ====================================== 47 | // = Test Cases = 48 | // ====================================== 49 | 50 | @Test 51 | public void should_be_deployed() 52 | { 53 | Assert.assertNotNull(itemservice); 54 | } 55 | 56 | @Test 57 | public void should_crud() 58 | { 59 | // Gets all the objects 60 | int initialSize = itemservice.listAll().size(); 61 | 62 | // Creates an object 63 | Category category = new Category("Dummy value", "Dummy value"); 64 | Product product = new Product("Dummy value", "Dummy value", category); 65 | Item item = new Item("Dummy value", 10f, "Dummy value", "Dummy value", product); 66 | 67 | // Inserts the object into the database 68 | item = itemservice.persist(item); 69 | assertNotNull(item.getId()); 70 | assertEquals(initialSize + 1, itemservice.listAll().size()); 71 | 72 | // Finds the object from the database and checks it's the right one 73 | item = itemservice.findById(item.getId()); 74 | assertEquals("Dummy value", item.getName()); 75 | 76 | // Updates the object 77 | item.setName("A new value"); 78 | item = itemservice.merge(item); 79 | 80 | // Finds the object from the database and checks it has been updated 81 | item = itemservice.findById(item.getId()); 82 | assertEquals("A new value", item.getName()); 83 | 84 | // Deletes the object from the database and checks it's not there anymore 85 | itemservice.remove(item); 86 | assertEquals(initialSize, itemservice.listAll().size()); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/service/ProductServiceTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.service; 2 | 3 | import org.agoncal.application.petstore.model.Category; 4 | import org.agoncal.application.petstore.model.Product; 5 | import javax.inject.Inject; 6 | 7 | import org.jboss.arquillian.container.test.api.Deployment; 8 | import org.jboss.arquillian.junit.Arquillian; 9 | import org.jboss.shrinkwrap.api.ShrinkWrap; 10 | import org.jboss.shrinkwrap.api.spec.JavaArchive; 11 | import org.jboss.shrinkwrap.api.asset.EmptyAsset; 12 | import org.junit.Assert; 13 | import org.junit.Test; 14 | import org.junit.runner.RunWith; 15 | import static org.junit.Assert.*; 16 | 17 | @RunWith(Arquillian.class) 18 | public class ProductServiceTest 19 | { 20 | 21 | // ====================================== 22 | // = Attributes = 23 | // ====================================== 24 | 25 | @Inject 26 | private ProductService productservice; 27 | 28 | // ====================================== 29 | // = Deployment = 30 | // ====================================== 31 | 32 | @Deployment 33 | public static JavaArchive createDeployment() 34 | { 35 | return ShrinkWrap.create(JavaArchive.class) 36 | .addClass(AbstractService.class) 37 | .addClass(ProductService.class) 38 | .addClass(Product.class) 39 | .addClass(Category.class) 40 | .addAsManifestResource("META-INF/persistence.xml", "persistence.xml") 41 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); 42 | } 43 | 44 | // ====================================== 45 | // = Test Cases = 46 | // ====================================== 47 | 48 | @Test 49 | public void should_be_deployed() 50 | { 51 | Assert.assertNotNull(productservice); 52 | } 53 | 54 | @Test 55 | public void should_crud() 56 | { 57 | // Gets all the objects 58 | int initialSize = productservice.listAll().size(); 59 | 60 | // Creates an object 61 | Category category = new Category("Dummy value", "Dummy value"); 62 | Product product = new Product("Dummy value", "Dummy value", category); 63 | 64 | // Inserts the object into the database 65 | product = productservice.persist(product); 66 | assertNotNull(product.getId()); 67 | assertEquals(initialSize + 1, productservice.listAll().size()); 68 | 69 | // Finds the object from the database and checks it's the right one 70 | product = productservice.findById(product.getId()); 71 | assertEquals("Dummy value", product.getName()); 72 | 73 | // Updates the object 74 | product.setName("A new value"); 75 | product = productservice.merge(product); 76 | 77 | // Finds the object from the database and checks it has been updated 78 | product = productservice.findById(product.getId()); 79 | assertEquals("A new value", product.getName()); 80 | 81 | // Deletes the object from the database and checks it's not there anymore 82 | productservice.remove(product); 83 | assertEquals(initialSize, productservice.listAll().size()); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/view/admin/CategoryBeanTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.view.admin; 2 | 3 | import org.agoncal.application.petstore.model.Category; 4 | import javax.inject.Inject; 5 | 6 | import org.jboss.arquillian.container.test.api.Deployment; 7 | import org.jboss.arquillian.junit.Arquillian; 8 | import org.jboss.shrinkwrap.api.ShrinkWrap; 9 | import org.jboss.shrinkwrap.api.spec.JavaArchive; 10 | import org.jboss.shrinkwrap.api.asset.EmptyAsset; 11 | import org.junit.Assert; 12 | import org.junit.Test; 13 | import org.junit.runner.RunWith; 14 | import static org.junit.Assert.*; 15 | 16 | @RunWith(Arquillian.class) 17 | public class CategoryBeanTest 18 | { 19 | 20 | // ====================================== 21 | // = Attributes = 22 | // ====================================== 23 | 24 | @Inject 25 | private CategoryBean categorybean; 26 | 27 | // ====================================== 28 | // = Deployment = 29 | // ====================================== 30 | 31 | @Deployment 32 | public static JavaArchive createDeployment() 33 | { 34 | return ShrinkWrap.create(JavaArchive.class) 35 | .addClass(CategoryBean.class) 36 | .addClass(Category.class) 37 | .addAsManifestResource("META-INF/persistence.xml", "persistence.xml") 38 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); 39 | } 40 | 41 | // ====================================== 42 | // = Test Cases = 43 | // ====================================== 44 | 45 | @Test 46 | public void should_be_deployed() 47 | { 48 | Assert.assertNotNull(categorybean); 49 | } 50 | 51 | @Test 52 | public void should_crud() 53 | { 54 | // Creates an object 55 | Category category = new Category(); 56 | category.setName("Dummy value"); 57 | category.setDescription("Dummy value"); 58 | 59 | // Inserts the object into the database 60 | categorybean.setCategory(category); 61 | categorybean.create(); 62 | categorybean.update(); 63 | category = categorybean.getCategory(); 64 | assertNotNull(category.getId()); 65 | 66 | // Finds the object from the database and checks it's the right one 67 | category = categorybean.findById(category.getId()); 68 | assertEquals("Dummy value", category.getName()); 69 | 70 | // Deletes the object from the database and checks it's not there anymore 71 | categorybean.setId(category.getId()); 72 | categorybean.create(); 73 | categorybean.delete(); 74 | category = categorybean.findById(category.getId()); 75 | assertNull(category); 76 | } 77 | 78 | @Test 79 | public void should_paginate() 80 | { 81 | // Creates an empty example 82 | Category example = new Category(); 83 | 84 | // Paginates through the example 85 | categorybean.setExample(example); 86 | categorybean.paginate(); 87 | assertTrue((categorybean.getPageItems().size() == categorybean.getPageSize()) || (categorybean.getPageItems().size() == categorybean.getCount())); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/view/admin/CountryBeanTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.view.admin; 2 | 3 | import org.agoncal.application.petstore.model.Country; 4 | import javax.inject.Inject; 5 | 6 | import org.jboss.arquillian.container.test.api.Deployment; 7 | import org.jboss.arquillian.junit.Arquillian; 8 | import org.jboss.shrinkwrap.api.ShrinkWrap; 9 | import org.jboss.shrinkwrap.api.spec.JavaArchive; 10 | import org.jboss.shrinkwrap.api.asset.EmptyAsset; 11 | import org.junit.Assert; 12 | import org.junit.Test; 13 | import org.junit.runner.RunWith; 14 | import static org.junit.Assert.*; 15 | 16 | @RunWith(Arquillian.class) 17 | public class CountryBeanTest 18 | { 19 | 20 | // ====================================== 21 | // = Attributes = 22 | // ====================================== 23 | 24 | @Inject 25 | private CountryBean countrybean; 26 | 27 | // ====================================== 28 | // = Deployment = 29 | // ====================================== 30 | 31 | @Deployment 32 | public static JavaArchive createDeployment() 33 | { 34 | return ShrinkWrap.create(JavaArchive.class) 35 | .addClass(CountryBean.class) 36 | .addClass(Country.class) 37 | .addAsManifestResource("META-INF/persistence.xml", "persistence.xml") 38 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); 39 | } 40 | 41 | // ====================================== 42 | // = Test Cases = 43 | // ====================================== 44 | 45 | @Test 46 | public void should_be_deployed() 47 | { 48 | Assert.assertNotNull(countrybean); 49 | } 50 | 51 | @Test 52 | public void should_crud() 53 | { 54 | // Creates an object 55 | Country country = new Country("DV", "Dummy value", "Dummy value", "DMV", "DMV"); 56 | 57 | // Inserts the object into the database 58 | countrybean.setCountry(country); 59 | countrybean.create(); 60 | countrybean.update(); 61 | country = countrybean.getCountry(); 62 | assertNotNull(country.getId()); 63 | 64 | // Finds the object from the database and checks it's the right one 65 | country = countrybean.findById(country.getId()); 66 | assertEquals("Dummy value", country.getName()); 67 | 68 | // Deletes the object from the database and checks it's not there anymore 69 | countrybean.setId(country.getId()); 70 | countrybean.create(); 71 | countrybean.delete(); 72 | country = countrybean.findById(country.getId()); 73 | assertNull(country); 74 | } 75 | 76 | @Test 77 | public void should_paginate() 78 | { 79 | // Creates an empty example 80 | Country example = new Country(); 81 | 82 | // Paginates through the example 83 | countrybean.setExample(example); 84 | countrybean.paginate(); 85 | assertTrue((countrybean.getPageItems().size() == countrybean.getPageSize()) || (countrybean.getPageItems().size() == countrybean.getCount())); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/view/admin/ItemBeanTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.view.admin; 2 | 3 | import org.agoncal.application.petstore.model.Category; 4 | import org.agoncal.application.petstore.model.Item; 5 | import org.agoncal.application.petstore.model.Product; 6 | import javax.inject.Inject; 7 | 8 | import org.jboss.arquillian.container.test.api.Deployment; 9 | import org.jboss.arquillian.junit.Arquillian; 10 | import org.jboss.shrinkwrap.api.ShrinkWrap; 11 | import org.jboss.shrinkwrap.api.spec.JavaArchive; 12 | import org.jboss.shrinkwrap.api.asset.EmptyAsset; 13 | import org.junit.Assert; 14 | import org.junit.Test; 15 | import org.junit.runner.RunWith; 16 | import static org.junit.Assert.*; 17 | 18 | @RunWith(Arquillian.class) 19 | public class ItemBeanTest 20 | { 21 | 22 | // ====================================== 23 | // = Attributes = 24 | // ====================================== 25 | 26 | @Inject 27 | private ItemBean itembean; 28 | 29 | // ====================================== 30 | // = Deployment = 31 | // ====================================== 32 | 33 | @Deployment 34 | public static JavaArchive createDeployment() 35 | { 36 | return ShrinkWrap.create(JavaArchive.class) 37 | .addClass(ItemBean.class) 38 | .addClass(Item.class) 39 | .addClass(Product.class) 40 | .addClass(Category.class) 41 | .addAsManifestResource("META-INF/persistence.xml", "persistence.xml") 42 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); 43 | } 44 | 45 | // ====================================== 46 | // = Test Cases = 47 | // ====================================== 48 | 49 | @Test 50 | public void should_be_deployed() 51 | { 52 | Assert.assertNotNull(itembean); 53 | } 54 | 55 | @Test 56 | public void should_crud() 57 | { 58 | // Creates an object 59 | Category category = new Category("Dummy value", "Dummy value"); 60 | Product product = new Product("Dummy value", "Dummy value", category); 61 | Item item = new Item("Dummy value", 10f, "Dummy value", "Dummy value", product); 62 | 63 | // Inserts the object into the database 64 | itembean.setItem(item); 65 | itembean.create(); 66 | itembean.update(); 67 | item = itembean.getItem(); 68 | assertNotNull(item.getId()); 69 | 70 | // Finds the object from the database and checks it's the right one 71 | item = itembean.findById(item.getId()); 72 | assertEquals("Dummy value", item.getName()); 73 | 74 | // Deletes the object from the database and checks it's not there anymore 75 | itembean.setId(item.getId()); 76 | itembean.create(); 77 | itembean.delete(); 78 | item = itembean.findById(item.getId()); 79 | assertNull(item); 80 | } 81 | 82 | @Test 83 | public void should_paginate() 84 | { 85 | // Creates an empty example 86 | Item example = new Item(); 87 | 88 | // Paginates through the example 89 | itembean.setExample(example); 90 | itembean.paginate(); 91 | assertTrue((itembean.getPageItems().size() == itembean.getPageSize()) || (itembean.getPageItems().size() == itembean.getCount())); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/test/java/org/agoncal/application/petstore/view/admin/ProductBeanTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.application.petstore.view.admin; 2 | 3 | import org.agoncal.application.petstore.model.Category; 4 | import org.agoncal.application.petstore.model.Product; 5 | import javax.inject.Inject; 6 | 7 | import org.jboss.arquillian.container.test.api.Deployment; 8 | import org.jboss.arquillian.junit.Arquillian; 9 | import org.jboss.shrinkwrap.api.ShrinkWrap; 10 | import org.jboss.shrinkwrap.api.spec.JavaArchive; 11 | import org.jboss.shrinkwrap.api.asset.EmptyAsset; 12 | import org.junit.Assert; 13 | import org.junit.Test; 14 | import org.junit.runner.RunWith; 15 | import static org.junit.Assert.*; 16 | 17 | @RunWith(Arquillian.class) 18 | public class ProductBeanTest 19 | { 20 | 21 | // ====================================== 22 | // = Attributes = 23 | // ====================================== 24 | 25 | @Inject 26 | private ProductBean productbean; 27 | 28 | // ====================================== 29 | // = Deployment = 30 | // ====================================== 31 | 32 | @Deployment 33 | public static JavaArchive createDeployment() 34 | { 35 | return ShrinkWrap.create(JavaArchive.class) 36 | .addClass(ProductBean.class) 37 | .addClass(Product.class) 38 | .addClass(Category.class) 39 | .addAsManifestResource("META-INF/persistence.xml", "persistence.xml") 40 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); 41 | } 42 | 43 | // ====================================== 44 | // = Test Cases = 45 | // ====================================== 46 | 47 | @Test 48 | public void should_be_deployed() 49 | { 50 | Assert.assertNotNull(productbean); 51 | } 52 | 53 | @Test 54 | public void should_crud() 55 | { 56 | // Creates an object 57 | Category category = new Category("Dummy value", "Dummy value"); 58 | Product product = new Product("Dummy value", "Dummy value", category); 59 | 60 | // Inserts the object into the database 61 | productbean.setProduct(product); 62 | productbean.create(); 63 | productbean.update(); 64 | product = productbean.getProduct(); 65 | assertNotNull(product.getId()); 66 | 67 | // Finds the object from the database and checks it's the right one 68 | product = productbean.findById(product.getId()); 69 | assertEquals("Dummy value", product.getName()); 70 | 71 | // Deletes the object from the database and checks it's not there anymore 72 | productbean.setId(product.getId()); 73 | productbean.create(); 74 | productbean.delete(); 75 | product = productbean.findById(product.getId()); 76 | assertNull(product); 77 | } 78 | 79 | @Test 80 | public void should_paginate() 81 | { 82 | // Creates an empty example 83 | Product example = new Product(); 84 | 85 | // Paginates through the example 86 | productbean.setExample(example); 87 | productbean.paginate(); 88 | assertTrue((productbean.getPageItems().size() == productbean.getPageSize()) || (productbean.getPageItems().size() == productbean.getCount())); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/test/resources/arquillian.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | target/wildfly-11.0.0.Final 9 | -Xmx1024m -Xnoagent -Djava.compiler=NONE -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 10 | 11 | true 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /step-00-setup-your-environment/README.md: -------------------------------------------------------------------------------- 1 | # 00 - Setup your environment 2 | 3 | __This guide is part of the [migrate Java EE app to Azure training](../README.md)__ 4 | 5 | Setting up all the necessary prerequisites in order to expeditiously complete the lab. 6 | 7 | --- 8 | 9 | ## Prerequisites 10 | 11 | In order to deploy a Java Web app to cloud, you need 12 | an Azure subscription. If you do not already have an Azure subscription, you can activate your 13 | [MSDN subscriber benefits](https://azure.microsoft.com/pricing/member-offers/msdn-benefits-details/) 14 | or sign up for a 15 | [free Azure account]((https://azure.microsoft.com/pricing/free-trial/)). 16 | 17 | This training lab requires the following to be installed on your development machine: 18 | 19 | * [JDK 1.8](https://www.azul.com/downloads/azure-only/zulu/?&version=java-8-lts&architecture=x86-64-bit&package=jdk) 20 | * A text editor or an IDE. If you do not already have an IDE for Java development, 21 | we recommend using [Visual Studio Code](https://code.visualstudio.com/) 22 | with the [Java Extension Pack](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack) 23 | * [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest) 24 | * The Bash shell. While Azure CLI should behave identically on all environments, some semantics may need to be modified if 25 | you use other shells. To complete this training on Windows, you can 26 | use [Git Bash that accompanies the Windows distribution of Git](https://git-scm.com/download/win) 27 | * [Maven](http://maven.apache.org/) 28 | * In section 3, you will create a database - PostgreSQL, MySQL or SQL Database. Based on the 29 | database of your choice, you will require the corresponding database's commandline tool: 30 | * [PostgreSQL CLI](https://www.postgresql.org/docs/current/app-psql.html) 31 | * [MySQL CLI](https://dev.mysql.com/downloads/shell/) 32 | * [SQLCMD CLI](https://cloudblogs.microsoft.com/sqlserver/2017/05/16/sql-server-command-line-tools-for-macos-released/). 33 | * The [`jq` utility](https://stedolan.github.io/jq/download/). On Windows, download [this Windows port of JQ](https://github.com/stedolan/jq/releases) and add the following to the `~/.bashrc` file: 34 | ```bash 35 | alias jq=/jq-win64.exe 36 | ``` 37 | 38 | The environment variable `JAVA_HOME` should be set to the path of `javac` in the JDK installation. 39 | 40 | --- 41 | 42 | ➡️ Next guide: [01 - Deploy a Java EE application to Azure](../step-01-deploy-java-ee-app-to-azure/README.md) -------------------------------------------------------------------------------- /step-01-deploy-java-ee-app-to-azure/media/YAPS-PetStore-H2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/step-01-deploy-java-ee-app-to-azure/media/YAPS-PetStore-H2.jpg -------------------------------------------------------------------------------- /step-02-create-a-database/README.md: -------------------------------------------------------------------------------- 1 | # 02 - Create a database 2 | 3 | __This guide is part of the [migrate Java EE app to Azure training](../README.md)__ 4 | 5 | Create a database of your choice using commandline tools. 6 | 7 | --- 8 | 9 | Azure offers three relational database services. You can choose any of the three services to create a database 10 | for Java EE applications: 11 | 12 | ## [02A - PostgreSQL](step-02A-create-a-postgresql-database/README.md) 13 | 14 | Create a petstore database using Azure Database for PostgreSQL. 15 | 16 | ## [02B - MySQL](step-02B-create-a-mysql-database/README.md) 17 | 18 | Create a petstore database using Azure Database for MySQL. 19 | 20 | ## [02C - SQL Database](step-02C-create-a-sql-database/README.md) 21 | 22 | Create a petstore database using Azure SQL Database. 23 | 24 | --- 25 | 26 | ⬅️ Previous guide: [01 - Deploy a Java EE application to Azure](../step-01-deploy-java-ee-app-to-azure/README.md) 27 | 28 | ➡️ Next guide: Create a [02A - PostgreSQL](step-02A-create-a-postgresql-database/README.md), [02B - MySQL](step-02B-create-a-mysql-database/README.md), or [02C - SQL Database](step-02C-create-a-sql-database/README.md) 29 | -------------------------------------------------------------------------------- /step-02-create-a-database/step-02B-create-a-mysql-database/README.md: -------------------------------------------------------------------------------- 1 | # 02B - Create a MySQL Database 2 | 3 | __This guide is part of the [migrate Java EE app to Azure training](../../README.md)__ 4 | 5 | Create a MySQL database using commandline tools. 6 | 7 | --- 8 | 9 | ## Create and Configure MySQL database in Azure Database for MySQL 10 | 11 | Create a Petstore database using Azure CLI and MySQL CLI: 12 | 13 | ```bash 14 | az mysql server create --resource-group ${RESOURCE_GROUP} \ 15 | --name ${MYSQL_SERVER_NAME} --location ${REGION} \ 16 | --admin-user ${MYSQL_SERVER_ADMIN_LOGIN_NAME} \ 17 | --admin-password ${MYSQL_SERVER_ADMIN_PASSWORD} \ 18 | --sku-name GP_Gen5_32 \ 19 | --ssl-enforcement Disabled \ 20 | --version 5.7 21 | 22 | // allow access from Azure resources 23 | az mysql server firewall-rule create --name allAzureIPs \ 24 | --server ${MYSQL_SERVER_NAME} \ 25 | --resource-group ${RESOURCE_GROUP} \ 26 | --start-ip-address 0.0.0.0 --end-ip-address 0.0.0.0 27 | 28 | // allow access from your dev machine for testing 29 | az mysql server firewall-rule create --name myDevBox \ 30 | --server ${MYSQL_SERVER_NAME} \ 31 | --resource-group ${RESOURCE_GROUP} \ 32 | --start-ip-address ${DEVBOX_IP_ADDRESS} --end-ip-address ${DEVBOX_IP_ADDRESS} 33 | 34 | // increase connection timeout 35 | az mysql server configuration set --name wait_timeout \ 36 | --resource-group ${RESOURCE_GROUP} \ 37 | --server ${MYSQL_SERVER_NAME} --value 2147483 38 | 39 | // log into mysql 40 | mysql -u ${MYSQL_SERVER_ADMIN_FULL_NAME} -h ${MYSQL_SERVER_FULL_NAME} -P 3306 -p 41 | ``` 42 | ```text 43 | Enter password: 44 | Welcome to the MySQL monitor. Commands end with ; or \g. 45 | Your MySQL connection id is 64096 46 | Server version: 5.6.39.0 MySQL Community Server (GPL) 47 | 48 | Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. 49 | 50 | Oracle is a registered trademark of Oracle Corporation and/or its 51 | affiliates. Other names may be trademarks of their respective 52 | owners. 53 | 54 | Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 55 | 56 | mysql> CREATE DATABASE petstore; 57 | Query OK, 1 row affected (0.05 sec) 58 | 59 | mysql> CREATE USER 'root' IDENTIFIED BY 'petstore'; 60 | Query OK, 0 rows affected (0.04 sec) 61 | 62 | mysql> GRANT ALL PRIVILEGES ON petstore.* TO 'root'; 63 | Query OK, 0 rows affected (0.05 sec) 64 | 65 | mysql> CALL mysql.az_load_timezone(); 66 | Query OK, 3179 rows affected, 1 warning (6.34 sec) 67 | 68 | mysql> SELECT name FROM mysql.time_zone_name; 69 | ... 70 | 71 | mysql> quit 72 | Bye 73 | ``` 74 | ```bash 75 | az mysql server configuration set --name time_zone \ 76 | --resource-group ${RESOURCE_GROUP} \ 77 | --server ${MYSQL_SERVER_NAME} --value "US/Pacific" 78 | ``` 79 | 80 | When you migrate Java applications to cloud, you will be considering moving data to cloud. 81 | To accelerate your transition to cloud, 82 | Azure offers plenty of options to [migrate your data](https://azure.microsoft.com/en-us/services/database-migration/) 83 | to cloud. 84 | 85 | Also, for your convenience, there is a [cheat sheet for MySQL CLI](http://www.mysqltutorial.org/mysql-cheat-sheet.aspx). 86 | 87 | --- 88 | 89 | ⬅️ Previous guide: [01 - Deploy a Java EE application to Azure](../../step-01-deploy-java-ee-app-to-azure/README.md) 90 | 91 | ➡️ Next guide: [03 - Bind Java EE application to the database](../../step-03-bind-java-ee-app-to-database/README.md) -------------------------------------------------------------------------------- /step-02-create-a-database/step-02C-create-a-sql-database/README.md: -------------------------------------------------------------------------------- 1 | # 02C - Create a SQL Database 2 | 3 | __This guide is part of the [migrate Java EE app to Azure training](../../README.md)__ 4 | 5 | Create a SQL database using commandline tools. 6 | 7 | --- 8 | 9 | ## Create and Configure SQL database in Azure SQL Database 10 | 11 | Create a Petstore database using Azure CLI: 12 | ```bash 13 | 14 | az sql server create --admin-user ${SQL_SERVER_ADMIN_LOGIN_NAME} \ 15 | --admin-password ${SQL_SERVER_ADMIN_PASSWORD} \ 16 | --name ${SQL_SERVER_NAME} \ 17 | --resource-group ${RESOURCE_GROUP} --location ${REGION} 18 | 19 | az sql server firewall-rule create --server ${SQL_SERVER_NAME} \ 20 | --name allAzureIPs \ 21 | --start-ip-address 0.0.0.0 --end-ip-address 0.0.0.0 \ 22 | --resource-group ${RESOURCE_GROUP} 23 | 24 | az sql server firewall-rule create --server ${SQL_SERVER_NAME} \ 25 | --name myDevBox \ 26 | --start-ip-address ${DEVBOX_IP_ADDRESS} --end-ip-address ${DEVBOX_IP_ADDRESS} \ 27 | --resource-group ${RESOURCE_GROUP} 28 | 29 | az sql db create --name ${SQL_DATABASE_NAME} \ 30 | --server ${SQL_SERVER_NAME} \ 31 | --resource-group ${RESOURCE_GROUP} 32 | 33 | ``` 34 | 35 | When you migrate Java applications to cloud, you will be considering moving data to cloud. 36 | To accelerate your transition to cloud, 37 | Azure offers plenty of options to [migrate your data](https://azure.microsoft.com/en-us/services/database-migration/) 38 | to cloud. 39 | 40 | Also, for your convenience, there is a [cheat sheet for sqlcmd CLI](https://docs.microsoft.com/en-us/sql/tools/sqlcmd-utility). 41 | 42 | --- 43 | 44 | ⬅️ Previous guide: [01 - Deploy a Java EE application to Azure](../../step-01-deploy-java-ee-app-to-azure/README.md) 45 | 46 | ➡️ Next guide: [03 - Bind Java EE application to the database](../../step-03-bind-java-ee-app-to-database/README.md) 47 | -------------------------------------------------------------------------------- /step-03-bind-java-ee-app-to-database/README.md: -------------------------------------------------------------------------------- 1 | # 03 - Bind Java EE application to database 2 | 3 | __This guide is part of the [migrate Java EE app to Azure training](../README.md)__ 4 | 5 | Configure JBoss EAP datasource and bind the Java EE application to the 6 | database of your choice. 7 | 8 | --- 9 | 10 | ## Bind application to database 11 | 12 | Depending on your choice of the database that you created, you can pick one of the three paths 13 | to bind the Java EE application to the database: 14 | 15 | ### [03A - PostgreSQL](step-03A-bind-app-to-postgresql/README.md) 16 | 17 | Bind the application to the petstore database in Azure Database for PostgreSQL. 18 | 19 | ### [03B - MySQL](step-03B-bind-app-to-mysql/README.md) 20 | 21 | Bind the application to the petstore database in Azure Database for MySQL. 22 | 23 | ### [03C - SQL Database](step-03C-bind-app-to-sql-database/README.md) 24 | 25 | Bind the application to the petstore database in Azure SQL Database. 26 | 27 | --- 28 | 29 | ⬅️ Previous guide: [02 - Deploy a Java EE application to Azure](../step-02-create-a-database/README.md) 30 | 31 | ➡️ Next guide: Bind application to [03A - PostgreSQL](step-03A-bind-app-to-postgresql/README.md), [03B - MySQL](step-03B-bind-app-to-mysql/README.md), or [03C - SQL Database](step-03C-bind-app-to-sql-database/README.md) 32 | -------------------------------------------------------------------------------- /step-04-monitor-java-ee-app/media/Create-Application-Insights.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/step-04-monitor-java-ee-app/media/Create-Application-Insights.jpg -------------------------------------------------------------------------------- /step-04-monitor-java-ee-app/media/app-service-ai-menu-sh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/step-04-monitor-java-ee-app/media/app-service-ai-menu-sh.png -------------------------------------------------------------------------------- /step-04-monitor-java-ee-app/media/app-service-configure-ai-sh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/step-04-monitor-java-ee-app/media/app-service-configure-ai-sh.png -------------------------------------------------------------------------------- /step-04-monitor-java-ee-app/media/app-service-enable-ai-sh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/step-04-monitor-java-ee-app/media/app-service-enable-ai-sh.png -------------------------------------------------------------------------------- /step-04-monitor-java-ee-app/media/app-service-view-ai-sh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/step-04-monitor-java-ee-app/media/app-service-view-ai-sh.png -------------------------------------------------------------------------------- /step-04-monitor-java-ee-app/media/seattle-petstore-app-logs-in-log-analytics.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/step-04-monitor-java-ee-app/media/seattle-petstore-app-logs-in-log-analytics.jpg -------------------------------------------------------------------------------- /step-04-monitor-java-ee-app/media/seattle-petstore-application-map.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/step-04-monitor-java-ee-app/media/seattle-petstore-application-map.jpg -------------------------------------------------------------------------------- /step-04-monitor-java-ee-app/media/seattle-petstore-end-to-end-transaction.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/step-04-monitor-java-ee-app/media/seattle-petstore-end-to-end-transaction.jpg -------------------------------------------------------------------------------- /step-04-monitor-java-ee-app/media/seattle-petstore-live-metrics.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/step-04-monitor-java-ee-app/media/seattle-petstore-live-metrics.jpg -------------------------------------------------------------------------------- /step-04-monitor-java-ee-app/media/seattle-petstore-operation-performance-in-log-analytics.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/step-04-monitor-java-ee-app/media/seattle-petstore-operation-performance-in-log-analytics.jpg -------------------------------------------------------------------------------- /step-04-monitor-java-ee-app/media/seattle-petstore-performance.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/step-04-monitor-java-ee-app/media/seattle-petstore-performance.jpg -------------------------------------------------------------------------------- /step-04-monitor-java-ee-app/media/seattle-petstore-sql-dependencies.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/step-04-monitor-java-ee-app/media/seattle-petstore-sql-dependencies.jpg -------------------------------------------------------------------------------- /step-05-setup-github-actions/media/download_publish_profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/step-05-setup-github-actions/media/download_publish_profile.png -------------------------------------------------------------------------------- /step-05-setup-github-actions/media/search_logs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/step-05-setup-github-actions/media/search_logs.png -------------------------------------------------------------------------------- /step-05-setup-github-actions/media/set_github_secret.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/step-05-setup-github-actions/media/set_github_secret.png -------------------------------------------------------------------------------- /step-05-setup-github-actions/media/view_logs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/migrate-javaee-app-to-azure-training/c53ecab83186caf9c332aaff9d4ac90862f1f5d4/step-05-setup-github-actions/media/view_logs.png -------------------------------------------------------------------------------- /step-99-conclusion/README.md: -------------------------------------------------------------------------------- 1 | # Conclusion 2 | 3 | __This guide is part of the [migrate Java EE app to Azure training](../README.md)__ 4 | 5 | --- 6 | 7 | ## Congratulations! 8 | 9 | Congratulations!! You migrated an existing Java EE application to Azure, aka application 10 | to App Service Linux and application's data to Azure Database for PostgreSQL, MySQL and or 11 | SQL Database. Also, you migrated without worrying about the underlying infrastructure resources. 12 | 13 | Time to clean up ... 14 | 15 | ## Cleaning up 16 | 17 | Unless you plan to perform additional tasks with the Azure resources from the workshop 18 | (such as tutorials referenced below), it is important to destroy the resources that we 19 | created for it to avoid the cost of keeping them provisioned. 20 | 21 | The easiest way to do this is to delete the entire resource group. 22 | 23 | ```bash 24 | az group delete -g ${RESOURCE_GROUP} --yes --no-wait 25 | ``` 26 | 27 | ## Additional Resources 28 | 29 | As an addendum to this workshop, consider taking the [tutorial on using alerts and action groups with Azure Spring Cloud](https://docs.microsoft.com/azure/spring-cloud/spring-cloud-tutorial-alerts-action-groups/?WT.mc_id=azurespringcloud-github-judubois) to detect and respond to abnormal conditions. 30 | 31 | Have a look through the the following quick starts, tutorials, cheat sheets and 32 | reference materials: 33 | - [Java Enterprise Guide for App Service on Linux](https://docs.microsoft.com/en-us/azure/app-service/containers/app-service-java-enterprise) 34 | - [Maven Plugin for Azure App Service](https://docs.microsoft.com/en-us/java/api/overview/azure/maven/azure-webapp-maven-plugin/readme?view=azure-java-stable) 35 | - [JBoss Data Source Management](https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html/configuration_guide/datasource_management) 36 | - [JBoss/WildFly CLI Guide](https://docs.jboss.org/author/display/WFLY/Command+Line+Interface) 37 | - [JDBC driver for PostgreSQL](https://jdbc.postgresql.org/download.html) 38 | - [PostgreSQL CLI Cheat Sheet](http://www.postgresqltutorial.com/postgresql-cheat-sheet/) 39 | - [JDBC driver for MySQL](https://dev.mysql.com/downloads/connector/j/) 40 | - [MySQL CLI Cheat Sheet](http://www.mysqltutorial.org/mysql-cheat-sheet.aspx) 41 | - [Cheat sheet for sqlcmd CLI](https://docs.microsoft.com/en-us/sql/tools/sqlcmd-utility) 42 | - [Opening an SSH connection from your development machine](https://docs.microsoft.com/en-us/azure/app-service/containers/app-service-linux-ssh-support#open-ssh-session-from-remote-shell) 43 | - [Azure for Java Developers](https://docs.microsoft.com/en-us/java/azure/) 44 | 45 | --- 46 | 47 | ⬅️ Previous guide: [03 - Bind Java EE application to database](../step-03-bind-java-ee-app-to-database/README.md) --------------------------------------------------------------------------------