Q:

Selenium: Run Automation code with different URL for three environments

I have an automation testing framework in Java.  I need this code run on multiple environment such as SIT, UAT and Prod but all of these environment have different URL. 
sit-config.properties
hompepage = XXX
uat-config.properties
homepage = YYY
Maven Profile
<profiles>
    <profile>
        <id>sit</id>
        <activation>
            <property>
                <name>environment</name>
                <value>sit</value>
            </property>
        </activation>
    </profile>
    <!--  mvn -Denvironment=sit clean test -->

    <profile>
        <id>uat</id>
        <activation>
            <property>
                <name>environment</name>
                <value>uat</value>
            </property>
        </activation>
    </profile>

  </profiles>

I got an example for Java Owner library but for testng not Maven. 
http://www.testautomationguru.com/selenium-webdriver-how-to-execute-tests-in-multiple-environments/
Questions: 
How to integrate Java Owner library with maven profile?  
Please help.  Thanks. 

A:

It looks like you have a different data properties file for the different environment sit, uat and prod.  Actually, you do not need to create a separate profile for each execution environment.  Follow this:
1: Create a global property at the beginning of the pom.  Lets name of the property is property file and give it a default name like sit-config.properties
<properties>
    <propertyFile>sit-config.properties</propertyFile>
</properties>

2: Update the reader logic to read file name from the system property like
System.getProperty("propertyFile");

3: Now you can pass the file name from the command line like 
mvn clean test -DpropertyFile=uat-config.properties

