harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stepan Mishura" <stepan.mish...@gmail.com>
Subject Re: [classlib] trying new framework for testing serialization
Date Fri, 07 Jul 2006 05:59:15 GMT
Hi Nathan,

On 7/6/06, Nathan Beyer wrote:
>
> I have a couple comments on the code and guidelines after working with
> them
> for a little bit.
>
> * Do we need the "serialization" package prefix? I'd prefer to just have
> the
> resource be in the same folder/package as of the test case. The files are
> already separated into a "resource" folder.


No, we don't. The "serialization" package prefix shouldn't be used - we
agreed that we don't separate serialization tests from unit tests. The
prefix comes from the initial contribution (HARMONY-16).

* It seems a little awkward, or at least not immediately apparent that a
> file name after the test case is a serialized instance of an object. For
> example, "UUIDTest.golden.ser" would be an instance of the class UUID. My
> suggestion would be to take the Class object as an additional parameter
> and
> then use the following algorithm to build the path:
> '(testCaseInst.getClass().getPackage() + "/" +
> clazz.getSimpleName()).replaceAll('.','/')'. Note: getSimpleName may not
> be
> implemented yet, but you can subtract the package name from the full name.


The point is to identify by a resource name a test where the resource is
used, for example, we may have UUIDTest1 and UUIDTest2.

* When loading the resource, the name is assembled using File.separatorChar
> as the separator, but you should just be using the character "/" since
> that's the normative class path separator.



I didn't catch what the problem with File.separatorChar.

* Currently, the System ClassLoader is used, which we can probably get away
> with for now, but I would suggest using the ClassLoader of the TestCase
> passed. If the System ClassLoader is needed, it will be delegated down to
> it
> eventually.


Yes, it is possible to use the ClassLoader of the passed TestCase. There
will be only one minor restriction. Tests for serialization can not be
located on the bootclasspath because resource files are located on the
classpath. But currently we have a number of serialization tests are running
on the bootclasspath, for example, in security module. So we should
refractor these tests first to run them from the classpath.

* Why do all of the methods of SerializationTest start with 'verify' instead
> of 'assert'? This seems awkward and inconsistent with JUnit practices.



Yes, I also thought about starting with 'assert'. But it looked for me at
that time a little bit confusing. Now it seems that starting with 'assert'
looks more natural. So we will have methods 'assertGolden' and 'assertSelf'.
However in this case I'd change 'assertSelf' to something like
'assertSerializableObject'. Other suggestions?

* Why does SerializationTest extend TestCase? I suggest separating the
> assertion methods and the abstract TestCase functionality and remove the
> artificial coupling.



This also comes from the initial contribution (HARMONY-16) - the idea was to
unify serialization testing using inheritance so we have separate
serialization tests in 4 module that extend super-test
class(SerializationTest). But we agreed that we wouldn't test serialization
in that way  - so you should avoid extending SerializationTest and create
new serialization tests according to the guidelines [1].

* In all of the places where "TestCase.assertXXX" is used, I would suggest
> using "Assert.assertXXX", as this is the class that defines these methods.
> TestCase just extends Assert to simplify the usage of the 'assertXXX'
> methods for normal test classes.



Agree.



Thanks for you comments,

Stepan.



[1]
http://incubator.apache.org/harmony/subcomponents/classlibrary/ser_testing.html

