Package org.eclipse.sapphire.modeling

Examples of org.eclipse.sapphire.modeling.ByteArrayResourceStore


{
    @Test
   
    public void testDefaultBindingWrite1() throws Exception
    {
        final ByteArrayResourceStore resourceStore = new ByteArrayResourceStore();
        final XmlResourceStore xmlResourceStore = new XmlResourceStore( resourceStore );
        final TestRootElement model = TestRootElement.TYPE.instantiate( new RootXmlResource( xmlResourceStore ) );
       
        model.resource().setCorruptedResourceExceptionInterceptor
        (
             new CorruptedResourceExceptionInterceptor()
             {
                @Override
                public boolean shouldAttemptRepair()
                {
                    return true;
                }
             }
        );
       
        model.setValuePropertyA( "aaaa" );
        model.setValuePropertyB( "bbbb" );
       
        final TestChildElementA listChild1 = (TestChildElementA) model.getListPropertyA().insert( TestChildElementA.TYPE );
        listChild1.setValuePropertyA( "cccc" );
       
        final TestChildElementB listChild2 = (TestChildElementB) model.getListPropertyA().insert( TestChildElementB.TYPE );
        listChild2.setValuePropertyB( "dddd" );
       
        final TestChildElementA listChild3 = (TestChildElementA) model.getListPropertyA().insert( TestChildElementA.TYPE );
        listChild3.setValuePropertyA( "eeee" );
       
        final TestChildElementB elementChild = (TestChildElementB) model.getElementPropertyA().content( true, TestChildElementB.TYPE );
        elementChild.setValuePropertyB( "ffff" );
       
        model.resource().save();
       
        final String result = new String( resourceStore.getContents(), UTF8 );
       
        assertEqualsIgnoreNewLineDiffs( loadResource( "TestData.txt" ), result );
    }
View Full Code Here


   
    @Test
   
    public void testDefaultBindingWrite2() throws Exception
    {
        final ByteArrayResourceStore resourceStore = new ByteArrayResourceStore();
        final XmlResourceStore xmlResourceStore = new XmlResourceStore( resourceStore );
        final ITestRootElement model = ITestRootElement.TYPE.instantiate( new RootXmlResource( xmlResourceStore ) );
       
        model.resource().setCorruptedResourceExceptionInterceptor
        (
             new CorruptedResourceExceptionInterceptor()
             {
                @Override
                public boolean shouldAttemptRepair()
                {
                    return true;
                }
             }
        );
       
        model.setValuePropertyA( "aaaa" );
        model.setValuePropertyB( "bbbb" );
       
        final ITestChildElementA listChild1 = (ITestChildElementA) model.getListPropertyA().insert( ITestChildElementA.TYPE );
        listChild1.setValuePropertyA( "cccc" );
       
        final ITestChildElementB listChild2 = (ITestChildElementB) model.getListPropertyA().insert( ITestChildElementB.TYPE );
        listChild2.setValuePropertyB( "dddd" );
       
        final ITestChildElementA listChild3 = (ITestChildElementA) model.getListPropertyA().insert( ITestChildElementA.TYPE );
        listChild3.setValuePropertyA( "eeee" );
       
        final ITestChildElementB elementChild = (ITestChildElementB) model.getElementPropertyA().content( true, ITestChildElementB.TYPE );
        elementChild.setValuePropertyB( "ffff" );
       
        model.resource().save();
       
        final String result = new String( resourceStore.getContents(), UTF8 );
       
        assertEqualsIgnoreNewLineDiffs( loadResource( "TestData.txt" ), result );
    }
View Full Code Here

{
    @Test
   
    public void test() throws Exception
    {
        final ByteArrayResourceStore resourceStore = new ByteArrayResourceStore();
        final XmlResourceStore xmlResourceStore = new XmlResourceStore( resourceStore );
        final TestModelRoot root = TestModelRoot.TYPE.instantiate( new RootXmlResource( xmlResourceStore ) );
       
        ( (TestModelElementA1) root.getList().insert( TestModelElementA1.TYPE ) ).setValue( "1111" );
        ( (TestModelElementA2) root.getList().insert( TestModelElementA2.TYPE ) ).setValue( "2222" );
       
        ( (TestModelElementB2) root.getElement().content( true, TestModelElementB2.TYPE ) ).setValue( "3333" );
       
        root.resource().save();
       
        final String result = new String( resourceStore.getContents(), UTF8 );
       
        assertEqualsIgnoreNewLineDiffs( loadResource( "TestData.txt" ), result );
    }
View Full Code Here

   
    @Test
   
    public void testDefaultBindingRead1() throws Exception
    {
        final ByteArrayResourceStore resourceStore = new ByteArrayResourceStore( loadResourceAsStream( "TestData.txt" ) );
        final XmlResourceStore xmlResourceStore = new XmlResourceStore( resourceStore );
        final TestRootElement model = TestRootElement.TYPE.instantiate( new RootXmlResource( xmlResourceStore ) );
       
        assertEquals( "aaaa", model.getValuePropertyA().text() );
        assertEquals( "bbbb", model.getValuePropertyB().text() );
View Full Code Here

   
    @Test

    public void testDefaultBindingRead2() throws Exception
    {
        final ByteArrayResourceStore resourceStore = new ByteArrayResourceStore( loadResourceAsStream( "TestData.txt" ) );
        final XmlResourceStore xmlResourceStore = new XmlResourceStore( resourceStore );
        final ITestRootElement model = ITestRootElement.TYPE.instantiate( new RootXmlResource( xmlResourceStore ) );
       
        assertEquals( "aaaa", model.getValuePropertyA().text() );
        assertEquals( "bbbb", model.getValuePropertyB().text() );
View Full Code Here

{
    @Test
   
    public void test() throws Exception
    {
        final ByteArrayResourceStore byteArrayResourceStore = new ByteArrayResourceStore();
        final XmlResourceStore xmlResourceStore = new XmlResourceStore( byteArrayResourceStore );
       
        final TestXmlBinding0003A a = TestXmlBinding0003A.TYPE.instantiate( new RootXmlResource( xmlResourceStore ) );
        a.setAa( "aa" );
       
        final TestXmlBinding0003AB ab = a.getAb().content( true );
        ab.setAba( "aba" );
       
        final TestXmlBinding0003AC ac = a.getAc().insert();
        ac.setAca( "aca" );
        ac.setAcb( "acb" );
       
        final TestXmlBinding0003ACC acc = ac.getAcc().content( true );
        acc.setAcca( "acca" );
       
        final TestXmlBinding0003ACD acd = ac.getAcd().insert();
        acd.setAcda( "acda" );
       
        a.resource().save();
       
        final String actual = new String( byteArrayResourceStore.getContents(), UTF8 );
       
        assertEqualsIgnoreNewLineDiffs( loadResource( "expected.txt" ), actual );
    }
View Full Code Here

{
    @Test
   
    public void test() throws Exception
    {
        final ByteArrayResourceStore byteArrayResourceStore = new ByteArrayResourceStore();
        final XmlResourceStore xmlResourceStore = new XmlResourceStore( byteArrayResourceStore );

        final TestModelRoot root = TestModelRoot.TYPE.instantiate( new RootXmlResource( xmlResourceStore ) );
        final TestModelChild child = root.getChild();
       
        child.setAaa( "111" );
        child.setBbb( "222" );
        child.setCcc( "333" );
       
        root.resource().save();
        assertEqualsIgnoreNewLineDiffs( loadResource( "checkpoint-1.txt" ), new String( byteArrayResourceStore.getContents(), UTF8 ) );
       
        child.setAaa( null );

        root.resource().save();
        assertEqualsIgnoreNewLineDiffs( loadResource( "checkpoint-2.txt" ), new String( byteArrayResourceStore.getContents(), UTF8 ) );
       
        child.setBbb( null );

        root.resource().save();
        assertEqualsIgnoreNewLineDiffs( loadResource( "checkpoint-3.txt" ), new String( byteArrayResourceStore.getContents(), UTF8 ) );
       
        child.setCcc( null );

        root.resource().save();
        assertEqualsIgnoreNewLineDiffs( loadResource( "checkpoint-4.txt" ), new String( byteArrayResourceStore.getContents(), UTF8 ) );
    }
View Full Code Here

        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 testInsertOneAtEnd() throws Exception
    {
        final ByteArrayResourceStore resourceStore = new ByteArrayResourceStore();
        final XmlResourceStore xmlResourceStore = new XmlResourceStore( resourceStore );
        final TestElement element = TestElement.TYPE.instantiatenew RootXmlResource( xmlResourceStore ) );
       
       
        try
View Full Code Here

   
    @Test

    public void testInsertTwoAtEnd() throws Exception
    {
        final ByteArrayResourceStore resourceStore = new ByteArrayResourceStore();
        final XmlResourceStore xmlResourceStore = new XmlResourceStore( resourceStore );
        final TestElement element = TestElement.TYPE.instantiatenew RootXmlResource( xmlResourceStore ) );
       
        try
        {
View Full Code Here

TOP

Related Classes of org.eclipse.sapphire.modeling.ByteArrayResourceStore

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.