diff options
author | Sergey Prigogin | 2016-08-08 04:51:33 +0000 |
---|---|---|
committer | Sergey Prigogin | 2016-08-08 04:55:42 +0000 |
commit | c14079638f082f3bcd2062f07fddcfd6391beaf8 (patch) | |
tree | 934fc4c3ba32c30d5b5f4a6f7fecad18005c2ff8 | |
parent | 007c431c1f36a68654d238fc68f7912c9530b228 (diff) | |
download | eclipse.platform.team-c14079638f082f3bcd2062f07fddcfd6391beaf8.tar.gz eclipse.platform.team-c14079638f082f3bcd2062f07fddcfd6391beaf8.tar.xz eclipse.platform.team-c14079638f082f3bcd2062f07fddcfd6391beaf8.zip |
Fixed compiler warnings.
Change-Id: Id03714d70eb65b4c8991cca5bad9d8f99c9c4b9f
9 files changed, 143 insertions, 151 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserAuthenticator.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserAuthenticator.java index 4415d2184..42bfda169 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserAuthenticator.java +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserAuthenticator.java @@ -11,6 +11,7 @@ *******************************************************************************/ package org.eclipse.team.internal.ccvs.core; +import java.util.List; import java.util.Map; /** @@ -20,7 +21,6 @@ import java.util.Map; * appropriate for the given repository type. */ public interface IUserAuthenticator { - /** * Button id for an "Ok" button (value 0). */ @@ -148,5 +148,5 @@ public interface IUserAuthenticator { * (as values) or <code>null</code> if the operation is to be * canceled */ - public abstract Map promptToConfigureRepositoryLocations(Map alternativeMap); + public abstract Map<ICVSRepositoryLocation, List<String>> promptToConfigureRepositoryLocations(Map<ICVSRepositoryLocation, List<String>> alternativeMap); } diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java index 59aee7086..f32fb4499 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java @@ -46,10 +46,8 @@ import org.osgi.service.prefs.Preferences; * * Instances must be disposed of when no longer needed in order to * notify the authenticator so cached properties can be cleared - * */ public class CVSRepositoryLocation extends PlatformObject implements ICVSRepositoryLocation, IUserInfo { - /** * Top secure preferences node to cache CVS information */ @@ -90,7 +88,7 @@ public class CVSRepositoryLocation extends PlatformObject implements ICVSReposit // Locks for ensuring that authentication to a host is serialized // so that invalid passwords do not result in account lockout - private static Map hostLocks = new HashMap(); + private static Map<String, ILock> hostLocks = new HashMap<String, ILock>(); private IConnectionMethod method; private String user; @@ -277,7 +275,7 @@ public class CVSRepositoryLocation extends PlatformObject implements ICVSReposit int end; // For parsing alternative location format int optionStart = location.indexOf(SEMICOLON); - HashMap hmOptions = new HashMap(); + HashMap<String, String> hmOptions = new HashMap<>(); if (start == 0) { end = location.indexOf(COLON, start + 1); @@ -422,7 +420,7 @@ public class CVSRepositoryLocation extends PlatformObject implements ICVSReposit */ public static IConnectionMethod[] getPluggedInConnectionMethods() { if(pluggedInConnectionMethods==null) { - List connectionMethods = new ArrayList(); + List<Object> connectionMethods = new ArrayList<Object>(); if (STANDALONE_MODE) { connectionMethods.add(new PServerConnectionMethod()); @@ -443,7 +441,7 @@ public class CVSRepositoryLocation extends PlatformObject implements ICVSReposit } } } - IConnectionMethod[] methods = (IConnectionMethod[]) connectionMethods.toArray(new IConnectionMethod[0]); + IConnectionMethod[] methods = connectionMethods.toArray(new IConnectionMethod[0]); Arrays.sort(methods, new Comparator(){ public int compare(Object o1, Object o2) { if (o1 instanceof IConnectionMethod && o2 instanceof IConnectionMethod) { @@ -660,14 +658,14 @@ public class CVSRepositoryLocation extends PlatformObject implements ICVSReposit ICVSRemoteResource[] resources = root.members(progress); // There is the off chance that there is a file in the root of the repository. // This is not supported by cvs so we need to make sure there are no files - List folders = new ArrayList(resources.length); + List<ICVSRemoteResource> folders = new ArrayList<ICVSRemoteResource>(resources.length); for (int i = 0; i < resources.length; i++) { ICVSRemoteResource remoteResource = resources[i]; if (remoteResource.isContainer()) { folders.add(remoteResource); } } - return (ICVSRemoteResource[]) folders.toArray(new ICVSRemoteResource[folders.size()]); + return folders.toArray(new ICVSRemoteResource[folders.size()]); } } catch (CVSException e){ // keep current CVSException @@ -757,7 +755,7 @@ public class CVSRepositoryLocation extends PlatformObject implements ICVSReposit Policy.checkCanceled(monitor); ILock hostLock; synchronized(hostLocks) { - hostLock = (ILock)hostLocks.get(getHost()); + hostLock = hostLocks.get(getHost()); if (hostLock == null) { hostLock = Job.getJobManager().newLock(); hostLocks.put(getHost(), hostLock); @@ -1124,7 +1122,7 @@ public class CVSRepositoryLocation extends PlatformObject implements ICVSReposit CVS_RSH_PARAMETERS = stringReplace(CVS_RSH_PARAMETERS, PORT_VARIABLE, new Integer(port).toString()); // Build the command list to be sent to the OS. - List commands = new ArrayList(); + List<String> commands = new ArrayList<String>(); commands.add(CVS_RSH); StringTokenizer tokenizer = new StringTokenizer(CVS_RSH_PARAMETERS); while (tokenizer.hasMoreTokens()) { @@ -1133,7 +1131,7 @@ public class CVSRepositoryLocation extends PlatformObject implements ICVSReposit } commands.add(CVS_SERVER); commands.add(INVOKE_SVR_CMD); - return (String[]) commands.toArray(new String[commands.size()]); + return commands.toArray(new String[commands.size()]); } /* diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseRunnable.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseRunnable.java index 3ded34115..5b5713371 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseRunnable.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseRunnable.java @@ -25,6 +25,7 @@ public class EclipseRunnable implements Runnable { this.op = op; } + @Override public void run() { try { op.run(monitor); diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java index d7cecce82..9d7c8ad2d 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java @@ -104,7 +104,6 @@ import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.internal.decorators.DecoratorManager; public class EclipseTest extends ResourceTest { - private static final int LOCK_WAIT_TIME = 1000; private static final String CVS_TEST_LOCK_FILE = ".lock"; private static final String CVS_TEST_LOCK_PROJECT = "cvsTestLock"; @@ -154,14 +153,14 @@ public class EclipseTest extends ResourceTest { } - public static Test suite(Class c) { + public static Test suite(Class<?> c) { String testName = System.getProperty("eclipse.cvs.testName"); if (testName == null) { TestSuite suite = new TestSuite(c); return new CVSTestSetup(suite); } else { try { - return new CVSTestSetup((Test)c.getConstructor(new Class[] { String.class }).newInstance(new Object[] {testName})); + return new CVSTestSetup((Test) c.getConstructor(new Class[] { String.class }).newInstance(new Object[] {testName})); } catch (Exception e) { fail(e.getMessage()); // Above will throw so below is never actually reached @@ -284,7 +283,7 @@ public class EclipseTest extends ResourceTest { * Delete the resources from an existing container and the changes to CVS */ public IResource[] changeResources(IContainer container, String[] hierarchy, boolean checkin) throws CoreException, TeamException { - List changedResources = new ArrayList(hierarchy.length); + List<IResource> changedResources = new ArrayList<>(hierarchy.length); for (int i=0;i<hierarchy.length;i++) { IResource resource = container.findMember(hierarchy[i]); if (resource.getType() == IResource.FILE) { @@ -292,7 +291,7 @@ public class EclipseTest extends ResourceTest { setContentsAndEnsureModified((IFile)resource); } } - IResource[] resources = (IResource[])changedResources.toArray(new IResource[changedResources.size()]); + IResource[] resources = changedResources.toArray(new IResource[changedResources.size()]); if (checkin) commitResources(resources, IResource.DEPTH_ZERO); return resources; } @@ -311,7 +310,7 @@ public class EclipseTest extends ResourceTest { /** * Delete the resources and mark them as outgoing deletions. * Deleting the resources is enough since the move/delete hook will - * tak care of making them outgoing deletions. + * take care of making them outgoing deletions. */ protected void deleteResources(IResource[] resources) throws TeamException, CoreException { if (resources.length == 0) return; @@ -363,19 +362,24 @@ public class EclipseTest extends ResourceTest { options = Command.NO_LOCAL_OPTIONS; if (isModelSyncEnabled() && options == Command.NO_LOCAL_OPTIONS) { executeHeadless(new ModelUpdateOperation(null, mappings, false) { - protected boolean isAttemptHeadlessMerge() { + @Override + protected boolean isAttemptHeadlessMerge() { return true; } - protected void handlePreviewRequest() { + @Override + protected void handlePreviewRequest() { // Don't preview anything } - protected void handleNoChanges() { + @Override + protected void handleNoChanges() { // Do nothing } - protected void handleValidationFailure(IStatus status) { + @Override + protected void handleValidationFailure(IStatus status) { // Do nothing } - protected void handleMergeFailure(IStatus status) { + @Override + protected void handleMergeFailure(IStatus status) { // Do nothing } }); @@ -397,16 +401,20 @@ public class EclipseTest extends ResourceTest { protected void replace(ResourceMapping[] mappings) throws CVSException { if (isModelSyncEnabled()) { executeHeadless(new ModelReplaceOperation(null, mappings, false) { - protected boolean promptForOverwrite() { + @Override + protected boolean promptForOverwrite() { return true; } - protected void handlePreviewRequest() { + @Override + protected void handlePreviewRequest() { // Don't prompt } - protected void handleMergeFailure(IStatus status) { + @Override + protected void handleMergeFailure(IStatus status) { // Don't prompt } - protected void handleValidationFailure(IStatus status) { + @Override + protected void handleValidationFailure(IStatus status) { // Don't prompt } }); @@ -536,11 +544,11 @@ public class EclipseTest extends ResourceTest { * resources are auto-managed, if false, they are left un-managed. */ public IResource[] buildResources(IContainer container, String[] hierarchy, boolean includeContainer) throws CoreException { - List resources = new ArrayList(hierarchy.length + 1); + List<IResource> resources = new ArrayList<>(hierarchy.length + 1); resources.addAll(Arrays.asList(buildResources(container, hierarchy))); if (includeContainer) resources.add(container); - IResource[] result = (IResource[]) resources.toArray(new IResource[resources.size()]); + IResource[] result = resources.toArray(new IResource[resources.size()]); ensureExistsInWorkspace(result, true); for (int i = 0; i < result.length; i++) { if (result[i].getType() == IResource.FILE) @@ -553,37 +561,36 @@ public class EclipseTest extends ResourceTest { /* * Checkout a copy of the project into a project with the given postfix */ - protected IProject checkoutCopy(IProject project, String postfix) throws TeamException { + protected IProject checkoutCopy(IProject project, String postfix) throws TeamException { // Check the project out under a different name and validate that the results are the same IProject copy = getWorkspace().getRoot().getProject(project.getName() + postfix); checkout(getRepository(), copy, CVSWorkspaceRoot.getCVSFolderFor(project).getFolderSyncInfo().getRepository(), null, DEFAULT_MONITOR); return copy; - } - - protected IProject checkoutCopy(IProject project, CVSTag tag) throws TeamException { + } + + protected IProject checkoutCopy(IProject project, CVSTag tag) throws TeamException { // Check the project out under a different name and validate that the results are the same IProject copy = getWorkspace().getRoot().getProject(project.getName() + tag.getName()); checkout(getRepository(), copy, - CVSWorkspaceRoot.getCVSFolderFor(project).getFolderSyncInfo().getRepository(), - tag, DEFAULT_MONITOR); + CVSWorkspaceRoot.getCVSFolderFor(project).getFolderSyncInfo().getRepository(), + tag, DEFAULT_MONITOR); return copy; - } - + } + public static void checkout( - final ICVSRepositoryLocation repository, - final IProject project, - final String sourceModule, - final CVSTag tag, - IProgressMonitor monitor) - throws TeamException { - + final ICVSRepositoryLocation repository, + final IProject project, + final String sourceModule, + final CVSTag tag, + IProgressMonitor monitor) + throws TeamException { RemoteFolder remote = new RemoteFolder(null, repository, sourceModule == null ? project.getName() : sourceModule, tag); executeHeadless(new CheckoutSingleProjectOperation(null, remote, project, null, false /* the project is not preconfigured */) { + @Override public boolean promptToOverwrite(String title, String msg, IResource resource) { return true; } }); - } protected IProject checkoutProject(IProject project, String moduleName, CVSTag tag) throws TeamException { @@ -591,7 +598,8 @@ public class EclipseTest extends ResourceTest { project = getWorkspace().getRoot().getProject(new Path(moduleName).lastSegment()); checkout(getRepository(), project, moduleName, tag, DEFAULT_MONITOR); return project; - } + } + /* * This method creates a project with the given resources, imports * it to CVS and checks it out @@ -776,12 +784,12 @@ public class EclipseTest extends ResourceTest { ICVSRemoteResource[] members1 = container1.getMembers(DEFAULT_MONITOR); ICVSRemoteResource[] members2 = container2.getMembers(DEFAULT_MONITOR); assertTrue("Number of members differ for " + path, members1.length == members2.length); - Map memberMap2 = new HashMap(); - for (int i= 0;i <members2.length;i++) { + Map<String, ICVSRemoteResource> memberMap2 = new HashMap<>(); + for (int i= 0; i < members2.length; i++) { memberMap2.put(members2[i].getName(), members2[i]); } - for (int i= 0;i <members1.length;i++) { - ICVSRemoteResource member2 = (ICVSRemoteResource)memberMap2.get(members1[i].getName()); + for (int i= 0; i < members1.length; i++) { + ICVSRemoteResource member2 = memberMap2.get(members1[i].getName()); assertNotNull("Resource does not exist: " + path.append(members1[i].getName()) + member2); assertEquals(path, members1[i], member2, includeTags); } @@ -862,6 +870,7 @@ public class EclipseTest extends ResourceTest { for (int i = 0; i < resources.length; i++) { IResource resource = resources[i]; resource.accept(new IResourceVisitor() { + @Override public boolean visit(IResource resource) throws CoreException { if (resource.getType() == IResource.FILE) { assertEquals(isReadOnly, resource.getResourceAttributes().isReadOnly()); @@ -991,14 +1000,14 @@ public class EclipseTest extends ResourceTest { } protected void commitNewProject(IProject project) throws CoreException, CVSException, TeamException { - List resourcesToAdd = new ArrayList(); + List<IResource> resourcesToAdd = new ArrayList<IResource>(); IResource[] members = project.members(); for (int i = 0; i < members.length; i++) { if ( ! CVSWorkspaceRoot.getCVSResourceFor(members[i]).isIgnored()) { resourcesToAdd.add(members[i]); } } - addResources((IResource[]) resourcesToAdd.toArray(new IResource[resourcesToAdd.size()])); + addResources(resourcesToAdd.toArray(new IResource[resourcesToAdd.size()])); commitResources(new IResource[] {project}, IResource.DEPTH_INFINITE); // Pause to ensure that future operations happen later than timestamp of committed resources waitMsec(1500); @@ -1008,6 +1017,7 @@ public class EclipseTest extends ResourceTest { * Return an input stream with some random text to use * as contents for a file resource. */ + @Override public InputStream getRandomContents() { return getRandomContents(RANDOM_CONTENT_SIZE); } @@ -1081,21 +1091,29 @@ public class EclipseTest extends ResourceTest { public static void waitForSubscriberInputHandling(SubscriberSyncInfoCollector input) { input.waitForCollector(new IProgressMonitor() { + @Override public void beginTask(String name, int totalWork) { } + @Override public void done() { } + @Override public void internalWorked(double work) { } + @Override public boolean isCanceled() { return false; } + @Override public void setCanceled(boolean value) { } + @Override public void setTaskName(String name) { } + @Override public void subTask(String name) { } + @Override public void worked(int work) { while (Display.getCurrent().readAndDispatch()) {} } @@ -1120,16 +1138,15 @@ public class EclipseTest extends ResourceTest { throw CVSException.wrapException(ex); } - protected void setUp() throws Exception { + @Override + protected void setUp() throws Exception { RepositoryProviderOperation.consultModelsWhenBuildingScope = false; if (CVSTestSetup.ENSURE_SEQUENTIAL_ACCESS) obtainCVSServerLock(); super.setUp(); } - /* (non-Javadoc) - * @see junit.framework.TestCase#tearDown() - */ + @Override protected void tearDown() throws Exception { RepositoryProviderOperation.consultModelsWhenBuildingScope = true; if (CVSTestSetup.ENSURE_SEQUENTIAL_ACCESS) @@ -1332,9 +1349,7 @@ public class EclipseTest extends ResourceTest { } } - /* (non-Javadoc) - * @see junit.framework.TestCase#runBare() - */ + @Override public void runBare() throws Throwable { try { super.runBare(); @@ -1364,9 +1379,7 @@ public class EclipseTest extends ResourceTest { return false; } - /* (non-Javadoc) - * @see org.eclipse.core.tests.harness.EclipseWorkspaceTest#ensureDoesNotExistInWorkspace(org.eclipse.core.resources.IResource) - */ + @Override public void ensureDoesNotExistInWorkspace(IResource resource) { // Overridden to change how the workspace is deleted on teardown if (resource.getType() == IResource.ROOT) { @@ -1400,6 +1413,7 @@ public class EclipseTest extends ResourceTest { if (resource.exists()) { try { resource.accept(new IResourceVisitor() { + @Override public boolean visit(IResource resource) throws CoreException { ResourceAttributes attrs = resource.getResourceAttributes(); if (resource.exists() && attrs.isReadOnly()) { @@ -1421,8 +1435,9 @@ public class EclipseTest extends ResourceTest { * contains any failures */ public void ensureDoesNotExistInWorkspace(final IProject[] projects) { - final Map failures = new HashMap(); + final Map<IProject, CoreException> failures = new HashMap<IProject, CoreException>(); IWorkspaceRunnable body = new IWorkspaceRunnable() { + @Override public void run(IProgressMonitor monitor) { for (int i = 0; i < projects.length; i++) { try { @@ -1454,8 +1469,8 @@ public class EclipseTest extends ResourceTest { if (!failures.isEmpty()) { StringBuffer text = new StringBuffer(); text.append("Could not delete all projects: "); - for (Iterator iter = failures.keySet().iterator(); iter.hasNext();) { - IProject project = (IProject) iter.next(); + for (Iterator<IProject> iter = failures.keySet().iterator(); iter.hasNext();) { + IProject project = iter.next(); text.append(project.getName()); } fail(text.toString()); @@ -1476,10 +1491,8 @@ public class EclipseTest extends ResourceTest { } } - /* (non-Javadoc) - * @see junit.framework.TestCase#runTest() - */ - protected void runTest() throws Throwable { + @Override + protected void runTest() throws Throwable { if (!CVSTestSetup.RECORD_PROTOCOL_TRAFFIC) { super.runTest(); return; @@ -1507,7 +1520,8 @@ public class EclipseTest extends ResourceTest { } } - protected void cleanup() throws CoreException { + @Override + protected void cleanup() throws CoreException { ensureDoesNotExistInWorkspace(getWorkspace().getRoot()); getWorkspace().save(true, null); //don't leak builder jobs, since they may affect subsequent tests diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/FindCommittersTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/FindCommittersTest.java index 85ed8897b..8dad46d06 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/FindCommittersTest.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/FindCommittersTest.java @@ -29,7 +29,7 @@ public class FindCommittersTest extends EclipseTest { public class FindCommittersOperation extends RemoteLogOperation { private LogEntryCache cache; - private Set authors; + private Set<String> authors; public FindCommittersOperation(IWorkbenchPart part, ICVSRemoteResource[] remoteResources, CVSTag tag1, CVSTag tag2, @@ -38,11 +38,14 @@ public class FindCommittersTest extends EclipseTest { this.cache = cache; } + @Override protected LocalOption[] getLocalOptions(CVSTag tag1, CVSTag tag2) { return new Command.LocalOption[] {RLog.NO_TAGS, RLog.ONLY_INCLUDE_CHANGES, RLog.REVISIONS_ON_DEFAULT_BRANCH, new LocalOption("-d" + tag1.asDate() + "<" + tag2.asDate().toString(), null) { }}; } + + @Override protected void execute(ICVSRepositoryLocation location, ICVSRemoteResource[] remoteResources, IProgressMonitor monitor) throws CVSException { @@ -54,9 +57,9 @@ public class FindCommittersTest extends EclipseTest { authors = getAuthors(cache); } - private Set getAuthors(RemoteLogOperation.LogEntryCache logEntryCache) { + private Set<String> getAuthors(RemoteLogOperation.LogEntryCache logEntryCache) { String[] paths = logEntryCache.getCachedFilePaths(); - Set authors = new HashSet(); + Set<String> authors = new HashSet<>(); for (int i = 0; i < paths.length; i++) { String path = paths[i]; ILogEntry[] entries = logEntryCache.getLogEntries(path); @@ -68,7 +71,7 @@ public class FindCommittersTest extends EclipseTest { return authors; } - public Set getAuthors() { + public Set<String> getAuthors() { return authors; } } @@ -94,23 +97,20 @@ public class FindCommittersTest extends EclipseTest { public void testFetchLogs() throws CVSException, InvocationTargetException, InterruptedException { CVSRepositoryLocation location = CVSRepositoryLocation.fromString(":pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse"); ICVSRemoteResource[] members = location.members(null, false, DEFAULT_MONITOR); - Set authors = fetchLogs(members); - for (Iterator iterator = authors.iterator(); iterator.hasNext();) { - String name = (String) iterator.next(); + Set<String> authors = fetchLogs(members); + for (String name : authors) { System.out.println(name); } - } - private Set fetchLogs( + private Set<String> fetchLogs( ICVSRemoteResource[] members) throws InvocationTargetException, InterruptedException { - CVSTag tag1 = new CVSTag(new Date(101, 10, 07)); + CVSTag tag1 = new CVSTag(new GregorianCalendar(2001, 10, 7).getTime()); CVSTag tag2 = new CVSTag(new Date()); RemoteLogOperation.LogEntryCache logEntryCache = new RemoteLogOperation.LogEntryCache(); FindCommittersOperation op = new FindCommittersOperation(null, members, tag1, tag2, logEntryCache); op.run(DEFAULT_MONITOR); return op.getAuthors(); } - } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/JUnitTestCase.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/JUnitTestCase.java index e4bf058b4..cde3a09e9 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/JUnitTestCase.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/JUnitTestCase.java @@ -34,9 +34,9 @@ import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; /** - * Base-class to the low level-testcases for the Session. - * Supplies convinience-methods and default attributes for the testcases. - * Especally data for a default-connection to the server is stored. + * Base-class to the low level test cases for the Session. + * Supplies convenience-methods and default attributes for the test cases. + * Especially data for a default-connection to the server is stored. */ public abstract class JUnitTestCase extends TestCase { protected static final int RANDOM_CONTENT_SIZE = 10000; @@ -47,7 +47,7 @@ public abstract class JUnitTestCase extends TestCase { public static final String[] EMPTY_ARGS = new String[0]; /** - * Init the options and arguments to standard-values + * Initializes the options and arguments to standard-values */ public JUnitTestCase(String name) { super(name); @@ -61,10 +61,12 @@ public abstract class JUnitTestCase extends TestCase { } /** - * Delete a project/resource form the specified cvs-server + * Deletes a project/resource form the specified cvs-server + * + * @throws CVSException */ protected static void magicDeleteRemote(ICVSRepositoryLocation location, String remoteName) - throws CVSException { + throws CVSException { CVSTestSetup.executeRemoteCommand(location, "rm -rf " + new Path(location.getRootDirectory()).append(remoteName).toString()); } @@ -108,13 +110,12 @@ public abstract class JUnitTestCase extends TestCase { * Compare Arrays and find the first different element */ protected static void assertEqualsArrays(Object[] obArr1, Object[] obArr2) { - assertEquals("Called assertEqualsArrays with null on one side", obArr1 == null,obArr2 == null); if (obArr1 == null) { return; } - for (int i=0; i<Math.min(obArr1.length,obArr2.length); i++) { + for (int i = 0; i < Math.min(obArr1.length,obArr2.length); i++) { assertEquals("At Element " + i + " of the array",obArr1[i],obArr2[i]); } @@ -130,14 +131,15 @@ public abstract class JUnitTestCase extends TestCase { assertEquals("Arrays of different length",obArr2[obArr1.length],null); return; } - } /** - * Write text lines to file from an array of strings. + * Writes text lines to file from an array of strings. + * + * @throws IOException */ protected static void writeToFile(IFile file, String[] contents) - throws IOException, CoreException { + throws IOException, CoreException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); PrintStream os = new PrintStream(bos); try { @@ -157,13 +159,14 @@ public abstract class JUnitTestCase extends TestCase { } /** - * Read text lines from file into an array of strings. + * Reads text lines from file into an array of strings. */ protected static String[] readFromFile(IFile file) - throws IOException, CoreException { - if (! file.exists()) return null; + throws IOException, CoreException { + if (!file.exists()) + return null; BufferedReader reader = new BufferedReader(new InputStreamReader(file.getContents())); - List fileContentStore = new ArrayList(); + List<String> fileContentStore = new ArrayList<>(); try { String line; while ((line = reader.readLine()) != null) { @@ -172,7 +175,7 @@ public abstract class JUnitTestCase extends TestCase { } finally { reader.close(); } - return (String[]) fileContentStore.toArray(new String[fileContentStore.size()]); + return fileContentStore.toArray(new String[fileContentStore.size()]); } /** @@ -212,23 +215,22 @@ public abstract class JUnitTestCase extends TestCase { } /** - * genertates Random content meand to be written in a File + * Generates random content meant to be written in a file. */ protected static String createRandomContent() { - StringBuffer content = new StringBuffer(); int contentSize; content.append("Random file generated for test" + PLATFORM_NEWLINE); contentSize = (int) Math.round(RANDOM_CONTENT_SIZE * 2 * Math.random()); - for (int i=0; i<contentSize; i++) { + for (int i = 0; i <contentSize; i++) { - if (Math.random()>0.99) { + if (Math.random() > 0.99) { content.append(PLATFORM_NEWLINE); } - if (Math.random()>0.99) { + if (Math.random() > 0.99) { content.append("\n"); } @@ -289,7 +291,7 @@ public abstract class JUnitTestCase extends TestCase { } /** - * Build the given fileStructure, all files are going to have + * Builds the given fileStructure, all files are going to have * sample content, all folders on the way are created. */ protected static void createRandomFile(IContainer parent, String[] fileNameArray) @@ -318,12 +320,11 @@ public abstract class JUnitTestCase extends TestCase { /** * Call this method from the main-method of your test-case. - * It initialises some required parameter and runs the testcase. + * It initializes some required parameter and runs the test case. */ - protected static void run(Class test) { + protected static void run(Class<? extends TestCase> test) { // XXX is this property used anywhere? System.setProperty("eclipse.cvs.standalone", "true"); TestRunner.run(test); } } - diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestConnection.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestConnection.java index 471204b69..3189f514e 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestConnection.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestConnection.java @@ -29,13 +29,11 @@ import org.eclipse.team.internal.ccvs.core.connection.CVSAuthenticationException * Window>Preferences>Java>Code Generation>Code and Comments */ public class TestConnection implements IServerConnection { - public static TestConnection currentConnection; - public static List previousLines; + public static List<String> previousLines; public static StringBuffer currentLine; - private ByteArrayInputStream serverResponse; private static final String VALID_SERVER_REQUESTS = "Valid-requests Root Valid-responses valid-requests Repository Directory Max-dotdot Static-directory Sticky Checkin-prog Update-prog Entry Kopt Checkin-time Modified Is-modified UseUnchanged Unchanged Notify Questionable Case Argument Argumentx Global_option Gzip-stream wrapper-sendme-rcsOptions Set Kerberos-encrypt Gssapi-encrypt Gssapi-authenticate expand-modules ci co update diff log rlog add remove update-patches gzip-file-contents status rdiff tag rtag import admin export history release watch-on watch-off watch-add watch-remove watchers editors init annotate rannotate noop version"; @@ -46,38 +44,31 @@ public class TestConnection implements IServerConnection { } public static String getLastLine() { - if (previousLines.isEmpty()) return null; - return (String)previousLines.get(previousLines.size() - 1); + if (previousLines.isEmpty()) + return null; + return previousLines.get(previousLines.size() - 1); } - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.IServerConnection#open(org.eclipse.core.runtime.IProgressMonitor) - */ + @Override public void open(IProgressMonitor monitor) throws IOException, CVSAuthenticationException { resetStreams(); } - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.IServerConnection#close() - */ + @Override public void close() throws IOException { resetStreams(); } - /** - * - */ private void resetStreams() { currentLine = new StringBuffer(); - previousLines = new ArrayList(); + previousLines = new ArrayList<>(); } - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.IServerConnection#getInputStream() - */ + @Override public InputStream getInputStream() { // TODO Auto-generated method stub return new InputStream() { + @Override public int read() throws IOException { if (serverResponse == null) { throw new IOException("Not prepared to make a response"); @@ -88,11 +79,10 @@ public class TestConnection implements IServerConnection { }; } - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.IServerConnection#getOutputStream() - */ + @Override public OutputStream getOutputStream() { return new OutputStream() { + @Override public void write(int output) throws IOException { byte b = (byte)output; if (b == '\n') { diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestConnectionMethod.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestConnectionMethod.java index 64d0f98e4..462b51911 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestConnectionMethod.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestConnectionMethod.java @@ -21,26 +21,18 @@ import org.eclipse.team.internal.ccvs.core.IServerConnection; * Window>Preferences>Java>Code Generation>Code and Comments */ public class TestConnectionMethod implements IConnectionMethod { - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.IConnectionMethod#getName() - */ + @Override public String getName() { return "test"; } - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.IConnectionMethod#createConnection(org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, java.lang.String) - */ + @Override public IServerConnection createConnection(ICVSRepositoryLocation location, String password) { return TestConnection.createConnection(location, password); } - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.IConnectionMethod#disconnect(org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation) - */ + @Override public void disconnect(ICVSRepositoryLocation location) { // Nothing need to be done } - } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestsUserAuthenticator.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestsUserAuthenticator.java index ad867573b..d8030db27 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestsUserAuthenticator.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestsUserAuthenticator.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.team.tests.ccvs.core; +import java.util.List; import java.util.Map; import org.eclipse.team.internal.ccvs.core.CVSException; @@ -21,32 +22,27 @@ import org.eclipse.team.internal.ccvs.core.IUserInfo; * A test authenticator that provide defaults for all methods. */ public class TestsUserAuthenticator implements IUserAuthenticator { - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.IUserAuthenticator#promptForUserInfo(org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, org.eclipse.team.internal.ccvs.core.IUserInfo, java.lang.String) - */ + @Override public void promptForUserInfo(ICVSRepositoryLocation location, IUserInfo userInfo, String message) throws CVSException { } - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.IUserAuthenticator#prompt(org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, int, java.lang.String, java.lang.String, int[], int) - */ + @Override public int prompt(ICVSRepositoryLocation location, int promptType, String title, String message, int[] promptResponses, int defaultResponseIndex) { return defaultResponseIndex; } - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.IUserAuthenticator#promptForKeyboradInteractive(org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, java.lang.String, java.lang.String, java.lang.String, java.lang.String[], boolean[]) - */ + @Override public String[] promptForKeyboradInteractive(ICVSRepositoryLocation location, String destination, String name, String instruction, String[] prompt, boolean[] echo) throws CVSException { return prompt; } - public boolean promptForHostKeyChange(ICVSRepositoryLocation location) { + @Override + public boolean promptForHostKeyChange(ICVSRepositoryLocation location) { return false; } - public Map promptToConfigureRepositoryLocations(Map alternativeMap) { + @Override + public Map<ICVSRepositoryLocation, List<String>> promptToConfigureRepositoryLocations(Map<ICVSRepositoryLocation, List<String>> alternativeMap) { return null; } } |