Skip to content

Commit

Permalink
Use mvn properties instead of propfile for the winrm test system
Browse files Browse the repository at this point in the history
Route maven properties as system properties via maven-surefire-plugin
into the wsman/winrm tests. Disable usage of config.properties file for
the time being.
  • Loading branch information
CMoH authored and kcris committed Jan 7, 2016
1 parent 8f70ab1 commit 38d5d73
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 36 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
# wsman4j
WS-Management java binding

# Running tests

Set up the appropriate WinRM test system by running setupWinRM.bat on it.
Run maven using the appropriate properties to reach the WinRM test system

mvn -Dwinrm.test.host=test-host \
-Dwinrm.test.user=TestUser \
-Dwinrm.test.pass=somePass \
test

TODO: don't use passwords on command-line etc
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
<maven.compiler.target>1.7</maven.compiler.target>

<cxf.version>3.1.4</cxf.version>

<winrm.test.host>localhost</winrm.test.host>
<winrm.test.port>5985</winrm.test.port>
<winrm.test.user>Administrator</winrm.test.user>
<winrm.test.pass>1234</winrm.test.pass>
</properties>

<organization>
Expand All @@ -38,6 +43,10 @@
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions wsman-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@
</instructions>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<winrm.host>${winrm.test.host}</winrm.host>
<winrm.port>${winrm.test.port}</winrm.port>
<winrm.user>${winrm.test.user}</winrm.user>
<winrm.pass>${winrm.test.pass}</winrm.pass>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,16 @@
* &lt;/properties&gt;
* ......
* &lt;plugin&gt;
* &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
* &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
* &lt;configuration&gt;
* &lt;systemProperties&gt;
* &lt;property&gt;
* &lt;name&gt;winrm.host&lt;/name&gt;
* &lt;value&gt;${winrm.host}&lt;/value&gt;
* &lt;/property&gt;
* &lt;property&gt;
* &lt;name&gt;winrm.port&lt;/name&gt;
* &lt;value&gt;${winrm.port}&lt;/value&gt;
* &lt;/property&gt;
* ......
* &lt;/systemProperties&gt;
* &lt;/configuration&gt;
* &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
* &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
* &lt;configuration&gt;
* &lt;systemPropertyVariables&gt;
* &lt;winrm.host&gt;${winrm.test.host}&lt;/winrm.host&gt;
* &lt;winrm.port&gt;${winrm.test.port}&lt;/winrm.port&gt;
* &lt;winrm.user&gt;${winrm.test.user}&lt;/winrm.user&gt;
* &lt;winrm.pass&gt;${winrm.test.pass}&lt;/winrm.pass&gt;
* &lt;/systemPropertyVariables&gt;
* &lt;/configuration&gt;
* &lt;/plugin&gt;
* </code>
*
Expand All @@ -58,13 +53,13 @@ public class SyspropsWinRMFixture implements WinRMFixture {
@Override
public WsmanCli createClient() {
WsmanCli cli = new WsmanCli();
cli.host = System.getProperty(WINRM_HOST);
cli.port = Integer.parseInt(System.getProperty(WINRM_PORT));
cli.user = System.getProperty(WINRM_USER);
cli.pass = System.getProperty(WINRM_PASS);
cli.host = System.getProperty(WINRM_HOST, "localhost");
cli.port = Integer.parseInt(System.getProperty(WINRM_PORT, "5985"));
cli.user = System.getProperty(WINRM_USER, "Administrator");
cli.pass = System.getProperty(WINRM_PASS, "1234");
cli.transport = Transport.plaintext;
//cli.cmd = prop.getProperty("cmd");
//cli.cmdArgs = Arrays.asList(prop.getProperty("cmdArgs").split(" "));
//cli.cmd = System.getProperty("cmd", "");
//cli.cmdArgs = Arrays.asList(System.getProperty("cmdArgs", "").split(" "));

return cli;
}
Expand Down
30 changes: 15 additions & 15 deletions wsman-cli/src/test/java/org/apifocal/wsman/cli/TestWsman.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
import java.util.UUID;
import javax.xml.bind.JAXB;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
import org.xmlsoap.schemas.ws._2004._09.transfer.CreateResponseType;
Expand All @@ -41,25 +39,27 @@ public class TestWsman {
public TestWsman() {
}

@BeforeClass
public static void setUpClass() {
//test is only runnable in a windows host
boolean isWindows = System.getProperty("os.name").startsWith("Windows");
org.junit.Assume.assumeTrue(isWindows); //failure causes the test to be ignored
// @BeforeClass
// public static void setUpClass() {
// //make sure to configure WinRM prior to running tests
// }

//make sure to configure WinRM prior to running tests
//Runtime.getRuntime().exec("cmd /c start setupWinRM.bat");
}

@AfterClass
public static void tearDownClass() {
}
// @AfterClass
// public static void tearDownClass() {
// }

@Before
public void setUp() throws Exception {
// TODO configure the fixture externally
WinRMFixture fixture = new PropfileWinRMFixture();
// WinRMFixture fixture = new PropfileWinRMFixture();
WinRMFixture fixture = new SyspropsWinRMFixture();
cli = fixture.createClient();

// if ("localhost".equals(cli.host)) {
// //test is only runnable in a windows host
// boolean isWindows = System.getProperty("os.name").startsWith("Windows");
// assumeTrue("This tests needs a windows host", isWindows); //failure causes the test to be ignored
// }
}

@After
Expand Down

0 comments on commit 38d5d73

Please sign in to comment.