Thursday, December 10, 2009

WLST JMS.properties file example


jmsPath = /JMSSystemResources/
jmsServerPath = /JMSServers/
jmsResourcePath= /JMSResource/


jmsServers = JMSServer1, JMSServer2, JMSServer3
############################################
JMSServer1Name = JMSServer1
JMSServer1SubDep = BEA_JMS_MODULE_SUBDEPLOYMENT_JMSServer1
JMSServer1SysRes = JMSModule1
JMSServer1SysResTarget=${ServerName}
JMSServer1PersStore =
JMSServer1Queues = au.com.queu1, au.com.queu2
JMSServer1NonPers = au.com.queu2

WSLT weblogic JMS creation script

here is a script i use at work to create JMS servers modules and queues.


#-------#
# JMSQueueScript.py
# Requires argument - either install, update or clean
#Requires properties folder to be in same directory as script
#Creates Queues, JMS servers, subdeployments, system modules and sets attributes
#-------#
import sys
import re

global jmsProp
global envProp

#Determine runMode- Install, Update or Clean
try:
runMode = sys.argv[1]

def connectToAdminServer():
global startedNewServer
loadProperties(envProp)
hideDisplay()
hideDumpStack("true")
# try connecting to a running server if it is already running ...
if connected=="false":
try:
URL="t3://"+adminServerListenAddress+":"+adminServerListenPort
print URL
connect(userName, passWord, URL)
except WLSTException:
print 'No server is running at '+URL
hideDumpStack("false")
if connected=="false":
print 'No connection established'

def startTransaction():
edit()
startEdit()

def endTransaction():
#startEdit()
save()
activate(block="true")

#----
# CREATE METHODS -
#----

def create_Queue(path, beanName):

cd(path)
try:
#print "creating Queue: "+beanName
theBean = cmo.lookupQueue(beanName)
if theBean == None:
cmo.createQueue(beanName)
except java.lang.UnsupportedOperationException, usoe:
pass
except weblogic.descriptor.BeanAlreadyExistsException,bae:
pass
except java.lang.reflect.UndeclaredThrowableException,udt:
pass

def create_JMSServer(path, beanName):
cd(path)
try:
#print "creating mbean of type JMSServer ... "
theBean = cmo.lookupJMSServer(beanName)
if theBean == None:
cmo.createJMSServer(beanName)
except java.lang.UnsupportedOperationException, usoe:
pass
except weblogic.descriptor.BeanAlreadyExistsException,bae:
pass
except java.lang.reflect.UndeclaredThrowableException,udt:
pass

def create_JMSSystemResource(path, beanName):
cd(path)
try:
#print "creating mbean of type JMSSystemResource ... "
theBean = cmo.lookupJMSSystemResource(beanName)
if theBean == None:
cmo.createJMSSystemResource(beanName)
except java.lang.UnsupportedOperationException, usoe:
pass
except weblogic.descriptor.BeanAlreadyExistsException,bae:
pass
except java.lang.reflect.UndeclaredThrowableException,udt:
pass

def create_SubDeployment(path, beanName):
cd(path)
try:
#print "creating mbean of type SubDeployment ... "
theBean = cmo.lookupSubDeployment(beanName)
if theBean == None:
cmo.createSubDeployment(beanName)
except java.lang.UnsupportedOperationException, usoe:
pass
except weblogic.descriptor.BeanAlreadyExistsException,bae:
pass
except java.lang.reflect.UndeclaredThrowableException,udt:
pass
#
#----
# SET ATTRIBUTE METHODS -
#----
#
def setAttributesForQueue(path, subdeployment, jndiname, queuename):
cd(path)
print "setting attributes for Queue: "+queuename
set("SubDeploymentName", subdeployment)
set("JNDIName", jndiname)
set("Name", queuename)

def setAttributes_DeliveryParamsOverrides(paramList, modulePath):

