Description

The BLOBTextGen Generator loads the file data in text format or file path from a user's local system into memory.


Parameters

The following parameters may be configured for the BLOBTextGen Generator. Parameters with an asterisk (*) are required.

  • filePath* - The file path on your local machine where the file is stored.
  • fileSubDir - The fileSubDir defines an optional sub directory under the filePath where the file to read is stored.
  • fileName* - The file name defines the name as a prefix of the file to open.
  • fileType* - The file type defines in which format the file will be read.
    • text = Loads the content of the file in text format.
    • binary = Loads the file path.

      Note: If the fileType is selected as binary, and in the GenericSQLInsertV2Receiver the columnType of the attribute is Blob then, the GenericSQLInsertV2Receiver will read the actual file from the file path and inserts the file into the Blob field in the database table.
  • maxSize - The maxSize defines the maximum size in KiloBytes (accepts the integer value) to be loaded into memory.
    • How to calculate the maxSize?
      • maxSize = Sum of all the file sizes in KiloBytes which needs to be loaded into the BLOBTextGen generator.

Please Note:

  • If maxSize is left empty then, by default 131072 value will be used. (128 MB * 1024 = 131072 KB)
  • If the maxSize is greater than the available heapMemory on the system, a warning message will be displayed on the command window.
  • exampleValue* - Since this Generator reads from a file, it cannot automatically show preview data. A default of 1000 has been included as preview data so that the Attribute is not blank.

Example Story

Actors

  • Tester - The QA Tester that wants to read the file from the local system to generate the test data.

  • Flat files- The files stored on the local system whose content as a text or the file itself needs to be read/loaded into the memory.


Key Components

  • Flat files - A flat file can be of any type, JSON file, Image file, CSV file, text file, etc..

  • BLOBTextGen Generator - Loads the file's data in text format or file path from a user's local system into memory.

  • GenericSQLInsertV2Receiver - When the selected attribute's dataType is set to Blob, the GenericSQLInsertV2Receiver does one of the following: 
    • Loads the file into memory - If the file path provided by the BLOBTextGen generator from a user's local system.
    • Reads the text data and inserts it into the specified field into the database table column - If file content as text is provided by the BLOBTextGen generator.


Plot

  • A Tester needs to save a file into a BLOB data type field of a database table.

  • A file can be a text file such as: XML, JSON, TXT, PDF, etc. or, it can be an image file such as: PNG, JPG, etc.

  • The BLOBTextGen Generator can then be configured to load the file's data in text format or the file path from a user's local system into memory.

  • GenericSQLInsertV2Receiver - When the selected attribute's dataType is set to Blob, the GenericSQLInsertV2Receiver does one of the following: 
    • Loads the file into memory - If the file path provided by the BLOBTextGen generator from a user's local system.
    • Reads the text data and inserts it into the specified field into the database table column - If file content as text is provided by the BLOBTextGen generator.

Using the BLOBTextGen Generator

Step 1: Basic Setup

  • Within the GenRocket Web Platform, the Tester will create a new Project.

  • Within this Project, the Tester will also need to create a Domain called, BlobDemo.

  • The Domain will contain the following Attributes with each associated to the following Generators:
    • id  - RangeGen
    • blobData - BLOBTextGen


Step 2: Replace blobData Attribute Generator

  • The blobData Attribute will be assigned a default Generator when it is initially created.

  • Select the blobData Attribute within the GenRocket web platform.

  • Use the Quick Generator Replace menu on the Attribute Tab to replace it with the BLOBTextGen Generator.


  • Enter BLOB into the input field within the menu and then click on BLOBTextGen to select this Generator.

  • Click the Replace button to finish.


Step 3: Configure the BLOBTextGen Generator

Complete the following within the GenRocket web platform:

  • Configure the filePath  Parameter for the Generator. Double click on the input field, select the Resources Tab, and then select the appropriate resource path.

  • Click on the fileSubDir input field and enter the name of the sub directory where the files are located. This is an optional field.

  • Click on the fileName input field and enter the name of the delimited file. For this example it will be testFile.

  • Select the required fileType from the drop-down menu regarding how you want the files to be loaded into the memory. For example: binary.


  • Since the file is stored on your local computer, preview data will not be available. To see preview data in the GenRocket web platform, you will need to add an exampleValue.


  • You will need to change the global.BlobDemo.loopCount to a different value than 1 to view multiple results. In the example below, it is set to 10. This means that 10 rows will be inserted in the database table.


Step 4: Add a New Receiver

Next, you will need to add a new Receiver to provide usable, formatted output data. For this example, we will be using the GenericSQLInsertV2Receiver to insert data into BLOB column in a database table..

Complete the following steps:

  • Click the New Receiver button when viewing the Domain in the Project Dashboard.


  • Enter Generic in the Filter input field and then select GenericSQLInsertV2Receiver.


  • Change the name of the Receiver (if desired) and then click Save.


  • Enter a resourceName for the Receiver (config.properties). This is the name of the config file on your local computer that contains the database connection information.

  • Enter all the required parameter values for the receiver.

  • Click the Save button to finish.


Note:

  1. You can use any desired Receiver and this example is using a GenericSQLInsertV2Receiver to show how the Generator works.
  2. To check out how to configure the GenericSQLInsertReceiver you can checkout these KB articles for the reference:


Step 5: Create and Run a Scenario

Next, you will need to create a quick Scenario, download the Scenario, and run it on your local computer. Complete the following steps to do so:

  • Click on Quick Scenario when viewing the Domain within the GenRocket web platform. This will quickly create a Scenario including the parent and sibling relationships with referential integrity for the Domain.


  • Enter a Description if desired for the Scenario and click the Save button.


  • Click on the Download button when viewing the Scenario in the GenRocket web platform to download the Scenario to your local computer.


  • Open a Command Window and change the directory to where the output file is stored.

  • Then type genrocket -r  ScenarioName.grs and use the Enter Key on your keyboard to run the Scenario. In this example, the Scenario Name is: BlobDemoScenario.grs.

  • After successful execution of the scenario, you will see files inserted into the database table within the BLOB column.