update_multiple_array_elements_using_greaterthenorequal_lessthenorequal_in_mongo

Updating multiple elements in Array data type in mongodb using shell

we have an 2 documents in mongodb like below

now we want to update grades value of which are greater then or equal  to 100 is the Query for updating multiple elements in Array.

 

 

in above Query all the elements which are greater then  or equal 100 are replace with 80 we have list of operators show here and dummy_collection is my Collection name

updatearrayselementinmongo

Updating single element in Array data type in mongodb using shell

I have an 2 documents in mongodb like below

now I want to update grades value of 100 to 1000 below is the Query for updating single element in Array.

in above Query  dummy_collection is the Collection name and it will replace 100 to 1000  from all documents in Collection

if we want to Update element in nested array

Now i want to update the 75 in grade array below will be the query

In above Query by using dotted Notation  we are mentioning the MongoDB to update the array which is under allGrades where grade array value is 75 to 80

 

 

 

sending-email-from-godaddy-servers-php

In this tutorial we will see how to send email using php from godaddy servers

  • download PHPMailer from here
  • php script as below

  • go to you cpanel and upload the file and try to execute the script from browser and see you inbox for email
  • before executing change the recipients email to valid email address and valid from email.

Happy programming

 

creating-entity-classes-from-database-schema

In this tutorial will see how to create the entity classes from db schema.

below are the required software’s to be installed in you local machine.

steps to download and install Hibernate Tools

After installation of hibernate tools follow below steps for creating entity class

go to perspective and select database development as below screen shot

 

  • Click on new profile

  • Selecting the database type from Popup

  • Next select the drivers in

  • Eclipse will show predefined drivers version, If your mysql drivers in list then select the respective drivers configuration and upload the respective drivers jar from JAR List tab as below. if your mysql version is not in list then upload downloaded drivers jar from JAR List tab

  • Click in Add Jars/ZIP button to browse the drivers jar file
  • After uploading the drivers jar you can see as above screen shot
  • Next add the DB configuration Setting in Properties Tab

  • in my case localhost is my database ip address
  • test is my database name
  • root is user name
  • for drivers class click browse button as shown below

  • Click blue dots button to add drivers class file

  • Select drivers class as com.mysql.jdbc.Driver, click on ok button
  • you will see the final configuration overview to finish setup as below

  • Provide the password and confirm the database and user name and click on test connection you should see below alert

  • Click on Ok button on popup and click on Finish button
  • you will see the connection details and database schema  in left side Data Source Explorer

Now Step 2 Creating JPA project 

  • Change Perspective to JPA 

  • Create new JPA Project as below steps

  • Select JPA Project under JPA folder
  • Use settings as above screen shot
  • Select the hibernate (JPA 2.1)

  • select connection which we created in step 1

  • Click on Finish button you will see project name in left side Project Explorer

  • Next creating Entities using jpa project
  • Right click on JPA project to see below options

  • Click on generate entities from tables

  • enter the package name to where classes need to be create and click on finish

  • Respective Entity classes created with respective the tables in database test
  • copy paste the entity classes into you project folder

 

 

Happy programming

Record the Https Request in Jmeter

  • Download the the Jmeter from apache Jmeter site
  • Download supported java version for your jmeter version

open jmeter using Jmeter.bat in window or jmeter.sh in linux or run the ApacheJmeter.jar file

after starting the Jmeter

  • Add HTTP(S) Test Script Recording to Test Plan.
  • Add Transaction Controller to Test Plan
  • Change target Controller to transaction controller created earlier
  • click on Start button in HTTP(S) Test Script Recording.
  • Jmeter will create Certificate by default in bin folder

Follow the below Steps to import the Jmeter certificate to record Https Traffic.

  • open Chrome or IE
  • open Chrome Setting and search for manage SSL

Certificates Window will open like below, Where we can import or export the certificates

Click on Import button Certificate Import Wizard as below

After Clicking On Next below window will be seen