for param in paramList:
path = modulePath+"/Queues/"+param+"/DeliveryParamsOverrides/"+param
cd(path)
print "setting DeliveryParamsOverrides to Non-Persistent:" +param
set("DeliveryMode", "Non-Persistent")

def setAttributesFor_c2JMSServer(path, server, persistenceStore):
cd(path)
print "setting attributes for mbean type JMSServer"
refBean0 = getMBean(server)
theValue = jarray.array([refBean0], Class.forName("weblogic.management.configuration.TargetMBean"))
cmo.setTargets(theValue)
#Set the persistence store if one is passed as a parameter
if (persistenceStore != None):
print "mbean is not equal to none"
print persistenceStore
bean = getMBean(persistenceStore)
print bean
cmo.setPersistentStore(bean)

def setAttributesFor_SubDeployment(path, server):
cd(path)
#print "setting attributes for mbean type SubDeployment"
refBean0 = getMBean(server)
theValue = jarray.array([refBean0], Class.forName("weblogic.management.configuration.TargetMBean"))
cmo.setTargets(theValue)

def setAttributesFor_JMSSystemResource(path, server):
cd(path)
#print "setting attributes for mbean type JMSSystemResource"
refBean0 = getMBean(server)
theValue = jarray.array([refBean0], Class.forName("weblogic.management.configuration.TargetMBean"))
cmo.setTargets(theValue)

def setAttributes_MessageLoggingParams(sysModule, jmsResource, loggingFormat, enabled):
path = jmsPath+sysModule+jmsResourcePath+sysModule+"/Queues/"+jmsResource+"/MessageLoggingParams/"+jmsResource
cd(path)
#print "setting attributes for mbean type MessageLoggingParams"
set("MessageLoggingFormat", loggingFormat)
set("MessageLoggingEnabled", enabled)

#----
# create_and_Set ATTRIBUTE METHODS
#----

def create_and_setAttributesFor_SubDeployment(jmsServerName, subDep, sysRes):
createPath = jmsPath + sysRes
create_SubDeployment(createPath, subDep)
setPath = createPath + "/SubDeployments/" + subDep
setAttributesFor_SubDeployment(setPath, jmsServerPath+jmsServerName)

def create_and_setAttributesFor_SystemResources(sysResource, server):

createPath = sPath
create_JMSSystemResource(createPath, sysResource)
setPath = jmsPath + sysResource
setAttributesFor_JMSSystemResource(setPath, server)

def create_and_setAttributesFor_JMSServer(serverName, bean):
create_JMSServer(sPath, serverName)
setPath = jmsServerPath+serverName
setAttributesFor_c2JMSServer(setPath, serversPath+beServerName, bean)

def create_and_setQueues(jndiList, modulePath, c2iDepName):
#create and then set
for jndiName in jndiList:
#print jndiName
create_Queue(modulePath, jndiName)
queuePath = modulePath +"/Queues/" + jndiName
setAttributesForQueue(queuePath, c2iDepName, jndiName, jndiName)

#This could be usefull for one off queues
# for q in customQList:
# exec """qJndiName = """+q+"""jndi"""
# exec """qSysRes = """+q+"""sysRes"""
# exec """qSubDep = """+q+"""subDep"""
# createPath="/JMSSystemResources/"+qSysRes+"/JMSResource/"+qSysRes
# print "createQpath "
# print createPath
# create_Queue(createPath, qJndiName)
# setAttributesForQueue(createPath+"/Queues/"+qJndiName, qSubDep, qJndiName, qJndiName)

