April 27, 2017

Vinod Khanna dies at 70, was suffering from bladder cancer

Veteran actor Vinod Khanna, who was suffering from cancer, passed away on Thursday morning at Mumbai's HN Reliance Hospital.

BARC Ratings (Impressions)- Week 16, 2017

Maven Interview Questions And Answers

What is Maven?
Apache Maven is an advanced build tool to support the developer at the whole process of a software project. Maven allows the developer to automate the process of the creation of the initial folder structure for the Java application, performing the compilation, testing, packaging and deployment of the final product.

Since Maven is implemented in Java which makes it platform-independent.

Common activities we perform while developing an application:
  1. Multiple Jars: if you are using couple of frameworks like (Spring or Hibernate etc) in your application, then you need to include all the required jars.
  2. Dependencies: When you are adding multiple jars, you might face a issue where one jar is dependent on another jar, which in turn depend on some other jar. You need to make sure, you have added matching versions of jars.
  3. Setting Project Structure:  We need to set proper project structure.
  4. Building, deploying and publishing.

Maven helps us in these 4 activities, it has very elegant solution for each activity.

What are the key features of Maven?
  • Convention over configuration: Maven tries to avoid as much configuration as possible, by choosing real world default values and supplying project templates (archtypes).
  • Dependency management: It is possible to define dependencies to other projects. During the build, the Maven build system resolves the dependencies and it also builds the dependent projects if needed.
  • Repository: Project dependencies can be loaded from the local file system, from the Internet or public repositories. The company behind the Maven project also provides a central repository called Maven Central.
  • Extensible via plug-ins: The Maven build system is extensible via plug-ins, which allows to keep the Maven core small. The Maven core does for example not know how to compile Java source code, this is handled by the compiler plug-in.
What is Maven Repository?
A maven repository is a directory of packaged JAR file with pom.xml file. Maven searches for dependencies in the repositories. There are 3 types of maven repository: Local, Central, and Remote.

Maven searches for the dependencies in the following order: Local repository then Central repository then Remote repository. If dependency is not found in these repositories, maven stops processing and throws an error.

  • Maven local repository is located in your local system. It is created by the maven when you run any maven command. By default, maven local repository is %USER_HOME%/.m2 directory.
  • Maven central repository is located on the web. It has been created by the apache maven community itself. The path of central repository is: http://repo1.maven.org/maven2/. The central repository contains a lot of common libraries that can be viewed by this url http://search.maven.org/#browse.
  • Maven remote repository is located on the web. Most of libraries can be missing from the central repository such as JBoss library etc, so we need to define remote repository in pom.xml file. e.g:
< dependencies >  
    < dependency >  
      < groupId > junit< /groupId >  
      < artifactId > junit< /artifactId >  
      < version > 4.8.2< /version >  
      < scope > test< /scope >  
    < /dependency >  
< /dependencies >  


Can you change the location of Maven Local Repository?
Yes, we can change the location of maven local repository by changing the settings.xml file, which is located in MAVEN_HOME/conf/settings.xml.
< settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"  
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
   xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd" >  
  < !-- localRepository 
   | The path to the local repository maven will use to store artifacts. 
   | 
   | Default: ${user.home}/.m2/repository 
  < localRepository > /path/to/local/repo< /localRepository >  
  -- >  
 
... 
< /settings >  


If you want to change the Local Repository location to mavenlocalrepo folder in D drive then change the value in localRepository tag:
< localRepository > d:/mavenlocalrepo< /localRepository >   
What is Maven Central?
Maven Central is an open repository provided by the company Sonatype. This repository hosts libraries which can be used in your build. By default, a Maven build uses Maven Central to search for required libraries.

How can you download and install Maven?
If you are planning to use Maven only from within the Eclipse IDE, this installation is not required.

Else, download the maven from http://maven.apache.org/download.cgi

After downloading, extract the downloaded distribution to a selected folder on your computer. Add a new environment variable M2_HOME pointing to this directory and add M2_HOME/bin to the PATH variable.

To validate whether Maven is installed correctly , open a console and run the following command:
mvn -version

