diff --git a/Docker/MAQSSQLServer/SeedData/MagenicAutomation/Cities.bcp b/Docker/MAQSSQLServer/SeedData/MagenicAutomation/Cities.bcp new file mode 100644 index 000000000..16c80b2c8 Binary files /dev/null and b/Docker/MAQSSQLServer/SeedData/MagenicAutomation/Cities.bcp differ diff --git a/Docker/MAQSSQLServer/SeedData/MagenicAutomation/Datatype.bcp b/Docker/MAQSSQLServer/SeedData/MagenicAutomation/Datatype.bcp new file mode 100644 index 000000000..b576dfdfa Binary files /dev/null and b/Docker/MAQSSQLServer/SeedData/MagenicAutomation/Datatype.bcp differ diff --git a/Docker/MAQSSQLServer/SeedData/MagenicAutomation/States.bcp b/Docker/MAQSSQLServer/SeedData/MagenicAutomation/States.bcp new file mode 100644 index 000000000..9accc9837 Binary files /dev/null and b/Docker/MAQSSQLServer/SeedData/MagenicAutomation/States.bcp differ diff --git a/Docker/MAQSSQLServer/docker-compose.yml b/Docker/MAQSSQLServer/docker-compose.yml new file mode 100644 index 000000000..1094afb27 --- /dev/null +++ b/Docker/MAQSSQLServer/docker-compose.yml @@ -0,0 +1,18 @@ +version: '2' + +services: + mssql: + image: mcr.microsoft.com/mssql/server:latest + ports: + - 1433:1433 + environment: + - ACCEPT_EULA=Y + - SA_PASSWORD=magenicMAQS2 + - MSSQL_PID=Developer + expose: + - 1433 + volumes: + # Mount the current directory onto /mnt/host on the image. + - ./:/mnt/host/ + # Run a custom bash script that bootstraps the database after it is started. + command: ['/bin/bash', '/mnt/host/initialize_and_start_sqlserver.sh'] \ No newline at end of file diff --git a/Docker/MAQSSQLServer/initialize_and_start_sqlserver.sh b/Docker/MAQSSQLServer/initialize_and_start_sqlserver.sh new file mode 100644 index 000000000..72b2ff37f --- /dev/null +++ b/Docker/MAQSSQLServer/initialize_and_start_sqlserver.sh @@ -0,0 +1,34 @@ +#!/bin/bash +{ + # Wait for SQL Server to start up + # Check if the server is ready + not_ready=1 + while [ $not_ready != 0 ] + do + # Wait for the return code of the following statement to be zero + /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P magenicMAQS2 -d master -Q "SELECT TOP 1 message_id FROM sys.messages" + not_ready=$? + + if [ $not_ready != 0 ] + then + echo "Could not contact sql server, will try again in 5 seconds." + sleep 5s + fi + done + + echo "Started initializing database" + # Set up the schema and stored procedures + /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P magenicMAQS2 -d master -i `dirname $0`/schema.sql + /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P magenicMAQS2 -d master -i `dirname $0`/stored_procedures.sql + # Use BCP to import test data + /opt/mssql-tools/bin/bcp MagenicAutomation.dbo.States in "`dirname $0`/SeedData/MagenicAutomation/States.bcp" \ + -n -S localhost -U sa -P magenicMAQS2 + /opt/mssql-tools/bin/bcp MagenicAutomation.dbo.Cities in "`dirname $0`/SeedData/MagenicAutomation/Cities.bcp" \ + -n -S localhost -U sa -P magenicMAQS2 + /opt/mssql-tools/bin/bcp MagenicAutomation.dbo.Datatype in "`dirname $0`/SeedData/MagenicAutomation/Datatype.bcp" \ + -n -S localhost -U sa -P magenicMAQS2 + echo "Finished initializing database" +}& + +# Start SQL server +exec /opt/mssql/bin/sqlservr \ No newline at end of file diff --git a/Docker/MAQSSQLServer/schema.sql b/Docker/MAQSSQLServer/schema.sql new file mode 100644 index 000000000..83392ccf8 --- /dev/null +++ b/Docker/MAQSSQLServer/schema.sql @@ -0,0 +1,31 @@ +CREATE DATABASE MagenicAutomation; +GO +USE MagenicAutomation; +GO +CREATE TABLE [dbo].[States]( + [StateID] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL, + [StateName] [nvarchar](max) NOT NULL, + [StateAbbreviation] [nvarchar](2) NULL +); +GO +CREATE TABLE [dbo].[Cities]( + [CityID] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL, + [CityName] [nvarchar](max) NOT NULL, + [CityPopulation] [decimal](18, 2) +); +GO +CREATE TABLE [dbo].[Datatype]( + [bitintType] [bigint] NULL, + [bitType] [bit] NULL, + [char10Type] [char](10) NULL, + [dateType] [date] NULL, + [dateTimeType] [datetime] NULL, + [floatType] [float] NULL, + [intType] [int] NULL, + [ncharType] [nchar](10) NULL, + [nvarcharType] [nvarchar](50) NULL, + [varcharType] [varchar](50) NULL, + [decimalType] [decimal](18, 2) NULL, + [xmlType] [xml] NULL +); +GO \ No newline at end of file diff --git a/Docker/MAQSSQLServer/stored_procedures.sql b/Docker/MAQSSQLServer/stored_procedures.sql new file mode 100644 index 000000000..e2c3351ad --- /dev/null +++ b/Docker/MAQSSQLServer/stored_procedures.sql @@ -0,0 +1,17 @@ +USE MagenicAutomation; +GO +CREATE PROCEDURE [dbo].[getStateAbbrevMatch] + @StateAbbreviation VARCHAR(2) + AS BEGIN + SELECT StateAbbreviation FROM States + WHERE StateAbbreviation = @StateAbbreviation + END +GO +CREATE PROCEDURE [dbo].[setStateAbbrevToSelf] + @StateAbbreviation VARCHAR(2) + AS BEGIN + UPDATE States + SET StateAbbreviation = @StateAbbreviation + WHERE StateAbbreviation = @StateAbbreviation + END +GO diff --git a/jmaqs-database/config.xml b/jmaqs-database/config.xml index 7ad966208..825f57f87 100644 --- a/jmaqs-database/config.xml +++ b/jmaqs-database/config.xml @@ -52,10 +52,11 @@ MagenicAutomation + SQL - MagenicQA - 1magenicMARQ - jdbc:sqlserver://qasqlserver.database.windows.net + sa + magenicMAQS2 + jdbc:sqlserver://localhost ./src/test/java/com/magenic/jmaqs/database/entities/ com.magenic.jmaqs.database.entities diff --git a/jmaqs-database/pom.xml b/jmaqs-database/pom.xml index 941910713..6244a1063 100644 --- a/jmaqs-database/pom.xml +++ b/jmaqs-database/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 @@ -67,4 +67,33 @@ ${sqlite-jdbc.version} + + + + io.fabric8 + docker-maven-plugin + 0.37.0 + + + + mssql + mcr.microsoft.com/mssql/server:latest + + compose + ../Docker/MAQSSQLServer/ + docker-compose.yml + + + + + setup-database + process-test-resources + + start + + + + + + diff --git a/jmaqs-database/src/test/java/com/magenic/jmaqs/database/DatabaseConfigUnitTest.java b/jmaqs-database/src/test/java/com/magenic/jmaqs/database/DatabaseConfigUnitTest.java index 6accfb1b5..29f4fe3fe 100644 --- a/jmaqs-database/src/test/java/com/magenic/jmaqs/database/DatabaseConfigUnitTest.java +++ b/jmaqs-database/src/test/java/com/magenic/jmaqs/database/DatabaseConfigUnitTest.java @@ -23,7 +23,7 @@ public class DatabaseConfigUnitTest extends BaseGenericTest { @Test(groups = TestCategories.DATABASE) public void testGetConnectionString() { Assert.assertEquals(DatabaseConfig.getConnectionString(), - "jdbc:sqlserver://qasqlserver.database.windows.net"); + "jdbc:sqlserver://localhost"); } /** @@ -68,11 +68,11 @@ public void testGetDatabaseName() { @Test(groups = TestCategories.DATABASE) public void testGetDatabaseUser() { - Assert.assertEquals(DatabaseConfig.getDatabaseUser(), "MagenicQA"); + Assert.assertEquals(DatabaseConfig.getDatabaseUser(), "sa"); } @Test(groups = TestCategories.DATABASE) public void testGetDatabasePassword() { - Assert.assertEquals(DatabaseConfig.getDatabasePassword(), "1magenicMARQ"); + Assert.assertEquals(DatabaseConfig.getDatabasePassword(), "magenicMAQS2"); } } diff --git a/jmaqs-selenium/src/main/java/com/magenic/jmaqs/selenium/WebDriverFactory.java b/jmaqs-selenium/src/main/java/com/magenic/jmaqs/selenium/WebDriverFactory.java index 59ed30465..5edfe9383 100644 --- a/jmaqs-selenium/src/main/java/com/magenic/jmaqs/selenium/WebDriverFactory.java +++ b/jmaqs-selenium/src/main/java/com/magenic/jmaqs/selenium/WebDriverFactory.java @@ -7,11 +7,8 @@ import com.magenic.jmaqs.selenium.constants.BrowserType; import com.magenic.jmaqs.selenium.constants.OperatingSystem; import com.magenic.jmaqs.selenium.constants.RemoteBrowserType; -import com.magenic.jmaqs.selenium.constants.WebDriverFile; import com.magenic.jmaqs.selenium.exceptions.DriverNotFoundException; import com.magenic.jmaqs.selenium.exceptions.WebDriverFactoryException; -import com.magenic.jmaqs.utilities.helper.Config; -import com.magenic.jmaqs.utilities.helper.ConfigSection; import com.magenic.jmaqs.utilities.helper.StringProcessor; import java.io.File; import java.net.URL; diff --git a/pom.xml b/pom.xml index 8111befe1..399922159 100644 --- a/pom.xml +++ b/pom.xml @@ -230,22 +230,41 @@ testing + true testing + + org.apache.maven.plugins + maven-dependency-plugin + 3.1.2 + + + + properties + + + + org.apache.maven.plugins maven-surefire-plugin - ${surefire.plugin.version} + 3.0.0-M5 methods 5 - - + ${argLine} -javaagent:@{io.github.bonigarcia:webdrivermanager:jar} + + + org.apache.maven.surefire + surefire-testng + 3.0.0-M5 + + @@ -421,35 +440,6 @@ - - org.apache.maven.plugins - maven-dependency-plugin - 3.1.2 - - - - properties - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 3.0.0-M5 - - methods - 5 - -javaagent:@{io.github.bonigarcia:webdrivermanager:jar} - - - - org.apache.maven.surefire - surefire-testng - 3.0.0-M5 - - - org.apache.maven.plugins maven-checkstyle-plugin