Anand A. Parikh

Greenhorn
+ Follow
since May 12, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Anand A. Parikh

I changed the methods by removing println() and returning values from the methods. Now, I can write unit tests for the methods.

One question - can I use the Book class to call methods on a Book object OR
do I have to generate mock objects for Book class? (since it is external to Library class)

8 years ago
The assignment in the course was to implement the Library class so that it would execute main() (already provided).
So, I implemented it and it does execute main(). The course does not talk about writing unit tests, that was my own addition to the problem.
After implementing Library class, I did think it was not implemented such that one could write unit tests, hence my posting.
Thanks for clarifying this, I will try to refactor it so that I can write unit tests for it.

Thanks,
Anand
8 years ago
Hello,

I am learning unit testing by creating unit tests for the MIT Open Courseware course 6.092.

I have the following two classes. How can I unit test borrowBook(), printAvailableBooks() of Library?

borrowBook() has return type void and changes the status 'borrowed' of Book. I can unit test the case of 'successfully borrowing a book',
but how can I unit test cases of 'book already borrowed' or 'book not in catalog'?

printAvailableBooks() has return type void and it does not change any data.

Thanks,
Anand



8 years ago
I exported the web app as a .war file and started Tomcat independently (external to Eclipse IDE).
Now, the example works OK.

There is definitely a problem running Tomcat through Eclipse IDE.
8 years ago
I should have given more details in the reply.

I am still running Tomcat through Eclipse IDE. I have copied the jersey jars to the WEB-INF/lib folder and to the Java Build Path -> Libraries folder of the web app.
Yet I am getting the exception.
8 years ago

Hi Ulf,

I also copied all the jersey jars to the WEB-INF/lib folder.
I get the same error. What could be the problem?

Thanks,
Anand
8 years ago

I am having the same problem with another tutorial.

I am using Eclipse (STS 3.2), Tomcat 7.0.26, Jersey 1.17, JDK 1.6.

When Tomcat starts up I see the following error message:

Jul 25, 2013 7:53:02 AM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /de.vogella.jersey.first threw load() exception
java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer

The class in question is in jersey-servlet-1.17.jar and all the jersey jars are in the Java Build Path -> Libraries.

Can anyone tell me what the problem is and how to fix it?

Thanks,
Anand
8 years ago
Thanks Sumit and Tim.

Using PowerMock with EasyMock, I was able to mock static method Math.random() in test class and unit test roll().
Then I created a helper method mockRoll() in test class to enable me to unit test toString() and sum().

As Tim suggested, if I changed the diceArray to package or protected access, I could override roll() in test class and unit test it that way too.
8 years ago
Hello,

I have the following class where roll() generates random values of dice. All the other methods in the class depend on the values generated by roll(). How can I unit test the methods including roll() with JUnit, since the actual value is different each time roll() is called?

Thank you for helping,
Anand

8 years ago
I have this NB installation for quite some time and I have been updating it.
I have the platform\modules\ext\updater.jar in the NB installation...

Anyway, if I was to uninstall and reinstall, which one is the settings directory?
Is it the Userdir: C:\Users\aparikh\.netbeans\7.0?
Installation dir is C:\Program Files\NetBeans 7.0
My project dirs located under C:\NetBeans will be OK, right?

Thanks,
Anand
Hello All,

I am running:
Product Version: NetBeans IDE 7.0 (Build 201107282000)
Java: 1.6.0_23; Java HotSpot(TM) 64-Bit Server VM 19.0-b09
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
Userdir: C:\Users\aparikh\.netbeans\7.0

