javamavenmaven-failsafe-pluginoracle-ucm

Maven Testing - How can I get current Maven Settings from Java


I'm building integration testing for a WCC-Component in Maven.

In mavens pom.xml I have a plugin configured too:

  1. Build the component
  2. deploy the component
  3. enable the component
  4. restart the component

Once that is complete I'm working on Getting the Maven-Failsafe-Plugin to test the installed plugin.

Before I can test the plugin I need to set some things up. I decided the easiest way would be to create a parent class for my Integration tests that would only initialize if it hadn't been run already.

Example:

@BeforeClass
public static initialize()
{  
   //lazy init here
}

since my component is already installed/enabled from the maven configuration I want to leverage that information instead of duplicating it for the integration tests.

In my pom.xml I have:

<plugin>
  <groupId>org.ucmtwine</groupId>
  <artifactId>ucm-maven-plugin</artifactId>
  <version>0.1.2-SNAPSHOT</version>
  <extensions>true</extensions> <!-- Allows WCC packaging type -->
  <configuration>
    <servers>
      <server>            
        <id>sandbox</id>
        <url>http://localhost:16200/cs/idcplg</url>
        <username>myUser</username>
        <password>myPass</password>
        <adminServer>
          <hostname>localhost</hostname> 
          <serverName>AdminAServer</serverName> 
          <wlsServerName>UCM_server1</wlsServerName> 
        </adminServer>
      </server>
    </servers>
  </configuration>
</plugin>

How can I access that information from my @BeforeClass initialization method? Additionally my Maven plugin also supports -Dserver so the user can choose which server configuration to use (based on ID). How would I access that parameter as well?

Note: I am not using settings.xml for this.


Solution

  • IMO you shouldn't try to do this. The settings.xml as a typical Maven file accessible by Maven and Maven Plugins. The component is a standalone piece of code, you shouldn't try to mix these two. I can think of several options:

    The first two matches closest to your requirements, but I'd prefer the third option.