If you get the output then Maven is installed.

How can you build a Maven project via the command line?
To build the project you need to run 'mvn' command from the command line. This command need to be executed in the directory which contains the relevant pom file. You need to provide the mvn command with the life cycle phase or goal to execute.

The Maven tooling reads the pom file and resolves the dependencies of the project. Maven validates if required components are available in a local repository (which is found in the .m2/repository folder of the users home directory). If the dependency is not available in the build reactor or the local repo, Maven downloads the depended artifacts from the central repository or the specified ones into the local repository.

Maven executes all life cycle phases until the specified one. e.g, the 'mvn clean install' command triggers the jar packaging. This includes compiling the sources, executing the tests and packaging the compiled files in a JAR file. As last step the install phase installs the resulting artifact into the local repository, so it can be used as dependencies by other Maven builds.

Maven creates the build result in the target folder.

'mvn install' will compile, build and install the build result. 

To ensure that the build target is removed before a new build, add the clean target. run 'mvn clean install' command.

By default, Maven checks online if the dependencies have been changed. If you want to use your local repository, you can use the -o to tell Maven to work offline. To do this run, 'mvn -o clean install' command.

In how many ways, you can deal with build failure?
If you are running a complex multi-module project build, you can define how the Maven build system should react to errors in one module.
  • -fae, --fail-at-end - fails the build after all modules are build; allow all non-impacted builds to continue
  • -ff, --fail-fast - Stop at first module build failure
  • -fn, --fail-never - NEVER fail the build, regardless of module build result

The -fn and -fae options are useful to verify builds that are running within a continuous integration tool like Jenkins and to see all errors in the build

What is Maven Wrapper?
When building with Maven the same input should always result in the same output. To ensure this on different machines, every machine has to have the same version of Maven. Having the same version on different machines is bit difficult sometimes, when different projects require different versions of Maven. To overcome this issue Maven Wrapper is specified for Maven projects.

The Maven Wrapper allows to run a Wrapper, which wraps a specified version of Maven for a projects build. When having a Maven Wrapper for a project there is no need to install a certain version of Maven on a machine. Only for the inital creation of the Maven Wrapper files a local Maven installation is necessary.

How can we create a Maven Wrapper?

To create a Maven Wrapper for a project with the latest available Maven version.

C:\...project directory > mvn -N io.takari:maven:wrapper

Create a Maven Wrapper for a project with a specified Maven version by using the maven property.

C:\...project directory > mvn -N io.takari:maven:wrapper -Dmaven=3.3.0

What are the aspects does Maven Manages?
 Maven handles following activities of a developer
• Build
• Documentation
• Reporting
• Dependencies
• SCMs
• Releases
• Distribution
• Mailing list

Mention the three build lifecycle of Maven?
Clean
: Cleans up artifacts that are created by prior builds
Default (build): Used to create the application
Site: For the project generates site documentation

Explain what is POM?

In Maven, POM (Project Object Model) is the fundamental unit of work. It is an XML file which holds the information about the project and configuration details used to build a project by Maven. Maven reads the pom.xml file, then executes the goal.

Before maven 2, it was named as project.xml file. But, since maven 2, it is renamed as pom.xml.

What are the elements of maven pom.xml file?

  • project:It is the root element of pom.xml file.
  • modelVersion:It is the sub element of project. It specifies the modelVersion. It should be set to 4.0.0.
  • groupId:It is the sub element of project. It specifies the id for the project group.
  • artifactId:It is the sub element of project. It specifies the id for the artifact (project). An artifact is something that is either produced or used by a project. Examples of artifacts produced by Maven for a project include: JARs, source and binary distributions, and WARs.
  • version:It is the sub element of project. It specifies the version of the artifact under given group.
  • packaging:defines packaging type such as jar, war etc.
  • name:defines name of the maven project.
  • url:defines url of the project.
  • dependencies:defines dependencies for this project.
  • dependency:defines a dependency. It is used inside dependencies.
  • scope:defines scope for this maven project. It can be compile, provided, runtime, test and system.
