Package org.eclipse.sapphire

Examples of org.eclipse.sapphire.MasterConversionService


   
    @Test
   
    public void testIFileToByteArrayResourceStore() throws Exception
    {
        final MasterConversionService service = Sapphire.service( MasterConversionService.class );
        final IProject project = project();
       
        final IFile xmlFile = project.getFile( "file.xml" );
        xmlFile.create( new ByteArrayInputStream( new byte[ 0 ] ), true, null );
       
        final ByteArrayResourceStore xmlFileStore = service.convert( xmlFile, ByteArrayResourceStore.class );
        assertNotNull( xmlFileStore );
       
        final IFile txtFile = project.getFile( "file.txt" );
        txtFile.create( new ByteArrayInputStream( new byte[ 0 ] ), true, null );
       
        final ByteArrayResourceStore txtFileStore = service.convert( txtFile, ByteArrayResourceStore.class );
        assertNotNull( txtFileStore );
       
        final IFile binFile = project.getFile( "file.bin" );
        binFile.create( new ByteArrayInputStream( new byte[ 0 ] ), true, null );
       
        final ByteArrayResourceStore binFileStore = service.convert( binFile, ByteArrayResourceStore.class );
        assertNotNull( binFileStore );
    }
View Full Code Here


   
    @Test

    public void testIFileToResourceStore() throws Exception
    {
        final MasterConversionService service = Sapphire.service( MasterConversionService.class );
        final IProject project = project();
       
        final IFile xmlFile = project.getFile( "file.xml" );
        xmlFile.create( new ByteArrayInputStream( new byte[ 0 ] ), true, null );
       
        final ResourceStore xmlFileStore = service.convert( xmlFile, ResourceStore.class );
        assertNotNull( xmlFileStore );
       
        final IFile txtFile = project.getFile( "file.txt" );
        txtFile.create( new ByteArrayInputStream( new byte[ 0 ] ), true, null );
       
        final ResourceStore txtFileStore = service.convert( txtFile, ResourceStore.class );
        assertNotNull( txtFileStore );
       
        final IFile binFile = project.getFile( "file.bin" );
        binFile.create( new ByteArrayInputStream( new byte[ 0 ] ), true, null );
       
        final ResourceStore binFileStore = service.convert( binFile, ResourceStore.class );
        assertNotNull( binFileStore );
    }
View Full Code Here

   
    @Test

    public void testIFileToRootXmlResource() throws Exception
    {
        final MasterConversionService service = Sapphire.service( MasterConversionService.class );
        final IProject project = project();
       
        final IFile xmlFile = project.getFile( "file.xml" );
        xmlFile.create( new ByteArrayInputStream( new byte[ 0 ] ), true, null );
       
        final RootXmlResource xmlFileResource = service.convert( xmlFile, RootXmlResource.class );
        assertNotNull( xmlFileResource );

        final IFile txtFile = project.getFile( "file.txt" );
        txtFile.create( new ByteArrayInputStream( new byte[ 0 ] ), true, null );
       
        final RootXmlResource txtFileStore = service.convert( txtFile, RootXmlResource.class );
        assertNull( txtFileStore );
    }
View Full Code Here

   
    @Test

    public void testIFileToXmlResource() throws Exception
    {
        final MasterConversionService service = Sapphire.service( MasterConversionService.class );
        final IProject project = project();
       
        final IFile xmlFile = project.getFile( "file.xml" );
        xmlFile.create( new ByteArrayInputStream( new byte[ 0 ] ), true, null );
       
        final XmlResource xmlFileResource = service.convert( xmlFile, XmlResource.class );
        assertNotNull( xmlFileResource );

        final IFile txtFile = project.getFile( "file.txt" );
        txtFile.create( new ByteArrayInputStream( new byte[ 0 ] ), true, null );
       
        final XmlResource txtFileStore = service.convert( txtFile, XmlResource.class );
        assertNull( txtFileStore );
    }
View Full Code Here

   
    @Test

    public void testIFileToResource() throws Exception
    {
        final MasterConversionService service = Sapphire.service( MasterConversionService.class );
        final IProject project = project();
       
        final IFile xmlFile = project.getFile( "file.xml" );
        xmlFile.create( new ByteArrayInputStream( new byte[ 0 ] ), true, null );
       
        final Resource xmlFileResource = service.convert( xmlFile, Resource.class );
        assertNotNull( xmlFileResource );

        final IFile txtFile = project.getFile( "file.txt" );
        txtFile.create( new ByteArrayInputStream( new byte[ 0 ] ), true, null );
       
        final Resource txtFileStore = service.convert( txtFile, Resource.class );
        assertNull( txtFileStore );
    }
View Full Code Here

   
    @Test
   
    public void testModelElementToDomDocument() throws Exception
    {
        final MasterConversionService service = Sapphire.service( MasterConversionService.class );
       
        final XmlResourceStore xmlResourceStore = new XmlResourceStore();
        final RootXmlResource xmlResource = new RootXmlResource( xmlResourceStore );
        final XmlConversionTestElement elementOnXml = XmlConversionTestElement.TYPE.instantiate( xmlResource );

        final Document document = service.convert( elementOnXml, Document.class );
       
        assertNotNull( document );
        assertSame( document, xmlResource.getDomDocument() );
        assertSame( document, elementOnXml.adapt( Document.class ) );
        assertSame( document, elementOnXml.getList().insert().adapt( Document.class ) );
       
        final XmlConversionTestElement elementNotOnXml = XmlConversionTestElement.TYPE.instantiate();
       
        assertNull( service.convert( elementNotOnXml, Document.class ) );
        assertNull( service.convert( elementNotOnXml.getList().insert(), Document.class ) );
    }