Browse the path to jmeter bin folder and certificate will be show as below

select the Certificate and click On Next

instead of Selecting Personal click On browse and select Trusted Root Certificates

Click Ok and Next 

 

After Clicking on  Finish Security Window will be opened as below

Click On  Yes button you will be show an alert as Certificate imported Successfully

 

then restart the Browser and Jmeter and follow the below post for recording script

click here to recording script post

 

How to Record HTTP application in Jmeter

For Recording Script using Jmeter follow the Steps

  • Download Jmeter from apache jmeter site
  • Download JDK/JRE (download java which should support downloaded jmeter version).

Open the Jmeter using jmeter.bat in Windows, jmeter.sh in linux Or run ApacheJmeter.jar from bin folder then click on highlighted icon shown in below screen shoot(which is basically opens predefined templates given by Jmeter)

and select the Recording and click Create

then Jmeter will create recording template (Http Recorder and recording template) as below.

Expand the Thread group and delete Recording Controller and right Click On Thread Group and Add–>Logic Controller–>Transaction Controller

we can add multiple Transaction controller based on work flow. Generally each page navigation will be considered as a transaction. Some time based on requirement we will individual requests as a transaction.

Then Click on Http(S) Test Script Recorder.

In above Picture 1 is Port number which we will use to add proxy server. and in point instead of User recording Controller we should choose transaction which we created earlier.

next click on start for start button in bottom.

Then open chrome or internet explorer

in Chrome

  • open setting and search for Proxy 

click on Highlighted proxy setting

click on LAN Setting a popup will be open like below

check the higlighted Checkbox and add server name as localhost and Port as which we have given in jmeter HTTP(S) Test Script Recorder (port number in proxy setting and jmeter Http(s) Test Script recorder should match to capture requests)’

Now we good to start record our script open the chrome new window and start the navigation you should see the requests in trasaction controller what we have selected in HTTP(s) test recording target option

 

 

How to add Parallel/Concurrent Requests in Jmeter

We have many tools for testing performance of the application. Below are few popular tools generally used.

  • Jmeter (Opensource)
  • Load runner
  • Neo Load
  • Soasta
  • Web Load

What is Concurrent/Parallel  Requests?

Concurrent requests are requests which are fired at same time from the browser.

How the response Time is calculated for Concurrent/Parallel Requests

Let assume 5 requests are fired parallelly from browser and response times are like 1, 2, 3, 4, 5 Seconds  respectively. Response Time will be considered as 5 Sec which is highest response time out 5 requests.

Concurrent requests connection limit are different for different browsers.

Why Concurrent/Parallel Requests are used

All latest browsers will use Concurrent requests for downloading resources like css,js,fonts etc.. to reduce User interaction time. and Some developers will use parallel asynchronous requests to get data and display it effectively.

How to Simulate Concurrent/Parallel Requests from Jmeter

  • Download JDK/JRE 1.8 or above
  • Download Jmeter(4.0)
  • Download Jmeter Plugin Manager and copy the jar file to jmeter root directory/lib/ext

Start the jmeter using jmeter.bat/jmeter.sh or ApacheJmeter.jar

you will be seeing below window after jmeter starts

Click On plugin Manager as show in below

 

after clicking plugin manager popup will be open as below

From Left side search box search for parallel in search results you will be seen Parallel Controller select and click on apply change and restart button bottom right

After restarting Jmeter. Open the already existing script or create new thread group and right click on thread Group use will be seen below options

 

Select bzm-Parallel Controller and Add all parallel requests to added bzm-Parallel Controller and click on generate parent sample to get accurate response.

 

 

run the test to see the responses

 

Happy Testing!!

 

Sending Email using PHPMailer

Steps before you start

Create email.php &  copy the downloaded PHPMailer source code into htdocs or in your project directory & in your project directory which will look like below.

 

 

edit email.php file and paste below code

Save the file and try to access http://localhost:serverportnumber/email.php

HTML Code for Popup window

HTML Code for Popup Window