Explain what is Maven artifact? 
Usually an artifact is a JAR file which gets arrayed to a Maven repository. One or more artifacts a maven build produces such as compiled JAR and a sources JAR. Each artifact includes a group ID, an artifact ID and a version string.

Why Maven Plugins are used?

Maven plugins are used to
• Create a jar file
• Create war file
• Compile code files
• Unit testing of code
• Documenting projects
• Reporting

List out the dependency scope in Maven?

 The various dependency scope used in Maven are:
• Compile: It is the default scope, and it indicates what dependency is available in the classpath of the project
• Provided: It indicates that the dependency is provided by JDK or web server or container at runtime
• Runtime: This tells that the dependency is not needed for compilation but is required during execution
• Test: It says dependency is available only for the test compilation and execution phases
• System: It indicates you have to provide the system path
• Import: This indicates that the identified or specified POM should be replaced with the dependencies in that POM’s section.

Mention how profiles are specified in Maven?
Profiles are specified in Maven by using a subset of the elements existing in the POM itself.

Explain how you can exclude dependency?
By using the exclusion element, dependency can be excluded

Mention the difference between Apache Ant and Maven? 
  • Ant doesn't has formal conventions, so we need to provide information of the project structure in build.xml file. Maven has a convention to place source code, compiled code etc. So we don't need to provide information about the project structure in pom.xml file.
  • Ant is procedural, you need to provide information about what to do and when to do through code. You need to provide order.    Maven is declarative, everything you define in the pom.xml file.
  • There is no life cycle in Ant.  There is life cycle in Maven.
  • Ant is a tool box, whereas Maven is a framework.
  • Ant is mainly a build tool, whereas Maven is mainly a project management tool.
  • The ant scripts are not reusable. The maven plugins are reusable.

List out what are the build phases in Maven?
Build phases in Maven are
• Validate
• Compile
• Test
• Package
• Install
• Deploy

Explain what would the “jar: jar” goal do?

jar: jar will not recompile sources; it will imply just create a JAR from the target/classes directory considering that everything else has been done.

For POM what are the minimum required elements?
The minimum required elements for POM are project root, modelVersion, groupID, artifactID and version

How to build the maven project or how to package maven project?
The mvn package command completes the build life cycle of the maven project.

A Maven build lifecycle is made up of phases. Each of these build lifecycles is defined by a different list of build phases, wherein a build phase represents a stage in the lifecycle. The default lifecycle comprises of the following phases:
  • validate - validate the project is correct and all necessary information is available
  • compile - compile the source code of the project
  • test - test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
  • package - take the compiled code and package it in its distributable format, such as a JAR.
  • verify - run any checks on results of integration tests to ensure quality criteria are met
  • install - install the package into the local repository, for use as a dependency in other projects locally
  • deploy - done in the build environment, copies the final package to the remote repository for sharing with other developers and projects. 
-K Himaanshu Shuklaa..

April 26, 2017

I am a confused orthodox person : Krishnamachari Srikkanth

Former India captain Krishnamachari Srikkanth, a veteran in the sport, revealed that while cricketers such as Sandeep Patil and himself may not go down in history as legends, they will be remembered for the entertainers that they were, on and off field. Srikkanth, who is the mentor for Sunrisers Hyderabad this IPL season, joined Sandeep on his show ‘Taste Match’ which airs on Living Foodz and &TV.

The duo had a candid conversation about the golden days of Indian cricket and Srikkanth confessed that he has always been superstitious. The exuberant batsman has a superstition with the number 9 and he would even chant shlokas on the field. However, being an electrical engineer, Srikkanth leveraged his analytical abilities to calculate risk perfectly and take shots that always paid off! Laughing about this fusion Srikkanth said, “I am a confused orthodox person.”

April 25, 2017

Esha Gupta looked gorgeous at the Cama Awards!

Be it attending a formal event, or a dinner, Esha Gupta’s outfits have always been on point! Esha attended the Cama Awards in Ahmedabad recently and amazed everyone with what she wore!

Whoopie! Evelyn Sharma gets 3 million hits and a piano!!