def create_and_setAttributesFor_JMSComponents(jmsList):
for jms in jmsList:
exec """jmsName = """+jms+"""Name"""
exec """subDep = """+jms+"""SubDep"""
exec """sysRes = """+jms+"""SysRes"""
exec """sysResTarget = """+jms+"""SysResTarget"""
exec """store = """+jms+"""PersStore"""
exec """jndiList = """+jms+"""Queues"""
exec """nonPersistentList = """+jms+"""NonPers"""
if (len(store)==0):
store=None
create_and_setAttributesFor_JMSServer(jmsName, store)
create_and_setAttributesFor_SystemResources(sysRes, serversPath+sysResTarget)
create_and_setAttributesFor_SubDeployment(jmsName, subDep, sysRes)
modulePath = jmsPath+sysRes+jmsResourcePath+sysRes
if(len(jndiList)>0):
jndiList = standardStringSplit(jndiList,", ")
create_and_setQueues(jndiList, modulePath, subDep)
if(len(nonPersistentList)>0):
nonPersistentList = standardStringSplit(nonPersistentList,", ")
setAttributes_DeliveryParamsOverrides(nonPersistentList, modulePath)

#--------------------------

def install():
#Create JMS Servers
loadProperties(jmsProp)
jmsServerList = standardStringSplit(jmsServers, ", ")
print "Creating and Setting JMS Servers"
create_and_setAttributesFor_JMSComponents(jmsServerList)
#---Below 4 variables are hardcoded for time being
#This should be changed eventually
sysModule = "c2JMSModule"
loggingFormat="%header%,%properties%"
enabled="false"
jmsResource="c2.AsyncDispatcherRequestQ"
setAttributes_MessageLoggingParams(sysModule, jmsResource, loggingFormat, enabled)

def update():
install()

def clean():
loadProperties(jmsProp)
jmsServerList = standardStringSplit(jmsServers, ", ")
remove_JMSServers(jmsServerList)

def run_mode(mode):

if (mode=="install"):
install()
elif (mode=="update"):
#update()
print "Not fully implemented"

elif (mode=="clean"):
#clean()
print "Not fully implemented"

else:
print mode + " is not a valid argument: Current Args are 'install' 'clean' 'update'"
pass

#---------------
def standardStringSplit(strToSplit, splitString):
splitter = re.compile(splitString)
splitList = splitter.split(strToSplit)
return splitList

def remove_JMSServers(jmsServerList):
path = jmsServerPath
for jmsServer in jmsServerList:
exec """jmsName = """+jmsServer+"""Name"""
print jmsName
clean_bean(path, jmsName, 'JMSServer')

def clean_bean(path, beanName, beanType):
cd(path)
#try:
print "Attempting to remove "+beanType+": "+ beanName
exec """theBean = cmo.lookup"""+beanType+"""('"""+beanName+"""')"""
if theBean != None:
print "Deleting "+beanName+"..."
delete(beanName, beanType)

#-------#

try:
if (runMode == []):
print('Run mode must be set')
pass
else:
parentpath = sys.argv[3]
envProp = parentpath+'/weblogic_setup/properties/env.properties'
jmsProp = parentpath+'/weblogic_setup/properties/JMS.properties'
connectToAdminServer()
startTransaction()
run_mode(runMode)
endTransaction()
finally:
print 'JMSQueueScript done'

except IndexError:
print "Default action:Nothing"
print "Argument should be either 'install', 'clean' or 'update'"



Wednesday, December 09, 2009

jmeter ant script

this ant script run jmeter and also generates reports

this ant script takes in two folder locations, and many test scripts and a time to run from each folder.

this is used to run one set of the test then change folder and run another set of the same tests with different throughput numbers



<?xml version="1.0"?>
<!--
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="ant-jmeter" default="all">

<property file="${Properties}">

<description>

Sample build file for use with ant-jmeter.jar
See http://www.programmerplanet.org/pages/projects/jmeter-ant-task.php

To run a test and create the output report:
ant -Dtest=script

To run a test only:
ant -Dtest=script run

To run report on existing test output
ant -Dtest=script report

The "script" parameter is the name of the script without the .jmx suffix.

Additional options:

-Dtest2=script2
-Dtest3=script3
-Dtest4=script4
-Dtest5=script5
-Dtest6=script6

