Author: nickboldt
Date: 2010-04-27 10:16:02 -0400 (Tue, 27 Apr 2010)
New Revision: 21732
Modified:
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractRefactorTest.java
Log:
refresh from trunk version
Modified:
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractRefactorTest.java
===================================================================
---
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractRefactorTest.java 2010-04-27
14:12:50 UTC (rev 21731)
+++
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractRefactorTest.java 2010-04-27
14:16:02 UTC (rev 21732)
@@ -1,5 +1,7 @@
package org.jboss.tools.tests;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
@@ -13,7 +15,6 @@
import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
import org.eclipse.text.edits.MultiTextEdit;
-import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.test.util.JobUtils;
public class AbstractRefactorTest extends TestCase{
@@ -30,7 +31,7 @@
IFile file = changeStructure.getProject().getFile(changeStructure.getFileName());
String content = null;
try {
- content = FileUtil.readStream(file);
+ content = readStream(file);
} catch (CoreException e) {
e.printStackTrace();
fail(e.getMessage());
@@ -67,7 +68,7 @@
for(TestChangeStructure changeStructure : changeList){
IFile file = changeStructure.getProject().getFile(changeStructure.getFileName());
String content = null;
- content = FileUtil.readStream(file);
+ content = readStream(file);
for(TestTextChange change : changeStructure.getTextChanges()){
assertEquals("There is unexpected change in resource -
"+file.getName(),change.getText(), content.substring(change.getOffset(),
change.getOffset()+change.getLength()));
}
@@ -140,5 +141,41 @@
return text;
}
}
+
+ public static String readStream(InputStream is) {
+ StringBuffer sb = new StringBuffer(""); //$NON-NLS-1$
+ try {
+ byte[] b = new byte[4096];
+ while(true) {
+ int l = is.read(b, 0, b.length);
+ if(l < 0) break;
+ sb.append(new String(b, 0, l));
+ }
+ is.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ return sb.toString();
+ }
+
+ public static String readStream(IFile file) throws CoreException {
+ String content = null;
+ InputStream in = null;
+ try {
+ in = file.getContents();
+ content = readStream(in);
+ } finally {
+ if(in!=null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+ }
+ return content;
+ }
}
Show replies by date