Author: lresende
Date: Fri Feb  8 18:29:25 2008
New Revision: 620064

URL: http://svn.apache.org/viewvc?rev=620064&view=rev
Log:
Test Automation integration for Websphere host environment

Added:
    incubator/tuscany/java/sca/itest/build-was-integration.xml   (with props)
    incubator/tuscany/java/sca/itest/wasAdmin.py   (with props)
Modified:
    incubator/tuscany/java/sca/itest/pom.xml

Added: incubator/tuscany/java/sca/itest/build-was-integration.xml
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/build-was-integration.xml?rev=620064&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/build-was-integration.xml (added)
+++ incubator/tuscany/java/sca/itest/build-was-integration.xml Fri Feb  8 
18:29:25 2008
@@ -0,0 +1,63 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+-->
+
+<project name="was-integration" default="main" basedir="."> 
+
+  <property environment="env"/>
+
+  <target name="startServer">
+    <exec dir="." executable="${env.WAS_HOME}/bin/startServer.sh">
+      <arg value="server1" />
+      <!--
+      <arg value="-username" />
+      <arg value="${sWasUser}" />
+      <arg value="-password" />
+      <arg value="${sWasPassword}" />
+      -->
+    </exec>
+  </target>
+
+  <target name="stopServer">
+    <exec dir="." executable="${env.WAS_HOME}/bin/stopServer.sh">
+      <arg value="server1" />
+      <!--
+      <arg value="-username" />
+      <arg value="${sWasUser}" />
+      <arg value="-password" />
+      <arg value="${sWasPassword}" />
+      -->
+    </exec>
+  </target>
+
+  <target name="installApplication">
+    <echo>Installing war ${application.war} on ${application.server} using 
name ${application.name} and context root ${application.contextRoot} </echo>
+    <exec dir="." executable="${env.WAS_HOME}/bin/wsadmin.sh">
+       <arg line="-conntype SOAP -lang jython -f ../wasAdmin.py 
installApplicationOnServer ${application.war} ${application.name} 
${application.contextRoot} ${application.server}" />
+    </exec>
+   </target>
+
+  <target name="uninstallApplication">
+    <echo>Uninstalling ${application.name} </echo>
+    <exec dir="." executable="${env.WAS_HOME}/bin/wsadmin.sh">
+       <arg line="-conntype SOAP -lang jython -f ../wasAdmin.py 
uninstallApplicationOnServer ${application.name}" />
+    </exec>
+   </target>
+
+ 
+</project>

Propchange: incubator/tuscany/java/sca/itest/build-was-integration.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/build-was-integration.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/tuscany/java/sca/itest/build-was-integration.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/tuscany/java/sca/itest/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/pom.xml?rev=620064&r1=620063&r2=620064&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/pom.xml (original)
+++ incubator/tuscany/java/sca/itest/pom.xml Fri Feb  8 18:29:25 2008
@@ -176,6 +176,7 @@
                 <module>scopes</module>
             </modules>
 
+
             <build>
                 <pluginManagement>
                     <plugins>
@@ -551,6 +552,119 @@
                 </plugins>
             </build>
         </profile>
+
+        <profile>
+            <id>websphere</id>
+            <activation>
+                <activeByDefault>false</activeByDefault>
+            </activation>
+            <properties>
+                <http.port>8080</http.port>
+                <http.base>http://127.0.0.1:${http.port}</http.base>
+                <websphere.home>${env.WAS_HOME}</websphere.home>
+            </properties>
+
+            <build>
+                <plugins>
+                    <!-- Generate web-xml and geronimo deployment descriptor 
-->
+                    <plugin>
+                        <groupId>org.apache.tuscany.sca</groupId>
+                        <artifactId>tuscany-maven-web-junit</artifactId>
+                        <version>1.2-incubating-SNAPSHOT</version>
+                        <executions>
+                            <execution>
+                                <id>generate-web-xml</id>
+                                <phase>process-resources</phase>
+                                <goals>
+                                    <goal>generate</goal>
+                                </goals>
+                            </execution>
+                            <execution>
+                                <id>web-junit-test</id>
+                                <phase>integration-test</phase>
+                                <goals>
+                                    <goal>test</goal>
+                                </goals>
+                                <configuration>
+                                    
<url>${http.base}/${project.build.finalName}/junit</url>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+
+                   <!--WAS ant integration -->
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-antrun-plugin</artifactId>
+                        <version>1.1</version>
+                        <executions>
+                            <!-- start Websphere server -->
+                            <execution>
+                                <id>start-container</id>
+                                <phase>pre-integration-test</phase>
+                                <goals>
+                                    <goal>run</goal>
+                                </goals>
+                               <configuration>
+                                   <tasks>
+                                       <ant 
antfile="../build-was-integration.xml" target="startServer"/>
+                                   </tasks>
+                               </configuration>
+                           </execution>
+                            <!-- Deploy war application -->
+                            <execution>
+                                <id>deploy-war</id>
+                                <phase>pre-integration-test</phase>
+                                <goals>
+                                    <goal>run</goal>
+                                </goals>
+                               <configuration>
+                                   <tasks>
+                                       <ant 
antfile="../build-was-integration.xml" target="installApplication">
+                                            <property name="application.war" 
value="${project.build.directory}/${project.build.finalName}.war"/>
+                                            <property name="application.name" 
value="${project.build.finalName}.war"/>
+                                            <property 
name="application.contextRoot" value="${project.build.finalName}"/>
+                                            <property 
name="application.server" value="server1"/>
+                                        </ant>
+                                   </tasks>
+                               </configuration>
+                            </execution>
+                            <!-- unDeploy war application -->
+                            <execution>
+                                <id>undeploy-war</id>
+                                <phase>post-integration-test</phase>
+                                <goals>
+                                    <goal>run</goal>
+                                </goals>
+                               <configuration>
+                                   <tasks>
+                                       <ant 
antfile="../build-was-integration.xml" target="uninstallApplication">
+                                            <property name="application.name" 
value="${project.build.finalName}.war"/>
+                                        </ant>
+                                   </tasks>
+                               </configuration>
+                            </execution>
+                            <!-- Stop Websphere server -->
+                            <execution>
+                                <id>stop-container</id>
+                                <phase>post-integration-test</phase>
+                                <goals>
+                                    <goal>run</goal>
+                                </goals>
+                               <configuration>
+                                   <tasks>
+                                       <ant 
antfile="../build-was-integration.xml" target="stopServer"/>
+                                   </tasks>
+                               </configuration>
+                            </execution>
+
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+
+
     </profiles>
 
 </project>