-DshutdownPort=4445
-DshutdownPort2=4446
-DshutdownPort3=4447
-DshutdownPort4=4448
-DshutdownPort5=4449
-DshutdownPort6=4450

-Dtestpath=xyz - path to test file(s) (default user.dir).
N.B. Ant interprets relative paths against the build file
-Dtestpath2=xyz - path to test file(s) second home eg 125 phl
N.B. Ant interprets relative paths against the build file

-DtestTime=y - time to run each test set

-DtestTimeOut=x - time for timeout to stop the test set in milliseconds eg, 30min = 30 * 60 * 1000

-Djmeter.home=.. - path to JMeter home directory (defaults to parent of this build file)
-Dshow-data=y - include response data in Failure Details

Deprecated:
-Dformat=2.0 - use version 2.0 JTL files rather than 2.1

</description>

<!-- this is the test time for the test -->
<property name="testTime" value="1">
<!-- timeout is in milliseconds, and must be 4mins more than test time eg, 30min = 30 * 60 * 100-->
<property name="testTimeOut" value="300000">

<property name="testpath" value="${user.dir}">
<property name="jmeter.home" value="${basedir}/..">

<!-- Name of test (without .jmx) -->
<property name="test" value="Test">

<property name="shutdownPort" value="4445">
<property name="shutdownPort2" value="4446">
<property name="shutdownPort3" value="4447">
<property name="shutdownPort4" value="4448">
<property name="shutdownPort5" value="4449">
<property name="shutdownPort6" value="4450">

<!-- Should report include response data for failures? -->
<property name="show-data" value="n">

<property name="output" value="out">

<property name="format" value="2.1">

<condition property="style_version" value="">
<equals arg1="${format}" arg2="2.0">
</condition>

<condition property="style_version" value="_21">
<equals arg1="${format}" arg2="2.1">
</condition>

<condition property="funcMode">
<equals arg1="${show-data}" arg2="y">
</condition>

<condition property="funcMode" value="false">
<not>
<equals arg1="${show-data}" arg2="y">
</not>
</condition>

<!-- Allow jar to be picked up locally -->
<path id="jmeter.classpath">
<fileset dir="${basedir}">
<include name="ant-jmeter*.jar">
</fileset>
</path>

<taskdef
name="jmeter"
classpathref="jmeter.classpath"
classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"/>

<target name="all" depends="run,report">

<target name="run">

<antcall target="jmeterParallel">
<param name="jmParallelPath" value="${testpath}">
<param name="jmParallelRunTime" value="${testTime}">
<param name="jmParallelTimeout" value="${testTimeOut}">
</antcall>
<antcall target="jmeterParallel">
<param name="jmParallelPath" value="${testpath2}">
<param name="jmParallelRunTime" value="${testTime}">
<param name="jmParallelTimeout" value="${testTimeOut}">
</antcall>
</target>

<target name="jmeterParallel">
<parallel failonany="false" timeout="${jmParallelTimeout}">
<antcall target="jmeterStart">
<param name="jmTest" value="${test}">
<param name="jmPort" value="${shutdownPort}">
<param name="jmPath" value="${jmParallelPath}">
</antcall>
<antcall target="jmeterStart">
<param name="jmTest" value="${test2}">
<param name="jmPort" value="${shutdownPort2}">
<param name="jmPath" value="${jmParallelPath}">
</antcall>
<antcall target="jmeterStart">
<param name="jmTest" value="${test3}">
<param name="jmPort" value="${shutdownPort3}">
<param name="jmPath" value="${jmParallelPath}">
</antcall>
<antcall target="jmeterStart">
<param name="jmTest" value="${test4}">
<param name="jmPort" value="${shutdownPort4}">
<param name="jmPath" value="${jmParallelPath}">
</antcall>
<antcall target="jmeterStart">
<param name="jmTest" value="${test5}">
<param name="jmPort" value="${shutdownPort5}">
<param name="jmPath" value="${jmParallelPath}">
</antcall>
<antcall target="jmeterStart">
<param name="jmTest" value="${test6}">
<param name="jmPort" value="${shutdownPort6}">
<param name="jmPath" value="${jmParallelPath}">
</antcall>
<sequential>
<!-- sleep till we want to shut down -->
<sleep minutes="${jmParallelRunTime}">
<antcall target="shutdownJmeter">
</sequential>
</parallel>

