You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@netbeans.apache.org by GitBox <gi...@apache.org> on 2017/10/19 07:47:31 UTC

[GitHub] geertjanw closed pull request #44: Testcases related fixes

geertjanw closed pull request #44: Testcases related fixes
URL: https://github.com/apache/incubator-netbeans/pull/44
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/autoupdate.services/test/unit/src/org/netbeans/api/autoupdate/UpdateProviderFactoryCreateTest.java b/autoupdate.services/test/unit/src/org/netbeans/api/autoupdate/UpdateProviderFactoryCreateTest.java
index f59cd2f1e..c42fa549a 100644
--- a/autoupdate.services/test/unit/src/org/netbeans/api/autoupdate/UpdateProviderFactoryCreateTest.java
+++ b/autoupdate.services/test/unit/src/org/netbeans/api/autoupdate/UpdateProviderFactoryCreateTest.java
@@ -23,7 +23,6 @@
 import java.util.List;
 import org.netbeans.junit.MockServices;
 import org.netbeans.junit.NbTestCase;
-import org.netbeans.modules.autoupdate.services.UpdateUnitFactoryTest;
 import org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogProvider;
 
 /**
@@ -50,7 +49,7 @@ protected void tearDown () throws  Exception {
     public void testCreate () throws Exception {
         String name = "new-one";
         String displayName = "Newone";
-        URL url = UpdateUnitFactoryTest.class.getResource ("data/catalog.xml");
+        URL url = getClass().getResource ("/org/netbeans/modules/autoupdate/updateprovider/data/catalog.xml");
         
         UpdateUnitProvider newone = UpdateUnitProviderFactory.getDefault ().create(name, displayName, url);
         assertNotNull ("New provider was created.", newone);
@@ -71,13 +70,13 @@ public void testCreate () throws Exception {
 
     public static class MyProvider extends AutoupdateCatalogProvider {
         public MyProvider () {
-            super ("test-updates-provider", "test-updates-provider", UpdateUnitFactoryTest.class.getResource ("data/catalog.xml"));
+            super ("test-updates-provider", "test-updates-provider", UpdateProviderFactoryCreateTest.class.getResource ("/org/netbeans/modules/autoupdate/updateprovider/data/catalog.xml"));
         }
     }
     
     public static class MyProvider2 extends AutoupdateCatalogProvider {
         public MyProvider2 () {
-            super ("test-updates-provider-2", "test-updates-provider-2", UpdateUnitFactoryTest.class.getResource ("data/catalog.xml"));
+            super ("test-updates-provider-2", "test-updates-provider-2", UpdateProviderFactoryCreateTest.class.getResource ("/org/netbeans/modules/autoupdate/updateprovider/data/catalog.xml"));
         }
     }
 }
diff --git a/autoupdate.services/test/unit/src/org/netbeans/api/autoupdate/UpdateProviderFactoryTest.java b/autoupdate.services/test/unit/src/org/netbeans/api/autoupdate/UpdateProviderFactoryTest.java
index ae4d2e64b..32eef949c 100644
--- a/autoupdate.services/test/unit/src/org/netbeans/api/autoupdate/UpdateProviderFactoryTest.java
+++ b/autoupdate.services/test/unit/src/org/netbeans/api/autoupdate/UpdateProviderFactoryTest.java
@@ -19,11 +19,9 @@
 
 package org.netbeans.api.autoupdate;
 
-import java.net.URL;
 import java.util.List;
 import org.netbeans.junit.MockServices;
 import org.netbeans.junit.NbTestCase;
-import org.netbeans.modules.autoupdate.services.UpdateUnitFactoryTest;
 import org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogProvider;
 
 /**
@@ -72,13 +70,13 @@ public void testSetEnable () {
 
     public static class MyProvider extends AutoupdateCatalogProvider {
         public MyProvider () {
-            super ("test-updates-provider", "test-updates-provider", UpdateUnitFactoryTest.class.getResource ("data/catalog.xml"));
+            super ("test-updates-provider", "test-updates-provider", UpdateProviderFactoryTest.class.getResource ("data/catalog.xml"));
         }
     }
     
     public static class MyProvider2 extends AutoupdateCatalogProvider {
         public MyProvider2 () {
-            super ("test-updates-provider-2", "test-updates-provider-2", UpdateUnitFactoryTest.class.getResource ("data/catalog.xml"));
+            super ("test-updates-provider-2", "test-updates-provider-2", UpdateProviderFactoryTest.class.getResource ("/org/netbeans/modules/autoupdate/updateprovider/data/catalog.xml"));
         }
     }
 }
diff --git a/autoupdate.services/test/unit/src/org/netbeans/modules/autoupdate/services/UpdateUnitFactoryTest.java b/autoupdate.services/test/unit/src/org/netbeans/modules/autoupdate/services/UpdateUnitFactoryTest.java
deleted file mode 100644
index 6c03c29b4..000000000
--- a/autoupdate.services/test/unit/src/org/netbeans/modules/autoupdate/services/UpdateUnitFactoryTest.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.netbeans.modules.autoupdate.services;
-
-import org.netbeans.modules.autoupdate.updateprovider.InstalledModuleProvider;
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.netbeans.api.autoupdate.UpdateElement;
-import org.netbeans.api.autoupdate.UpdateUnit;
-import org.netbeans.junit.NbTestCase;
-import org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogProvider;
-import org.netbeans.modules.autoupdate.updateprovider.AutoupdateInfoParserTest;
-import org.netbeans.modules.autoupdate.updateprovider.LocalNBMsProvider;
-import org.netbeans.spi.autoupdate.UpdateItem;
-import org.netbeans.spi.autoupdate.UpdateProvider;
-import org.openide.modules.ModuleInfo;
-import org.openide.util.Lookup;
-import org.openide.util.Utilities;
-
-/**
- *
- * @author Jiri Rechtacek
- */
-public class UpdateUnitFactoryTest extends NbTestCase {
-    
-    public UpdateUnitFactoryTest (String testName) {
-        super (testName);
-    }
-    
-    private UpdateProvider p = null;
-    private static File NBM_FILE = null;
-    
-    @Override
-    protected void setUp () throws IOException, URISyntaxException {
-        clearWorkDir ();
-        System.setProperty ("netbeans.user", getWorkDirPath ());
-        Lookup.getDefault ().lookup (ModuleInfo.class);
-        try {
-            p = new MyProvider ();
-        } catch (Exception x) {
-            x.printStackTrace ();
-        }
-        p.refresh (true);
-        URL urlToFile = AutoupdateInfoParserTest.class.getResource ("data/org-yourorghere-depending.nbm");
-        NBM_FILE = Utilities.toFile(urlToFile.toURI ());
-        assertNotNull ("data/org-yourorghere-depending.nbm file must found.", NBM_FILE);
-    }
-    
-    public void testAppendInstalledModule () {
-        Map<String, UpdateUnit> unitImpls = new HashMap<String, UpdateUnit> ();
-        Map<String, ModuleInfo> modules = InstalledModuleProvider.getInstalledModules ();
-        assertNotNull ("Some modules are installed.", modules);
-        assertFalse ("Some modules are installed.", modules.isEmpty ());
-        
-        Map<String, UpdateUnit> newImpls = UpdateUnitFactory.getDefault ().appendUpdateItems (
-                unitImpls,
-                InstalledModuleProvider.getDefault());
-        assertNotNull ("Some units found.", newImpls);
-        assertFalse ("Some units found.", newImpls.isEmpty ());
-        
-        int modulesC = 0;
-        int features = 0;
-        
-        for (UpdateUnit unit : newImpls.values ()) {
-            switch (unit.getType ()) {
-            case KIT_MODULE :
-                modulesC ++;
-                break;
-            case MODULE :
-                modulesC ++;
-                break;
-            case LOCALIZATION :
-            case FEATURE :
-                features ++;
-                break;
-            }
-        }
-        assertEquals ("Same size of installed modules and UpdateUnit (except FeatureElement).", modules.size (), modulesC);
-    }
-    
-    public void testAppendUpdateItems () throws IOException {
-        Map<String, UpdateUnit> unitImpls = new HashMap<String, UpdateUnit> ();
-        Map<String, UpdateItem> updates = p.getUpdateItems ();
-        assertNotNull ("Some upadtes are present.", updates);
-        assertFalse ("Some upadtes are present.", updates.isEmpty ());
-        
-        Map<String, UpdateUnit> newImpls = UpdateUnitFactory.getDefault ().appendUpdateItems (
-                unitImpls,
-                p);
-        assertNotNull ("Some units found.", newImpls);
-        assertFalse ("Some units found.", newImpls.isEmpty ());
-        
-        int modules = 0;
-        int features = 0;
-        int kits = 0;
-        int installed = 0;
-        
-        for (UpdateUnit unit : newImpls.values ()) {
-            switch (unit.getType ()) {
-            case MODULE :
-                modules ++;
-                if (unit.getInstalled () != null) {
-                    installed ++;
-                }
-                break;
-            case KIT_MODULE :
-                kits ++;
-                if (unit.getInstalled () != null) {
-                    installed ++;
-                }
-                break;
-            case LOCALIZATION :
-            case FEATURE :
-                features ++;
-                break;
-            }
-        }
-        assertEquals ("Same size of upadtes (modules + features) and UpdateUnit", updates.size () - installed, kits + modules + features);
-    }
-    
-    public void testGroupInstalledAndUpdates () {
-        Map<String, UpdateUnit> unitImpls = new HashMap<String, UpdateUnit> ();
-        Map<String, UpdateUnit> installedImpls = UpdateUnitFactory.getDefault ().appendUpdateItems (
-                unitImpls,
-                InstalledModuleProvider.getDefault());
-        Map<String, UpdateUnit> updatedImpls = UpdateUnitFactory.getDefault ().appendUpdateItems (
-                installedImpls, p);
-        boolean isInstalledAndHasUpdates = false;
-        for (String id : updatedImpls.keySet ()) {
-            UpdateUnit impl = updatedImpls.get (id);
-            UpdateElement installed = impl.getInstalled ();
-            List<UpdateElement> updates = impl.getAvailableUpdates ();
-            isInstalledAndHasUpdates = isInstalledAndHasUpdates || installed != null && updates != null && ! updates.isEmpty ();
-            if (installed != null && updates != null && ! updates.isEmpty ()) {
-                assertTrue ("Updates of module " + id + " contain newer one.", updates.get (0).getSpecificationVersion ().compareTo (installed.getSpecificationVersion ()) > 0);
-            }
-        }
-        assertTrue ("Some module is installed and has updates.", isInstalledAndHasUpdates);
-    }
-    
-    public void testGetUpdateUnitsInNbmFile () {
-        UpdateProvider localFilesProvider = new LocalNBMsProvider ("test-local-file-provider", NBM_FILE);
-        assertNotNull ("LocalNBMsProvider found for file " + NBM_FILE, localFilesProvider);
-        Map<String, UpdateUnit> units = UpdateUnitFactory.getDefault().getUpdateUnits (localFilesProvider);
-        assertNotNull ("UpdateUnit found in provider " + localFilesProvider.getDisplayName (), units);
-        assertEquals ("Provider providers only once unit in provider" + localFilesProvider.getName (), 1, units.size ());
-        String id = units.keySet ().iterator ().next ();
-        assertNotNull (localFilesProvider.getName () + " gives UpdateUnit.", units.get (id));
-        UpdateUnit u = units.get (id);
-        assertNull ("Unit is not installed.", u.getInstalled ());
-        assertNotNull ("Unit has update.", u.getAvailableUpdates ());
-        assertFalse ("Unit.getAvailableUpdates() is not empty.", u.getAvailableUpdates ().isEmpty ());
-        assertEquals ("Unit has only one update.", 1, u.getAvailableUpdates ().size ());
-        UpdateElement el = u.getAvailableUpdates ().get (0);
-        assertEquals ("org.yourorghere.depending", el.getCodeName ());
-        assertEquals ("1.0", el.getSpecificationVersion ());
-        assertEquals (0, el.getDownloadSize ());
-    }
-    
-    public static class MyProvider extends AutoupdateCatalogProvider {
-        public MyProvider () {
-            super ("test-updates-provider", "test-updates-provider", UpdateUnitFactoryTest.class.getResource ("data/catalog.xml"));
-        }
-    }
-    
-}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services