Search in sources :

Example 6 with UnsupportedCharsetExceptionWithDetail

use of org.eclipse.wst.sse.core.internal.exceptions.UnsupportedCharsetExceptionWithDetail in project webtools.sourceediting by eclipse.

the class CreateCodedReaderTester method testCreateAllFiles.

public void testCreateAllFiles() throws CoreException, IOException {
    if (RECREATE_FILES) {
        List allFiles = TestsPlugin.getAllTestFiles(TEST_FILE_DIR);
        URL outputDirURL = TestsPlugin.getInstallLocation();
        File zipoutFile = new File(outputDirURL.getPath(), TESTFILES_ZIPFILE_NAME);
        java.io.FileOutputStream zipOut = new FileOutputStream(zipoutFile);
        ZipOutputStream zipOutputStream = new ZipOutputStream(zipOut);
        int count = 1;
        for (Iterator iter = allFiles.iterator(); iter.hasNext(); ) {
            File file = (File) iter.next();
            createZipEntry(zipOutputStream, file);
            CodedReaderCreator codedReaderCreator = new CodedReaderCreator();
            codedReaderCreator.set(file.getName(), new FileInputStream(file));
            String detectedCharsetName = null;
            String javaCharsetName = null;
            String expectedException = null;
            try {
                // just used for debug info, but can throw exception
                javaCharsetName = codedReaderCreator.getEncodingMemento().getJavaCharsetName();
                detectedCharsetName = codedReaderCreator.getEncodingMemento().getDetectedCharsetName();
            } catch (UnsupportedCharsetExceptionWithDetail e) {
                // ignore for simply creating tests
                expectedException = e.getClass().getName() + ".class";
            } catch (MalformedInputException e) {
                // ignore for simply creating tests
                expectedException = e.getClass().getName() + ".class";
            } catch (IllegalCharsetNameException e) {
                // ignore for simply creating tests
                expectedException = e.getClass().getName() + ".class";
            }
            String subpath = getSubPathName(file);
            createTestMethodSource(count, subpath, detectedCharsetName, javaCharsetName, expectedException);
            count++;
        }
        zipOutputStream.close();
        zipOut.close();
        assertTrue(true);
    }
}
Also used : CodedReaderCreator(org.eclipse.wst.sse.core.internal.encoding.CodedReaderCreator) FileOutputStream(java.io.FileOutputStream) URL(java.net.URL) FileInputStream(java.io.FileInputStream) IllegalCharsetNameException(java.nio.charset.IllegalCharsetNameException) ZipOutputStream(java.util.zip.ZipOutputStream) FileOutputStream(java.io.FileOutputStream) Iterator(java.util.Iterator) MalformedInputException(java.nio.charset.MalformedInputException) List(java.util.List) UnsupportedCharsetExceptionWithDetail(org.eclipse.wst.sse.core.internal.exceptions.UnsupportedCharsetExceptionWithDetail) File(java.io.File)

Aggregations

UnsupportedCharsetExceptionWithDetail (org.eclipse.wst.sse.core.internal.exceptions.UnsupportedCharsetExceptionWithDetail)6 BufferedReader (java.io.BufferedReader)2 IOException (java.io.IOException)2 Reader (java.io.Reader)2 Charset (java.nio.charset.Charset)2 IFile (org.eclipse.core.resources.IFile)2 CoreException (org.eclipse.core.runtime.CoreException)2 IModelManager (org.eclipse.wst.sse.core.internal.provisional.IModelManager)2 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)2 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)2 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)2 BufferedInputStream (java.io.BufferedInputStream)1 CharArrayReader (java.io.CharArrayReader)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 OutputStreamWriter (java.io.OutputStreamWriter)1 StringReader (java.io.StringReader)1