Evelyn Sharma is on cloud nine. Her music video Party Nonstop with Kangna singer-music producer Dr Zeus along with Punjabi singer Jasmine Sandlas (of Kick's Yaar Na Mila fame) and rapper Ikka (of High Heels fame), has crossed three million hits on YouTube within just about three days.

Manisha Koirala gets nostalgic about R.D.Burman

The charismatic Manisha Koirala, who was Anil Kapoor's love and obsession in the memorable song 'Ek Ladki Ko Dekha Toh Aisa Laga' from the illustrious R.D.Burman's last movie 1942: A Love Story, seemed nostalgic about the composer this week. Manisha was delighted when at a recent event, senior award-winning journalist Chaitanya Padukone presented her a copy of his authored book R.D.BurMania.

“What a musical masterpiece genius Panchamda came up with. Even today, his amazing melodies soothe the heart,"
said Manisha, who is playing the legendary Nargis Dutt in the biopic on Sanjay Dutt, being directed by Rajkumar Hirani.

April 24, 2017

All about JUnit..

What is JUnit and Unit Test Case?
JUnit is a testing framework for unit testing. It uses Java as a programming platform, and it is an Open Source Software managed by the JUnit.org community.

Unit Test Case is a part of the code that ensures that the another part of code (method) behaves as expected. For each requirement, there must be at least two test cases one negative test and one positive test.

First JUnit test case:

1). Create a java class file name TestJunit, which has a method testName(). This method will compare whether 'name' is valid or not

import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class TestJunit {
   @Test   
   public void testName() {
      String name = "Name is K Himaanshu Shuklaa";
      assertEquals("Name is K Himaanshu Shuklaa",name);
   }
}


2). Create a java class file name TestRunner.
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;

public class TestRunner {
   public static void main(String[] args) {
      Result result = JUnitCore.runClasses(TestJunit.class);       
      for (Failure failure : result.getFailures()) {
         System.out.println("failure result="+failure.toString());
      }       
      System.out.println("is test successful? "+result.wasSuccessful());
   }
}


When you run TestRunner, it will call testName() method of TestJunit. If the 'name' is equal to the value passed in assertEquals, then output will be:
"is test successful? true"

But suppose, the value of 'name' variable is 'Name is Tiger Shroff', then output will be :
failure result=testName(com.junit.TestJunit): expected: < Name is [K Himaanshu Shuklaa] > but was: < Name is [Tiger Shroff] >
is test successful? false


Features of JUnit Test Framework : JUnit test framework provides the following important features :-

1). Fixture : A test fixture is a fixed state in code which is tested used as input for a test. Another way to describe this is a test precondition. For example, a test fixture might be a a fixed string, which is used as input for a method. The test would validate if the method behaves correctly with this input

It includes :
  • setUp() method, which runs before every test invocation.
  • tearDown() method, which runs after every test method.

e.g: Let us make some changes in TestJunit, we need to extend TestCase class and add two methods setUp() and tearDown().
import junit.framework.TestCase;
import org.junit.Test;
public class TestJunit extends TestCase{
    protected String name;
    protected void setUp() {
        System.out.println("Inside setUp()");
        name = "Name is Tiger Shroff";
    }
    protected void tearDown() {
        System.out.println("Inside tearDown()");
    }
    @Test
    public void testName() {
        System.out.println("Inside testName()");
        assertEquals("Name is K Himaanshu Shuklaa", name);
    }
}


Now when you run TestRunner, it will give an output (test is failed because the 'name' is nt equal to the value passed in assertEquals):
Inside setUp()
Inside testName()
Inside tearDown()
failure result=testName(com.junit.TestJunit): expected: < Name is [K Himaanshu Shuklaa]> but was: < Name is [Tiger Shroff] >
is test successful? false


2). Test Suites : If you have several test classes, you can combine them into a test suite. Running a test suite executes all test classes in that suite in the specified order. A test suite can also contain other test suites.

In JUnit, both @RunWith and @Suite annotation are used to run the suite test. Given below is an example that uses TestJunit1 & TestJunit2 test classes.

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({
                TestJunit1.class,
                TestJunit2.class })

public class TestRunner {

}

