Author: akazakov
Date: 2009-11-09 17:36:17 -0500 (Mon, 09 Nov 2009)
New Revision: 18522
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/refactoring/SeamContextVariableRefactoringTest.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistTestCase.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/view/SeamComponentsViewTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5179
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java 2009-11-09
22:35:15 UTC (rev 18521)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java 2009-11-09
22:36:17 UTC (rev 18522)
@@ -11,6 +11,7 @@
package org.jboss.tools.seam.core.test;
import java.io.IOException;
+import java.io.InputStream;
import java.util.Set;
import org.eclipse.core.resources.IFile;
@@ -21,6 +22,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.preference.IPersistentPreferenceStore;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.jsf.JSFModelPlugin;
import org.jboss.tools.jsf.preferences.JSFSeverityPreferences;
import org.jboss.tools.jst.web.kb.validation.IValidator;
@@ -123,10 +125,20 @@
}
private void copyContentsFile(IFile originalFile, IFile newContentFile){
- try{
- originalFile.setContents(newContentFile.getContents(), true, false, null);
- }catch(Exception e){
+ InputStream is = null;
+ try {
+ is = newContentFile.getContents();
+ originalFile.setContents(is, true, false, null);
+ } catch (CoreException e) {
JUnitUtils.fail("Error during changing
'"+originalFile.getFullPath()+"' content to
'"+newContentFile.getFullPath()+"'", e);
+ } finally {
+ if(is!=null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
}
}
@@ -212,7 +224,7 @@
IFile newContentFile =
project.getFile("src/action/org/domain/SeamWebWarTestProject/session/BbcComponent.3");
IFile targetFile =
project.getFile("src/action/org/domain/SeamWebWarTestProject/session/BbcComponent.java");
- targetFile.setContents(newContentFile.getContents(), true, false, null);
+ FileUtil.copyContent(newContentFile, targetFile, true, false, null);
refreshProject(project);
}
@@ -400,14 +412,26 @@
*/
protected void assertMarkerIsCreated(String targetPath, String newContentPath,
String pattern, int line) throws CoreException {
-
+
IFile newContentFile = project.getFile(newContentPath);
IFile targetFile = project.getFile(targetPath);
- targetFile.setContents(newContentFile.getContents(), true, false, null);
+ InputStream is = null;
+ try {
+ is = newContentFile.getContents();
+ targetFile.setContents(is, true, false, null);
+ } finally {
+ if(is!=null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
refreshProject(project);
assertMarkerIsCreated(targetFile, MARKER_TYPE, pattern, line);
}
-
+
/**
* @param statefulComponentFile
* @param string
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/refactoring/SeamContextVariableRefactoringTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/refactoring/SeamContextVariableRefactoringTest.java 2009-11-09
22:35:15 UTC (rev 18521)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/refactoring/SeamContextVariableRefactoringTest.java 2009-11-09
22:36:17 UTC (rev 18522)
@@ -68,7 +68,7 @@
for(TestChangeStructure changeStructure : changeList){
IFile file = changeStructure.getProject().getFile(changeStructure.getFileName());
String content = null;
- content = FileUtil.readStream(file.getContents());
+ content = FileUtil.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()));
}
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistTestCase.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistTestCase.java 2009-11-09
22:35:15 UTC (rev 18521)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistTestCase.java 2009-11-09
22:36:17 UTC (rev 18522)
@@ -32,6 +32,7 @@
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
+import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.jst.jsp.contentassist.AutoContentAssistantProposal;
import org.jboss.tools.jst.jsp.test.TestUtil;
import org.jboss.tools.jst.jsp.test.ca.ContentAssistantTestCase;
@@ -290,7 +291,7 @@
IFile newComponent =
project.getFile("src/action/demo/TestComponentForVarAttributes.1");
IFile emptyComponent =
project.getFile("src/action/demo/TestComponentForVarAttributes.2");
try{
- component.setContents(newComponent.getContents(), true, false, new
NullProgressMonitor());
+ FileUtil.copyContent(newComponent, component, true, false, new
NullProgressMonitor());
}catch(Exception e){
JUnitUtils.fail("Error during changing
'TestComponentForVarAttributes.java' content to
'TestComponentForVarAttributes.1'", e);
}
@@ -300,7 +301,7 @@
checkProposals("/WebContent/varAttributes.xhtml", 640, new
String[]{"item.name"}, false);
try{
- component.setContents(emptyComponent.getContents(), true, false, new
NullProgressMonitor());
+ FileUtil.copyContent(emptyComponent, component, true, false, new
NullProgressMonitor());
}catch(Exception e){
JUnitUtils.fail("Error during changing
'TestComponentForVarAttributes.java' content to
'TestComponentForVarAttributes.2'", e);
}
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/view/SeamComponentsViewTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/view/SeamComponentsViewTest.java 2009-11-09
22:35:15 UTC (rev 18521)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/view/SeamComponentsViewTest.java 2009-11-09
22:36:17 UTC (rev 18522)
@@ -39,7 +39,7 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.WorkbenchException;
import org.eclipse.ui.navigator.CommonNavigator;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamPackage;
import org.jboss.tools.seam.core.SeamCorePlugin;
@@ -100,15 +100,24 @@
fail("Cannot find test data file
'WebContent/WEB-INF/components.1'");
}
-
+ InputStream is = null;
try {
- componentsFile.setContents(file1.getContents(),
- true, false, new NullProgressMonitor());
+ is = file1.getContents();
+ componentsFile.setContents(is,
+ true, false, new NullProgressMonitor());
} catch (CoreException e) {
JUnitUtils.fail("Error in changing 'components.xml' content to " +
"'WebContent/WEB-INF/components.1'", e);
+ } finally {
+ if(is!=null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
}
-
+
refreshProject(project);
navigator.getCommonViewer().refresh(true);
@@ -149,7 +158,7 @@
}
try{
- componentsFile.setContents(file1.getContents(), true, false, new
NullProgressMonitor());
+ FileUtil.copyContent(file1, componentsFile, true, false, new NullProgressMonitor());
}catch(Exception ex){
JUnitUtils.fail("Error in changing 'components.xml' content to " +
"'WebContent/WEB-INF/components.2'", ex);
@@ -172,7 +181,7 @@
fail("Cannot find test data file
'WebContent/WEB-INF/components.3'");
}
try{
- componentsFile.setContents(file1.getContents(), true, false, new
NullProgressMonitor());
+ FileUtil.copyContent(file1, componentsFile, true, false, new NullProgressMonitor());
}catch(Exception ex){
JUnitUtils.fail("Error in changing 'components.xml' content to " +
"'WebContent/WEB-INF/components.3'", ex);
@@ -209,22 +218,32 @@
IFile file1 = project.getFile("WebContent/WEB-INF/components.4");
assertTrue("Cannot find components.2 in test project", file1 != null
&& file1.exists());
-
- try{
- componentsFile.setContents(file1.getContents(), true, false, new
NullProgressMonitor());
- }catch(Exception ex){
- JUnitUtils.fail("Cannot read file WebContent/WEB-INF/components.4", ex);
+
+ InputStream is = null;
+ try {
+ is = file1.getContents();
+ componentsFile.setContents(is,
+ true, false, new NullProgressMonitor());
+ } catch (CoreException e) {
+ JUnitUtils.fail("Cannot read file WebContent/WEB-INF/components.4", e);
+ } finally {
+ if(is!=null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
}
-
+
refreshProject(project);
navigator.getCommonViewer().refresh(true);
navigator.getCommonViewer().expandAll();
-
+
seamPackage = findSeamPackage(tree, "myNewPackage");
assertTrue("Package \"myNewPackage\" found!",seamPackage==null);
+ }
- }
-
public void testAddComponentInClass(){
classFile = project.getFile("JavaSource/demo/Person.java");
@@ -289,7 +308,7 @@
assertTrue("Cannot find Person.2 in test project", file1 != null &&
file1.exists());
try{
- classFile.setContents(file1.getContents(), true, false, new NullProgressMonitor());
+ FileUtil.copyContent(file1, classFile, true, false, new NullProgressMonitor());
}catch(Exception ex){
JUnitUtils.fail("Cannot read file JavaSource/demo/Person.2", ex);
}
@@ -311,7 +330,7 @@
assertTrue("Cannot find Person.3 in test project", file2 != null &&
file2.exists());
try{
- classFile.setContents(file2.getContents(), true, false, new NullProgressMonitor());
+ FileUtil.copyContent(file2, classFile, true, false, new NullProgressMonitor());
}catch(Exception ex){
JUnitUtils.fail("Cannot read file JavaSource/demo/Person.3", ex);
}