Search in sources :

Example 1 with BatchLinkableResourceStorageWritable

use of org.eclipse.xtext.xbase.resource.BatchLinkableResourceStorageWritable in project xtext-xtend by eclipse.

the class ResourceStorageTest method testFailedWrite.

@Test(expected = IOException.class)
public void testFailedWrite() throws Exception {
    final XtendFile file = this.file("class C{}");
    ByteArrayOutputStream _byteArrayOutputStream = new ByteArrayOutputStream();
    Resource _eResource = file.eResource();
    new BatchLinkableResourceStorageWritable(_byteArrayOutputStream, false) {

        @Override
        protected void writeAssociationsAdapter(final BatchLinkableResource resource, final OutputStream zipOut) throws IOException {
            final Function1<Adapter, Boolean> _function = (Adapter it) -> {
                return Boolean.valueOf((it instanceof JvmModelAssociator.Adapter));
            };
            final Adapter removeMe = IterableExtensions.<Adapter>findFirst(resource.eAdapters(), _function);
            Assert.assertTrue(resource.eAdapters().remove(removeMe));
            super.writeAssociationsAdapter(resource, zipOut);
        }
    }.writeResource(((StorageAwareResource) _eResource));
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) BatchLinkableResource(org.eclipse.xtext.xbase.resource.BatchLinkableResource) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) Resource(org.eclipse.emf.ecore.resource.Resource) BatchLinkableResource(org.eclipse.xtext.xbase.resource.BatchLinkableResource) StorageAwareResource(org.eclipse.xtext.resource.persistence.StorageAwareResource) BatchLinkableResourceStorageWritable(org.eclipse.xtext.xbase.resource.BatchLinkableResourceStorageWritable) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) DocumentationAdapter(org.eclipse.xtext.xbase.compiler.DocumentationAdapter) Adapter(org.eclipse.emf.common.notify.Adapter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) StorageAwareResource(org.eclipse.xtext.resource.persistence.StorageAwareResource) Test(org.junit.Test)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 Adapter (org.eclipse.emf.common.notify.Adapter)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)1 StorageAwareResource (org.eclipse.xtext.resource.persistence.StorageAwareResource)1 DocumentationAdapter (org.eclipse.xtext.xbase.compiler.DocumentationAdapter)1 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)1 BatchLinkableResource (org.eclipse.xtext.xbase.resource.BatchLinkableResource)1 BatchLinkableResourceStorageWritable (org.eclipse.xtext.xbase.resource.BatchLinkableResourceStorageWritable)1 Test (org.junit.Test)1