View Full Code Here

   
    @Test

    public void testModelElementToDomElement() throws Exception
    {
        final MasterConversionService service = Sapphire.service( MasterConversionService.class );
       
        final XmlResourceStore xmlResourceStore = new XmlResourceStore();
        final RootXmlResource xmlResource = new RootXmlResource( xmlResourceStore );
        final XmlConversionTestElement elementOnXml = XmlConversionTestElement.TYPE.instantiate( xmlResource );
       
        xmlResource.save();

        final Element xmlElement = service.convert( elementOnXml, Element.class );
       
        assertNotNull( xmlElement );
        assertSame( xmlElement, xmlResource.getXmlElement().getDomNode() );
        assertSame( xmlElement, elementOnXml.adapt( Element.class ) );
       
        final XmlConversionTestElement.ListEntry childElement = elementOnXml.getList().insert();
        final Element childXmlElement = service.convert( childElement, Element.class );
       
        assertNotNull( childXmlElement );
        assertSame( childXmlElement, ( (XmlResource) childElement.resource() ).getXmlElement().getDomNode() );
        assertSame( childXmlElement, childElement.adapt( Element.class ) );
        assertNotSame( childXmlElement, xmlElement );
       
        final XmlConversionTestElement elementNotOnXml = XmlConversionTestElement.TYPE.instantiate();
       
        assertNull( service.convert( elementNotOnXml, Element.class ) );
        assertNull( service.convert( elementNotOnXml.getList().insert(), Element.class ) );
    }
View Full Code Here

   
    @Test
   
    public void testModelElementToXmlElement() throws Exception
    {
        final MasterConversionService service = Sapphire.service( MasterConversionService.class );
       
        final XmlResourceStore xmlResourceStore = new XmlResourceStore();
        final RootXmlResource xmlResource = new RootXmlResource( xmlResourceStore );
        final XmlConversionTestElement elementOnXml = XmlConversionTestElement.TYPE.instantiate( xmlResource );
       
        xmlResource.save();

        final XmlElement xmlElement = service.convert( elementOnXml, XmlElement.class );
       
        assertNotNull( xmlElement );
        assertSame( xmlElement, xmlResource.getXmlElement() );
        assertSame( xmlElement, elementOnXml.adapt( XmlElement.class ) );
       
        final XmlConversionTestElement.ListEntry childElement = elementOnXml.getList().insert();
        final XmlElement childXmlElement = service.convert( childElement, XmlElement.class );
       
        assertNotNull( childXmlElement );
        assertSame( childXmlElement, ( (XmlResource) childElement.resource() ).getXmlElement() );
        assertSame( childXmlElement, childElement.adapt( XmlElement.class ) );
        assertNotSame( childXmlElement, xmlElement );
       
        final XmlConversionTestElement elementNotOnXml = XmlConversionTestElement.TYPE.instantiate();
       
        assertNull( service.convert( elementNotOnXml, XmlElement.class ) );
        assertNull( service.convert( elementNotOnXml.getList().insert(), XmlElement.class ) );
    }
View Full Code Here

   
    @Test
   
    public void testXmlResourceToDomDocument() throws Exception
    {
        final MasterConversionService service = Sapphire.service( MasterConversionService.class );
       
        final XmlResourceStore xmlResourceStore = new XmlResourceStore();
        final RootXmlResource xmlResource = new RootXmlResource( xmlResourceStore );

        final Document document = service.convert( xmlResource, Document.class );
       
        assertNotNull( document );
        assertSame( document, xmlResource.getDomDocument() );
        assertSame( document, xmlResource.adapt( Document.class ) );
    }
View Full Code Here

   
    @Test
   
    public void testXmlResourceToDomElement() throws Exception
    {
        final MasterConversionService service = Sapphire.service( MasterConversionService.class );
       
        final XmlResourceStore xmlResourceStore = new XmlResourceStore();
        final RootXmlResource xmlResource = new RootXmlResource( xmlResourceStore );
        final XmlConversionTestElement elementOnXml = XmlConversionTestElement.TYPE.instantiate( xmlResource );
       
        xmlResource.save();

        final Element xmlElement = service.convert( xmlResource, Element.class );
       
        assertNotNull( xmlElement );
        assertSame( xmlElement, xmlResource.getXmlElement().getDomNode() );
        assertSame( xmlElement, xmlResource.adapt( Element.class ) );
       
        final XmlConversionTestElement.ListEntry childElement = elementOnXml.getList().insert();
        final Element childXmlElement = service.convert( childElement.resource(), Element.class );
        final XmlResource childXmlResource = (XmlResource) childElement.resource();
       
        assertNotNull( childXmlElement );
        assertSame( childXmlElement, childXmlResource.getXmlElement().getDomNode() );
        assertSame( childXmlElement, childXmlResource.adapt( Element.class ) );
View Full Code Here

TOP

Related Classes of org.eclipse.sapphire.MasterConversionService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.