-Nathan
>
> > -----Original Message-----
> > From: Stepan Mishura [mailto:stepan.mishura@gmail.com]
> > Sent: Wednesday, July 05, 2006 3:08 AM
> > To: harmony-dev@incubator.apache.org
> > Subject: Re: [classlib] trying new framework for testing serialization
> >
> > Hi Andrew,
> >
> > On 7/3/06, Andrew Zhang wrote:
> > >
> > > Hi Stepan,
> > >
> > > I tried serialization test framework, and found it's really easy to
> use.
> > > :)
> > >
> > > Here I have a small question: why TestCase is designed as first
> > parameter?
> >
> >
> > Because it is required for all methods for testing compatibility so I
> made
> > it as first parameter.
> >
> > > If I understand correctly, it's used to parse exception name.
> >
> > No, it is not. It is used to locate resource files only. For example,
> > TestCase:
> >    org.apache.harmony.luni.tests.java.lang.SomeClassTest
> > Resource:
> >    org/apache/harmony/luni/tests/java/lang/SomeClassTest.golden.ser
> >
> > So is it the
> > > same  if we simply pass the String or Class of the object to
> > > SerializationTest?
> >
> >
> > Do you mean Class of TestCase or an object to be tested?
> >
> > Maybe it's a tradeoff for highly automated, still I think pass String or
> > > Class is not a big deal for user.
> > >
> > > Did I miss something? Or TestCase is used for other reasons?
> >
> >
> > It is used to locate resource files only.
> >
> > Thanks,
> > Stepan.
> >
> > >
> > >
> > >
> > >
> > > On 6/30/06, Stepan Mishura wrote:
> > > >
> > > > On 6/30/06, Jimmy, Jing Lv wrote:
> > > > >
> > > > > Stepan Mishura wrote:
> > > > > > Hi Jimmy,
> > > > > >
> > > > > <SNIP>
> > > > > > 3. The test needs ser-files, so it may be necessary to add a
> > method
> > > to
> > > > > >> create this file easily just like the old framework. I find
a
> > > > protected
> > > > > >> method produceGoldenFiles(), is that used for it (why
> > protected?)?
> > > > This
> > > > > >> may be necessary to guildance.
> > > > > >> What's more, the ser-file must be end with ".ser", but in
new
> > > > > framework,
> > > > > >> I still find it uses ".dat" . And the path is
> > > "test/common/unit/..."
> > > > > but
> > > > > >> in Harmony's Test Guildance
> > > > > tells:"/src/test/resources/serialization..."
> > > > > >
> > > > > >
> > > > > > Yes, I agree that utility method for producing golden files
will
> > be
> > > > > useful.
> > > > > > I didn't think how to implement it yet - so suggestion and
> patches
> > > are
> > > > > > welcome.
> > > > > >
> > > > >
> > > > > I see now, thank you very much Stepan! :)
> > > > > To produce golden files,  I believe a little change to
> > > > > produceGoldenFiles() may meet this requirement. I'd like to
> help.:)
> > > >
> > > >
> > > > Great!
> > > >
> > > > But first of all it may change its search path, as when I create a
> new
> > > > > test and try verifyGolden(), I find a FileNotFoundException. It
> > seems
> > > > > trying to search "test/common/unit/.../SomeTest.golden.dat", is
> that
> > > > > because of serialization-test for security? Waiting for your
> > > refactoring
> > > > > :)
> > > > >
> > > > >
> > > > >
> > > > > Currently the framework search resource files in the next order:
> > > > it tries to load a resource file from the classpath (resource file
> > name
> > > > should follow new conventions); if it failed then it loads it in
> 'old'
> > > way
> > > > (
> > > > i.e. using RESOURCE_DIR system property). The 'old' way will be
> > removed
> > > > after completing 'security' tests migration.
> > > >
> > > > If you see FileNotFoundException then it means that the framework
> can
> > > find
> > > > resource file on the classpath. Please check that:
> > > > 1) a resource file follows new naming conventions
> > > > 2) a resource file is on the classpath
> > > >
> > > > BTW, I've refactored one security test[1]. You may wish to use it as
> > > > example.
> > > >
> > > > Thanks,
> > > > Stepan Mishura
> > > >
> > > > P.S.
> > > > I'll have random access to e-mail starting next week. Please expect
> > some
> > > > delay in response.
> > > >
> > > > [1]
> > > >
> > > >
> > >
> >
> http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/mod
> >
> ules/security/src/test/api/java/org/apache/harmony/security/tests/java/sec
> > urity/serialization/KeyPairTest.java?revision=418191&view=markup
> > > >
> > > > ------------------------------------------------------
> > > > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > > > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > > > For additional commands, e-mail:
> harmony-dev-help@incubator.apache.org
> > > >
> > > >
> > >
> > >
> > > --
> > > Andrew Zhang
> > > China Software Development Lab, IBM
>
>


-- 
Thanks,
Stepan Mishura
Intel Middleware Products Division

------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message