13 Building Oracle SOA Suite and Oracle Business Process Management Projects with
7. Click OK to complete the import
13.9 What You May Need to Know About Deploying SOA Composites
<!--<jndi.properties.input>${basedir}/jndi.properties</jndi.properties.input>-->
<scatest.result>${scac.output.dir}/testResult</scatest.result>
<!-- input is the name of the composite to run test suties against -->
<input>project12</input>
</properties>
13.8 Running SCA Test Suites with Maven
If you want to execute your SCA Test Suites as part of the Maven build process, you need to create a jndi.properties file (as you would if you were executing SCA Test Suites from ANT, for example) in your SOA composite project directory. This file contains the following information:
Additionally, you need to uncomment the jndi.properties entry in the SOA composite project POM (pom.xml) and ensure that it points to the file you just created.
The SOA Maven Plug-in executes the SCA Tests in the integration-test phase. To compile and package your composite, deploy it to a server and run the SCA Tests, execute this command:
mvn verify
13.9 What You May Need to Know About Deploying SOA Composites
When you create a SOA composite, you may use new resources, such as WebLogic data sources, JMS queues, and Topics. These resources may not be present in the runtime environment where you want to deploy your composite. This means that you may not be able to successfully execute any instances of your composite, for example to run test cases.
While it is possible to manually create these resources through the WebLogic console, this would not be appropriate for an automated build environment. To address this issue, WLST scripts can be created and executed as part of the build to ensure that any necessary resources are created and configured on the runtime environment. You can execute the WLST scripts at the appropriate time in your build using the
weblogic-maven-plugin:wlst goal.
The following is an example of a WLST script to create a data source. You could add it to your project as misc/create-datasource.py:
# Copyright 2012, 2014 Oracle Corporation.
# All Rights Reserved.
#
# Provided on an 'as is' basis, without warranties or conditions of any kind,
# either express or implied, including, without limitation, any warranties or
# conditions of title, non-infringement, merchantability, or fitness for a
# particular purpose. You are solely responsible for determining the
# appropriateness of using and assume any risks. You may not redistribute.
#
# This WLST script can be used as part of a continuous integration build process
# before deploying a SCA composite, to create any necessary Java EE data sources
# on the WebLogic Server.
#
# In addition to creating the data source, this script will also update the
# resource adapter and redeploy it.
import time
#
# These are the parameters that you need to edit before running this script
#
# admin server url
url = 't3://localhost:7001'
# username to connect to the admin server username = 'weblogic'
# password to connect to the admin server password = 'welcome1'
# the name for the EIS - as defined in the DB Adapter wizard in JDEV eisName = 'eis/db/myDS'
# the admin or managed server to target where the DbAdapter is deployed serverName = 'soa_server1'
# the name for the data source dsName = 'myDS'
# the JNDI name for the data source jndiName = 'jbdc/myDS'
# the database url for the data source
dbUrl = 'jdbc:oracle:thin:@localhost:1521:orcl'
# the database user
dbUser = 'mark'
# the database password
dbPassword = 'welcome1'
# the database driver to use
dbDriver = 'oracle.jdbc.xa.client.OracleXADataSource'
# the host where node manager is running nmHost = 'localhost'
# the port to connect to node manager (5556 is default for plain mode) nmPort = '5556'
# the user to connect to node manager nmUser = 'weblogic'
# the password to connection to node manager nmPassword = 'welcome1'
# the name of the weblogic domain domain = 'base_domain'
# don't change these ones uniqueString = '' appName = 'DbAdapter'
moduleOverrideName = appName+'.rar'
moduleDescriptorName = 'META-INF/weblogic-ra.xml'
#
# method definitions
What You May Need to Know About Deploying SOA Composites
#
def makeDeploymentPlanVariable(wlstPlan, name, value, xpath, origin='planbased'):
"""Create a varaible in the Plan.
This method is used to create the variables that are needed in the Plan in order to add an entry for the outbound connection pool for the new data source.
"""
try:
variableAssignment = wlstPlan.createVariableAssignment(name, moduleOverrideName, moduleDescriptorName)
variableAssignment.setXpath(xpath) variableAssignment.setOrigin(origin) wlstPlan.createVariable(name, value) except:
print('--> was not able to create deployment plan variables successfully') def main():
print ' Copyright 2012, 2014 Oracle Corporation. ' print ' All Rights Reserved. '
print ''
print ' Provided on an ''as is'' basis, without warranties or conditions of any kind, '
print ' either express or implied, including, without limitation, any warranties or '
print ' conditions of title, non-infringement, merchantability, or fitness for a '
print ' particular purpose. You are solely responsible for determining the ' print ' appropriateness of using and assume any risks. You may not
redistribute.' print ''
print ' This WLST script can be used as part of a continuous integration build process'
print ' before deploying a SCA composite, to create any necessary Java EE data sources'
print ' on the WebLogic Server.' print ''
print ' In addition to creating the data source, this script will also update the '
print ' resource adapter and redeploy it.' print ''
print ' !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING
!!!' print ''
print ' This script will make changes to your WebLogic domain. Make sure you know '
print ' what you are doing. There is no support for this script. If something bad '
print ' happens, you are on your own! You have been warned.' #
# generate a unique string to use in the names #
uniqueString = str(int(time.time()))
#
# Create a JDBC Data Source.
# try:
print('--> about to connect to weblogic') connect(username, password, url)
print('--> about to create a data source ' + dsName) edit()
startEdit()
cmo.createJDBCSystemResource(dsName)
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName) cmo.setName(dsName)
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDataSourceParams/' + dsName)
set('JNDINames',jarray.array([String(jndiName)], String))
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName)
cmo.setUrl(dbUrl)
cmo.setDriverName(dbDriver) cmo.setPassword(dbPassword)
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCConnectionPoolParams/' + dsName)
cmo.setTestTableName('DUAL')
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName + '/Properties/' + dsName)
cmo.createProperty('user')
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName + '/Properties/' + dsName + '/Properties/user') cmo.setValue(dbUser)
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDataSourceParams/' + dsName)
cmo.setGlobalTransactionsProtocol('TwoPhaseCommit') cd('/JDBCSystemResources/' + dsName)
set('Targets',jarray.array([ObjectName('com.bea:Name=' + serverName + ',Type=Server')], ObjectName))
save()
print('--> activating changes') activate()
print('--> done')
#
# update the deployment plan
#
print('--> about to update the deployment plan for the DbAdapter') startEdit()
planPath = get('/AppDeployments/DbAdapter/PlanPath') appPath = get('/AppDeployments/DbAdapter/SourcePath') print('--> Using plan ' + planPath)
plan = loadApplication(appPath, planPath) print('--> adding variables to plan')
makeDeploymentPlanVariable(plan, 'ConnectionInstance_eis/DB/' + dsName + '_
JNDIName_' + uniqueString, eisName,
'/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connec tion-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance /[jndi-name="' + eisName + '"]/jndi-name')
makeDeploymentPlanVariable(plan, 'ConfigProperty_xADataSourceName_Value_' + uniqueString, eisName,
'/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connec tion-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance /[jndi-name="' + eisName +
'"]/connection-properties/properties/property/[name="xADataSourceName"]/value') print('--> saving plan')
What You May Need to Know About ADF Human Task User Interface Projects
plan.save();
save();
print('--> activating changes') activate(block='true');
cd('/AppDeployments/DbAdapter/Targets');
print('--> redeploying the DbAdapter')
redeploy(appName, planPath, targets=cmo.getTargets());
print('--> done') except:
print('--> something went wrong, bailing out') stopEdit('y')
raise SystemExit #
# disconnect from the admin server #
print('--> disconnecting from admin server now') disconnect()
#
# this is the main entry point main()
To execute this script during the pre-integration-test phase of your build, you would include a plugin section similar to the following in your SOA Project POM:
<plugin>
<id>wlst-create-datasource</id>
<phase>pre-integration-test</phase>
<goals>
<goal>wlst</goal>
</goals>
<configuration>
<middlewareHome>c:/wls1212</middlewareHome>
<fileName>${project.basedir}/misc/create-datasource.py</fileName>
</configuration>
</execution>
</executions>
</plugin>