[hg] main-silver: more tests

  • From: Tomas Stupka < >
  • To:
  • Subject: [hg] main-silver: more tests
  • Date: Fri, 01 Mar 2013 12:40:19 -0800

changeset 3b64225dc8f0 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/3b64225dc8f0
description:
        more tests

diffstat:

 bugtracking/src/org/netbeans/modules/bugtracking/RepositoryRegistry.java     
         |   17 +-
 
bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestConnector.java
  |  256 +++++++++-
 
bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestIssue.java
      |   14 +-
 
bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestKit.java
        |  232 +--------
 
bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestRepository.java
 |   31 +-
 
bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/RepositoryTest.java
    |   48 +-
 6 files changed, 349 insertions(+), 249 deletions(-)

diffs (780 lines):

diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/RepositoryRegistry.java 
b/bugtracking/src/org/netbeans/modules/bugtracking/RepositoryRegistry.java
--- a/bugtracking/src/org/netbeans/modules/bugtracking/RepositoryRegistry.java
+++ b/bugtracking/src/org/netbeans/modules/bugtracking/RepositoryRegistry.java
@@ -248,10 +248,7 @@
                     if(c.getID().equals(connectorId)) {
                         RepositoryInfo info = 
SPIAccessor.IMPL.read(getPreferences(), id);
                         if(info != null) {
-                            Repository repo = c.createRepository(info);
-                            if (repo != null) {
-                                
repositories.put(APIAccessor.IMPL.getImpl(repo));
-                            }
+                            putRepository(c, info);
                         }
                     }
                 }
@@ -310,6 +307,18 @@
         changeSupport.firePropertyChange(EVENT_REPOSITORIES_CHANGED, 
oldRepositories, newRepositories);
     }
 
+    /**
+     * Do not call this!!! Public for testing purposes only
+     * @param c
+     * @param info 
+     */
+    public void putRepository(DelegatingConnector c, RepositoryInfo info) {
+        Repository repo = c.createRepository(info);
+        if (repo != null) {
+            repositories.put(APIAccessor.IMPL.getImpl(repo));
+        }
+    }
+
     private class RepositoriesMap extends HashMap<String, Map<String, 
