|
Lines 11-18
Link Here
|
| 11 |
******************************************************************************/ |
11 |
******************************************************************************/ |
| 12 |
package org.eclipse.rwt.internal.resources; |
12 |
package org.eclipse.rwt.internal.resources; |
| 13 |
|
13 |
|
| 14 |
import java.io.File; |
14 |
import java.io.*; |
| 15 |
import java.io.IOException; |
|
|
| 16 |
|
15 |
|
| 17 |
import junit.framework.TestCase; |
16 |
import junit.framework.TestCase; |
| 18 |
|
17 |
|
|
Lines 82-87
Link Here
|
| 82 |
assertEquals( "foo\nbar\n", result ); |
81 |
assertEquals( "foo\nbar\n", result ); |
| 83 |
} |
82 |
} |
| 84 |
|
83 |
|
|
|
84 |
public void testReadText() throws IOException { |
| 85 |
String input = createTestString( 10000 ); |
| 86 |
InputStream inputStream = new ByteArrayInputStream( input.getBytes( "UTF-8" ) ); |
| 87 |
int[] result = ResourceUtil.readText( inputStream, "UTF-8", false ); |
| 88 |
byte[] bytes = toByteArray( result ); |
| 89 |
assertEquals( input, new String( bytes ) ); |
| 90 |
} |
| 91 |
|
| 92 |
private static byte[] toByteArray( int[] result ) { |
| 93 |
byte[] bytes = new byte[ result.length ]; |
| 94 |
for( int i = 0; i < bytes.length; i++ ) { |
| 95 |
bytes[ i ] = ( byte )result[ i ]; |
| 96 |
} |
| 97 |
return bytes; |
| 98 |
} |
| 99 |
|
| 100 |
private static String createTestString( int length ) { |
| 101 |
StringBuffer buffer = new StringBuffer( length ); |
| 102 |
for( int i = 0; i < length; i++ ) { |
| 103 |
buffer.append( (char) ( 32 + ( i % 32 ) ) ); |
| 104 |
} |
| 105 |
return buffer.toString(); |
| 106 |
} |
| 107 |
|
| 85 |
private static int[] getStringAsIntArray( String string ) { |
108 |
private static int[] getStringAsIntArray( String string ) { |
| 86 |
byte[] bytes = string.getBytes(); |
109 |
byte[] bytes = string.getBytes(); |
| 87 |
int[] content = new int[ bytes.length ]; |
110 |
int[] content = new int[ bytes.length ]; |