Regression in itw from Tue Mar 26

Jiri Vanek jvanek at redhat.com
Thu Apr 25 01:18:39 PDT 2013


On 04/24/2013 06:41 PM, Adam Domurad wrote:
> On 04/24/2013 12:37 PM, Jiri Vanek wrote:
>> On 04/24/2013 06:34 PM, Adam Domurad wrote:
>>>> +    @Test
>>>> +    public void testNotNullJnlpFile(){
>>>> +        SecurityDesc securityDesc = new SecurityDesc(new DummyJNLPFile(),
>>>> SecurityDesc.SANDBOX_PERMISSIONS, "hey!");
>>>> +        Assert.assertNotNull("securityDesc should not be ",securityDesc);
>>>> +
>>>> +    }
>>>
>>> Huh. Why is this still in ? Sorry, I can't support superstitious coding.
>>>
>>> At least drop the assert if you want a constructor sanity check.
>>
>> No. I would like to keep it inside even with  assert.
>> The code inside the constructor can change later. Eg some dummy jnl file will be tried to be
>> created and used into if argument is null.
>>
>> I would like to have it recorded.
>
> Sorry, but this assert is really a no-op. How could the result of 'new' ever be null ?

No ists not "no-op"

It is testing that securityDesc was filled. Whta is somthing what will not happened when exception 
is thrown from constructor.

We are little more in theoretical  level and depends on point of view a bit.

Maybe what you want to see is:


     @Test
     public void testNotNullJnlpFile(){
Exception ex = null;
try{
         SecurityDesc securityDesc = new SecurityDesc(new DummyJNLPFile(), 
SecurityDesc.SANDBOX_PERMISSIONS, "hey!");
}catch(Exception exx){
ex=exx;
}
         Assert.assertNull("no exception expectd ",ex);

     }

It is more verbose the same as what I'm testing.


J.


As test you can answer this questions:

Lets have:

public class XXX {

     private static TerrorClass t;

     public static final class TerrorClass {
         public TerrorClass() {
             t = this;
                 throw new RuntimeException("Muhehe");
         }
     }

     public static void main(String[] args) {
         TerrorClass tt = null;
         try {
             tt = new TerrorClass();
         } catch (Exception ex) {
         }
         System.out.println(tt);
         System.out.println(t);

     }
}




What will be in "t"  and what in "tt" atetr main execution?
And .. If there "will be something"" will it be "working"?

As solution you can see the result  or run.. But solution is probably obvious for you (no ironic, 
you know already java better then me).







> I'm OK with just running the constructor, but I really don't understand why you want this line. It's
> like asserting assertNotNull(new Object()); It's plain superstition.
> -Adam
>
>>
>>>
>>> Push without this please. Otherwise good.
>>>
>>> Happy hacking,
>>> -Adam
>>
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: XXX.java
Type: text/x-java
Size: 950 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/distro-pkg-dev/attachments/20130425/81ead16d/XXX.java 
-------------- next part --------------
null
XXX$TerrorClass at 259f5e3f
0
0
1


More information about the distro-pkg-dev mailing list