3). Test Runners : It is used for executing the test cases.
4). JUnit Classes : They are important classes, used in writing and testing JUnits. Some of the important classes are −
  • Assert − Contains a set of assert methods.
  • TestCase − Contains a test case that defines the fixture to run multiple tests.
  • TestResult − Contains methods to collect the results of executing a test case.
junit.framework : Its the most important package in JUnit because it contains all the core classes.
  • Assert : A set of assert methods.
  • TestCase : A test case defines the fixture to run multiple tests.
  • TestResult : A TestResult collects the results of executing a test case.
  • TestSuite : A TestSuite is a composite of tests.

Assert Class : It is present in org.junit package of junit.framework. Assert class provides a set of assertion methods useful for writing tests. Only failed assertions are recorded.

A few methods to assert test results (parameters in [] brackets are optional and of type String):
fail(message) : Let the method fail. Might be used to check that a certain part of the code is not reached or to have a failing test before the test code is implemented. The message parameter is optional.
  • assertTrue([message,] boolean condition) : Checks that the boolean condition is true.
  • assertFalse([message,] boolean condition) : Checks that the boolean condition is false.
  • assertEquals([message,] expected, actual) : Tests that two values are the same. Note: for arrays the reference is checked not the content of the arrays.
  • assertEquals([message,] expected, actual, tolerance) : Test that float or double values match. The tolerance is the number of decimals which must be the same.
  • assertNull([message,] object) : Checks that the object is null.
  • assertNotNull([message,] object) : Checks that the object is not null.
  • assertSame([message,] expected, actual) : Checks that both variables refer to the same object.
  • assertNotSame([message,] expected, actual) : Checks that both variables refer to different objects

TestCase Class : It is present in org.junit package of junit.framework, this class extends Assert and implements Test interface. Some of the important methods of TestCase class are :
  • int countTestCases() Counts the number of test cases executed by run(TestResult result).
  • TestResult createResult() Creates a default TestResult object.
  • String getName() Gets the name of a TestCase.
  • TestResult run() A convenience method to run this test, collecting the results with a default TestResult object.
  • void run(TestResult result) Runs the test case and collects the results in TestResult.
  • void setName(String name) Sets the name of a TestCase.
  • void setUp() Sets up the fixture, for example, open a network connection.
  • void tearDown() Tears down the fixture, for example, close a network connection.
  • String toString() Returns a string representation of the test case.

TestResult Class : It is present in org.junit package of junit.framework. A TestResult collects the results of executing a test case. It is an instance of the Collecting Parameter pattern. The test framework distinguishes between failures and errors. A failure is anticipated and checked for with assertions. Errors are unanticipated problems like an ArrayIndexOutOfBoundsException. Some of the important methods of TestResult class are :
  • void addError(Test test, Throwable t) Adds an error to the list of errors.
  • void addFailure(Test test, AssertionFailedError t) Adds a failure to the list of failures.
  • void endTest(Test test) Informs the result that a test was completed.
  • int errorCount() Gets the number of detected errors.
  • Enumeration errors() Returns an Enumeration for the errors.
  • int failureCount() Gets the number of detected failures.
  • void run(TestCase test) Runs a TestCase.
  • int runCount() Gets the number of run tests.
  • void startTest(Test test) Informs the result that a test will be started.
  • void stop() Marks that the test run should stop.
What is the difference between errors and failures?
failures occurs when your test cases fail,  i.e. your assertions are incorrect. Errors are unexpected errors that occur while trying to actually run the test - exceptions, etc.

TestSuite : It is a Composite of tests. It runs a collection of test cases. Some of the important methods of TestSuite class are:
  • void addTest(Test test) Adds a test to the suite.
  • void addTestSuite(Class testClass) Adds the tests from the given class to the suite.
  • int countTestCases() Counts the number of test cases that will be run by this test.
  • String getName() Returns the name of the suite.
  • void run(TestResult result) Runs the tests and collects their result in a TestResult.
  • void setName(String name) Sets the name of the suite.
  • Test testAt(int index) Returns the test at the given index.
  • int testCount() Returns the number of tests in this suite.
  • static Test warning(String message) Returns a test which will fail and log a warning message.
