Posts

Showing posts from October, 2015

Database Test Plan with JMeter

Image
Let us see how we can test the database in Jmeter using JDBC Request Sampler. In this tutorial we will use oracle jdbc driver. Required jar E.g. “ojdbc6.jar” is placed in <JMETER_Path>/lib. Prepare a Test Plan as shown below: Here we have added: User Defined Variables – Defined the required parameters for Database Connection JDBC Connection Configuration Thread Group JDBC Request under Thread Group BeanShell Sampler – To display the output of the JDBC Request. View Results Tree – To View the Results JDBC Request Sampler is used to send an JDBC Request to database. But before using this we need to setup the required JDBC connection and it is done via JDBC Connection Configuration element. Under JDBC Connection Configuration we have the below defined values: We defined the Variable Name as “JDBC_Pool”. The values required for Database Connection are defined in User Defined Variables and are used here. E.g: jdbc_url = jdbc:oracle:thin:@DB_Server:por

Using a Custom Jar in BeanShell Sampler in Jmeter

Image
Let us see an example on how we can use a custom Java classes and methods in JMeter BeanShell sampler. Outline of the steps: Write Java classes and methods in IDE tools like Eclipse or NetBeans Create a Jar of the above project Import the Jar to JMeter location Use the Java method in Jmeter BeanShell sampler Run the test plan and check results Let us see the above step by step: For getting the concepts clear, let us create an example class which will generate factorial of a given number. The number will also be a random number. Let us create a class containing the method to calculate a factorial and this will be used in JMeter. I created the method as below in eclipse. Here we have created new project “FactorialJar”. Under the project, we created two projects named as “FactClass” and “TestFact”. Under each class we created a Class called “Fact” and “Facttest”. Code for Fact.java is as below: package  FactClass; public   class  Fact {         public   int