Skip to main content

Command Palette

Search for a command to run...

JMeter Template for Oracle APEX Applications

Published
5 min read
JMeter Template for Oracle APEX Applications
M

With around 20 years on the job, Matt is one of the most experienced software developers at Pretius. He likes meeting new people, traveling to conferences, and working on different projects.

He’s also a big sports fan (regularly watches Leeds United, Formula 1, and boxing), and not just as a spectator – he often starts his days on a mountain bike, to tune his mind.

As Oracle APEX developers, ensuring our applications can handle real-world usage is a technical necessity.

Load testing is an essential part of this process, yet it often involves complicated manual setups or reliance on commercial tools.

The Pretius JMeter APEX Template addresses this need, by providing a configurable, open-source starter project designed specifically for Oracle APEX load testing using Apache JMeter.


Purpose and Features

This project implements a JMeter login/logout script for APEX environments:

  • Automates login, home page navigation, and logout for your APEX application.

  • Provides ready-made configuration to minimize manual edits.

  • Allows quick ramp-up for both functional and basic performance/load tests.

The idea is that you use a sample APEX application to peform this test on.

You can ramp up the number of users and scale-up, so imagine 100 users simultanuously trying to login and logout of your APEX environment. Now image how that would fair? JMeter can answer these questions.

You can additionally add some DB intensive activivites (script provded) on the Home Page to simulate load. Now run it with 100 users and see how that goes.

WARNING: Performing Performance Testing on oracleapex.com violates the ORACLE APEX SERVICE AGREEMENT that you accepted when you signed up.


Version Compatibility

  • The template supports Oracle APEX 24.2 out of the box.

  • For earlier or later versions, slight adjustments may be necessary.


Quick Start Guide

You can find the same guide here

Preparation

  1. Download this repo

  2. Download the latest JMeter binaries on the https://jmeter.apache.org/download_jmeter.cgi website (do not download the source)

  3. Extract the binaries to the root folder i.e /pretius-jmeter-apex-template/apache-jmeter-x.x.x

    alt folder

Start & Configure JMeter Project

  1. Navigate to /pretius-jmeter-apex-template/apache-jmeter-x.x.x/bin and run command ./jmeter

  2. Open the project /jmx/Pretius Starter.jmx

  3. Expand tree to find User Defined Variables & change the variable values to refer to your app e.g https://example.com/ords/r/jmeter/jmeter-demo

    alt folder

  4. Find CSV Data Set Config and use the Browse button to change the File Name to point at /users/users.csv

    alt folder

  5. Modify file /users/users.csv to add your Usernames & Passwords you want to use.

     username,password
     enter_username_here,password_goes_here
    

    Alternatively create a new Default Custom APEX Authentication scheme of:

     function my_authentication (
      p_username in varchar2,
      p_password in varchar2 )
      return boolean
      is    
      begin
          return true;
      end;
    
  6. Find JSR223 PostProcessor and use the Browse button to change the File Name to point at /groovy/jsr223.groovy

    alt folder

  7. File > Save

Running the Project

  1. Click on View Results Tree

  2. Click Clear All icon in the toolbar

    alt folder

  3. Click Start icon in the toolbar

    alt folder

  4. Observe the results. Specifically you are looking for a valid redirectURL in the Response Body of the POST Credentials step

    alt folder

Adding Load (users)

  1. Find Thread Group

  2. Adjust the Number of Threads (Users) e.g 3

  3. Adjust the Ramp-up period (Seconds) e.g 3

  4. Run the Project (see steps above)

alt folder