Assertion in JUnit
All the assertions are declared inside Assert class. This class provides a set of assertion methods, useful for writing tests. Only failed assertions are recorded. Some of the important methods of Assert class are:
  • void assertEquals(boolean expected, boolean actual) : Checks that two primitives/objects are equal.
  • void assertTrue(boolean expected, boolean actual) : Checks that a condition is true.
  • void assertFalse(boolean condition) : Checks that a condition is false.
  • void assertNotNull(Object object) : Checks that an object isn't null.
  • void assertNull(Object object) : Checks that an object is null.
  • void assertSame(boolean condition) : The assertSame() method tests if two object references point to the same object.
  • void assertNotSame(boolean condition) : The assertNotSame() method tests if two object references do not point to the same object.
  • void assertArrayEquals(expectedArray, resultArray): It  will test whether two arrays are equal to each other.
Annotation in JUnit:
  • @Test : The Test annotation tells JUnit that the public void method to which it is attached can be run as a test case.
  • @Before : Several tests need similar objects created before they can run. Annotating a public void method with @Before causes that method to be run before each Test method.
  • @After : If you allocate external resources in a Before method, you need to release them after the test runs. Annotating a public void method with @After causes that method to be run after the Test method.
  • @BeforeClass : Annotating a public static void method with @BeforeClass causes it to be run once before any of the test methods in the class.
  • @AfterClass : This will perform the method after all tests have finished. This can be used to perform clean-up activities.
  • @Ignore : The Ignore annotation is used to ignore the test and that test will not be executed.
Call sequence:
  • First of all, the beforeClass() method executes only once.
  • The afterClass() method executes only once.
  • The before() method executes for each test case, but before executing the test case.
  • The after() method executes for each test case, but after the execution of test case.
  • In between before() and after(), each test case executes.
Ignore Test: Sometimes it so happens that our code is not completely ready while running a test case. As a result, the test case fails. The @Ignore annotation helps in this scenario.
A test method annotated with @Ignore will not be executed.
If a test class is annotated with @Ignore, then none of its test methods will be executed.

Time Test: If a test case takes more time than the specified number of milliseconds, then JUnit will automatically mark it as failed. The timeout parameter is used along with @Test annotation.

e.g: if testName() takes more than 1000 milliseconds, then JUnit will mark it as failed.

@Test(timeout = 1000)  
public void testName() {
   String name = "Name is K Himaanshu Shuklaa";
   assertEquals("Name is K Himaanshu Shuklaa",name);
}


Exceptions Test: JUnit provides an option of tracing the exception handling of code. You can test whether the code throws a desired exception or not. The expected parameter is used along with @Test annotation

@Test(expected = ArithmeticException.class)
public void testName() {
   String name = "Name is K Himaanshu Shuklaa";
   assertEquals("Name is K Himaanshu Shuklaa",name);
}

Parameterized Test: It is introduced in JUnit 4. Parameterized tests allow a developer to run the same test over and over again using different values.

There are five steps that we need to follow to create a parameterized test:
  1. Annotate test class with @RunWith(Parameterized.class).
  2. Create a public static method annotated with @Parameters that returns a Collection of Objects (as Array) as test data set.
  3. Create a public constructor that takes in what is equivalent to one "row" of test data.
  4. Create an instance variable for each "column" of test data.
  5. Create your test case(s) using the instance variables as the source of the test data.

1).
public class PrimeNumberChecker {
    public Boolean validate(final Integer primeNumber) {
        for (int i = 2; i < (primeNumber / 2); i++) {
            if (primeNumber % i == 0) {
                return false;
            }
        }
        return true;
    }
}


2).
import java.util.Arrays;
import java.util.Collection;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import static org.junit.Assert.assertEquals;
@RunWith(Parameterized.class)
public class PrimeNumberCheckerTest {

    private Integer inputNumber;
    private Boolean expectedResult;
    private PrimeNumberChecker primeNumberChecker;
   