</target>

<target name="jmeterStart" depends="jmeterStart.check" if="jmeterStart.run">
<echo>funcMode = ${funcMode}</echo>
<delete file="${output}/${jmPath}/${jmTest}.html">
<jmeter
jmeterhome="${jmeter.home}"
testplan ="${jmPath}/${jmTest}.jmx"
resultlog="${output}/${jmPath}/${jmTest}.jtl">
<jvmarg value="-Xmx256m">
<!--
<jvmarg value="-Xincgc">
<jvmarg value="-Xmx128m">
<jvmarg value="-Dproperty=value">
<jmeterarg value="-qextra.properties">
-->
<!-- Force suitable defaults -->
<property name="jmeterengine.nongui.port" value="${jmPort}">
<property name="jmeter.save.saveservice.output_format" value="xml">
<property name="jmeter.save.saveservice.assertion_results" value="all">
<property name="jmeter.save.saveservice.bytes" value="true">
<property name="file_format.testlog" value="${format}">
<property name="jmeter.save.saveservice.response_data.on_error" value="${funcMode}">
</jmeter>
</target>

<target name="jmeterStart.check">
<condition property="jmeterStart.run">
<and>
<not>
<matches pattern ="^\$\{.+" string="${jmPath}">
</not>
<not>
<matches pattern ="^\$\{.+" string="${jmTest}">
</not>
</and>
</condition>
</target>

<target name="shutdownJmeter">
<antcall target="jmeterStop">
<param name="jmPort" value = "${shutdownPort}">
</antcall>

<antcall target="jmeterStop">
<param name="jmPort" value= "${shutdownPort2}">
</antcall>
<antcall target="jmeterStop">
<param name="jmPort" value= "${shutdownPort3}">
</antcall>
<antcall target="jmeterStop">
<param name="jmPort" value= "${shutdownPort4}">
</antcall>
<antcall target="jmeterStop">
<param name="jmPort" value= "${shutdownPort5}">
</antcall>
<antcall target="jmeterStop">
<param name="jmPort" value= "${shutdownPort6}">
</antcall>
</target>

<target name="jmeterStop">
<java classname="org.apache.jmeter.util.ShutdownClient" timeout="100">
<arg value="StopTestNow">
<arg value="${jmPort}">
<classpath>
<pathelement location="${jmeter.home}/bin/ApacheJMeter.jar">
</classpath>
</java>
<java classname="org.apache.jmeter.util.ShutdownClient" timeout="100">
<arg value="shutdown">
<arg value="${jmPort}">
<classpath>
<pathelement location="${jmeter.home}/bin/ApacheJMeter.jar">
</classpath>
</java>
</target>


<property name="lib.dir" value="${jmeter.home}/lib">
<property name="xalan.jar" value="${lib.dir}/xalan_2_7_1.jar">
<property name="serializer.jar" value="${lib.dir}/serializer-2_9_1.jar">

<!-- Use xalan copy from JMeter lib directory to ensure consistent processing with Java 1.4+ -->
<path id="xslt.classpath">
<pathelement location="${xalan.jar}">
<pathelement location="${serializer.jar}">
</path>

