チェンジセット 3355

差分発生行の前後
無視リスト:
コミット日時:
2010/01/26 17:01:10 (2 年前)
コミッタ:
Seacolor
ログメッセージ:

主キーのないレコードは更新できない事を忘れていたので各エンティティに主キーを追加
自動インクリメントエンティティのテストを追加
作成日時エンティティのテストを追加
更新日時エンティティのテストを追加
各エンティティの更新のテストを追加
各エンティティの挿入後取得のテストを追加

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • air/AirDao/tests/OnMemoryTest.as

    r3332 r3355  
    1616                 * @private 
    1717                 */ 
    18                 public var t1:ConstructorTest; 
     18                //public var t1:ConstructorTest; 
    1919                /** 
    2020                 * @private 
    2121                 */ 
    22                 public var t2:InsertTest; 
     22                //public var t2:InsertTest; 
    2323                /** 
    2424                 * @private 
    2525                 */ 
    26                 public var t3:UpdateTest; 
     26                //public var t3:UpdateTest; 
    2727                /** 
    2828                 * @private 
  • air/AirDao/tests/entities/BooleanOnly.as

    r3332 r3355  
    88        public class BooleanOnly  
    99        { 
     10                [Primary] 
     11                [Autoincrement] 
     12                public var id:int; 
    1013                public var flag:Boolean; 
    1114        } 
  • air/AirDao/tests/entities/ByteArrayOnly.as

    r3332 r3355  
    99        public class ByteArrayOnly  
    1010        { 
     11                [Primary] 
     12                [Autoincrement] 
     13                public var id:int; 
    1114                public var byte_array:ByteArray; 
    1215        } 
  • air/AirDao/tests/entities/DateOnly.as

    r3332 r3355  
    88        public class DateOnly  
    99        { 
     10                [Primary] 
     11                [Autoincrement] 
     12                public var id:int; 
    1013                public var date:Date; 
    1114        } 
  • air/AirDao/tests/entities/IntOnly.as

    r3332 r3355  
    99        public class IntOnly  
    1010        { 
     11                [Primary] 
     12                [Autoincrement] 
     13                public var id:int; 
    1114                public var max_value:int; 
    1215                public var min_value:int; 
  • air/AirDao/tests/entities/NumberOnly.as

    r3332 r3355  
    88        public class NumberOnly  
    99        { 
     10                [Primary] 
     11                [Autoincrement] 
     12                public var id:int; 
    1013                public var min_value:Number; 
    1114                public var max_value:Number; 
  • air/AirDao/tests/entities/StringOnly.as

    r3332 r3355  
    88        public class StringOnly  
    99        { 
     10                [Primary] 
     11                [Autoincrement] 
     12                public var id:int; 
    1013                public var name:String; 
    1114        } 
  • air/AirDao/tests/entities/UIntOnly.as

    r3332 r3355  
    88        public class UIntOnly  
    99        { 
     10                [Primary] 
     11                [Autoincrement] 
     12                public var id:int; 
    1013                public var min_value:uint; 
    1114                public var max_value:uint; 
  • air/AirDao/tests/entities/XMLListOnly.as

    r3332 r3355  
    88        public class XMLListOnly  
    99        { 
     10                [Primary] 
     11                [Autoincrement] 
     12                public var id:int; 
    1013                public var xml_list:XMLList; 
    1114        } 
  • air/AirDao/tests/entities/XMLOnly.as

    r3332 r3355  
    88        public class XMLOnly  
    99        { 
     10                [Primary] 
     11                [Autoincrement] 
     12                public var id:int; 
    1013                public var xml:XML; 
    1114        } 
  • air/AirDao/tests/onMemory/InsertTest.as

    r3332 r3355  
    22{ 
    33        import com.seacolorswind.dbi.AirDao; 
     4        import entities.AutoincrementColumnOnly; 
    45        import entities.BooleanOnly; 
    56        import entities.ByteArrayOnly; 
     7        import entities.CreatedOnColumnOnly; 
    68        import entities.DateOnly; 
    79        import entities.IntOnly; 
     
    911        import entities.StringOnly; 
    1012        import entities.UIntOnly; 
     13        import entities.UpdatedOnColumnOnly; 
    1114        import entities.User; 
    1215        import entities.XMLListOnly; 
     
    1518        import flash.events.EventDispatcher; 
    1619        import flash.utils.ByteArray; 
     20        import mx.logging.Log; 
     21        import mx.logging.LogEventLevel; 
     22        import mx.logging.targets.TraceTarget; 
    1723        import org.flexunit.Assert; 
    1824    import org.flexunit.async.Async; 
     
    2733                protected var error:Error; 
    2834                 
     35                [BeforeClass] 
     36                public static function runBeforeClass():void { 
     37                        var tt:TraceTarget = new TraceTarget(); 
     38                        tt.includeDate = true; 
     39                        tt.includeTime = true; 
     40                        tt.includeLevel = true; 
     41                        tt.includeCategory = true; 
     42                        tt.level = LogEventLevel.DEBUG; 
     43                        Log.addTarget(tt); 
     44                } 
     45                 
    2946                [Before] 
    3047                public function setUp():void { 
     
    213230                        newEntity.byte_array.writeMultiByte("あいうえお", "utf-8"); 
    214231                        newEntity.byte_array.position = 0; 
     232                         
     233                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     234                         
     235                        var handleSuccess:Function = function():void { 
     236                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     237                        }; 
     238                        var handleError:Function = function(e:Error):void { 
     239                                error = e; 
     240                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     241                        }; 
     242                         
     243                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 500, null, handleTimeout); 
     244                         
     245                        testTarget = new AirDao(); 
     246                        testTarget.create(newEntity, handleSuccess, handleError); 
     247                } 
     248                 
     249                [Test(async, expects="flash.errors.SQLError")] 
     250                public function insertAutoincrementColumn():void { 
     251                        var newEntity:AutoincrementColumnOnly = new AutoincrementColumnOnly(); 
     252                         
     253                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     254                         
     255                        var handleSuccess:Function = function():void { 
     256                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     257                        }; 
     258                        var handleError:Function = function(e:Error):void { 
     259                                error = e; 
     260                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     261                        }; 
     262                         
     263                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 500, null, handleTimeout); 
     264                         
     265                        testTarget = new AirDao(); 
     266                        testTarget.create(newEntity, handleSuccess, handleError); 
     267                } 
     268                 
     269                [Test(async)] 
     270                public function insertCreatedOnColumn():void { 
     271                        var newEntity:CreatedOnColumnOnly = new CreatedOnColumnOnly(); 
     272                         
     273                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     274                         
     275                        var handleSuccess:Function = function():void { 
     276                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     277                        }; 
     278                        var handleError:Function = function(e:Error):void { 
     279                                error = e; 
     280                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     281                        }; 
     282                         
     283                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 500, null, handleTimeout); 
     284                         
     285                        testTarget = new AirDao(); 
     286                        testTarget.create(newEntity, handleSuccess, handleError); 
     287                } 
     288                 
     289                [Test(async)] 
     290                public function insertUpdatedOnColumn():void { 
     291                        var newEntity:UpdatedOnColumnOnly = new UpdatedOnColumnOnly(); 
    215292                         
    216293                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
  • air/AirDao/tests/onMemory/ReadTest.as

    r3332 r3355  
    22{ 
    33        import com.seacolorswind.dbi.AirDao; 
     4        import entities.BooleanOnly; 
     5        import entities.ByteArrayOnly; 
     6        import entities.DateOnly; 
     7        import entities.IntOnly; 
     8        import entities.NumberOnly; 
     9        import entities.StringOnly; 
     10        import entities.UIntOnly; 
    411        import entities.User; 
     12        import entities.XMLListOnly; 
     13        import entities.XMLOnly; 
    514        import flash.events.Event; 
    615        import flash.events.EventDispatcher; 
     16        import flash.utils.ByteArray; 
    717        import org.flexunit.Assert; 
    818        import org.flexunit.assertThat; 
     
    2535        { 
    2636                private var testTarget:AirDao; 
    27                 protected var isError:Boolean
     37                protected var error:Error
    2838                 
    2939                [Before] 
    3040                public function setUp():void { 
    31                         isError = false; 
    32                 } 
    33                  
     41                        error = null; 
     42                } 
     43                 
     44                [Test(async)] 
     45                public function readOneOfInsertedInt():void { 
     46                        var newEntity:IntOnly = new IntOnly(); 
     47                        newEntity.max_value = int.MAX_VALUE; 
     48                        newEntity.min_value = int.MIN_VALUE; 
     49                         
     50                        var actual:Array; 
     51                         
     52                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     53                         
     54                        var handleComplete:Function = function(event:Event, passThroughData:Object):void { 
     55                                if (error) { 
     56                                        throw error; 
     57                                        return; 
     58                                } 
     59                                assertThat(actual, arrayWithSize(1)); 
     60                                assertThat(actual, everyItem(isA(IntOnly))); 
     61                                assertThat(actual[0], hasProperties( { 
     62                                        max_value: equalTo(newEntity.max_value), 
     63                                        min_value: equalTo(newEntity.min_value) 
     64                                })); 
     65                        }; 
     66                        var handleSuccess:Function = function(result:Array):void { 
     67                                actual = result; 
     68                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     69                        }; 
     70                        var handleCreateSuccess:Function = function():void { 
     71                                testTarget.read(IntOnly, handleSuccess, null, null, handleError); 
     72                        }; 
     73                        var handleError:Function = function(e:Error):void { 
     74                                error = e; 
     75                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     76                        }; 
     77                         
     78                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 500, null, handleTimeout); 
     79                         
     80                        testTarget = new AirDao(); 
     81                        testTarget.create(newEntity, handleCreateSuccess, handleError); 
     82                } 
     83                 
     84                [Test(async)] 
     85                public function readOneOfInsertedUInt():void { 
     86                        var newEntity:UIntOnly = new UIntOnly(); 
     87                        newEntity.max_value = uint.MAX_VALUE; 
     88                        newEntity.min_value = uint.MIN_VALUE; 
     89                         
     90                        var actual:Array; 
     91                         
     92                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     93                         
     94                        var handleComplete:Function = function(event:Event, passThroughData:Object):void { 
     95                                if (error) { 
     96                                        throw error; 
     97                                        return; 
     98                                } 
     99                                assertThat(actual, arrayWithSize(1)); 
     100                                assertThat(actual, everyItem(isA(UIntOnly))); 
     101                                assertThat(actual[0], hasProperties( { 
     102                                        max_value: equalTo(newEntity.max_value), 
     103                                        min_value: equalTo(newEntity.min_value) 
     104                                })); 
     105                        }; 
     106                        var handleSuccess:Function = function(result:Array):void { 
     107                                actual = result; 
     108                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     109                        }; 
     110                        var handleCreateSuccess:Function = function():void { 
     111                                testTarget.read(UIntOnly, handleSuccess, null, null, handleError); 
     112                        }; 
     113                        var handleError:Function = function(e:Error):void { 
     114                                error = e; 
     115                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     116                        }; 
     117                         
     118                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 500, null, handleTimeout); 
     119                         
     120                        testTarget = new AirDao(); 
     121                        testTarget.create(newEntity, handleCreateSuccess, handleError); 
     122                } 
     123                 
     124                [Test(async)] 
     125                public function readOneOfInsertedNumber():void { 
     126                        var newEntity:NumberOnly = new NumberOnly(); 
     127                        newEntity.max_value = Number.MAX_VALUE; 
     128                        newEntity.min_value = Number.MIN_VALUE; 
     129                         
     130                        var actual:Array; 
     131                         
     132                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     133                         
     134                        var handleComplete:Function = function(event:Event, passThroughData:Object):void { 
     135                                if (error) { 
     136                                        throw error; 
     137                                        return; 
     138                                } 
     139                                assertThat(actual, arrayWithSize(1)); 
     140                                assertThat(actual, everyItem(isA(NumberOnly))); 
     141                                assertThat(actual[0], hasProperties( { 
     142                                        max_value: equalTo(newEntity.max_value), 
     143                                        min_value: equalTo(newEntity.min_value) 
     144                                })); 
     145                        }; 
     146                        var handleSuccess:Function = function(result:Array):void { 
     147                                actual = result; 
     148                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     149                        }; 
     150                        var handleCreateSuccess:Function = function():void { 
     151                                testTarget.read(NumberOnly, handleSuccess, null, null, handleError); 
     152                        }; 
     153                        var handleError:Function = function(e:Error):void { 
     154                                error = e; 
     155                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     156                        }; 
     157                         
     158                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 500, null, handleTimeout); 
     159                         
     160                        testTarget = new AirDao(); 
     161                        testTarget.create(newEntity, handleCreateSuccess, handleError); 
     162                } 
     163                 
     164                [Test(async)] 
     165                public function readOneOfInsertedString():void { 
     166                        var newEntity:StringOnly = new StringOnly(); 
     167                        newEntity.name = "user"; 
     168                         
     169                        var actual:Array; 
     170                         
     171                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     172                         
     173                        var handleComplete:Function = function(event:Event, passThroughData:Object):void { 
     174                                if (error) { 
     175                                        throw error; 
     176                                        return; 
     177                                } 
     178                                assertThat(actual, arrayWithSize(1)); 
     179                                assertThat(actual, everyItem(isA(StringOnly))); 
     180                                assertThat(actual[0], hasProperties( { 
     181                                        name: equalTo(newEntity.name) 
     182                                })); 
     183                        }; 
     184                        var handleSuccess:Function = function(result:Array):void { 
     185                                actual = result; 
     186                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     187                        }; 
     188                        var handleCreateSuccess:Function = function():void { 
     189                                testTarget.read(StringOnly, handleSuccess, null, null, handleError); 
     190                        }; 
     191                        var handleError:Function = function(e:Error):void { 
     192                                error = e; 
     193                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     194                        }; 
     195                         
     196                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 500, null, handleTimeout); 
     197                         
     198                        testTarget = new AirDao(); 
     199                        testTarget.create(newEntity, handleCreateSuccess, handleError); 
     200                } 
     201                 
     202                [Test(async)] 
     203                public function readOneOfInsertedBoolean():void { 
     204                        var newEntity:BooleanOnly = new BooleanOnly(); 
     205                        newEntity.flag = true; 
     206                         
     207                        var actual:Array; 
     208                         
     209                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     210                         
     211                        var handleComplete:Function = function(event:Event, passThroughData:Object):void { 
     212                                if (error) { 
     213                                        throw error; 
     214                                        return; 
     215                                } 
     216                                assertThat(actual, arrayWithSize(1)); 
     217                                assertThat(actual, everyItem(isA(BooleanOnly))); 
     218                                assertThat(actual[0], hasProperties( { 
     219                                        flag: equalTo(newEntity.flag) 
     220                                })); 
     221                        }; 
     222                        var handleSuccess:Function = function(result:Array):void { 
     223                                actual = result; 
     224                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     225                        }; 
     226                        var handleCreateSuccess:Function = function():void { 
     227                                testTarget.read(BooleanOnly, handleSuccess, null, null, handleError); 
     228                        }; 
     229                        var handleError:Function = function(e:Error):void { 
     230                                error = e; 
     231                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     232                        }; 
     233                         
     234                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 500, null, handleTimeout); 
     235                         
     236                        testTarget = new AirDao(); 
     237                        testTarget.create(newEntity, handleCreateSuccess, handleError); 
     238                } 
     239                 
     240                [Test(async)] 
     241                public function readOneOfInsertedDate():void { 
     242                        var newEntity:DateOnly = new DateOnly(); 
     243                        newEntity.date = new Date(); 
     244                         
     245                        var actual:Array; 
     246                         
     247                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     248                         
     249                        var handleComplete:Function = function(event:Event, passThroughData:Object):void { 
     250                                if (error) { 
     251                                        throw error; 
     252                                        return; 
     253                                } 
     254                                assertThat(actual, arrayWithSize(1)); 
     255                                assertThat(actual, everyItem(isA(DateOnly))); 
     256                                assertThat(actual[0], hasProperties( { 
     257                                        date: dateEqual(newEntity.date) 
     258                                })); 
     259                        }; 
     260                        var handleSuccess:Function = function(result:Array):void { 
     261                                actual = result; 
     262                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     263                        }; 
     264                        var handleCreateSuccess:Function = function():void { 
     265                                testTarget.read(DateOnly, handleSuccess, null, null, handleError); 
     266                        }; 
     267                        var handleError:Function = function(e:Error):void { 
     268                                error = e; 
     269                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     270                        }; 
     271                         
     272                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 500, null, handleTimeout); 
     273                         
     274                        testTarget = new AirDao(); 
     275                        testTarget.create(newEntity, handleCreateSuccess, handleError); 
     276                } 
     277                 
     278                [Test(async)] 
     279                public function readOneOfInsertedXML():void { 
     280                        var newEntity:XMLOnly = new XMLOnly(); 
     281                        newEntity.xml = <root><code>0</code><message>OK</message></root>; 
     282                         
     283                        var actual:Array; 
     284                         
     285                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     286                         
     287                        var handleComplete:Function = function(event:Event, passThroughData:Object):void { 
     288                                if (error) { 
     289                                        throw error; 
     290                                        return; 
     291                                } 
     292                                assertThat(actual, arrayWithSize(1)); 
     293                                assertThat(actual, everyItem(isA(XMLOnly))); 
     294                                assertThat(actual[0], hasProperties( { 
     295                                        xml: equalTo(newEntity.xml) 
     296                                })); 
     297                        }; 
     298                        var handleSuccess:Function = function(result:Array):void { 
     299                                actual = result; 
     300                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     301                        }; 
     302                        var handleCreateSuccess:Function = function():void { 
     303                                testTarget.read(XMLOnly, handleSuccess, null, null, handleError); 
     304                        }; 
     305                        var handleError:Function = function(e:Error):void { 
     306                                error = e; 
     307                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     308                        }; 
     309                         
     310                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 500, null, handleTimeout); 
     311                         
     312                        testTarget = new AirDao(); 
     313                        testTarget.create(newEntity, handleCreateSuccess, handleError); 
     314                } 
     315                 
     316                [Test(async)] 
     317                public function readOneOfInsertedXMLList():void { 
     318                        var newEntity:XMLListOnly = new XMLListOnly(); 
     319                        newEntity.xml_list = <> 
     320                                <item><name>name0</name><id>1</id></item> 
     321                                <item><name>name1</name><id>2</id></item> 
     322                                <item><name>name2</name><id>3</id></item> 
     323                        </>; 
     324                         
     325                        var actual:Array; 
     326                         
     327                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     328                         
     329                        var handleComplete:Function = function(event:Event, passThroughData:Object):void { 
     330                                if (error) { 
     331                                        throw error; 
     332                                        return; 
     333                                } 
     334                                assertThat(actual, arrayWithSize(1)); 
     335                                assertThat(actual, everyItem(isA(XMLListOnly))); 
     336                                assertThat(actual[0], hasProperties( { 
     337                                        xml_list: equalTo(newEntity.xml_list) 
     338                                })); 
     339                        }; 
     340                        var handleSuccess:Function = function(result:Array):void { 
     341                                actual = result; 
     342                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     343                        }; 
     344                        var handleCreateSuccess:Function = function():void { 
     345                                testTarget.read(XMLListOnly, handleSuccess, null, null, handleError); 
     346                        }; 
     347                        var handleError:Function = function(e:Error):void { 
     348                                error = e; 
     349                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     350                        }; 
     351                         
     352                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 500, null, handleTimeout); 
     353                         
     354                        testTarget = new AirDao(); 
     355                        testTarget.create(newEntity, handleCreateSuccess, handleError); 
     356                } 
     357                 
     358                [Test(async)] 
     359                public function readOneOfInsertedByteArray():void { 
     360                        var newEntity:ByteArrayOnly = new ByteArrayOnly(); 
     361                        newEntity.byte_array = new ByteArray(); 
     362                        newEntity.byte_array.writeMultiByte("あいうえお", "utf-8"); 
     363                        newEntity.byte_array.position = 0; 
     364                         
     365                        var actual:Array; 
     366                         
     367                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     368                         
     369                        var handleComplete:Function = function(event:Event, passThroughData:Object):void { 
     370                                if (error) { 
     371                                        throw error; 
     372                                        return; 
     373                                } 
     374                                assertThat(actual, arrayWithSize(1)); 
     375                                assertThat(actual, everyItem(isA(ByteArrayOnly))); 
     376                                assertThat(actual[0], hasProperties( { 
     377                                        byte_array: equalTo(newEntity.byte_array) 
     378                                })); 
     379                        }; 
     380                        var handleSuccess:Function = function(result:Array):void { 
     381                                actual = result; 
     382                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     383                        }; 
     384                        var handleCreateSuccess:Function = function():void { 
     385                                testTarget.read(ByteArrayOnly, handleSuccess, null, null, handleError); 
     386                        }; 
     387                        var handleError:Function = function(e:Error):void { 
     388                                error = e; 
     389                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     390                        }; 
     391                         
     392                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 500, null, handleTimeout); 
     393                         
     394                        testTarget = new AirDao(); 
     395                        testTarget.create(newEntity, handleCreateSuccess, handleError); 
     396                } 
     397                [Ignore] 
    34398                [Test(async)] 
    35399                public function readOneOfInserted():void { 
     
    43407                         
    44408                        var handleComplete:Function = function(event:Event, passThroughData:Object):void { 
    45                                 if (isError) { 
    46                                         Assert.fail("method faild")
     409                                if (error) { 
     410                                        throw error
    47411                                        return; 
    48412                                } 
     
    66430                        }; 
    67431                        var handleError:Function = function(e:Error):void { 
    68                                 isError = true; 
    69                                 eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
    70                         }; 
    71                          
    72                         Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 500, null, handleTimeout); 
    73                          
    74                         testTarget = new AirDao(); 
    75                         testTarget.create(newEntity, handleCreateSuccess, handleError); 
    76                 } 
    77                  
     432                                error = e; 
     433                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     434                        }; 
     435                         
     436                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 500, null, handleTimeout); 
     437                         
     438                        testTarget = new AirDao(); 
     439                        testTarget.create(newEntity, handleCreateSuccess, handleError); 
     440                } 
     441                [Ignore] 
    78442                [Test(async)] 
    79443                public function readManyOfInserted():void { 
     
    93457                         
    94458                        var handleComplete:Function = function(event:Event, passThroughData:Object):void { 
    95                                 if (isError) { 
    96                                         Assert.fail("method faild")
     459                                if (error) { 
     460                                        throw error
    97461                                        return; 
    98462                                } 
     
    124488                        }; 
    125489                        var handleError:Function = function(e:Error):void { 
    126                                 isError = true; 
     490                                error = e; 
    127491                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
    128492                        }; 
     
    135499                        } 
    136500                } 
    137                  
     501                [Ignore] 
    138502                [Test(async)] 
    139503                public function readOneOfUpdated():void { 
     
    146510                         
    147511                        var handleComplete:Function = function(event:Event, passThroughData:Object):void { 
    148                                 if (isError) { 
    149                                         Assert.fail("method faild")
     512                                if (error) { 
     513                                        throw error
    150514                                        return; 
    151515                                } 
     
    178542                        }; 
    179543                        var handleError:Function = function(e:Error):void { 
    180                                 isError = true; 
     544                                error = e; 
    181545                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
    182546                        }; 
  • air/AirDao/tests/onMemory/UpdateTest.as

    r3332 r3355  
    22{ 
    33        import com.seacolorswind.dbi.AirDao; 
     4        import entities.BooleanOnly; 
     5        import entities.ByteArrayOnly; 
     6        import entities.CreatedOnColumnOnly; 
     7        import entities.DateOnly; 
     8        import entities.IntOnly; 
     9        import entities.NumberOnly; 
     10        import entities.StringOnly; 
     11        import entities.UIntOnly; 
     12        import entities.UpdatedOnColumnOnly; 
    413        import entities.User; 
     14        import entities.XMLListOnly; 
     15        import entities.XMLOnly; 
    516        import flash.events.Event; 
    617        import flash.events.EventDispatcher; 
     18        import flash.utils.ByteArray; 
     19        import mx.logging.Log; 
     20        import mx.logging.LogEventLevel; 
     21        import mx.logging.targets.TraceTarget; 
    722        import org.flexunit.Assert; 
    823    import org.flexunit.async.Async; 
     
    1530        { 
    1631                private var testTarget:AirDao; 
    17                 protected var isError:Boolean; 
     32                protected var error:Error; 
     33                 
     34                [BeforeClass] 
     35                public static function runBeforeClass():void { 
     36                        var tt:TraceTarget = new TraceTarget(); 
     37                        tt.includeDate = true; 
     38                        tt.includeTime = true; 
     39                        tt.includeLevel = true; 
     40                        tt.includeCategory = true; 
     41                        tt.level = LogEventLevel.DEBUG; 
     42                        Log.addTarget(tt); 
     43                } 
    1844                 
    1945                [Before] 
    2046                public function setUp():void { 
    21                         isError = false; 
     47                        error = null; 
     48                } 
     49                 
     50                [Test(async)] 
     51                public function updateInt():void { 
     52                        var newEntity:IntOnly = new IntOnly(); 
     53                        newEntity.min_value = int.MIN_VALUE + 1; 
     54                        newEntity.max_value = int.MAX_VALUE - 1; 
     55                         
     56                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     57                         
     58                        var handleSuccess:Function = function():void { 
     59                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     60                        }; 
     61                        var handleReadSuccess:Function = function(result:Array):void { 
     62                                var updateEntity:IntOnly = result[0]; 
     63                                updateEntity.min_value--; 
     64                                updateEntity.max_value++; 
     65                                testTarget.update(updateEntity, handleSuccess, handleError); 
     66                        }; 
     67                        var handleCreateSuccess:Function = function():void { 
     68                                testTarget.read(IntOnly, handleReadSuccess, null, null, handleError); 
     69                        }; 
     70                        var handleError:Function = function(e:Error):void { 
     71                                error = e; 
     72                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     73                        }; 
     74                         
     75                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 750, null, handleTimeout); 
     76                         
     77                        testTarget = new AirDao(); 
     78                        testTarget.create(newEntity, handleCreateSuccess, handleError); 
     79                } 
     80                 
     81                [Test(async)] 
     82                public function updateUInt():void { 
     83                        var newEntity:UIntOnly = new UIntOnly(); 
     84                        newEntity.min_value = uint.MIN_VALUE + 1; 
     85                        newEntity.max_value = uint.MAX_VALUE - 1; 
     86                         
     87                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     88                         
     89                        var handleSuccess:Function = function():void { 
     90                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     91                        }; 
     92                        var handleReadSuccess:Function = function(result:Array):void { 
     93                                var updateEntity:UIntOnly = result[0]; 
     94                                updateEntity.min_value--; 
     95                                updateEntity.max_value++; 
     96                                testTarget.update(updateEntity, handleSuccess, handleError); 
     97                        }; 
     98                        var handleCreateSuccess:Function = function():void { 
     99                                testTarget.read(UIntOnly, handleReadSuccess, null, null, handleError); 
     100                        }; 
     101                        var handleError:Function = function(e:Error):void { 
     102                                error = e; 
     103                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     104                        }; 
     105                         
     106                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 750, null, handleTimeout); 
     107                         
     108                        testTarget = new AirDao(); 
     109                        testTarget.create(newEntity, handleCreateSuccess, handleError); 
     110                } 
     111                 
     112                [Test(async)] 
     113                public function updateNumber():void { 
     114                        var newEntity:NumberOnly = new NumberOnly(); 
     115                        newEntity.min_value = Number.MIN_VALUE + 1; 
     116                        newEntity.max_value = Number.MAX_VALUE - 1; 
     117                         
     118                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     119                         
     120                        var handleSuccess:Function = function():void { 
     121                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     122                        }; 
     123                        var handleReadSuccess:Function = function(result:Array):void { 
     124                                var updateEntity:NumberOnly = result[0]; 
     125                                updateEntity.min_value--; 
     126                                updateEntity.max_value++; 
     127                                testTarget.update(updateEntity, handleSuccess, handleError); 
     128                        }; 
     129                        var handleCreateSuccess:Function = function():void { 
     130                                testTarget.read(NumberOnly, handleReadSuccess, null, null, handleError); 
     131                        }; 
     132                        var handleError:Function = function(e:Error):void { 
     133                                error = e; 
     134                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     135                        }; 
     136                         
     137                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 750, null, handleTimeout); 
     138                         
     139                        testTarget = new AirDao(); 
     140                        testTarget.create(newEntity, handleCreateSuccess, handleError); 
     141                } 
     142                 
     143                [Test(async)] 
     144                public function updateString():void { 
     145                        var newEntity:StringOnly = new StringOnly(); 
     146                        newEntity.name = "user"; 
     147                         
     148                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     149                         
     150                        var handleSuccess:Function = function():void { 
     151                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     152                        }; 
     153                        var handleReadSuccess:Function = function(result:Array):void { 
     154                                var updateEntity:StringOnly = result[0]; 
     155                                updateEntity.name = "changed " + updateEntity.name; 
     156                                testTarget.update(updateEntity, handleSuccess, handleError); 
     157                        }; 
     158                        var handleCreateSuccess:Function = function():void { 
     159                                testTarget.read(StringOnly, handleReadSuccess, null, null, handleError); 
     160                        }; 
     161                        var handleError:Function = function(e:Error):void { 
     162                                error = e; 
     163                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     164                        }; 
     165                         
     166                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 750, null, handleTimeout); 
     167                         
     168                        testTarget = new AirDao(); 
     169                        testTarget.create(newEntity, handleCreateSuccess, handleError); 
     170                } 
     171                 
     172                [Test(async)] 
     173                public function updateBoolean():void { 
     174                        var newEntity:BooleanOnly = new BooleanOnly(); 
     175                        newEntity.flag = true; 
     176                         
     177                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     178                         
     179                        var handleSuccess:Function = function():void { 
     180                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     181                        }; 
     182                        var handleReadSuccess:Function = function(result:Array):void { 
     183                                var updateEntity:BooleanOnly = result[0]; 
     184                                updateEntity.flag = !updateEntity.flag; 
     185                                testTarget.update(updateEntity, handleSuccess, handleError); 
     186                        }; 
     187                        var handleCreateSuccess:Function = function():void { 
     188                                testTarget.read(BooleanOnly, handleReadSuccess, null, null, handleError); 
     189                        }; 
     190                        var handleError:Function = function(e:Error):void { 
     191                                error = e; 
     192                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     193                        }; 
     194                         
     195                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 750, null, handleTimeout); 
     196                         
     197                        testTarget = new AirDao(); 
     198                        testTarget.create(newEntity, handleCreateSuccess, handleError); 
     199                } 
     200                 
     201                [Test(async)] 
     202                public function updateDate():void { 
     203                        var newEntity:DateOnly = new DateOnly(); 
     204                        newEntity.date = new Date(); 
     205                         
     206                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     207                         
     208                        var handleSuccess:Function = function():void { 
     209                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     210                        }; 
     211                        var handleReadSuccess:Function = function(result:Array):void { 
     212                                var updateEntity:DateOnly = result[0]; 
     213                                updateEntity.date = new Date(); 
     214                                testTarget.update(updateEntity, handleSuccess, handleError); 
     215                        }; 
     216                        var handleCreateSuccess:Function = function():void { 
     217                                testTarget.read(DateOnly, handleReadSuccess, null, null, handleError); 
     218                        }; 
     219                        var handleError:Function = function(e:Error):void { 
     220                                error = e; 
     221                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     222                        }; 
     223                         
     224                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 750, null, handleTimeout); 
     225                         
     226                        testTarget = new AirDao(); 
     227                        testTarget.create(newEntity, handleCreateSuccess, handleError); 
     228                } 
     229                 
     230                [Test(async)] 
     231                public function updateXML():void { 
     232                        var newEntity:XMLOnly = new XMLOnly(); 
     233                        newEntity.xml = <root><code>0</code><message>OK</message></root>; 
     234                         
     235                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     236                         
     237                        var handleSuccess:Function = function():void { 
     238                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     239                        }; 
     240                        var handleReadSuccess:Function = function(result:Array):void { 
     241                                var updateEntity:XMLOnly = result[0]; 
     242                                updateEntity.xml = <root><code>1</code><message>NOT OK</message></root>; 
     243                                testTarget.update(updateEntity, handleSuccess, handleError); 
     244                        }; 
     245                        var handleCreateSuccess:Function = function():void { 
     246                                testTarget.read(XMLOnly, handleReadSuccess, null, null, handleError); 
     247                        }; 
     248                        var handleError:Function = function(e:Error):void { 
     249                                error = e; 
     250                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     251                        }; 
     252                         
     253                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 750, null, handleTimeout); 
     254                         
     255                        testTarget = new AirDao(); 
     256                        testTarget.create(newEntity, handleCreateSuccess, handleError); 
     257                } 
     258                 
     259                [Test(async)] 
     260                public function updateXMLList():void { 
     261                        var newEntity:XMLListOnly = new XMLListOnly(); 
     262                        newEntity.xml_list = <> 
     263                                <item><name>name0</name><id>1</id></item> 
     264                                <item><name>name1</name><id>2</id></item> 
     265                                <item><name>name2</name><id>3</id></item> 
     266                        </>; 
     267                         
     268                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     269                         
     270                        var handleSuccess:Function = function():void { 
     271                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     272                        }; 
     273                        var handleReadSuccess:Function = function(result:Array):void { 
     274                                var updateEntity:XMLListOnly = result[0]; 
     275                                updateEntity.xml_list = <> 
     276                                        <item><name>name0</name><id>1</id></item> 
     277                                        <item><name>name2</name><id>3</id></item> 
     278                                        <item><name>name3</name><id>4</id></item> 
     279                                        <item><name>name4</name><id>5</id></item> 
     280                                </>; 
     281                                testTarget.update(updateEntity, handleSuccess, handleError); 
     282                        }; 
     283                        var handleCreateSuccess:Function = function():void { 
     284                                testTarget.read(XMLListOnly, handleReadSuccess, null, null, handleError); 
     285                        }; 
     286                        var handleError:Function = function(e:Error):void { 
     287                                error = e; 
     288                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     289                        }; 
     290                         
     291                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 750, null, handleTimeout); 
     292                         
     293                        testTarget = new AirDao(); 
     294                        testTarget.create(newEntity, handleCreateSuccess, handleError); 
     295                } 
     296                 
     297                [Test(async)] 
     298                public function updateByteArray():void { 
     299                        var newEntity:ByteArrayOnly = new ByteArrayOnly(); 
     300                        newEntity.byte_array = new ByteArray(); 
     301                        newEntity.byte_array.writeMultiByte("あいうえお", "utf-8"); 
     302                        newEntity.byte_array.position = 0; 
     303                         
     304                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     305                         
     306                        var handleSuccess:Function = function():void { 
     307                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     308                        }; 
     309                        var handleReadSuccess:Function = function(result:Array):void { 
     310                                var updateEntity:ByteArrayOnly = result[0]; 
     311                                updateEntity.byte_array = new ByteArray(); 
     312                                updateEntity.byte_array.writeMultiByte("かきくけこ", "utf-8"); 
     313                                updateEntity.byte_array.position = 0; 
     314                                testTarget.update(updateEntity, handleSuccess, handleError); 
     315                        }; 
     316                        var handleCreateSuccess:Function = function():void { 
     317                                testTarget.read(ByteArrayOnly, handleReadSuccess, null, null, handleError); 
     318                        }; 
     319                        var handleError:Function = function(e:Error):void { 
     320                                error = e; 
     321                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     322                        }; 
     323                         
     324                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 750, null, handleTimeout); 
     325                         
     326                        testTarget = new AirDao(); 
     327                        testTarget.create(newEntity, handleCreateSuccess, handleError); 
     328                } 
     329                 
     330                [Test(async)] 
     331                public function updateCreatedOnColumn():void { 
     332                        var newEntity:CreatedOnColumnOnly = new CreatedOnColumnOnly(); 
     333                         
     334                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     335                         
     336                        var handleSuccess:Function = function():void { 
     337                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     338                        }; 
     339                        var handleReadSuccess:Function = function(result:Array):void { 
     340                                var updateEntity:CreatedOnColumnOnly = result[0]; 
     341                                testTarget.update(updateEntity, handleSuccess, handleError); 
     342                        }; 
     343                        var handleCreateSuccess:Function = function():void { 
     344                                testTarget.read(CreatedOnColumnOnly, handleReadSuccess, null, null, handleError); 
     345                        }; 
     346                        var handleError:Function = function(e:Error):void { 
     347                                error = e; 
     348                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     349                        }; 
     350                         
     351                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 750, null, handleTimeout); 
     352                         
     353                        testTarget = new AirDao(); 
     354                        testTarget.create(newEntity, handleCreateSuccess, handleError); 
     355                } 
     356                 
     357                [Test(async)] 
     358                public function updateUpdatedOnColumn():void { 
     359                        var newEntity:UpdatedOnColumnOnly = new UpdatedOnColumnOnly(); 
     360                         
     361                        var eventDispatcher:EventDispatcher = new EventDispatcher(); 
     362                         
     363                        var handleSuccess:Function = function():void { 
     364                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     365                        }; 
     366                        var handleReadSuccess:Function = function(result:Array):void { 
     367                                var updateEntity:UpdatedOnColumnOnly = result[0]; 
     368                                testTarget.update(updateEntity, handleSuccess, handleError); 
     369                        }; 
     370                        var handleCreateSuccess:Function = function():void { 
     371                                testTarget.read(UpdatedOnColumnOnly, handleReadSuccess, null, null, handleError); 
     372                        }; 
     373                        var handleError:Function = function(e:Error):void { 
     374                                error = e; 
     375                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
     376                        }; 
     377                         
     378                        Async.handleEvent(this, eventDispatcher, Event.COMPLETE, handleComplete, 750, null, handleTimeout); 
     379                         
     380                        testTarget = new AirDao(); 
     381                        testTarget.create(newEntity, handleCreateSuccess, handleError); 
    22382                } 
    23383                 
     
    43403                        }; 
    44404                        var handleError:Function = function(e:Error):void { 
    45                                 isError = true; 
     405                                error = e; 
    46406                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
    47407                        }; 
     
    90450                        }; 
    91451                        var handleError:Function = function(e:Error):void { 
    92                                 isError = true; 
     452                                error = e; 
    93453                                eventDispatcher.dispatchEvent(new Event(Event.COMPLETE)); 
    94454                        }; 
     
    103463                 
    104464                protected function handleComplete(event:Event, passThroughData:Object):void { 
    105                         if (isError) { 
    106                                 Assert.fail("update faild")
     465                        if (error) { 
     466                                throw error
    107467                                return; 
    108468                        }