Tuesday, March 16, 2010

JMX Sample

public class MessageHolder implements MessageHolderMBean{
public static void main(String[] args) {

}
private String message;
@Override
public void setMessage(String message) {
this.message = message;
}

@Override
public String getMessage() {
return this.message; //To change body of implemented methods use File | Settings | File Templates.
}

@Override
public void sayHello() {
System.out.println("Messsage:"+message);
}
}


public class JmxAgent {

private MBeanServer mbs = null;

public JmxAgent() {

// Get the platform MBeanServer
mbs = ManagementFactory.getPlatformMBeanServer();

// Unique identification of MBeans
MessageHolder helloBean = new MessageHolder();
ObjectName helloName = null;

try {
// Uniquely identify the MBeans and register them with the platform MBeanServer
helloName = new ObjectName("SimpleAgent:name=ManageYourProgram");
mbs.registerMBean(helloBean, helloName);
} catch(Exception e) {
e.printStackTrace();
}
}

// Utility method: so that the application continues to run
private static void waitForEnterPressed() {
try {
System.out.println("Press to continue...");
System.in.read();
} catch (Exception e) {
e.printStackTrace();
}
}

public static void main(String argv[]) {
JmxAgent agent = new JmxAgent();
System.out.println("SimpleAgent is running...");
JmxAgent.waitForEnterPressed();
}
}


public interface MessageHolderMBean
{

public void setMessage(String message);

public String getMessage();

public void sayHello();
}

Friday, March 12, 2010

Some Groovy on Soapui tests :)

Write some entry in a file like below.

[serkans@serkanslnx ~] cat /home/serkans/phoneNumbersOnly.txt
9001234560
9001234561
9001234562
9001234563
9001234564
9001234565
9001234566
9001234567
9001234562
9001234568
9001234562
9001234569

Create a test step , right click on it , Select add new Step , Select Groovy Script.Enter the following lines to it.Play Run button on the window to execute it.Do some customization to run it.File path etc..



// read the file as a properties file, but it is not :)we will get only keys from it
def properties = new java.util.Properties();
properties.load( new java.io.FileInputStream("/home/serkans/phoneNumbersOnly.txt" ));
//get a random index acc. file's line size
Random r = new Random();
def randomIndex  = r.nextInt(properties.size());
            def valueFromFile = (String) properties.entrySet().toArray()[randomIndex].toString();
            valueFromFile = valueFromFile.toString().replaceAll("=","");
log.info(valueFromFile);
return valueFromFile;


After than you need to transfer this value by using another type of Steps in soapui.
Select add new Step , Select "Property Transfer" ,Select GroovyScript as Source and select result as Property to transfer on it,Select your "Test Request" as destination and select Request as Destination.And write "//par1[@*]" to the target window.
     Look at the picture for better understanding.That is why i prefer to watch rather than reading generally:)

It will provide you Random values from file.You can use in your load tests.Enjoy!


Visit soapui page for more.

How to get SystemInfo in HP servers

[root@hpserver ~]# hpasmcli
HP management CLI for Linux (v1.0)
Copyright 2004 Hewlett-Packard Development Group, L.P.

--------------------------------------------------------------------------
NOTE: Some hpasmcli commands may not be supported on all Proliant servers.
Type 'help' to get a list of all top level commands.
--------------------------------------------------------------------------
hpasmcli> show server
System : ProLiant DL380 G5
Serial No. : CZC82758BX
ROM version : P56 01/24/2008
iLo present : Yes
Embedded NICs : 2
NIC1 MAC: 00:1X:29:e8:2c:9a
NIC2 MAC: 00:1X:29:e8:2c:98

Processor: 0
Name : Intel Xeon
Stepping : 6
Speed : 3000 MHz
Bus : 1333 MHz
Core : 4
Thread : 4
Socket : 1
Level2 Cache : 12288 KBytes
Status : Ok

Processor: 1
Name : Intel Xeon
Stepping : 6
Speed : 3000 MHz
Bus : 1333 MHz
Core : 4
Thread : 4
Socket : 2
Level2 Cache : 12288 KBytes
Status : Ok

Processor total : 2

Memory installed : 8192 MBytes
ECC supported : Yes
hpasmcli> exit
[root@hpserver ~]#

AXIS2 Web Service Level Parameters

in the services.xml you need to define your parameters like below

<parameter locked="false" name="MY_PARAMETER_NAME">MY_PARAMETER_VALUE

In your Skel class you can get the value like that:

String paramValue = (String) MessageContext.getCurrentMessageContext().getParameter ("MY_PARAMETER_NAME");