<target name="report" depends="_message_xalan">
<parallel>
<antcall target="reportGenerate">
<param name="jmPath" value = "${testpath}">
<param name="jmTest" value = "${test}">
</antcall>
<antcall target="reportGenerate">
<param name="jmPath" value = "${testpath}">
<param name="jmTest" value = "${test2}">
</antcall>
<antcall target="reportGenerate">
<param name="jmPath" value = "${testpath}">
<param name="jmTest" value = "${test3}">
</antcall>
<antcall target="reportGenerate">
<param name="jmPath" value = "${testpath}">
<param name="jmTest" value = "${test4}">
</antcall>
<antcall target="reportGenerate">
<param name="jmPath" value = "${testpath}">
<param name="jmTest" value = "${test5}">
</antcall>
<antcall target="reportGenerate">
<param name="jmPath" value = "${testpath}">
<param name="jmTest" value = "${test6}">
</antcall>
<antcall target="reportGenerate">
<param name="jmPath" value = "${testpath2}">
<param name="jmTest" value = "${test}">
</antcall>
<antcall target="reportGenerate">
<param name="jmPath" value = "${testpath2}">
<param name="jmTest" value = "${test2}">
</antcall>
<antcall target="reportGenerate">
<param name="jmPath" value = "${testpath2}">
<param name="jmTest" value = "${test3}">
</antcall>
<antcall target="reportGenerate">
<param name="jmPath" value = "${testpath2}">
<param name="jmTest" value = "${test4}">
</antcall>
<antcall target="reportGenerate">
<param name="jmPath" value = "${testpath2}">
<param name="jmTest" value = "${test5}">
</antcall>
<antcall target="reportGenerate">
<param name="jmPath" value = "${testpath2}">
<param name="jmTest" value = "${test6}">
</antcall>
</parallel>
</target>


<target name="reportGenerate" depends="reportGenerate.check" if="reportGenerate.run">
<xslt
classpathref="xslt.classpath"
force="true"
in="${output}/${jmPath}/${jmTest}.jtl"
out="${output}/${jmPath}/${jmTest}.html"
style="${jmeter.home}/extras/jmeter-results-detail-report${style_version}.xsl">
<param name="showData" expression="${show-data}">
</xslt>
&lt;/target>

<target name="reportGenerate.check">
<condition property="reportGenerate.run">
<and>
<not>
<matches pattern ="^\$\{.+" string="${jmPath}">
</not>
<not>
<matches pattern ="^\$\{.+" string="${jmTest}">
</not>
</and>
</condition>
</target>


<!-- Check that the xalan libraries are present -->
<condition property="xalan.present">
<and>
<!-- No need to check all jars; just check a few -->
<available classpathref="xslt.classpath" classname="org.apache.xalan.processor.TransformerFactoryImpl">
<available classpathref="xslt.classpath" classname="org.apache.xml.serializer.ExtendedContentHandler">
</and>
</condition>

<target name="_message_xalan" unless="xalan.present">
<echo>Cannot find all xalan and/or serialiser jars</echo>
<echo>The XSLT formatting may not work correctly.</echo>
<echo>Check you have ${xalan.jar} and ${serializer.jar}</echo>
</target>


</project>

Tuesday, May 12, 2009

svn source build, just need to get 64bit working :)

http://dougmunsinger.com/2009/04/subversion-compile-and-install-as-non-privileged-user.html

Sunday, April 26, 2009

selenium + netbeans = seleniumPlugin

been doing some searching, be aware that the seleniumPlugin can only be used/found for netbeans in the development branch, the same goes for the TestNG plugin....


http://wiki.netbeans.org/SeleniumPlugin

Saturday, April 25, 2009

web development work

My friend Jeremy has given me a job to create part of the new Waxy's Irish Pub website, they did not have one before a month ago, Waxy's is based on the sunshine coast, the owners also own omalleys on Queen street brisbane, you can check out what they have at ozpubgroup.com.au


waxysirishpub.com.au

eXtreme Programming

Extreme programing is something that everyone wants, but with an exisiting app, it takes along time to get into it.

hopefully i can make a difference at my workplace for the better.

http://intellectualcramps.blogspot.com/2009/04/eclipse-development-process-technical.html