Adding Load (DB Load)

  1. In APEX, edit your Home Page.

  2. Add a Dynamic Content Region with the following code

      DECLARE
          l_collection_name VARCHAR2(100) := 'TEST_COLLECTION';
          l_member_id NUMBER;
          l_start_time PLS_INTEGER;
          l_end_time PLS_INTEGER;
          l_elapsed_seconds NUMBER;
          l_result VARCHAR2(4000);
      BEGIN
          -- Record start time
          l_start_time := DBMS_UTILITY.GET_TIME;
    
          -- Enable debug logging
          APEX_DEBUG.ENABLE(p_level => APEX_DEBUG.c_log_level_info);
    
          -- 1. Delete the collection if it exists
          IF APEX_COLLECTION.COLLECTION_EXISTS(p_collection_name => l_collection_name) THEN
              APEX_COLLECTION.DELETE_COLLECTION(p_collection_name => l_collection_name);
              APEX_DEBUG.INFO('Collection deleted: %s', l_collection_name);
          END IF;
    
          -- 2. Create a new empty collection
          APEX_COLLECTION.CREATE_COLLECTION(p_collection_name => l_collection_name);
          APEX_DEBUG.INFO('Collection created: %s', l_collection_name);
    
          -- 3. Fill the collection with 2500 members
          FOR i IN 1..2500 LOOP
              l_member_id := APEX_COLLECTION.ADD_MEMBER(
                  p_collection_name => l_collection_name,
                  p_c001 => 'Member_' || i,
                  p_c002 => 'Description for member ' || i,
                  p_c003 => 'Category_' || MOD(i, 10),
                  p_n001 => i,
                  p_n002 => i * 1000,
                  p_n003 => ROUND(i / 10, 2),
                  p_d001 => SYSDATE + i
              );
    
              IF MOD(i, 500) = 0 THEN
                  APEX_DEBUG.MESSAGE('Added %s members to collection', i);
              END IF;
          END LOOP;
    
          -- Get final count
          SELECT COUNT(*) INTO l_member_id FROM apex_collections WHERE collection_name = l_collection_name;
          APEX_DEBUG.MESSAGE('Total members in collection: %s', l_member_id);
    
          -- 4. Delete the collection
          APEX_COLLECTION.DELETE_COLLECTION(p_collection_name => l_collection_name);
          APEX_DEBUG.INFO('Collection deleted: %s', l_collection_name);
    
          -- Calculate elapsed time
          l_end_time := DBMS_UTILITY.GET_TIME;
          l_elapsed_seconds := (l_end_time - l_start_time) / 100;
    
          -- Build detailed result message
          l_result := 'SUCCESS: Created collection with ' || l_member_id || ' members and deleted it. ' ||
                      'Execution time: ' || ROUND(l_elapsed_seconds, 3) || ' seconds (' ||
                      ROUND(l_elapsed_seconds * 1000, 1) || ' ms)';
    
          APEX_DEBUG.INFO(l_result);
    
          RETURN l_result;
    
      END;
    

Intrepret the Results

Find the Summary Report

alt folder

Using the HTTP(S) Test Script Recorder

  1. Add the following line to apache-jmeter-x.x.x\bin\jmeter.properties which is required for Oracle APEX Applications.

     # Remove Accept-Encoding from recorded headers
     proxy.headers.remove=Accept-Encoding,If-Modified-Since,If-None-Match,Host
    
  2. Quit & Restart JMeter

  3. The first time you run the recorder, JMeter automatically generates a root certificate file named /bin/ApacheJMeterTemporaryRootCA.crt

  4. In Firefox, go to Settings (or Options) → Privacy & Security → down to the Certificates section.

  5. Click View Certificates, then Import.

  6. Select the JMeter certificate file /bin/ApacheJMeterTemporaryRootCA.crt

  7. Approve any prompts to trust the certificate for website identification.

  8. Still in Firefox, go to Settings → Network Settings (scroll to the bottom).

  9. Click Settings for Network.

  10. Choose Manual proxy configuration.

  11. Set the HTTP proxy to localhost and port 8888

  12. Check “Use this proxy server for all protocols”.

  13. Click OK to apply changes.

  14. Start browsing/recording the target application; JMeter will capture all HTTP/S requests.


Whats the picture? A clump of Wild Chamomile in a field near The Kestral. Visit Yorkshire!