Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 181601 Details for
Bug 303511
Allow to specify encoding for source attachments
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Fixes for tests
bug_303511a.txt (text/plain), 9.37 KB, created by
Jay Arthanareeswaran
on 2010-10-24 15:51:52 EDT
(
hide
)
Description:
Fixes for tests
Filename:
MIME Type:
Creator:
Jay Arthanareeswaran
Created:
2010-10-24 15:51:52 EDT
Size:
9.37 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/EncodingTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/EncodingTests.java,v >retrieving revision 1.55 >diff -u -r1.55 EncodingTests.java >--- src/org/eclipse/jdt/core/tests/model/EncodingTests.java 22 Oct 2010 11:18:03 -0000 1.55 >+++ src/org/eclipse/jdt/core/tests/model/EncodingTests.java 24 Oct 2010 19:23:51 -0000 >@@ -37,6 +37,7 @@ > import org.eclipse.jdt.core.ISourceReference; > import org.eclipse.jdt.core.JavaCore; > import org.eclipse.jdt.core.JavaModelException; >+import org.eclipse.jdt.core.compiler.CharOperation; > import org.eclipse.jdt.core.search.IJavaSearchConstants; > import org.eclipse.jdt.core.search.IJavaSearchScope; > import org.eclipse.jdt.core.search.SearchEngine; >@@ -463,19 +464,24 @@ > * Verification is done by comparing source with file contents read directly with UTF-8 encoding... > */ > public void test022() throws JavaModelException, CoreException { >+ String oldEncoding = this.encodingProject.getDefaultCharset(); >+ try{ >+ // Set project encoding >+ String encoding = "UTF-8".equals(vmEncoding) ? "Cp1252" : "UTF-8"; >+ this.encodingProject.setDefaultCharset(vmEncoding, null); > >- // Set project encoding >- String encoding = "UTF-8".equals(vmEncoding) ? "Cp1252" : "UTF-8"; >- this.encodingProject.setDefaultCharset(encoding, null); >- >- // Get class file and compare source (should not be the same as modify charset on zip file has no effect...) >- IPackageFragmentRoot root = getPackageFragmentRoot("Encoding", "testUTF8.jar"); >- this.utf8Source = root.getPackageFragment("testUTF8").getClassFile("Test.class"); >- assertNotNull(this.utf8Source); >- String source = this.utf8Source.getSource(); >- assertNotNull(source); >- String encodedContents = new String (Util.getResourceContentsAsCharArray(this.utf8File, encoding)); >- assertFalse("Sources should not be the same as they were decoded with different encoding!", encodedContents.equals(source)); >+ // Get class file and compare source (should not be the same as modify charset on zip file has no effect...) >+ IPackageFragmentRoot root = getPackageFragmentRoot("Encoding", "testUTF8.jar"); >+ this.utf8Source = root.getPackageFragment("testUTF8").getClassFile("Test.class"); >+ assertNotNull(this.utf8Source); >+ String source = this.utf8Source.getSource(); >+ assertNotNull(source); >+ String encodedContents = new String (Util.getResourceContentsAsCharArray(this.utf8File, encoding)); >+ assertFalse("Sources should not be the same as they were decoded with different encoding!", encodedContents.equals(source)); >+ } >+ finally{ >+ this.encodingProject.setDefaultCharset(oldEncoding, null); >+ } > } > > /* >@@ -483,24 +489,26 @@ > * Verification is done by comparing source with file contents read directly with UTF-8 encoding... > */ > public void test023() throws JavaModelException, CoreException { >- >- // Set file encoding >- String encoding = "UTF-8".equals(vmEncoding) ? "Cp1252" : "UTF-8"; > IFile zipFile = (IFile) this.encodingProject.findMember("testUTF8.zip"); //$NON-NLS-1$ >- assertNotNull("Cannot find class file!", zipFile); >- zipFile.setCharset(encoding, null); >- >- // Get class file and compare source (should not be the same as modify charset on zip file has no effect...) >- IPackageFragmentRoot root = getPackageFragmentRoot("Encoding", "testUTF8.jar"); >- this.utf8Source = root.getPackageFragment("testUTF8").getClassFile("Test.class"); >- assertNotNull(this.utf8Source); >- String source = this.utf8Source.getSource(); >- assertNotNull(source); >- String encodedContents = new String (Util.getResourceContentsAsCharArray(this.utf8File, encoding)); >- assertFalse("Sources should not be the same as they were decoded with different encoding!", encodedContents.equals(source)); >+ try { >+ // Set file encoding >+ String encoding = "UTF-8".equals(vmEncoding) ? "Cp1252" : "UTF-8"; >+ assertNotNull("Cannot find class file!", zipFile); >+ zipFile.setCharset(vmEncoding, null); > >- // Reset zip file encoding >- zipFile.setCharset(null, null); >+ // Get class file and compare source (should not be the same as modify charset on zip file has no effect...) >+ IPackageFragmentRoot root = getPackageFragmentRoot("Encoding", "testUTF8.jar"); >+ this.utf8Source = root.getPackageFragment("testUTF8").getClassFile("Test.class"); >+ assertNotNull(this.utf8Source); >+ String source = this.utf8Source.getSource(); >+ assertNotNull(source); >+ String encodedContents = new String (Util.getResourceContentsAsCharArray(this.utf8File, encoding)); >+ assertFalse("Sources should not be the same as they were decoded with different encoding!", encodedContents.equals(source)); >+ } >+ finally { >+ // Reset zip file encoding >+ zipFile.setCharset(null, null); >+ } > } > > /** >@@ -959,7 +967,11 @@ > assertNotNull(sourceRef); > String source = sourceRef.getSource(); > assertNotNull(source); >+ char[] charArray = source.toCharArray(); >+ source = new String(CharOperation.remove(charArray, '\r')); > String encodedContents = new String (Util.getResourceContentsAsCharArray(sourceFile, encoding)); >+ charArray = encodedContents.toCharArray(); >+ encodedContents = new String(CharOperation.remove(charArray, '\r')); > assertTrue("Sources should be decoded the same way", encodedContents.equals(source)); > > // Reset zip file encoding >@@ -973,6 +985,10 @@ > source = sourceRef.getSource(); > assertNotNull(source); > encodedContents = new String (Util.getResourceContentsAsCharArray(sourceFile, encoding)); >+ charArray = encodedContents.toCharArray(); >+ encodedContents = new String(CharOperation.remove(charArray, '\r')); >+ charArray = source.toCharArray(); >+ source = new String(CharOperation.remove(charArray, '\r')); > assertTrue("Sources should be decoded the same way", encodedContents.equals(source)); > > this.encodingProject.setDefaultCharset(null, null); >@@ -983,6 +999,10 @@ > source = sourceRef.getSource(); > assertNotNull(source); > encodedContents = new String (Util.getResourceContentsAsCharArray(sourceFile, encoding)); >+ charArray = encodedContents.toCharArray(); >+ encodedContents = new String(CharOperation.remove(charArray, '\r')); >+ charArray = source.toCharArray(); >+ source = new String(CharOperation.remove(charArray, '\r')); > assertFalse("Sources should be decoded the same way", encodedContents.equals(source)); > > // Reset zip file encoding >@@ -1033,6 +1053,10 @@ > String source = sourceRef.getSource(); > assertNotNull(source); > String encodedContents = new String (Util.getResourceContentsAsCharArray(sourceFile, encoding)); >+ char[] charArray = encodedContents.toCharArray(); >+ encodedContents = new String(CharOperation.remove(charArray, '\r')); >+ charArray = source.toCharArray(); >+ source = new String(CharOperation.remove(charArray, '\r')); > assertTrue("Sources should be decoded the same way", encodedContents.equals(source)); > > entries = this.encodingJavaProject.getRawClasspath(); >@@ -1099,6 +1123,10 @@ > String source = sourceRef.getSource(); > assertNotNull(source); > String encodedContents = new String (Util.getResourceContentsAsCharArray(sourceFile, encoding)); >+ char[] charArray = encodedContents.toCharArray(); >+ encodedContents = new String(CharOperation.remove(charArray, '\r')); >+ charArray = source.toCharArray(); >+ source = new String(CharOperation.remove(charArray, '\r')); > assertTrue("Sources should be decoded the same way", encodedContents.equals(source)); > > zipFile.setCharset(null, null); >@@ -1110,6 +1138,10 @@ > source = sourceRef.getSource(); > assertNotNull(source); > encodedContents = new String (Util.getResourceContentsAsCharArray(sourceFile, encoding)); >+ charArray = encodedContents.toCharArray(); >+ encodedContents = new String(CharOperation.remove(charArray, '\r')); >+ charArray = source.toCharArray(); >+ source = new String(CharOperation.remove(charArray, '\r')); > assertTrue("Sources should be decoded the same way", encodedContents.equals(source)); > > this.encodingProject.setDefaultCharset(oldEncoding, null); >@@ -1157,6 +1189,10 @@ > String source = sourceRef.getSource(); > assertNotNull(source); > String encodedContents = new String (Util.getResourceContentsAsCharArray(sourceFile, encoding)); >+ char[] charArray = encodedContents.toCharArray(); >+ encodedContents = new String(CharOperation.remove(charArray, '\r')); >+ charArray = source.toCharArray(); >+ source = new String(CharOperation.remove(charArray, '\r')); > assertTrue("Sources should be decoded the same way", encodedContents.equals(source)); > > this.encodingProject.setDefaultCharset(oldEncoding, null); >@@ -1168,6 +1204,10 @@ > source = sourceRef.getSource(); > assertNotNull(source); > encodedContents = new String (Util.getResourceContentsAsCharArray(sourceFile, encoding)); >+ charArray = encodedContents.toCharArray(); >+ encodedContents = new String(CharOperation.remove(charArray, '\r')); >+ charArray = source.toCharArray(); >+ source = new String(CharOperation.remove(charArray, '\r')); > assertTrue("Sources should be decoded the same way", encodedContents.equals(source)); > > sourceFile.setCharset(null, null);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 303511
:
181323
|
181364
|
181365
|
181399
|
181484
| 181601