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: reporting failure
Date Tue, 11 Apr 2006 05:56:10 GMT
This url was send before ... resending

See: http://www.javaworld.com/javaworld/jw-12-2000/jw-1221-junit_p.html
Paragraph: *Utilize JUnit's assert/fail methods and exception handling for
clean test code*

Thanks,
Stepan.

On 4/11/06, Mikhail Loenko wrote:
>
> I'm evaluating failures caused by intagration of H-88 tests and found out
> that that style which is used in some tests is not very convinient for me.
>
> I'd like to hear others' opinion.
>
> So for example here is a failure
> test: tests.api.java.security.AlgorithmParameterGeneratorTest
> test case: test_initLjava_security_spec_AlgorithmParameterSpec
>
> InvalidAlgorithmParameterException getting spec
>
> junit.framework.AssertionFailedError:
> InvalidAlgorithmParameterException getting spec at
>
> tests.api.java.security.AlgorithmParameterGeneratorTest.test_initLjava_security_spec_AlgorithmParameterSpec
> (AlgorithmParameterGeneratorTest.java:207)
> at
> java.lang.reflect.AccessibleObject.invokeV(AccessibleObject.java:205)
>
> This is how the test currently looks like:
>
> public void test_initLjava_security_spec_AlgorithmParameterSpec() {
>    ....
>    try {
>        DSAParameterSpec spec = new DSAParameterSpec(
>                BigInteger.ONE, BigInteger.ONE, BigInteger.ONE);
>        AlgorithmParameterGenerator gen = AlgorithmParameterGenerator
>                .getInstance("DSA");
>        gen.init(spec);
>    } catch (NoSuchAlgorithmException e) {
>        fail("getInstance did not find algorithm DSA");
>    } catch (InvalidAlgorithmParameterException e) {
>        fail("InvalidAlgorithmParameterException getting spec");
>    }
> }
>
> This is how I would rewrite the test:
>
> public void test_initLjava_security_spec_AlgorithmParameterSpec()
> throws Exception {
>    ...
>    // checks that no exception is thrown
>    DSAParameterSpec spec = new DSAParameterSpec(BigInteger.ONE,
>            BigInteger.ONE, BigInteger.ONE);
>    AlgorithmParameterGenerator gen = AlgorithmParameterGenerator
>            .getInstance("DSA");
>    gen.init(spec);
> }
>
> And here is new output:
> No supported AlgorithmParameterSpec for DSA parameter generation.
>
> java.security.InvalidAlgorithmParameterException: No supported
> AlgorithmParameterSpec for DSA parameter generation. at
>
> org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DSA.engineInit
> (Unknown
> Source) at java.security.AlgorithmParameterGenerator.init(
> AlgorithmParameterGenerator.java:164)
> at
> tests.api.java.security.AlgorithmParameterGeneratorTest.test_initLjava_security_spec_AlgorithmParameterSpec
> (AlgorithmParameterGeneratorTest.java:203)
> at java.lang.reflect.AccessibleObject.invokeV(AccessibleObject.java:205)
>
>
> I can see where the failure occurs and its reason (missing
> functionality rather then
> invalid parameter spec)
>
> Comments?
>
> Thanks,
> Mikhail
>
> ---------------------------------------------------------------------
> 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
>
>


--
---------------------------------------------------------------------
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

Thanks,
Stepan Mishura
Intel Middleware Products Division

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