Thursday, December 31, 2015

Postgresql Commands

1. Collumn Count:

select count(*) from information_schema.columns

                  where table_name='tm_ctrl';


2. Select query with LIMIT OFFSET:

select * from td_nyukin limit 5 offset 0







N.B: i) LIMIT: How much row will be shown here
        ii) OFFSET: Start from which position

Wednesday, December 30, 2015

Git-Gerrit Made Easy - Part 2

First Procedure:

1.   At First, commit your change to local branch.
2.   ($ git log --oneline --decorate --graph). Then grab the commit id.
3.   fetch my origin ($ git fetch origin)
4.   and then rebase master. ($ git rebase origin/master)
5.   Then I have to give the push command.( $ git push origin HEAD:refs/for/develop).
6.   Finished. Now need new code for further development:
7.   $ git fetch origin
8.   $ git checkout -b task#2021 origin/develop

Second Procedure:

l  At First, commit your change to local branch.
l  ($ git log --oneline --decorate --graph). Then grab the commit id.
l  fetch my origin ($ git fetch origin)
l  and then rebase master. ($ git rebase origin/master)
l  If any kind of problem occurs in rebasing position. I have to create a new branch from origin/master. Then cherry-pick the previous commit id. Then push it.
l  Create a new branch (git checkout -b bug#75#L origin/master)
l  Then cherry-pick the commit id(git cherry-pick b6e82b5)
l  Then I have to give the push command.( $ git push origin HEAD:refs/for/develop).
l  After pushing, we need to create a new branch for further coding. For this reason we need to fetch the origin. Then I have to create a branch.
l  $ git fetch origin
l  $ git checkout -b task#2021 origin/develop

REVIEW, FEEDBACK AND PATCH SET:

I have pushed all fixes. My TL reviews the code and want some comments. So he gives some feedback. I have added all comments and make a patch set using the previous commit ID 26889. All step are given below step by step:

USER@zakir-rizvi MINGW64 /c/bapf/eBuilder722/eclipse/workspace/bookstore_project (bug#75#1)
$ git push origin HEAD:refs/for/develop
Counting objects: 17, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (13/13), done.
Writing objects: 100% (17/17), 2.56 KiB | 0 bytes/s, done.
Total 17 (delta 10), reused 0 (delta 0)
remote:
remote: New Changes:
remote:   https://review.g2it.com:8443/26889
remote:
To ssh://abu.rizvi@review.g2it.com:29418/bookstore_project
 * [new branch]      HEAD -> refs/for/develop

USER@zakir-rizvi MINGW64 /c/bapf/eBuilder722/eclipse/workspace/bookstore_project (bug#75#1)
$ git branch
* bug#75#1
  master

USER@zakir-rizvi MINGW64 /c/bapf/eBuilder722/eclipse/workspace/bookstore_project (bug#75#1)
$ git push origin HEAD:refs/changes/26889
Counting objects: 17, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (13/13), done.
Writing objects: 100% (17/17), 2.54 KiB | 0 bytes/s, done.
Total 17 (delta 10), reused 0 (delta 0)
To ssh://abu.rizvi@review.g2it.com:29418/bookstore_project
 * [new branch]      HEAD -> refs/changes/26889

USER@zakir-rizvi MINGW64 /c/bapf/eBuilder722/eclipse/workspace/bookstore_project (bug#75#1)
$ git push origin HEAD:refs/changes/26889
Counting objects: 17, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (13/13), done.
Writing objects: 100% (17/17), 2.54 KiB | 0 bytes/s, done.
Total 17 (delta 10), reused 0 (delta 0)
To ssh://abu.rizvi@review.g2it.com:29418/bookstore_project

 * [new branch]      HEAD -> refs/changes/26889

Wednesday, December 23, 2015

Git-Gerrit Made Easy - Part 1

First Procedure:
1.   At First, commit your change to local branch.
2.   ($ git log --oneline --decorate --graph). Then grab the commit id.
3.   fetch my origin ($ git fetch origin)
4.   and then rebase master. ($ git rebase origin/master)
5.   Then I have to give the push command.( $ git push origin HEAD:refs/for/develop).

Second Procedure:
l  At First, commit your change to local branch.
l  ($ git log --oneline --decorate --graph). Then grab the commit id.
l  fetch my origin ($ git fetch origin)
l  and then rebase master. ($ git rebase origin/master)
l  If any kind of problem occurs in rebasing position. I have to create a new branch from origin/master. Then cherry-pick the previous commit id. Then push it.
l  Create a new branch (git checkout -b bug#75#L origin/master)
l  Then cherry-pick the commit id(git cherry-pick b6e82b5)
l  Then I have to give the push command.( $ git push origin HEAD:refs/for/develop).


Thursday, November 19, 2015

Git Made Easy - Part 4

Once I got a problem. I have tried to checkout my master branch dev. But got an irrelevant message. thats given below.

$ git checkout dev
Switched to branch 'dev'
Your branch is ahead of 'origin/dev' by 1 commit.
  (use "git push" to publish your local commits)

My manager give me a quick solution thats given below:

$ git reset --hard HEAD~1

Tuesday, November 3, 2015

Git Made Easy - Part 3

When we want to push any branch, we need to get log files. There are 3 ways to get log files. They are --
1.  git log
2.  git log –stat
3.  git log –oneline

$ git log
commit 2297ac77d75a57aa1760e2e7560fe331e832a644
Author: Rizvi <abu.rizvi@rgroup.com>
Date:   Tue Nov 3 14:37:24 2015 +0600

    Some changes#1

commit 78d5c1ba8efef0ee6c715ab957a1a7a2ae65b3ef
Author: Rizvi <abu.rizvi@rgroup.com>
Date:   Tue Nov 3 13:39:46 2015 +0600

    .gitignore added

Description: “git log” gives commit number, author name, commit date and commit message.

$ git log --stat
commit 2297ac77d75a57aa1760e2e7560fe331e832a644
Author: Rizvi <abu.rizvi@rgroup.com>
Date:   Tue Nov 3 14:37:24 2015 +0600

    Some changes#1

 src/org/generics/MaximumTest.java | 57 +++++++++++++++++++--------------------
 src/org/generics/Test.java        |  9 +++++++
 2 files changed, 36 insertions(+), 30 deletions(-)

Description: “git log --stat” gives commit number, author name, commit date, commit message, name of classes which are changed and number of files.

$ git log --oneline
2297ac7 Some changes#1
78d5c1b .gitignore added
1987f90 Generics features added
b3e47f6 Thread Class newly added
63b4126 Merge pull request #3 from rizvi/br1005#ext

Description: “git log --stat” gives commit numbers and commit messages.

N.B.: If you amend, then git force push.
Scenerio: First br2009 is pushed to master
$ git push origin br2009:master
Then I have not created any branch and worked on same branch br2009. I amend the new code and then push forcibly makes success.

$ git push origin br2009:master  -f

Generics Made Easy - Part 2

Double.compare(d1,d2)
·         d1 -- first double to compare
·         d2 -- second double to compare.

0, if d1 is numerically equal to d2;
<0, if d1 is numerically less than d2;
>0, if d1 is numerically greater than d2.

General Format:
package org.generics;
public class MaximumTestFirst {
        public static void main(String[] args) {
                System.out.println(maximum(7.5, 6.5));
        }
        private static double maximum(double d1, double d2) {
                double max = d1;
                if (Double.compare(max, d2) < 0) {
                        max = d2; // d2 is the largest so far
                }
                return max;
        }
}

Generics Standard Format:
package org.generics;
public class MaximumTestFirst {
        public static void main(String[] args) {
                System.out.println(maximum(7.5, 6.5));
        }
        private static <T extends Comparable<T>> T maximum(T d1, T d2) {
                T max = d1;
                if (d2.compareTo(max) > 0) {
                        max = d2; // d2 is the largest so far
                }
                return max;
        }
}

Converting area:
Method type
double
<T extends Comparable<T>> T
Parameter type
(double d1, double d2)
(T d1, T d2)
Differences
Double.compare(max, d2)
d2.compareTo(max)


Generics Made Easy - Part 1

Monday, October 5, 2015

Multiple Browser Parallel Execution for Test Automation

Multiple Browser Parallel Execution:
SuitePortalMultipleBrowser.xml
<?xml version="1.0" encoding="UTF-8"?>
<suite name="Parallel_Execution" parallel="tests" thread-count="2"
        verbose="10">
        <listeners>
                <listener
class-name="org.imaginea.jenkins.plugins.testinprogress.testng.TestNGProgressRunListener" />
        </listeners>
        <test name='Test1'>
                <classes>
                        <class name='com.net.OfficersPortalTest' />
                </classes>
        </test>
        <test name='Test2'>
                <classes>
                        <class name='com.net.DisplaySettingsPortalTest' />
                </classes>
        </test>
        <test name='Test3'>
                <classes>
                        <class name='com.net.MessagePortalTest' />
                </classes>
        </test>
        <test name='Test4'>
                <classes>
                        <class name='com.net.FamilynFriendsPortalTest' />
                </classes>
        </test>
</suite>

Here,
·          parallel = “tests” à It helps to parallel run of test classes.
·          thread-count = “2” à 2 is number of browser which are executed parallelly. Here we can use 3, 4 or so on.
·          Verbose =”10” à Verbose Attribute lets you obtain clear reports through IDE console. This attribute will be placed inside the <Suite> tag of testng.xml as shown below:
<suite name="Parallel_Execution" parallel="tests" thread-count="2" verbose="10">
Some conditions also needed to perform parallel browser execution for elementary level.
Condition - 1:  RemoteWebDriver will not be static.
       /**
         * driver for the browser
         */
        public RemoteWebDriver driverBrowser;
Condition - 2: If we want to quit the browser after processing every test class, we need to add the method in every test class.
        /**
         * Called by TestNG after each Test is called.
         *
         * @throws Exception
         */
        @AfterTest(alwaysRun = true)
        public void testCleanUp() throws Exception {
                if (driverBrowser != null) {
                        driverBrowser.quit();
                }


        }

Monday, August 31, 2015

Grouping in Selenium


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suite1">
   <test name="test1">

      <groups>
         <define name="all">
            <exclude name="functest"/>
            <include name="checkintest"/>
         </define>

         <run>
            <include name="all"/>
         </run>
      </groups>

      <classes>
         <class name="GroupTestExample" />
      </classes>

   </test>

Thursday, August 13, 2015

Page Object Pattern -Made Easy 1

Git Made Easy - Part 1

$ git checkout main_dev
$ git pull
When first pull gives "Already up-to-date.". Then I can proceed in this way.
$ git checkout task#r1005
$ git push origin task#r1005:main_dev
$ git checkout main_dev
$ git pull
$ git checkout -b task#r1006

Git Made Easy - Part 2

Approach #2

$ git checkout main_dev
$ git pull
 src/test/resources/testdata.json                   |   9 ++
 18 files changed, 454 insertions(+), 338 deletions(-)
$ git checkout -b task#r1001#ext
$ git checkout task#r1001
$ git log
commit 6e86b7b50d10623eec33f49917a7c3c50a4cff2a
Author: Rizvi <abu.rizvi@gmail.com>
Date:   Wed Aug 5 14:49:04 2015 +0600

    RZ# Facility Portal fix and new Test Cases.
$ git checkout task#r1001#ext
$ git cherry-pick 6e86b7b50d10623eec33f49917a7c3c50a4cff2a
$ git push origin task#r1001#ext:main_dev
$ git checkout main_dev
$ git pull
 src/test/resources/testdata.json                   |  10 +-
 3 files changed, 528 insertions(+), 10 deletions(-)
$ git checkout -b task#r1002

From first pull, if we get any kind of changes, insertions or deletions, we have to follow above rule.
we have to make another branch named by task#r1001#ext which containing everyone's updated code.

Here task#r1001 is containing only my updates. So I need to take the log file to get my commit number. Then I go to branch  task#r1001#ext  which is updated except my new commit code. So, I want to cherry-pick from this branch giving my commit number.

Then I will push the updated to main_dev. Then I will pull so that I can get my all changes here. Here after I will make new branch to work further.