Today, a faster test cycle at lower cost is vital to stay competitive. Re-usable test automation frameworks coupled with open source tools and technologies is a key solution to shrink test cycle time and related costs. Here I have come up with a very robust Automation framework for automating RESTful webservices. I used Rest-Assured to build this framework. Below is the link to it: https://github.com/nainappa/ConfianceAPIAutomationFramework
Friday, 6 April 2018
Thursday, 22 March 2018
Replace Jenkins Logo and Text of your choice in JenkinsUI
Often times we have several Jenkins CI Servers and we always get confused to determine them. Some times we may need to change the Logo and text to customize Jenkins UI to reflect your organization details. This post helps to you to change the header and Logo on your Jenkins UI.
Custom styling can be applied via modification of the CSS structure being used by Jenkins.
Simple Theme Plugin is the most popular approach to customizing CSS outputs.
Below are the steps to customize your Logo and Header Text:
Custom styling can be applied via modification of the CSS structure being used by Jenkins.
Simple Theme Plugin is the most popular approach to customizing CSS outputs.
Below are the steps to customize your Logo and Header Text:
- Install Simple Theme Plugin
- Go to the <JENKINS_HOME>/userContent directory in your jenkins host machine.
- Create the layout directory
- Create the style.css file, copy the contents provided below.
- Customize the “Sample Project” text
- Put the logo of your instance to <JENKINS_HOME>/userContent/layout/logo.png. The logo should have 40px height.
- Go to the global configuration of your CJP instance and find the Theme section there (Manage Jenkins--> Configure System)
- In URL of Theme CSS specify the following path: <JENKINS_HOME>/userContent/layout/logo.png eg:http://localhost:8080/userContent/layout/logo.png
Below is the css code to be used. Make sure you make the required changes as mentioned above.
/* Custom style for Autobahn Jenkins Platform */ .logo img { content:url("<JENKINS_HOME>/userContent/layout/logo.jpg"); /*change the path to your logo path*/ } #jenkins-name-icon { display: none; } .logo:after { content: 'Sample Project'; font-weight: bold; font-size: 40px; font-family:"Brush Script MT", cursive; margin-left: 200px; margin-right: 12px; color: Aqua; line-height: 40px; } |
Sunday, 7 January 2018
Collections In-depth : Part 2: How Hash Map works internally?
HashMap works on the principle of Hashing. To understand Hashing, we should understand three terms.They are Hash Function , Hash Value and Bucket.
Hash Function , Hash Value and Bucket:
When we try to add any value to the hashmap, Java internally calls this hashfunction in order to get unique integer value. This function generates the unique integer value based on the key that we pass. That Value is called as hash value. In java, every object has a method "public int hashcode()" which returns a hash value for a given object.
A bucket is used to store key value pairs. A bucket can have multiple key-value pairs. In hash map, bucket uses simple linked list to store objects.
When we create a hash map, it creates array of nodes. Each node contains hash code, key, value and next node's reference as shown in the above picture.
Lets jump into its internal working mechanism. We will start will PUT.
PUT Functionality:
Lets consider we are storing the below values into hash map using PUT functionality.
marks.put("Ram", 100); marks.put("Ravi", 89); marks.put("Rajesh", 70); marks.put("Ramesh", 99); |
As we discussed earlier the hash map comprises of the table. The initial size of the table would be 0-15 slots.
Now lets see how we can fit our values into this table.
When we add "marks.put("Ram", 100);" entry to the map, Java internally calls hash function in order to get hashcode.
put(K k,V v)
hash(k)
index=hash&(n-1) |
In our case, hash code will be calculated for "Ram" which is our key. Based on the returned hash code, index will be calculated as shown in the above method. Lets consider index as 4. So, our key value pair will be stored in that table as a node with key, value, hash code and next node reference. If you observe here, our next node reference is null. We will discuss about it later.
Lets consider that index for the next entry is 3 and stored as shown in below.
For now all the entries has unique hash code and unique index value. What will happen, if hash() function returns the same value for two different entries. We call this scenario as hash collision.
Lets see, how hash map deals this situation.
For that consider, 3rd entry in our map has got the same hashcode and index as our first entry. In this case, our new entry would also be stored in index 4, but as a linked list of node as shown below.
As you see in the above picture, first entry got the reference of 3rd entry as its next node. So, when there is a collision in hash code, those entries would be stored as linked list of nodes. This is how we avoid hash collision.
Note: In Java hash map allows null keys and it is always stored index 0 as hash of null is 0.
GET Functionality:
V get(Object key)
hash(key)
index=hash&(n-1) |
For GET functionality also, java performs the same kind of operations.
Lets get the first entry in our hash map. When we try to get the value for "Ram" (which is the key for our first entry), it finds the hash of the key, and will compute the index. It returns the index 4. Now will look up index 4 in the table. We have an entry there. At this point, it compares the hashcode returned in our GET functionality and the hashcode stored in that node. Both will match. After this, it also compares the Key that we are sending for GET functionality and Key stored in our node by using equals() method. Both will match. So, it returns the value 100 which is stored in the node.
Now lets try to get our 3rd entry value which is little complicated. When we pass "Rajesh"(our 3rd entry's key), it calculates both the hash code and index returned as 4. We will go to index 4. The first node in index 4 is "Ram". It will try to compare both the hashcode and key of the node. They will not match. But by using the reference of the next node, it will go to next node and try to compare both hashcode and key. So, it returns value 70, which is stored in the second node of that index.
The hashmap implementation provides constant time performance for (get and put) basic operations i.e the complexity of get() and put() is O(1) , assuming the hash function disperses the elements properly among the buckets.
Wednesday, 27 December 2017
Collections In-depth : Part 1: How HashSet works internally
As we know that a set is a well-defined collection of distinct objects. Each member of a set is called an element of the set. So in other words, we can say that a set will never contain duplicate elements.
How HashSet Works internally:
Each and every element in the set is unique. So that there are no duplicate elements in set.
In java if we want to add elements in the set then we write code like this:
public class SeleniumOcean{
public static void main(String[] args)
{
HashSet<Object> hashset = new HashSet<Object>();
hashset.add(3);
hashset.add("India");
hashset.add("US");
System.out.println("Set is: "+hashset);
}
}
It will print the result : Set is: [3, India, US]
Now lets add duplicate element in the above code
public class SeleniumOcean{
public static void main(String[] args)
{
HashSet<Object> hashset = new HashSet<Object>();
hashset.add(3);
hashset.add("India");
hashset.add("US");
hashset.add(3); // duplicate elements
hashset.add("India"); // duplicate elements
System.out.println("Set is: "+hashset);
}
}
It will print the result : Set is: [3, India, US]
When we add duplicate elements in the add() method of the Set object, it returns false and do not add to the HashSet , as the element is already present. You may be thinking how does hashset returns false and do not add.
All the classes of Set interface internally backed up by Map. HashSet uses HashMap for storing its object internally. You must be wondering that to enter a value in HashMap we need a key-value pair, but in HashSet we are passing only one value.
When you open the HashSet implementation of the add() method in Java Apis that is rt.jar, you will find the following code in it:
public class HashSet<E>
extends AbstractSet<E>
implements Set<E>, Cloneable, java.io.Serializable
{
private transient HashMap<E,Object> map;
// Dummy value to associate with an Object in the backing Map
private static final Object PRESENT = new Object();
public HashSet() {
map = new HashMap<>();
}
// SOME CODE ,i.e Other methods in Hash Set
public boolean add(E e) {
return map.put(e, PRESENT)==null;
}
// SOME CODE ,i.e Other methods in Hash Set
}
So, we are achieving this uniqueness in Set through HashMap. Whenever you create an object of HashSet, it will create an object of HashMap as you can see in the in the above code.
We know that in HashMap each key is unique. So what we do in the set is that we pass the argument in the add(Elemene E) that is E as a key to HashMap. Now we need to associate some value to the key. Set implementation internally passes the Dummy value that is ( new Object () ) which is referred by Object reference PRESENT.
When you are adding a line in HashSet like hashset.add(3), java internally puts that element 3 as a key in the HashMap(created during HashSet object creation) and some dummy value that is PRESENT object is passed as a value to the key.
In HashMap internal implementation (we will see this implementation in our next post), when we try to use put(Key, Value) method with the already existing value, map returns previous value associated with key. And if we try to use put(Key, Value) method with new value, map returns null value.
1. If map.put(key, value) returns null, then the statement “map.put(e, PRESENT) == null” will return true and element is added to the HashSet(internally HashMap).
2. If map.put(key, value) returns old value of the key, then the statement “map.put(e, PRESENT) == null” will return false and element is not added to the HashSet(internally HashMap).
Thursday, 16 November 2017
Automating Accessibility scanning with selenium
Are you fed up with manually verifying accessibility audit? You don't have much time to do accessibility audit and you still don't want to compromise on it?
Automating the accessibility audit would solve your problems. Automating accessibility testing is not only about making it easier for those with disabilities to access your site and app, but also optimizing your overall accessibility testing efforts, in order to support speedy product delivery without sacrificing software quality.
I have developed a tool with the help of 2 most frequently used tools in the industry called GoogleChrome accessibility-developer-tools and aXe-core to automate accessibility auditing. It provides PDF report with comprehensive auditing results. It also gives the reference URLs for the users to follow the best practices.
Below is the repo Link:
https://github.com/nainappa/aXe-chrome-accessibility
Automating the accessibility audit would solve your problems. Automating accessibility testing is not only about making it easier for those with disabilities to access your site and app, but also optimizing your overall accessibility testing efforts, in order to support speedy product delivery without sacrificing software quality.
I have developed a tool with the help of 2 most frequently used tools in the industry called GoogleChrome accessibility-developer-tools and aXe-core to automate accessibility auditing. It provides PDF report with comprehensive auditing results. It also gives the reference URLs for the users to follow the best practices.
Below is the repo Link:
https://github.com/nainappa/aXe-chrome-accessibility
Saturday, 5 August 2017
AWS Messaging Utilities Repo
Amazon Web Services offers a broad set of global cloud-based products including compute, storage, databases, analytics, networking, mobile, developer tools, management tools, IoT, security and enterprise applications. These services help organizations move faster, lower IT costs, and scale. AWS is trusted by the largest enterprises and the hottest start-ups to power a wide variety of workloads including: web and mobile applications, game development, data processing and warehousing, storage, archive, and many others.
Now a days so many companies started using these AWS components as part of their systems. I have written a repo with the some frequently used and most essential utilities for 3 most important AWS Messaging components namingly SQS, SNS, DynamoDB.
I hope these will be useful for the people who are working with AWS Messaging products.
Below is the repo link:
Friday, 19 May 2017
Test Execution Report implementation Using JUnit Listeners
We all know that JUnit doesn't provide any execution report apart from what we get in the editor. Many of us even doesn't know that JUnit has listeners. I have attempted to implement a light weight reporting using HTML. Below is the repo link.
This implementation not only tells you about how to implement reporting, but also tells you JUnit listener implementation, how to attach the listener to the test classes, how to group the test cases to run together etc.
After importing the repo, read the README, which has more information about it's implementation.
Subscribe to:
Posts (Atom)