When I go to Tools->Plugins, 'Updates', 'Available Plugins', 'Installed' tabs are empty.
When I click the 'Reload Catalog' button, I get the following error message (lower right hand corner red icon):
java.lang.NoClassDefFoundError: org/netbeans/updater/XMLUtil
at org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogParser.newEntityResolver(AutoupdateCatalogParser.java:126)
at org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogParser.<init>(AutoupdateCatalogParser.java:95)
at org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogParser.getUpdateItems(AutoupdateCatalogParser.java:187)
at org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogProvider.getUpdateItems(AutoupdateCatalogProvider.java:126)
at org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogProvider.getDescription(AutoupdateCatalogProvider.java:104)
at org.netbeans.modules.autoupdate.services.UpdateUnitProviderImpl.getDescription(UpdateUnitProviderImpl.java:113)
at org.netbeans.api.autoupdate.UpdateUnitProvider.getDescription(UpdateUnitProvider.java:107)
at org.netbeans.modules.autoupdate.ui.actions.ShowNotifications.getMessage(ShowNotifications.java:89)
at org.netbeans.modules.autoupdate.ui.actions.ShowNotifications.checkNotification(ShowNotifications.java:76)
at org.netbeans.modules.autoupdate.ui.Utilities.showProviderNotification(Utilities.java:553)
at org.netbeans.modules.autoupdate.ui.Utilities.tryRefreshProviders(Utilities.java:571)
at org.netbeans.modules.autoupdate.ui.Utilities.doRefreshProviders(Utilities.java:548)
at org.netbeans.modules.autoupdate.ui.Utilities.presentRefreshProviders(Utilities.java:542)
at org.netbeans.modules.autoupdate.ui.UnitTab$13.run(UnitTab.java:761)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1424)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1968)

I don't see any solution on the internet.

Please help.

Thanks,
Anand
I have been reading the book 'Programming Interviews Exposed', 2nd Edition.

It is a good book to prepare for coding interviews. There are a lot of questions, explanation to solving the problems and answers in Java/C/C++/C#.

-Anand

--------------------------------------------------------------------------------------------------
The following is from the book description:

The pressure is on during the interview process but with the right preparation, you can walk away with your dream job. This classic book uncovers what interviews are really like at America's top software and computer companies and provides you with the tools to succeed in any situation. The authors take you step-by-step through new problems and complex brainteasers they were asked during recent technical interviews.

50 interview scenarios are presented along with in-depth analysis of the possible solutions. The problem-solving process is clearly illustrated so you'll be able to easily apply what you've learned during crunch time. You'll also find expert tips on what questions to ask, how to approach a problem, and how to recover if you become stuck. All of this will help you ace the interview and get the job you want.

What you will learn from this book

Tips for effectively completing the job application
Ways to prepare for the entire programming interview process
How to find the kind of programming job that fits you best
Strategies for choosing a solution and what your approach says about you
How to improve your interviewing skills so that you can respond to any question or situation
Techniques for solving knowledge-based problems, logic puzzles, and programming problems
9 years ago

Couple of books which have a good review on Amazon.com are:

Programming Interviews Exposed: Secrets to Landing Your Next Job, 2nd Edition (Programmer to Programmer) by John Mongan, Noah Suojanen and Eric Giguère (Paperback - Apr 30, 2007)

Cracking the Coding Interview: 150 Programming Questions and Solutions by Gayle Laakmann McDowell (Paperback - Aug 22, 2011)

Has anyone studied from these books?

Anand
9 years ago
Hello,

What books are out there to prepare for a SDET / SET (Sw Dev Engr in Test / Sw Engr in Test) job interview in US?

I have several years of job experience as a Sw Test Engr / QA Engr but I have not interviewed for quite some time.
I know the that the type of questions asked in an interview has changed. There are a few books that I found by searching on Amazon.com, but I would like to get some input from people who have studied from some of the books.

Thanks,
Anand
9 years ago
I see those two lines in several job descriptions for SDET/SET positions.

BTW, I am not a newbie, I have a about 15 years of job experience (in US) but as a Software Test Engr. I have finished my last position and I am looking to do something a little different from what I did before. I did take a algorithms course in university long back but have not had to use the knowledge at work.

I agree that formal courses in a university can be good, but once you have a degree in Electrical Engr/Computer Science/Computer Engr, after that you keep learning on your own or along with your work. There are good books (non textbooks) and good internet tutorials out there.

Thanks,
Anand



10 years ago