RepositoryImpl>> {
         public void remove(String connectorID, RepositoryImpl repository) {
             Map<String, RepositoryImpl> m = get(connectorID);
diff --git 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestConnector.java
 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestConnector.java
--- 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestConnector.java
+++ 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestConnector.java
@@ -41,21 +41,57 @@
  */
 package org.netbeans.modules.bugtracking.api;
 
+import java.awt.Image;
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import org.netbeans.modules.bugtracking.BugtrackingManager;
+import org.netbeans.modules.bugtracking.DelegatingConnector;
+import org.netbeans.modules.bugtracking.RepositoryRegistry;
 import org.netbeans.modules.bugtracking.TestKit;
+import static org.netbeans.modules.bugtracking.api.APITestKit.getAPIRepo;
 import org.netbeans.modules.bugtracking.spi.BugtrackingConnector;
+import org.netbeans.modules.bugtracking.spi.BugtrackingController;
+import org.netbeans.modules.bugtracking.spi.BugtrackingFactory;
+import org.netbeans.modules.bugtracking.spi.IssueProvider;
+import org.netbeans.modules.bugtracking.spi.QueryController;
+import org.netbeans.modules.bugtracking.spi.QueryProvider;
+import org.netbeans.modules.bugtracking.spi.RepositoryController;
 import org.netbeans.modules.bugtracking.spi.RepositoryInfo;
+import org.netbeans.modules.bugtracking.spi.RepositoryProvider;
 import org.openide.util.Lookup;
 
 /**
  *
  * @author tomas
  */
-@BugtrackingConnector.Registration 
(id=APITestConnector.ID_CONNECTOR,displayName=APITestConnector.ID_CONNECTOR,tooltip=APITestConnector.ID_CONNECTOR)
    
+@BugtrackingConnector.Registration (
+    id=APITestConnector.ID_CONNECTOR,
+    displayName=APITestConnector.ID_CONNECTOR,
+    tooltip=APITestConnector.ID_CONNECTOR)    
 public class APITestConnector extends BugtrackingConnector {
 
-    public static final String ID_CONNECTOR = "RepositoryTestConector";
+    private static final BugtrackingFactory<APITestRepository, APITestQuery, 
APITestIssue> factory = 
+            new BugtrackingFactory<APITestRepository, APITestQuery, 
APITestIssue>();
     
-    public APITestConnector() { }
+    private static Map<String, APITestRepository> apiRepos = new 
HashMap<String, APITestRepository>();
+    
+    public static final String ID_CONNECTOR = "APITestConector";
+
+    public APITestConnector() { 
+    }
+
+    public static void init() {
+        DelegatingConnector[] cons = 
BugtrackingManager.getInstance().getConnectors();
+        for (DelegatingConnector dc : cons) {
+            if(ID_CONNECTOR.equals(dc.getID())) {
+                // init repos
+                RepositoryRegistry.getInstance().putRepository(dc, 
getInfo());
+            }
+        }
+    }
 
     public Lookup getLookup() {
         return Lookup.EMPTY;
@@ -63,11 +99,223 @@
 
     @Override
     public Repository createRepository(RepositoryInfo info) {
-        return TestKit.getRepository(new 
APITestRepository(info)).getRepository();
+        APITestRepository  apiRepo = apiRepos.get(info.getId());
+        if (apiRepo == null) {
+            apiRepo = createAPIRepo(getInfo());
+            apiRepos.put(info.getId(), apiRepo);
+        }
+        return factory.createRepository(
+            apiRepo, 
+            new APITestRepositoryProvider(), 
+            new APITestQueryProvider(),
+            new APITestIssueProvider());
     }
 
     @Override
     public Repository createRepository() {
         throw new UnsupportedOperationException("Not supported yet.");
     }
+    
+    public static APITestRepository getAPIRepo(String id) {
+        return apiRepos.get(id);
 }        
+    
+    private static APITestRepository createAPIRepo(RepositoryInfo info) {
+        return new APITestRepository(info);
+    }
+    
+    private static RepositoryInfo getInfo() {
+        return new RepositoryInfo(
+            APITestRepository.ID, 
+            APITestConnector.ID_CONNECTOR, 
+            APITestRepository.URL, 
+            APITestRepository.DISPLAY_NAME, 
+            APITestRepository.TOOLTIP);
+    }
+    
+    public static class APITestQueryProvider extends 
QueryProvider<APITestQuery, APITestIssue> {
+
+        @Override
+        public String getDisplayName(APITestQuery q) {
+            return q.getDisplayName();
+        }
+
+        @Override
+        public String getTooltip(APITestQuery q) {
+            return q.getTooltip();
+        }
+
+        @Override
+        public QueryController getController(APITestQuery q) {
+            return q.getController();
+        }
+
+        @Override
+        public void remove(APITestQuery q) {
+            q.remove();
+        }
+
+        @Override
+        public boolean isSaved(APITestQuery q) {
+            return q.isSaved();
+        }
+
+        @Override
+        public Collection<APITestIssue> getIssues(APITestQuery q) {
+            throw new UnsupportedOperationException("Not supported yet."); 
//To change body of generated methods, choose Tools | Templates.
+        }
+
+        @Override
+        public boolean contains(APITestQuery q, String id) {
+            return q.contains(id);
+        }
+
+        @Override
+        public void refresh(APITestQuery q) {
+            q.refresh();
+        }
+
+        @Override
+        public void removePropertyChangeListener(APITestQuery q, 
PropertyChangeListener listener) {
+            q.removePropertyChangeListener(listener);
+        }
+
+        @Override
+        public void addPropertyChangeListener(APITestQuery q, 
PropertyChangeListener listener) {
+            q.addPropertyChangeListener(listener);
+        }
+
+    }
+
+    public static class APITestRepositoryProvider extends 
RepositoryProvider<APITestRepository, APITestQuery, APITestIssue> {
+
+        @Override
+        public RepositoryInfo getInfo(APITestRepository r) {
+            return r.getInfo();
+        }
+
+        @Override
+        public Image getIcon(APITestRepository r) {
+            return r.getIcon();
+        }
+
+        @Override
+        public void remove(APITestRepository r) {
+            r.remove();
+        }
+
+        @Override
+        public RepositoryController getController(APITestRepository r) {
+            return r.getController();
+        }
+
+        @Override
+        public Lookup getLookup(APITestRepository r) {
+            return r.getLookup();
+        }
+
+        @Override
+        public void removePropertyChangeListener(APITestRepository r, 
PropertyChangeListener listener) {
+            r.removePropertyChangeListener(listener);
+        }
+
+        @Override
+        public void addPropertyChangeListener(APITestRepository r, 
PropertyChangeListener listener) {
+            r.addPropertyChangeListener(listener);
+        }
+
+        @Override
+        public APITestIssue[] getIssues(APITestRepository r, String... ids) {
+            return r.getIssues(ids);
+        }
+
+        @Override
+        public APITestQuery createQuery(APITestRepository r) {
+            throw new UnsupportedOperationException("Not supported yet."); 
//To change body of generated methods, choose Tools | Templates.
+        }
+
+        @Override
+        public APITestIssue createIssue(APITestRepository r) {
+            throw new UnsupportedOperationException("Not supported yet."); 
//To change body of generated methods, choose Tools | Templates.
+        }
+
+        @Override
+        public Collection<APITestQuery> getQueries(APITestRepository r) {
+            return r.getQueries();
+        }
+
+        @Override
+        public Collection<APITestIssue> simpleSearch(APITestRepository r, 
String criteria) {
+            throw new UnsupportedOperationException("Not supported yet."); 
//To change body of generated methods, choose Tools | Templates.
+        }
+    }
+
+    public static class APITestIssueProvider extends 
IssueProvider<APITestIssue> {
+
+        @Override
+        public String[] getSubtasks(APITestIssue data) {
+            return data.getSubtasks();
+        }
+
+        @Override
+        public String getDisplayName(APITestIssue data) {
+            return data.getDisplayName();
+        }
+
+        @Override
+        public String getTooltip(APITestIssue data) {
+            return data.getTooltip();
+        }
+
+        @Override
+        public String getID(APITestIssue data) {
+            return data.getID();
+        }
+
+        @Override
+        public String getSummary(APITestIssue data) {
+            return data.getSummary();
+        }
+
+        @Override
+        public boolean isNew(APITestIssue data) {
+            return data.isNew();
+        }
+
+        @Override
+        public boolean isFinished(APITestIssue data) {
+            return data.isFinished();
+        }
+
+        @Override
+        public boolean refresh(APITestIssue data) {
+            return data.refresh();
+        }
+
+        @Override
+        public void addComment(APITestIssue data, String comment, boolean 
closeAsFixed) {
+            data.addComment(comment, closeAsFixed);
+        }
+
+        @Override
+        public void attachPatch(APITestIssue data, File file, String 
description) {
+            data.attachPatch(file, description);
+        }
+
+        @Override
+        public BugtrackingController getController(APITestIssue data) {
+            return data.getController();
+        }
+
+        @Override
+        public void removePropertyChangeListener(APITestIssue data, 
PropertyChangeListener listener) {
+            data.removePropertyChangeListener(listener);
+        }
+
+        @Override
+        public void addPropertyChangeListener(APITestIssue data, 
PropertyChangeListener listener) {
+            data.addPropertyChangeListener(listener);
+        }
+
+    }    
+}        
diff --git 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestIssue.java
 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestIssue.java
--- 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestIssue.java
+++ 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestIssue.java
@@ -51,20 +51,28 @@
  * @author tomas
  */
 public class APITestIssue extends TestIssue {
+    static final String ID_1 = "1";
+    static final String ID_2 = "2";
+
+    private final String id;
+
+    public APITestIssue(String id) {
+        this.id = id;
+    }
 
     @Override
     public String getDisplayName() {
-        throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
+        return "Issue : " + id;
     }
 
     @Override
     public String getTooltip() {
-        throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
+        return getDisplayName() + " tooltip";
     }
 
     @Override
     public String getID() {
-        throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
+        return id;
     }
 
     @Override
diff --git 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestKit.java
 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestKit.java
--- 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestKit.java
+++ 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestKit.java
@@ -41,242 +41,26 @@
  */
 package org.netbeans.modules.bugtracking.api;
 
-import java.awt.Image;
-import java.beans.PropertyChangeListener;
-import java.io.File;
 import java.util.Collection;
-import org.netbeans.modules.bugtracking.TestQuery;
-import org.netbeans.modules.bugtracking.spi.BugtrackingController;
-import org.netbeans.modules.bugtracking.spi.BugtrackingFactory;
-import org.netbeans.modules.bugtracking.spi.IssueProvider;
-import org.netbeans.modules.bugtracking.spi.QueryController;
-import org.netbeans.modules.bugtracking.spi.QueryProvider;
-import org.netbeans.modules.bugtracking.spi.RepositoryController;
-import org.netbeans.modules.bugtracking.spi.RepositoryInfo;
-import org.netbeans.modules.bugtracking.spi.RepositoryProvider;
-import org.openide.util.Lookup;
 
 /**
  *
  * @author tomas
  */
 public class APITestKit {
-    private static BugtrackingFactory<APITestRepository, APITestQuery, 
APITestIssue> factory = 
-            new BugtrackingFactory<APITestRepository, APITestQuery, 
APITestIssue>();
-    private static APITestRepository apiRepo;
-    private static Repository repo;
     
-    public static APITestRepository getAPIRepo() {
-        if(apiRepo == null) {
-            apiRepo = new APITestRepository(
-                        new RepositoryInfo(
-                            APITestRepository.ID, 
-                            APITestConnector.ID_CONNECTOR, 
-                            APITestRepository.URL, 
-                            APITestRepository.DISPLAY_NAME, 
-                            APITestRepository.TOOLTIP));
+    public static APITestRepository getAPIRepo(String id) {
+        return APITestConnector.getAPIRepo(id);
+
         }
-        return apiRepo;
-    }
-
-    public static Repository getRepo() {
-        if(repo == null) {
-            repo = APITestKit.createRepository(getAPIRepo());
-        }
+    public static Repository getRepo(String id) {
+        Collection<Repository> repos = 
RepositoryManager.getInstance().getRepositories(APITestConnector.ID_CONNECTOR);
+        for (Repository repo : repos) {
+            if(repo.getId().equals(id)) {
         return repo;
     }
-    
-    public static Repository createRepository(APITestRepository repo) {
-        return factory.createRepository(
-                repo, 
-                new APITestRepositoryProvider(), 
-                new APITestQueryProvider(),
-                new APITestIssueProvider());
     }
-    
-    public static class APITestQueryProvider extends 
QueryProvider<APITestQuery, APITestIssue> {
-
-        @Override
-        public String getDisplayName(APITestQuery q) {
-            return q.getDisplayName();
-        }
-
-        @Override
-        public String getTooltip(APITestQuery q) {
-            return q.getTooltip();
-        }
-
-        @Override
-        public QueryController getController(APITestQuery q) {
-            return q.getController();
-        }
-
-        @Override
-        public void remove(APITestQuery q) {
-            q.remove();
-        }
-
-        @Override
-        public boolean isSaved(APITestQuery q) {
-            return q.isSaved();
-        }
-
-        @Override
-        public Collection<APITestIssue> getIssues(APITestQuery q) {
-            throw new UnsupportedOperationException("Not supported yet."); 
//To change body of generated methods, choose Tools | Templates.
-        }
-
-        @Override
-        public boolean contains(APITestQuery q, String id) {
-            return q.contains(id);
-        }
-
-        @Override
-        public void refresh(APITestQuery q) {
-            q.refresh();
-        }
-
-        @Override
-        public void removePropertyChangeListener(APITestQuery q, 
PropertyChangeListener listener) {
-            q.removePropertyChangeListener(listener);
-        }
-
-        @Override
-        public void addPropertyChangeListener(APITestQuery q, 
PropertyChangeListener listener) {
-            q.addPropertyChangeListener(listener);
+        return null;
         }
 
     }
-
-    public static class APITestRepositoryProvider extends 
RepositoryProvider<APITestRepository, APITestQuery, APITestIssue> {
-
-        @Override
-        public RepositoryInfo getInfo(APITestRepository r) {
-            return r.getInfo();
-        }
-
-        @Override
-        public Image getIcon(APITestRepository r) {
-            return r.getIcon();
-        }
-
-        @Override
-        public void remove(APITestRepository r) {
-            r.remove();
-        }
-
-        @Override
-        public RepositoryController getController(APITestRepository r) {
-            return r.getController();
-        }
-
-        @Override
-        public Lookup getLookup(APITestRepository r) {
-            return r.getLookup();
-        }
-
-        @Override
-        public void removePropertyChangeListener(APITestRepository r, 
PropertyChangeListener listener) {
-            r.removePropertyChangeListener(listener);
-        }
-
-        @Override
-        public void addPropertyChangeListener(APITestRepository r, 
PropertyChangeListener listener) {
-            r.addPropertyChangeListener(listener);
-        }
-
-        @Override
-        public APITestIssue[] getIssues(APITestRepository r, String... ids) {
-            return r.getIssues(ids);
-        }
-
-        @Override
-        public APITestQuery createQuery(APITestRepository r) {
-            throw new UnsupportedOperationException("Not supported yet."); 
//To change body of generated methods, choose Tools | Templates.
-        }
-
-        @Override
-        public APITestIssue createIssue(APITestRepository r) {
-            throw new UnsupportedOperationException("Not supported yet."); 
//To change body of generated methods, choose Tools | Templates.
-        }
-
-        @Override
-        public Collection<APITestQuery> getQueries(APITestRepository r) {
-            return r.getQueries();
-        }
-
-        @Override
-        public Collection<APITestIssue> simpleSearch(APITestRepository r, 
String criteria) {
-            throw new UnsupportedOperationException("Not supported yet."); 
//To change body of generated methods, choose Tools | Templates.
-        }
-    }
-
-    public static class APITestIssueProvider extends 
IssueProvider<APITestIssue> {
-
-        @Override
-        public String[] getSubtasks(APITestIssue data) {
-            return data.getSubtasks();
-        }
-
-        @Override
-        public String getDisplayName(APITestIssue data) {
-            return data.getDisplayName();
-        }
-
-        @Override
-        public String getTooltip(APITestIssue data) {
-            return data.getTooltip();
-        }
-
-        @Override
-        public String getID(APITestIssue data) {
-            return data.getID();
-        }
-
-        @Override
-        public String getSummary(APITestIssue data) {
-            return data.getSummary();
-        }
-
-        @Override
-        public boolean isNew(APITestIssue data) {
-            return data.isNew();
-        }
-
-        @Override
-        public boolean isFinished(APITestIssue data) {
-            return data.isFinished();
-        }
-
-        @Override
-        public boolean refresh(APITestIssue data) {
-            return data.refresh();
-        }
-
-        @Override
-        public void addComment(APITestIssue data, String comment, boolean 
closeAsFixed) {
-            data.addComment(comment, closeAsFixed);
-        }
-
-        @Override
-        public void attachPatch(APITestIssue data, File file, String 
description) {
-            data.attachPatch(file, description);
-        }
-
-        @Override
-        public BugtrackingController getController(APITestIssue data) {
-            return data.getController();
-        }
-
-        @Override
-        public void removePropertyChangeListener(APITestIssue data, 
PropertyChangeListener listener) {
-            data.removePropertyChangeListener(listener);
-        }
-
-        @Override
-        public void addPropertyChangeListener(APITestIssue data, 
PropertyChangeListener listener) {
-            data.addPropertyChangeListener(listener);
-        }
-
-    }
-}
diff --git 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestRepository.java
 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestRepository.java
--- 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestRepository.java
+++ 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestRepository.java
@@ -48,6 +48,8 @@
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedList;
 import java.util.List;
 import javax.swing.JComponent;
 import javax.swing.event.ChangeListener;
@@ -74,6 +76,7 @@
     private RepositoryInfo info;
     private APITestRepositoryController controller;
     private List<APITestQuery> queries;
+    private HashMap<String, APITestIssue> issues;
 
     public APITestRepository(RepositoryInfo info) {
         this.info = info;
@@ -103,8 +106,20 @@
     }
 
     @Override
-    public APITestIssue[] getIssues(String[] id) {
-        throw new UnsupportedOperationException("Not supported yet.");
+    public synchronized APITestIssue[] getIssues(String[] ids) {
+        if(issues == null) {
+            issues = new HashMap<String, APITestIssue>();
+        }
+        List<APITestIssue> ret = new LinkedList<APITestIssue>();
+        for (String id : ids) {
+            APITestIssue i = issues.get(id);
+            if(i == null) {
+                i = new APITestIssue(id);
+                issues.put(id, i);
+            }
+            ret.add(i);
+        }
+        return ret.toArray(new APITestIssue[ret.size()]);
     }
 
     @Override
@@ -138,8 +153,16 @@
         return queries;
     }
     @Override
-    public Collection<TestIssue> simpleSearch(String criteria) {
-        throw new UnsupportedOperationException("Not supported yet.");
+    public synchronized Collection<APITestIssue> simpleSearch(String 
criteria) {
+        if(issues == null) {
+            issues = new HashMap<String, APITestIssue>();
+        }
+        List<APITestIssue> ret = new LinkedList<APITestIssue>();
+        APITestIssue i = issues.get(criteria);
+        if(i != null) {
+            ret.add(i);
+        }
+        return ret;
     }
 
     private PropertyChangeSupport support = new PropertyChangeSupport(this);
diff --git 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/RepositoryTest.java
 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/RepositoryTest.java
--- 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/RepositoryTest.java
+++ 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/RepositoryTest.java
@@ -49,8 +49,7 @@
 import java.util.logging.Level;
 import static junit.framework.Assert.assertTrue;
 import org.netbeans.junit.NbTestCase;
-import org.netbeans.modules.bugtracking.TestKit;
-import org.netbeans.modules.bugtracking.spi.RepositoryInfo;
+import org.openide.util.test.MockLookup;
 
 /**
  *
@@ -69,6 +68,8 @@
     
     @Override
     protected void setUp() throws Exception {    
+        MockLookup.setLayersAndInstances();
+        APITestConnector.init();
     }
 
     @Override
@@ -76,7 +77,7 @@
     }
 
     public void testAttributes() {
-        Repository repo = APITestKit.getRepo();
+        Repository repo = getRepo();
         assertEquals(APITestRepository.DISPLAY_NAME, repo.getDisplayName());
         assertEquals(APITestRepository.TOOLTIP, repo.getTooltip());
         assertEquals(APITestRepository.URL, repo.getUrl());
@@ -85,14 +86,33 @@
     }
     
     public void testGetQueries() {
-        APITestRepository apiRepo = APITestKit.getAPIRepo();
-        Repository repo = APITestKit.getRepo();
+        APITestRepository apiRepo = getApiRepo();
+        Repository repo = getRepo();
         assertEquals(apiRepo.getQueries().size(), repo.getQueries().size());
     }
     
+    public void testGetIssues() {
+        APITestRepository apiRepo = getApiRepo();
+        Repository repo = getRepo();
+        String[] ids = new String[] {APITestIssue.ID_1, APITestIssue.ID_2};
+        assertEquals(apiRepo.getIssues(ids).length, 
repo.getIssues(ids).length);
+    }
+    
+//    public void testSimpleSearch() {
+//        APITestRepository apiRepo = getApiRepo();
+//        Repository repo = getRepo();
+//        assertEquals(apiRepo.simpleSearch(APITestIssue.ID_1).size(), 
repo.(APITestIssue.ID_1).);
+//    }
+    
+    public void testIsMutable() {
+        Repository repo = getRepo();
+        String[] ids = new String[] {APITestIssue.ID_1, APITestIssue.ID_2};
+        assertEquals(true, repo.isMutable());
+    }
+    
     public void testQueryListChanged() {
-        APITestRepository apiTestRepo = APITestKit.getAPIRepo();
-        Repository repo = APITestKit.getRepo();
+        Repository repo = getRepo();
+        APITestRepository apiTestRepo = getApiRepo();
         
         final boolean[] received = new boolean[] {false};
         repo.addPropertyChangeListener(new PropertyChangeListener() {
@@ -109,20 +129,20 @@
 
     public void testDisplayNameChanged() throws IOException {
         final String newDisplayName = "newDisplayName";
-        APITestRepository apiTestRepo = APITestKit.getAPIRepo();
+        APITestRepository apiTestRepo = getApiRepo();
         apiTestRepo.getController().setDisplayName(newDisplayName);
         testAttributeChange(Repository.ATTRIBUTE_DISPLAY_NAME, 
APITestRepository.DISPLAY_NAME, newDisplayName);
     }
     
     public void testUrlChanged() throws IOException {
         final String newURL = "http://test/newUrl/";;
-        APITestRepository apiTestRepo = APITestKit.getAPIRepo();
+        APITestRepository apiTestRepo = getApiRepo();
         apiTestRepo.getController().setURL(newURL);
         testAttributeChange(Repository.ATTRIBUTE_URL, APITestRepository.URL, 
newURL);
     }
     
     private void testAttributeChange(final String key, final String 
expectedOldValue, final String expectedNewValue) throws IOException {
-        final Repository repo = APITestKit.getRepo();
+        final Repository repo = getRepo();
         
         final boolean[] received = new boolean[] {false};
         final PropertyChangeListener propertyChangeListener = new 
PropertyChangeListener() {
@@ -154,4 +174,12 @@
         assertTrue(received[0]);
     }
     
+    private APITestRepository getApiRepo() {
+        return APITestKit.getAPIRepo(APITestRepository.ID);
 }
+
+    private Repository getRepo() {
+        return APITestKit.getRepo(APITestRepository.ID);
+    }
+    
+}

[hg] main-silver: more tests

Tomas Stupka 03/01/2013

Project Features

About this Project

ConnectedDeveloper was started in November 2009, is owned by tpavek, and has 66 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close