    @Before
    public void initilize()
    {
        primeNumberChecker=new PrimeNumberChecker();
    }
//public PrimeNumberCheckerTest(){}
    public PrimeNumberCheckerTest(Integer inputNumber, Boolean expectedResult) {
        this.inputNumber = inputNumber;
        this.expectedResult = expectedResult;
    }
     @Parameterized.Parameters
    public static Collection primeNumbers() {
        return Arrays.asList(new Object[][] {
                { 2, true }, { 6, false },
                { 8, true }, { 22, false },
                { 23, true } });
    }   
    @Test
    public void testPrimeNumberChecker() {
        System.out.println("Parameterized Number is : " + inputNumber);
        assertEquals(expectedResult, primeNumberChecker.validate(inputNumber));
    }
}


3).
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;

public class TestRunner {
   public static void main(String[] args) {
      Result result = JUnitCore.runClasses(PrimeNumberCheckerTest.class);

      for (Failure failure : result.getFailures()) {
         System.out.println("***Inside TestRunner: failure result="+failure.toString());
      }
       
      System.out.println("***Inside TestRunner: is test successful?"+result.wasSuccessful());
   }
}

Output of TestRunner:
Parameterized Number is : 2
Parameterized Number is : 6
Parameterized Number is : 8
Parameterized Number is : 22
Parameterized Number is : 23
***Inside TestRunner: failure result=expected: but was:
***Inside TestRunner: is test successful?false



If you do not mention @RunWith(Parameterized.class) in PrimeNumberCheckerTest, then below exception will be thrown:
***Inside TestRunner: failure result=initializationError(com.parameter.PrimeNumberCheckerTest): Test class should have exactly one public zero-argument constructor

If you mention @RunWith(Parameterized.class), but forgot to add @Parameterized.Parameters in primeNumber() method of PrimeNumberCheckerTest, then below exception will occur
***Inside TestRunner: failure result=initializationError(com.parameter.PrimeNumberCheckerTest): No public static parameters method on class com.parameter.PrimeNumberCheckerTest


-K Himaanshu Shuklaa..

Ek Shringaar-Swabhiman actress Sangeita Chauhaan’s husband missing since Thursday

Ek Shringaar-Swabhiman actress Sangeita Chauhaan with her husband Chirag Shah
Television actress Sangeita Chauhaan's husband Chirag Shah, has been reportedly missing from the last few days.

April 21, 2017

Did you know Urvashi Dholakia was given an ultimatum to lose weight by producers?

Urvashi Dholakia, who played the iconic role of Komolika Basu in 'Kasautii Zindagii Kay' was recently subjected to body shaming. The pretty actress, met her friend and out of no context, he told her that she looked beautiful, but she needed to lose some weight. Miffed by this incident Urvashi vented out her emotions on social networking sites. She wrote, "I hate the thought of size zero. I love myself just the way I am! Be it healthy or healthier."

April 18, 2017

A street named after Diana Penty's ancestors!

Did you know that a street named ‘Penty Naka’ in Jabalpur, Madhya Pradesh is named after actress Diana Penty’s ancestors?

Diana, who is currently shooting for her upcoming film Lucknow Central, has a street named after her great grandfather, Maneck S. Penty. And since Diana comes from a family of food lovers, it's only fitting that Penty Naka is an area known for its street food!

Lisa Ray all set to be seen in Dobaara: See Your Evil

The incredibly gorgeous Lisa Ray who owns our hearts with her talent, gumption and her spirit is all set to take on the silver screen again - this time with Prawaal Raman's Dobaara: See Your Evil. Releasing on May 19, Lisa will be part of a four character based human drama with an edge of horror co-starring Huma Qureshi, Saqib Saleem and Adil Hussain.

April 17, 2017

April 12, 2017

Baahubali 2: The Conclusion exclusive IMAX Poster unveiled

The much awaited movie Baahubali 2: The Conclusion is all set to release this April. Ahead of its release, the movie’s exclusive poster in the IMAX format was launched today at INOX, R-City Mall Ghatkopar.

My association with Sony YAY! aims to bring happiness to all the young ones across the country : Tiger Shroff

