Jump to content

Java/j2Ee Discussions


lolliman

Recommended Posts

i have one question 

 

Lets say there is a class

 

Class A {

 

void doesSomething (HttpRequest req , HttpResponse res, Map<String, Object> model)

 
{

 

doeswhatever(req,res,model);

 

some business logic which throws servlet exception

}

}

 

Here i am over riding the method and catching the exception for flow to continue

 

 

 

Class B extends A{

 

@Override

 

void doesSomething (HttpRequest req , HttpResponse res, Map<String, Object> model)

 
{

 

try{

super.doeswhatever(req,res,model);

 

}catch( ServletException ex){

 

logger.warn(" doing nothing here just logging the statement");

}

}

 

}

 

 

 

Now my main task is to write test case using Junit and make the test pass for the exception  block in B

 

 

Void testThrowServletException () {

 

private final HttpRequest req = null

 

private final HttpResponse res= null

 

private final Map<String, Object> model = mock(Map.class) ; ------------> Using Mockito

 

 new B().doeswhatever(req,res,model);

 

Here i need to assert  for the logger .warn statement  in catch block for  Servlet exception and pass the test

 

New to Junit and mockito and dont know how to assert for log statement...pls help

 

 

 

}

ltt

Link to comment
Share on other sites

Jailer mayya 

 

post something related to OIF, OAM and SSO 

 

 

it will be good to learn 

 

SSO ? single sign on ?

 

 

Link to comment
Share on other sites

Jailer mayya 

 

post something related to OIF, OAM and SSO 

 

 

it will be good to learn 

i agree but most of them are tools driven

 

if in our project we are using i think we can easily adopt 

 

let us come to conclusion and will start with

OIM

Link to comment
Share on other sites

Bezawada_Bablu, on 09 Jan 2014 - 07:20 AM, said:snapback.png

deeniki threarefrence ,thread local ,atomic integer ivi use chesi cheyyali anadu

 

nakem ardam kala as i am begginer

 

tarvatha ma architect ae rasukunadu code

lot of ways to do

do u still need it ? or its done?

 

When i did i dd it independently 

 

llike servlet writes log to a file using Log4J

 

JSP read and displays on the web( mainly errors/ warnings etc)

Link to comment
Share on other sites

@benz

sare will try

 

 

who ever is the user servlet writes to one log file only?

 

based on ur question

 

i got a doubt..do u need to show the logs differently for different users?

Link to comment
Share on other sites

 

Bezawada_Bablu, on 09 Jan 2014 - 07:20 AM, said:snapback.png

lot of ways to do

do u still need it ? or its done?

 

When i did i dd it independently 

 

llike servlet writes log to a file using Log4J

 

JSP read and displays on the web( mainly errors/ warnings etc)

 

 

i mailed you a test mail kali ga vunapudu do that code snippet and give me anna

Link to comment
Share on other sites

bhayyiah kottaga Xforms orbeon ani okati chestuna

 

kudirithe chudandi adhi chala bavundhi

 

to handle rest calls in front end

oh thx let me have a look

Link to comment
Share on other sites

@benz

sare will try

 

 

who ever is the user servlet writes to one log file only?

 

based on ur question

 

i got a doubt..do u need to show the logs differently for different users?

 

exactly if in url i called /Servlet1- indhulo log.info("welcome user")

 

and user two invokes /Servlet2-indhulo info.error("something is wrong")

 

on right hand side we will have a button to display logs

 

i should get my log welcome user

 

user two should get something is wrong

Link to comment
Share on other sites

×
×
  • Create New...