Russy Bond

Greenhorn
+ Follow
since May 09, 2014
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
1
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 Russy Bond

I solved it. The path contains a carriage return. So, the right way to fix it would be
cd $(echo $P4_PATH | tr -d '\r')
8 years ago
I have 1) a properties file and 2) a shell script.

In my shell script, I am trying to call a property, P4_PATH (defined in the properties file).
If I try echo $P4_PATH, it works fine and prints the path (/Users/Russy/Perforce/iOS_develop).

Issue: If I try, cd $P4_PATH
I get “: No such file or directory: /Users/Russy/Perforce/iOS_develop

Can someone please let me know what could be going wrong?

The path is a valid one. If I manually cd to that path, it will work fine.

Thanks,
Russy
8 years ago
Thank you Fred. That was a good example. I get the mistake now. I think if I do not want to set the name through the new instance, the only way out for me is to declare the getName method as static and call it by TestA.getName().
9 years ago
Thanks Fred. I know that would work but my requirement is such that I want to access a value that has already been set and I do not want to set it again the second time.
For e.g you could think of loading all the properties file and set the property values in ClassA. Now from a different ClassB, I want to get a property value (that has already been set in ClassA).
9 years ago
Sorry about not adding more details. Actually I am using a @BeforeClass annotation of TestNG which makes sure myTestMethod gets definitely invoked and the name variable also gets set. I am able to print the value in TestA class. My only problem is now how to print this name or make the getter name print the value in TestB class. I hope I am being clear this time.
9 years ago
I have 2 classes. TestClassA has 1 getter and 1 setter. From my second class, TestClassB, I want to access the getter method of TestClassA. If I try to access it, I get null. How do I do it?
I do not want the methods to be declared as static. Can you please let me know how can the getter method value be printed in TestClassB (without marking anything as static)?


Now, in my classB i.e.

[Added code tags - see UseCodeTags for details]
Thanks,
Russy
9 years ago
I am caching the result now and that has resolved my problem. Thanks Ulf and Campbell for your quick responses.
9 years ago
According to my design, Method#2 of ClassB sends the request details to Method#1 of ClassA.

Method#1 is a generic method that does the main job of processing/posting the input HttpRequest (of any type i.e. POST, PUT, GET etc.) and return an output HttpResponse. You can think of this method as a common util that will be used by many classes.
So, in method#1, I am trying to log the request and the response.

In method#2, once I get back the HttpResponse, I want to make specific assertions against the request sent and response received.
That is why I am trying to trying to do the String conversion twice.

9 years ago
Sorry about not mentioning that in detail.

My method#1 returns a HttpResponse. Inside this method, before returning the response, I am calling
String data = EntityUtils.toString(httpResponse.getEntity()); in order to print "data" to the logs.

My method#2 of ClassB requires the HttpResponse that is returned by method#1 of ClassA.
In method#2, I am calling
String data = EntityUtils.toString(httpResponse.getEntity()); for assertions purposes.
9 years ago
I am trying to convert a HttpResponse to a String. So, I achieve this by doing:
String data = EntityUtils.toString(httpResponse.getEntity());
where EntityUtils class is part of org.apache.http.util package.

Now, the problem is that EntityUtils.toString(httpResponse.getEntity()) works fine only the first time. If this is called more than 1 time, I get back
java.io.IOException: Attempted read from closed stream.
at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:162)
at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:137)

My requirement is that I want to use the same HttpResponse object and convert it to String in two different methods.
How do I do this?

Any pointers on this will be highly appreciated.

Thanks,
Russy

9 years ago
Thank you Tim for your response. I realised that I had downloaded "32-bit/64-bit Windows Service Installer" which did not have the setenv file. I later downloaded "64-bit Windows zip" and added the mentioned JVM arg in the setenv file there and it worked.
Thanks again.
9 years ago
I am using Tomcat7.0.53 on Windows7. I want to add this JVM arg "-XX:-UseSplitVerifier" in Tomcat but am not sure how to do it on Windows.
Had it been Linux, I would have added it in setenv.sh as
JAVA_OPTS="${JAVA_OPTS} -XX:-UseSplitVerifier"

I have no clue how to do the same on Windows for this specific Tomcat version. Any help on this regard will be highly appreciated.

Thanks,
Russy
9 years ago