Sony Pictures Networks India (SPN) today announced the launch of its much-awaited Kid’s Entertainment Channel – Sony YAY! that will go LIVE on 18th April 2017. Promising to be the ‘Destination for Unlimited Happiness’ for Kids, the channel has roped in the young cinestar, Tiger Shroff, who has become a phenomenon with kids across the country, as its brand ambassador.

#CristyLane - One Day At A Time, Sweet Jesus lyrics

I'm only human, I'm just a woman.
Help me believe in what I could be
And all that I am.
Show me the stairway, I have to climb.
Lord for my sake, teach me to take
One day at a time.

April 07, 2017

Sony YAY! signs Tiger Shroff as Brand Ambassador

Sony YAY!, soon to be launched Kids’ Entertainment Channel from Sony Pictures Network, has roped in the country's newest heartthrob Tiger Shroff as the brand ambassador and face of the channel. This would be the debut television association of the young star whose popularity amongst children is today unbounded.

April 06, 2017

BARC Ratings (Impressions)- Week 13, 2017

'Jigariyaa' actor Harsh Vardhan Deo to play the gangster in a short film!

Actor Harsh Vardhan Deo, who played the role of boy-next-door in his Bollywood debut with 'Jigariyaa' has literally gone through a 360-degree transformation. He will be seen as a ruthless gangster in the upcoming short film 'Neelofar'.

Vinod Khanna suffering from cancer?

Ailing Vinod Khanna with his second wife Kavita and son Saakshi
Dashing veteran Bollywood actor Vinod Khanna, who mesmerized the audience with his acting in films like Dostana, Parvarish, etc., was hospitalised to HN Reliance Foundation and Research Centre in Girgaon, Mumbai on Friday after he complained of discomfort. He is reportedly suffering from bladder cancer. However, son Rahul Khanna says that he was recuperating fast and will soon be out of the hospital.

April 05, 2017

Evelyn Sharma launches Evelyn's Secrets..

They say, beauty is skin deep,
For it the world weeps,
Evelyn now lets you peep,
Her secrets safe you can keep.


Evelyn Sharma wants to get personal with her fans; inside out. More personal than her interactions on social media. And for this direct connect, the actress and fashion philanthropist has come up with a unique idea. She has gone online with her secrets.

ALTBalaji set to take over Netflix and Amazon Prime Video!

Move over Netflix and Amazon Prime Video. Balaji Telefilms' and Ekta Kapoor's new digital entertainment app, ALTBalaji is taking aim at the biggest players in the digital streaming market. With an original content developed web series exclusively for the 300 million smart phone users in India, the app is all set to dethrone their competitors. After dominating and being the queen of Indian television, and even successful films, Ekta Kapoor's latest venture aims to capture the attention of the non-english speaking masses of the country as well.

Rakhi Sawant was having watermelons, not evading Police

While a team of Punjab Police’s Ludhiana unit was said to have come to Mumbai to arrest her this week, Rakhi Sawant was gallivanting all over Mumbai suburbs with Bollywood PR guru Dale Bhagwagar. The police were reported to be looking for the firebrand actress for her alleged derogatory comments on sage Valmiki, who authored the Ramayana.

"Contrary to reports, Rakhi Sawant has not been on the run or in hiding. Nor has she been evading anyone. She has not received any summons or warrant, and she has not been arrested. She has contacted the Police, though that does not imply 'surrender;' as the media has conveniently misconstrued. If the Police calls her, she will present herself before them," said Dale.

April 04, 2017

Tusshar and his son, Laksshya to miss Jeetendra's 75th birthday celebrations!

Tusshar Kapoor is known to be a doting and hands on father to his adorable son, Laksshya. He is even taking his son along for the month long Hyderabad schedule of Golmaal again. Due to this reason, Tusshar and Laksshya will have to miss Jeetendra's 75th birthday celebrations in Jaipur.

Streams in Java 8 interview questions and answers

What is a Java Stream?
A stream represents a sequence of elements and supports different kind of operations to perform computations upon those elements.

In a simple term, a stream is an iterator whose role is to accept a set of actions to apply on each of the elements it contains.
RSSChomp Blog Directory