Added: incubator/tuscany/java/sca/itest/wasAdmin.py
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/wasAdmin.py?rev=620064&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/wasAdmin.py (added)
+++ incubator/tuscany/java/sca/itest/wasAdmin.py Fri Feb  8 18:29:25 2008
@@ -0,0 +1,91 @@
+"""
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+"""
+import sys
+
+def getCellName():
+    """Return the name of the cell connected to"""
+    return AdminControl.getCell()
+
+def getNodeName():
+    """Return the name of the node connected to"""
+    return AdminControl.getNode()
+
+def startApplicationOnServer(appName,serverName):
+    """Start the named application on one server"""
+    print "startApplicationOnServer: Entry. appname=%s servername=%s" % ( 
appName,serverName )
+    cellName = getCellName()
+    nodeName = getNodeName()
+    # Get the application manager 
+    appManager = 
AdminControl.queryNames('cell=%s,node=%s,type=ApplicationManager,process=%s,*' 
%(cellName,nodeName,serverName))
+    print "startApplicationOnServer: appManager=%s" % ( repr(appManager) )
+    # start it
+    rc = AdminControl.invoke(appManager, 'startApplication', appName)
+    print "startApplicationOnServer: Exit. rc=%s" % ( repr(rc) )
+
+def stopApplicationOnServer(appName,serverName):
+    """Stop the named application on one server"""
+    print "stopApplicationOnServer: Entry. appname=%s servername=%s" % ( 
appName,serverName )
+    cellName = getCellName()
+    nodeName = getNodeName()
+    # Get the application manager 
+    appManager = 
AdminControl.queryNames('cell=%s,node=%s,type=ApplicationManager,process=%s,*' 
%(cellName,nodeName,serverName))
+    print "stopApplicationOnServer: appManager=%s" % ( repr(appManager) )
+    # start it
+    rc = AdminControl.invoke(appManager, 'stopApplication', appName)
+    print "stopApplicationOnServer: Exit. rc=%s" % ( repr(rc) )
+
+def installApplicationOnServer( fileName, appName, contextRoot, serverName ):
+    """Install given application on the named server using given context 
root"""
+    print "installApplicationOnServer: fileName=%s appName=%s contextRoot=%s 
ServerName=%s" % ( fileName, appName,contextRoot,serverName )
+    AdminApp.install(fileName,'[-appname ' + appName + ' -contextroot ' + 
contextRoot  + ' -server ' + serverName + ' -usedefaultbindings ]')
+    AdminConfig.save()
+    """modify classloader model for application"""
+    deploymentID = AdminConfig.getid('/Deployment:' + appName + '/')
+    deploymentObject = AdminConfig.showAttribute(deploymentID, 
'deployedObject')
+    classldr = AdminConfig.showAttribute(deploymentObject, 'classloader')
+    print AdminConfig.showall(classldr)
+    AdminConfig.modify(classldr, [['mode', 'PARENT_LAST']])
+    """Modify WAR class loader model"""
+    AdminConfig.show(deploymentObject, 'warClassLoaderPolicy')
+    AdminConfig.modify(deploymentObject, [['warClassLoaderPolicy', 'SINGLE']])
+    AdminConfig.save()
+
+def uninstallApplicationOnServer( appName ):
+    """Delete the named application from the cell"""
+    AdminApp.uninstall( appName )
+    AdminConfig.save()
+
+
+
+"""-----------------------------------------------------------
+   Phyton script to interface with WAS Admin/Management Tools
+-----------------------------------------------------------"""
+
+if len(sys.argv) < 1:
+    print "wasAdmin.py : need parameters : functionName [args]"
+    sys.exit(0)
+if(sys.argv[0] == 'installApplicationOnServer'):
+    installApplicationOnServer(sys.argv[1], sys.argv[2], sys.argv[3], 
sys.argv[4])
+elif(sys.argv[0] == 'startApplicationOnServer'):
+    installApplicationOnServer(sys.argv[1], sys.argv[2])
+elif(sys.argv[0] == 'uninstallApplicationOnServer'):
+    uninstallApplicationOnServer(sys.argv[1])
+else:
+    print "Exiting without doing anything"
+

Propchange: incubator/tuscany/java/sca/itest/wasAdmin.py
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to