Fixed bug 381677: 5 compile warnings in official build
diff --git a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/mirror/MirrorManagerTestCase.java b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/mirror/MirrorManagerTestCase.java
index 400eba2..c16a89b 100644
--- a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/mirror/MirrorManagerTestCase.java
+++ b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/mirror/MirrorManagerTestCase.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,16 +11,25 @@
package org.eclipse.update.tests.mirror;
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.StringTokenizer;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Platform;
+
+import org.osgi.framework.Bundle;
+
import org.eclipse.update.configurator.ConfiguratorUtils;
import org.eclipse.update.internal.core.UpdateCore;
import org.eclipse.update.tests.UpdateManagerTestCase;
-import org.osgi.framework.Bundle;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
public class MirrorManagerTestCase extends UpdateManagerTestCase{
@@ -293,32 +302,27 @@
public boolean doesCategoryDefinitionExist(String url) {
File site = new File(url + "/site.xml");
assertTrue(site.exists());
- BufferedReader breader;
- FileReader freader;
+ BufferedReader breader = null;
String text = new String();
try {
- freader = new FileReader(site);
- breader = new BufferedReader(freader);
- } catch (FileNotFoundException e) {
- // would have been caught by assert above
- return false;
- }
-
- try {
+ breader = new BufferedReader(new FileReader(site));
while ((text = breader.readLine()) != null) {
- if (text.indexOf("category-def")!=-1)
+ if (text.indexOf("category-def") != -1)
return true;
}
-
- breader.close();
- freader.close();
return false;
} catch (IOException e) {
- e.printStackTrace();
return false;
+ } finally {
+ if (breader != null) {
+ try {
+ breader.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
}
-
}
public String getEclipseRoot() {
diff --git a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/standalone/StandaloneManagerTestCase.java b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/standalone/StandaloneManagerTestCase.java
index c0aebfe..0b73cd0 100644
--- a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/standalone/StandaloneManagerTestCase.java
+++ b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/standalone/StandaloneManagerTestCase.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,17 +11,28 @@
package org.eclipse.update.tests.standalone;
-import java.io.*;
-import java.net.*;
-import java.util.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import org.eclipse.update.configuration.IConfiguredSite;
+import org.eclipse.update.configuration.IInstallConfiguration;
+import org.eclipse.update.configuration.ILocalSite;
+import org.eclipse.update.configurator.ConfiguratorUtils;
+import org.eclipse.update.core.ISite;
+import org.eclipse.update.core.SiteManager;
+import org.eclipse.update.internal.core.InternalSiteManager;
+import org.eclipse.update.internal.core.UpdateCore;
+import org.eclipse.update.tests.UpdateManagerTestCase;
-import org.eclipse.core.runtime.*;
-import org.eclipse.update.configuration.*;
-import org.eclipse.update.configurator.*;
-import org.eclipse.update.core.*;
-import org.eclipse.update.internal.core.*;
-import org.eclipse.update.tests.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
public class StandaloneManagerTestCase extends UpdateManagerTestCase {
public static StringBuffer errOutput;
@@ -277,33 +288,39 @@
}
public File getLatestConfigurationFile(File localFile) {
-
+ BufferedReader breader = null;
try {
System.out.println("reading from : " + localFile.getAbsolutePath());
- FileReader freader = new FileReader(localFile);
- BufferedReader breader = new BufferedReader(freader);
- while (breader.ready()) {
- breader.readLine();
+ breader = new BufferedReader(new FileReader(localFile));
+ while (breader.ready()) {
+ breader.readLine();
// System.out.println(line);
+ }
+ // read config file
+ File parent = new File(localFile.getParent());
+ System.out.println("parent: " + parent.getAbsolutePath());
+ String[] parList= parent.list();
+ int latest= 0;
+ for (int i = parList.length - 1; i >= 0; i--) {
+ System.out.println("parList[" + i + "]: " + parList[i]);
+ if (parList[i].startsWith("platform")) {
+ latest= i;
+ break;
}
- // read config file
- File parent = new File(localFile.getParent());
- System.out.println("parent: " + parent.getAbsolutePath());
- String[] parList = parent.list();
- int latest = 0;
- for (int i = parList.length-1; i>=0; i--){
- System.out.println("parList[" + i + "]: " + parList[i]);
- if (parList[i].startsWith("platform")){
- latest = i;
- break;
- }
- }
- File configFile = new File(parent.getAbsolutePath() + File.separator + parList[latest]);
- return configFile;
- // end of config file read
+ }
+ File configFile = new File(parent.getAbsolutePath() + File.separator + parList[latest]);
+ return configFile;
+ // end of config file read
} catch (Exception e) {
- System.err.println(e);
e.printStackTrace();
+ } finally {
+ if (breader != null) {
+ try {
+ breader.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
}
return localFile;
}
diff --git a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/standalone/TestFeatureDisable.java b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/standalone/TestFeatureDisable.java
index 9632753..0a87426 100644
--- a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/standalone/TestFeatureDisable.java
+++ b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/standalone/TestFeatureDisable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,13 +11,17 @@
package org.eclipse.update.tests.standalone;
-import java.io.*;
-import java.util.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.eclipse.update.core.SiteManager;
+import org.eclipse.update.internal.core.LocalSite;
+import org.eclipse.update.standalone.StandaloneUpdateApplication;
import org.eclipse.core.runtime.IPlatformRunnable;
-import org.eclipse.update.core.*;
-import org.eclipse.update.internal.core.*;
-import org.eclipse.update.standalone.*;
public class TestFeatureDisable extends StandaloneManagerTestCase {
public static boolean isDisabled;
@@ -76,27 +80,35 @@
}
public boolean checkFeaturesDisabled(ArrayList featureNames, File configFile, String siteLocation){
+ BufferedReader breader = null;
try {
- FileReader freader = new FileReader(configFile);
- BufferedReader breader = new BufferedReader(freader);
+ breader = new BufferedReader(new FileReader(configFile));
String line;
System.out.println("now reading..." + configFile.getAbsolutePath());
boolean isSiteToCheck = false;
while (breader.ready()) {
line = breader.readLine();
- if (line.trim().startsWith("<site url")){
- isSiteToCheck = line.trim().split("\"")[1].replaceFirst("file:","").equals(siteLocation);
- } else if (isSiteToCheck && line.trim().startsWith("<feature configured")){
+ if (line.trim().startsWith("<site url")) {
+ isSiteToCheck = line.trim().split("\"")[1].replaceFirst("file:", "").equals(siteLocation);
+ } else if (isSiteToCheck && line.trim().startsWith("<feature configured")) {
System.err.println(line);
String[] configLine = line.split("\"");
- if (featureNames.contains(configLine[3]) && configLine[1].equals("true")){
+ if (featureNames.contains(configLine[3]) && configLine[1].equals("true")) {
fail(configLine[3] + " has not been disabled.");
}
}
}
} catch (Exception e) {
System.err.println(e);
- }
+ } finally {
+ if (breader != null) {
+ try {
+ breader.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
return true;
}
diff --git a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/standalone/TestFeatureEnable.java b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/standalone/TestFeatureEnable.java
index 3fc407c..12e4515 100644
--- a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/standalone/TestFeatureEnable.java
+++ b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/standalone/TestFeatureEnable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,13 +11,17 @@
package org.eclipse.update.tests.standalone;
-import java.io.*;
-import java.util.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.eclipse.update.core.SiteManager;
+import org.eclipse.update.internal.core.LocalSite;
+import org.eclipse.update.standalone.StandaloneUpdateApplication;
import org.eclipse.core.runtime.IPlatformRunnable;
-import org.eclipse.update.core.*;
-import org.eclipse.update.internal.core.*;
-import org.eclipse.update.standalone.*;
public class TestFeatureEnable extends StandaloneManagerTestCase {
public static boolean isEnabled;
@@ -77,21 +81,21 @@
assertTrue(checkFeaturesEnabled(getArrayList(names),configFile, TARGET_FILE_SITE.getFile()));
}
- public boolean checkFeaturesEnabled(ArrayList featureNames, File configFile, String siteLocation){
+ public boolean checkFeaturesEnabled(ArrayList featureNames, File configFile, String siteLocation) {
+ BufferedReader breader = null;
try {
- FileReader freader = new FileReader(configFile);
- BufferedReader breader = new BufferedReader(freader);
+ breader = new BufferedReader(new FileReader(configFile));
String line;
System.out.println("now reading..." + configFile.getAbsolutePath());
boolean isSiteToCheck = false;
while (breader.ready()) {
line = breader.readLine();
- if (line.trim().startsWith("<site url")){
- isSiteToCheck = line.trim().split("\"")[1].replaceFirst("file:","").equals(siteLocation);
- } else if (isSiteToCheck && line.trim().startsWith("<feature configured")){
+ if (line.trim().startsWith("<site url")) {
+ isSiteToCheck = line.trim().split("\"")[1].replaceFirst("file:", "").equals(siteLocation);
+ } else if (isSiteToCheck && line.trim().startsWith("<feature configured")) {
System.err.println(line);
String[] configLine = line.split("\"");
- if (featureNames.contains(configLine[3]) && configLine[1].equals("false")){
+ if (featureNames.contains(configLine[3]) && configLine[1].equals("false")) {
fail(configLine[3] + " has not been enabled.");
}
// temp - delete later
@@ -102,7 +106,15 @@
}
} catch (Exception e) {
System.err.println(e);
- }
+ } finally {
+ if (breader != null) {
+ try {
+ breader.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
return true;
}