mbien commented on code in PR #6296:
URL: https://github.com/apache/netbeans/pull/6296#discussion_r1284913775


##########
enterprise/j2ee.sun.dd/test/unit/src/org/netbeans/modules/j2ee/sun/dd/api/DDProviderTest.java:
##########
@@ -42,108 +43,71 @@ public DDProviderTest() {
         super("DDProvider");
     }
 
-    @Before
-    public void setUp() {
-    }
-
-    @After
-    public void tearDown() {
-    }
-
     @Test
     public void testGetEjbDDRoot() throws FileNotFoundException, IOException, 
SAXException {
         File[] list = getDataDir().listFiles();
         if (null == list || list.length == 0)
             return;
+        SunEjbJar root = null;
         for (File fo : list) {
             if (fo.getName().startsWith("valid-sun-ejb-jar")) {
-                InputStream is = null;
-                try {
-                    is = new FileInputStream(fo);
-
-                    DDProvider.getDefault().getEjbDDRoot(new InputSource(is));
-                } finally {
-                    if (null != is) {
-                        try {
-                            is.close();
-                        } catch (IOException ioe) { }
-                    }
+                try (InputStream is = new FileInputStream(fo)) {
+                    root = DDProvider.getDefault().getEjbDDRoot(new 
InputSource(is));
+                    assertNotNull(root);
                 }
             }
         }
-
-
+        assertNotNull(root);
     }
 
     @Test
     public void testGetWebDDRoot() throws FileNotFoundException, IOException, 
SAXException, DDException {
         File[] list = getDataDir().listFiles();
         if (null == list || list.length == 0)
             return;
+        SunWebApp root = null;
         for (File fo : list) {
             if (fo.getName().startsWith("valid-sun-web")) {
-                InputStream is = null;
-                try {
-                    is = new FileInputStream(fo);
-
-                    DDProvider.getDefault().getWebDDRoot(new InputSource(is));
-                } finally {
-                    if (null != is) {
-                        try {
-                            is.close();
-                        } catch (IOException ioe) { }
-                    }
+                try (InputStream is = new FileInputStream(fo)) {
+                    root = DDProvider.getDefault().getWebDDRoot(new 
InputSource(is));
+                    assertNotNull(root);
                 }
             }
         }
-
+        assertNotNull(root);
     }
 
     @Test
-    public void testGetAppDDRoot() throws FileNotFoundException, IOException, 
SAXException {
+    public void fails_testGetAppDDRoot() throws FileNotFoundException, 
IOException, SAXException {
         File[] list = getDataDir().listFiles();
         if (null == list || list.length == 0)
             return;
+        SunApplication root = null;
         for (File fo : list) {
             if (fo.getName().startsWith("valid-sun-application")) {
-                InputStream is = null;

Review Comment:
   fyi: those two test cases did pass even though the `if-block` never matched 
anything. Essentially a false positive.
   
   fixed the tests and turned them off



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to