testng verbose mode and HashCodeBuilder

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

testng verbose mode and HashCodeBuilder

tarun3kumar

Hey,

I'm semi new to testng and I've noticed some weird behaviour whereby changing the verbose mode from 1 to 3 when running my tests will cause apache commons HashCodeBuilder to generate different hashcodes. Has anyone else noticed this behaviour?
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=60328&messageID=117642#117642


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: testng verbose mode and HashCodeBuilder

Cédric Beust ♔


On 1/23/07, scrojaxx <[hidden email]> wrote:

Hey,

I'm semi new to testng and I've noticed some weird behaviour whereby changing the verbose mode from 1 to 3 when running my tests will cause apache commons HashCodeBuilder to generate different hashcodes. Has anyone else noticed this behaviour?

I'm not familiar with HashCodeBuilder, but since it probably builds hashes based on the field values of the objects, I don't find this particularly surprising...

Any reason why this is a problem to you?  Can you be more specific?  (which objects, which classes?)

--
Cédric
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: testng verbose mode and HashCodeBuilder

tarun3kumar

Hi Cédric,

the classes I'm talking about are entity classes used for persistence. You are correct in stating that I am using HashCodeBuilder creates a hash based on the properties/fields of an object.

It's a problem because I use HashCodeBuilder to create a business key to uniquely identify an object across jvms and across datastores so the hash code produced must be the same every time. If my tests fail I have no way of knowing if the error is a programmer error or testng or data access etc.

I'm interested to know how changing the verbose parameter would affect this. Also is it possible to access the verbose value within my code thereby changing the expected hash value for my test based on the verbose parameter.

Merci beaucoup,
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=60328&messageID=117652#117652


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: testng verbose mode and HashCodeBuilder

Cédric Beust ♔
Hi Scrojaxx,

This is very puzzling, I can't really imagine how TestNG could modify the business objects that your tests exercise since it has absolutely no knowledge of them...

Can you dump the content of these objects and compare them visually with different values of verbose?

--
Cedric


On 1/23/07, scrojaxx <[hidden email]> wrote:

Hi Cédric,

the classes I'm talking about are entity classes used for persistence. You are correct in stating that I am using HashCodeBuilder creates a hash based on the properties/fields of an object.

It's a problem because I use HashCodeBuilder to create a business key to uniquely identify an object across jvms and across datastores so the hash code produced must be the same every time. If my tests fail I have no way of knowing if the error is a programmer error or testng or data access etc.

I'm interested to know how changing the verbose parameter would affect this. Also is it possible to access the verbose value within my code thereby changing the expected hash value for my test based on the verbose parameter.

Merci beaucoup,
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=60328&messageID=117652#117652







--
Cédric
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: testng verbose mode and HashCodeBuilder

tarun3kumar

Ok, I've solved this issue turns out I was calling the wrong method on my HashCodeBuilder (i.e I was calling hashCode() instead of toHashCode() ) hashCode() uses reflection to generate the hash code for an object whereas toHashCode relies on you specifying which properties to use for hash code generation. Even though I fixed my original problem I'm still confused as to how changing the verbose parameter has resulted in this strange occurance. I'd say the issue lies somewhere within the HashCodeBuilder class and my misuse of it so I'll delve into it to quash my curiosity. But on the plus side TestNG helped me locate and fix a bug in my code, which is what it's for. yah

sorry for wasting you time Cédric
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=60328&messageID=117765#117765


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: testng verbose mode and HashCodeBuilder

Alexandru Popescu ☀

On 1/24/07, scrojaxx <[hidden email]> wrote:
>
> Ok, I've solved this issue turns out I was calling the wrong method on my HashCodeBuilder (i.e I was calling hashCode() instead of toHashCode() ) hashCode() uses reflection to generate the hash code for an object whereas toHashCode relies on you specifying which properties to use for hash code generation. Even though I fixed my original problem I'm still confused as to how changing the verbose parameter has resulted in this strange occurance. I'd say the issue lies somewhere within the HashCodeBuilder class and my misuse of it so I'll delve into it to quash my curiosity.

I am still not sure if the problem you have seen is related to your
test classes or your real objects. However, in both cases I would say
that the chances that the log level to change the hashcode are 0 (the
only classes being aware of the log level are TestNG internal
classes).

But on the plus side TestNG helped me locate and fix a bug in my code,
which is what it's for. yah

This is excellent! Hope it will continue to help you.

./alex
--
.w( the_mindstorm )p.
  TestNG co-founder
EclipseTestNG Creator

>
> sorry for wasting you time Cédric
> ---------------------------------------------------------------------
> Posted via Jive Forums
> http://forums.opensymphony.com/thread.jspa?threadID=60328&messageID=117765#117765
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: testng verbose mode and HashCodeBuilder

Steve Loughran-7

On 24/01/07, Alexandru Popescu <[hidden email]> wrote:

>
> On 1/24/07, scrojaxx <[hidden email]> wrote:
> >
> > Ok, I've solved this issue turns out I was calling the wrong method on my HashCodeBuilder (i.e I was calling hashCode() instead of toHashCode() ) hashCode() uses reflection to generate the hash code for an object whereas toHashCode relies on you specifying which properties to use for hash code generation. Even though I fixed my original problem I'm still confused as to how changing the verbose parameter has resulted in this strange occurance. I'd say the issue lies somewhere within the HashCodeBuilder class and my misuse of it so I'll delve into it to quash my curiosity.
>
> I am still not sure if the problem you have seen is related to your
> test classes or your real objects. However, in both cases I would say
> that the chances that the log level to change the hashcode are 0 (the
> only classes being aware of the log level are TestNG internal
> classes).
>

I could imagine if the log was logging the string value of these
objects, and their toString() operator changed their internal state,
then yes, logging would have side effects.

> But on the plus side TestNG helped me locate and fix a bug in my code,
> which is what it's for. yah
>

the only tests worth writing are those that find bugs, now or in the future.

-steve

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---