as3corelib 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. data/Gemfile +5 -0
  2. data/Gemfile.lock +28 -0
  3. data/README.textile +79 -0
  4. data/Rakefile +3 -0
  5. data/as3corelib.gemspec +23 -0
  6. data/build/build.properties +48 -0
  7. data/build/build.xml +104 -0
  8. data/examples/JSONExample/JSONExample.mxml +73 -0
  9. data/lib/as3corelib.rb +15 -0
  10. data/src/com/adobe/air/crypto/EncryptionKeyGenerator.as +313 -0
  11. data/src/com/adobe/air/filesystem/FileMonitor.as +245 -0
  12. data/src/com/adobe/air/filesystem/FileUtil.as +63 -0
  13. data/src/com/adobe/air/filesystem/VolumeMonitor.as +184 -0
  14. data/src/com/adobe/air/filesystem/events/FileMonitorEvent.as +61 -0
  15. data/src/com/adobe/air/logging/FileTarget.as +95 -0
  16. data/src/com/adobe/air/net/ResourceCache.as +165 -0
  17. data/src/com/adobe/air/net/events/ResourceCacheEvent.as +70 -0
  18. data/src/com/adobe/crypto/HMAC.as +127 -0
  19. data/src/com/adobe/crypto/MD5.as +281 -0
  20. data/src/com/adobe/crypto/MD5Stream.as +402 -0
  21. data/src/com/adobe/crypto/SHA1.as +289 -0
  22. data/src/com/adobe/crypto/SHA224.as +257 -0
  23. data/src/com/adobe/crypto/SHA256.as +261 -0
  24. data/src/com/adobe/crypto/WSSEUsernameToken.as +114 -0
  25. data/src/com/adobe/errors/IllegalStateError.as +63 -0
  26. data/src/com/adobe/fileformats/vcard/Address.as +47 -0
  27. data/src/com/adobe/fileformats/vcard/Email.as +39 -0
  28. data/src/com/adobe/fileformats/vcard/Phone.as +39 -0
  29. data/src/com/adobe/fileformats/vcard/VCard.as +54 -0
  30. data/src/com/adobe/fileformats/vcard/VCardParser.as +246 -0
  31. data/src/com/adobe/images/BitString.as +39 -0
  32. data/src/com/adobe/images/JPGEncoder.as +648 -0
  33. data/src/com/adobe/images/PNGEncoder.as +141 -0
  34. data/src/com/adobe/net/DynamicURLLoader.as +55 -0
  35. data/src/com/adobe/net/IURIResolver.as +76 -0
  36. data/src/com/adobe/net/MimeTypeMap.as +200 -0
  37. data/src/com/adobe/net/URI.as +2466 -0
  38. data/src/com/adobe/net/URIEncodingBitmap.as +139 -0
  39. data/src/com/adobe/net/proxies/RFC2817Socket.as +198 -0
  40. data/src/com/adobe/protocols/dict/Database.as +66 -0
  41. data/src/com/adobe/protocols/dict/Definition.as +71 -0
  42. data/src/com/adobe/protocols/dict/Dict.as +360 -0
  43. data/src/com/adobe/protocols/dict/DictionaryServer.as +60 -0
  44. data/src/com/adobe/protocols/dict/MatchStrategy.as +66 -0
  45. data/src/com/adobe/protocols/dict/Response.as +71 -0
  46. data/src/com/adobe/protocols/dict/events/ConnectedEvent.as +53 -0
  47. data/src/com/adobe/protocols/dict/events/DatabaseEvent.as +67 -0
  48. data/src/com/adobe/protocols/dict/events/DefinitionEvent.as +70 -0
  49. data/src/com/adobe/protocols/dict/events/DefinitionHeaderEvent.as +69 -0
  50. data/src/com/adobe/protocols/dict/events/DictionaryServerEvent.as +69 -0
  51. data/src/com/adobe/protocols/dict/events/DisconnectedEvent.as +55 -0
  52. data/src/com/adobe/protocols/dict/events/ErrorEvent.as +80 -0
  53. data/src/com/adobe/protocols/dict/events/MatchEvent.as +67 -0
  54. data/src/com/adobe/protocols/dict/events/MatchStrategiesEvent.as +70 -0
  55. data/src/com/adobe/protocols/dict/events/NoMatchEvent.as +54 -0
  56. data/src/com/adobe/protocols/dict/util/CompleteResponseEvent.as +68 -0
  57. data/src/com/adobe/protocols/dict/util/SocketHelper.as +81 -0
  58. data/src/com/adobe/serialization/json/JSON.as +86 -0
  59. data/src/com/adobe/serialization/json/JSONDecoder.as +327 -0
  60. data/src/com/adobe/serialization/json/JSONEncoder.as +312 -0
  61. data/src/com/adobe/serialization/json/JSONParseError.as +87 -0
  62. data/src/com/adobe/serialization/json/JSONToken.as +104 -0
  63. data/src/com/adobe/serialization/json/JSONTokenType.as +69 -0
  64. data/src/com/adobe/serialization/json/JSONTokenizer.as +702 -0
  65. data/src/com/adobe/utils/ArrayUtil.as +187 -0
  66. data/src/com/adobe/utils/DateUtil.as +701 -0
  67. data/src/com/adobe/utils/DictionaryUtil.as +87 -0
  68. data/src/com/adobe/utils/IntUtil.as +99 -0
  69. data/src/com/adobe/utils/NumberFormatter.as +74 -0
  70. data/src/com/adobe/utils/StringUtil.as +239 -0
  71. data/src/com/adobe/utils/XMLUtil.as +168 -0
  72. data/src/com/adobe/webapis/ServiceBase.as +48 -0
  73. data/src/com/adobe/webapis/URLLoaderBase.as +108 -0
  74. data/src/com/adobe/webapis/events/ServiceEvent.as +82 -0
  75. data/tests/src/CoreLibTestRunner-app.xml +135 -0
  76. data/tests/src/CoreLibTestRunner.as +138 -0
  77. data/tests/src/CoreLibTestRunner.mxml +46 -0
  78. data/tests/src/com/adobe/air/crypto/EncryptionKeyGeneratorTest.as +176 -0
  79. data/tests/src/com/adobe/air/filesystem/FileMonitorTest.as +63 -0
  80. data/tests/src/com/adobe/air/filesystem/VolumeMonitorTest.as +57 -0
  81. data/tests/src/com/adobe/air/filesystem/events/FileMonitorEventTest.as +59 -0
  82. data/tests/src/com/adobe/air/net/events/ResourceCacheEventTest.as +72 -0
  83. data/tests/src/com/adobe/crypto/HMACMD5Test.as +134 -0
  84. data/tests/src/com/adobe/crypto/HMACSHA1Test.as +138 -0
  85. data/tests/src/com/adobe/crypto/MD5Test.as +82 -0
  86. data/tests/src/com/adobe/crypto/SHA1Test.as +151 -0
  87. data/tests/src/com/adobe/crypto/SHA224Test.as +104 -0
  88. data/tests/src/com/adobe/crypto/SHA256Test.as +116 -0
  89. data/tests/src/com/adobe/crypto/WSSEUsernameTokenTest.as +87 -0
  90. data/tests/src/com/adobe/images/JPGEncoderTest.as +54 -0
  91. data/tests/src/com/adobe/images/PNGEncoderTest.as +54 -0
  92. data/tests/src/com/adobe/net/URITest.as +589 -0
  93. data/tests/src/com/adobe/protocols/events/ConnectedEventTest.as +59 -0
  94. data/tests/src/com/adobe/protocols/events/DatabaseEventTest.as +62 -0
  95. data/tests/src/com/adobe/protocols/events/DefinitionEventTest.as +61 -0
  96. data/tests/src/com/adobe/protocols/events/DefinitionHeaderEventTest.as +61 -0
  97. data/tests/src/com/adobe/protocols/events/DictionaryServerEventTest.as +61 -0
  98. data/tests/src/com/adobe/protocols/events/DisconnectedEventTest.as +59 -0
  99. data/tests/src/com/adobe/protocols/events/ErrorEventTest.as +63 -0
  100. data/tests/src/com/adobe/protocols/events/MatchEventTest.as +61 -0
  101. data/tests/src/com/adobe/protocols/events/MatchStrategiesEventTest.as +61 -0
  102. data/tests/src/com/adobe/protocols/events/NoMatchEventTest.as +58 -0
  103. data/tests/src/com/adobe/protocols/util/CompletedResponseEventTest.as +60 -0
  104. data/tests/src/com/adobe/serialization/json/JSONTest.as +522 -0
  105. data/tests/src/com/adobe/serialization/json/SimpleClass.as +85 -0
  106. data/tests/src/com/adobe/utils/ArrayUtilTest.as +173 -0
  107. data/tests/src/com/adobe/utils/DateUtilTest.as +436 -0
  108. data/tests/src/com/adobe/utils/DictionaryUtilTest.as +93 -0
  109. data/tests/src/com/adobe/utils/IntUtilTest.as +73 -0
  110. data/tests/src/com/adobe/utils/NumberFormatterTest.as +70 -0
  111. data/tests/src/com/adobe/utils/StringUtilTest.as +304 -0
  112. data/tests/src/com/adobe/utils/XMLUtilTest.as +101 -0
  113. data/tests/src/com/adobe/webapis/events/ServiceEventTest.as +66 -0
  114. metadata +196 -0
@@ -0,0 +1,176 @@
1
+ /*
2
+ Copyright (c) 2008, Adobe Systems Incorporated
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are
7
+ met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice,
10
+ this list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright
13
+ notice, this list of conditions and the following disclaimer in the
14
+ documentation and/or other materials provided with the distribution.
15
+
16
+ * Neither the name of Adobe Systems Incorporated nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ */
32
+
33
+ package com.adobe.air.crypto
34
+ {
35
+
36
+ import flash.data.EncryptedLocalStore;
37
+ import flash.utils.ByteArray;
38
+
39
+ import flexunit.framework.TestCase;
40
+
41
+ import mx.utils.Base64Encoder;
42
+
43
+ public class EncryptionKeyGeneratorTest extends TestCase {
44
+
45
+ private const ELS_KEY:String = "EncryptionKeyGeneratorTest";
46
+ private const DEFAULT_ELS_KEY:String = "com.adobe.air.crypto::EncryptedDBSalt$$$";
47
+
48
+ public function EncryptionKeyGeneratorTest( methodName:String = null ) {
49
+ super( methodName );
50
+ }
51
+
52
+ override public function setUp():void
53
+ {
54
+ var salt:ByteArray = new ByteArray();
55
+ salt.writeUnsignedInt(1989196088);
56
+ salt.writeUnsignedInt(4188830919);
57
+ salt.writeUnsignedInt(3631556863);
58
+ salt.writeUnsignedInt(2543121849);
59
+ salt.writeUnsignedInt(3166585847);
60
+ salt.writeUnsignedInt(4225038051);
61
+ salt.writeUnsignedInt(3182011233);
62
+ salt.writeUnsignedInt(152503506);
63
+
64
+ EncryptedLocalStore.setItem(ELS_KEY, salt);
65
+ }
66
+
67
+ override public function tearDown():void
68
+ {
69
+ EncryptedLocalStore.removeItem(ELS_KEY);
70
+ EncryptedLocalStore.removeItem(DEFAULT_ELS_KEY);
71
+ }
72
+
73
+ public function test_validateStrongPassword():void
74
+ {
75
+ var keyGen:EncryptionKeyGenerator = new EncryptionKeyGenerator();
76
+ assertTrue(keyGen.validateStrongPassword("ABcd95$bal"));
77
+ assertFalse(keyGen.validateStrongPassword("password"));
78
+ assertFalse(keyGen.validateStrongPassword("PassWord"));
79
+ assertTrue(keyGen.validateStrongPassword("pa$$Word"));
80
+ }
81
+
82
+ public function test_getEncryptionKey():void
83
+ {
84
+ var keyGen:EncryptionKeyGenerator = new EncryptionKeyGenerator();
85
+ var encoder:Base64Encoder = new Base64Encoder();
86
+ encoder.encodeBytes(keyGen.getEncryptionKey("pa$$Word", ELS_KEY));
87
+ assertEquals(encoder.toString(), "oy1N2GAxVFC7vCa0A2wP+Q==");
88
+ }
89
+
90
+ public function test_getEncryptionKeyAgain():void
91
+ {
92
+ var keyGen:EncryptionKeyGenerator = new EncryptionKeyGenerator();
93
+ var attempt1:ByteArray = keyGen.getEncryptionKey("ABcd95$bal");
94
+ var attempt2:ByteArray = keyGen.getEncryptionKey("ABcd95$bal");
95
+
96
+ var encoder1:Base64Encoder = new Base64Encoder();
97
+ encoder1.encodeBytes(attempt1);
98
+ var encoder2:Base64Encoder = new Base64Encoder();
99
+ encoder2.encodeBytes(attempt2);
100
+
101
+ assertEquals(encoder1.toString(), encoder2.toString());
102
+ }
103
+
104
+
105
+
106
+
107
+
108
+ // public function testSHA256():void {
109
+ //
110
+ //
111
+ // // from the spec ( http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf )
112
+ // assertSHA256( "abc", "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" );
113
+ // assertSHA256( "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1");
114
+ //
115
+ // var millionAs:String = new String("");
116
+ // for ( var i:int = 0; i < 1000000; i++ ) {
117
+ // millionAs += "a";
118
+ // }
119
+ // assertSHA256( millionAs, "cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0" );
120
+ //
121
+ // // from wikipedia
122
+ // assertSHA256( "The quick brown fox jumps over the lazy dog", "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592" );
123
+ // assertSHA256( "The quick brown fox jumps over the lazy cog", "e4c4d8f3bf76b692de791a173e05321150f7a345b46484fe427f6acc7ecc81be" );
124
+ // assertSHA256( "", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" );
125
+ //
126
+ // }
127
+ //
128
+ // public function testSHA256Binary():void {
129
+ //
130
+ // // from the spec ( http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf )
131
+ // assertSHA256Binary( "abc", "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" );
132
+ // assertSHA256Binary( "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1");
133
+ //
134
+ // var millionAs:String = new String("");
135
+ // for ( var i:int = 0; i < 1000000; i++ ) {
136
+ // millionAs += "a";
137
+ // }
138
+ // assertSHA256Binary( millionAs, "cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0" );
139
+ //
140
+ // // from wikipedia
141
+ // assertSHA256Binary( "The quick brown fox jumps over the lazy dog", "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592" );
142
+ // assertSHA256Binary( "The quick brown fox jumps over the lazy cog", "e4c4d8f3bf76b692de791a173e05321150f7a345b46484fe427f6acc7ecc81be" );
143
+ // assertSHA256Binary( "", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" );
144
+ //
145
+ // }
146
+ //
147
+ // public function testSHA256Base64():void {
148
+ //
149
+ // }
150
+ //
151
+ // private function assertSHA256( value:String, expected:String ):void {
152
+ // var result:String = SHA256.hash( value );
153
+ //
154
+ // assertTrue( "Hash of '" + value + "' returned wrong value ('" + result + "')",
155
+ // result == expected );
156
+ // }
157
+ //
158
+ // private function assertSHA256Binary(value:String, expected:String):void {
159
+ //
160
+ // var byteArray:ByteArray = new ByteArray();
161
+ // byteArray.writeUTFBytes(value);
162
+ //
163
+ // var result:String = SHA256.hashBytes( byteArray );
164
+ // assertTrue( "Hash of '" + value + "' returned wrong value ('" + result + "')",
165
+ // result == expected );
166
+ // }
167
+ //
168
+ // private function assertSHA256Base64( value:String, expected:String ):void {
169
+ // var result:String = SHA256.hashToBase64( value );
170
+ //
171
+ // assertTrue( "Hash of '" + value + "' returned wrong value ('" + result + "')",
172
+ // result == expected );
173
+ // }
174
+ //
175
+ }
176
+ }
@@ -0,0 +1,63 @@
1
+ /*
2
+ Copyright (c) 2009, Adobe Systems Incorporated
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are
7
+ met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice,
10
+ this list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright
13
+ notice, this list of conditions and the following disclaimer in the
14
+ documentation and/or other materials provided with the distribution.
15
+
16
+ * Neither the name of Adobe Systems Incorporated nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ */
32
+
33
+ package com.adobe.air.filesystem
34
+ {
35
+ import flexunit.framework.TestCase;
36
+ import flash.filesystem.File;
37
+
38
+ public class FileMonitorTest extends TestCase
39
+ {
40
+ public function FileMonitorTest(methodName:String=null)
41
+ {
42
+ super(methodName);
43
+ }
44
+
45
+ public function test_interval():void
46
+ {
47
+ var vm1:FileMonitor = new FileMonitor();
48
+ assertTrue("2000 == vm1.interval", FileMonitor.DEFAULT_MONITOR_INTERVAL == vm1.interval);
49
+
50
+ var vm2:FileMonitor = new FileMonitor(null, 3000);
51
+ assertTrue("3000 == vm2.interval", 3000 == vm2.interval);
52
+
53
+ var vm3:FileMonitor = new FileMonitor(null, 500);
54
+ assertTrue("1000 == vm3.interval", 1000 == vm3.interval);
55
+
56
+ var f:File = File.desktopDirectory;
57
+
58
+ var vm4:FileMonitor = new FileMonitor(f);
59
+ assertTrue("f == vm4.file", f == vm4.file);
60
+ }
61
+
62
+ }
63
+ }
@@ -0,0 +1,57 @@
1
+ /*
2
+ Copyright (c) 2009, Adobe Systems Incorporated
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are
7
+ met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice,
10
+ this list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright
13
+ notice, this list of conditions and the following disclaimer in the
14
+ documentation and/or other materials provided with the distribution.
15
+
16
+ * Neither the name of Adobe Systems Incorporated nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ */
32
+
33
+ package com.adobe.air.filesystem
34
+ {
35
+ import flexunit.framework.TestCase;
36
+
37
+ public class VolumeMonitorTest extends TestCase
38
+ {
39
+ public function VolumeMonitorTest(methodName:String=null)
40
+ {
41
+ super(methodName);
42
+ }
43
+
44
+ public function test_interval():void
45
+ {
46
+
47
+ var vm1:VolumeMonitor = new VolumeMonitor();
48
+ assertTrue("2000 == vm1.interval", 2000 == vm1.interval);
49
+
50
+ var vm2:VolumeMonitor = new VolumeMonitor(3000);
51
+ assertTrue("3000 == vm2.interval", 3000 == vm2.interval);
52
+
53
+ var vm3:VolumeMonitor = new VolumeMonitor(500);
54
+ assertTrue("1000 == vm3.interval", 1000 == vm3.interval);
55
+ }
56
+ }
57
+ }
@@ -0,0 +1,59 @@
1
+ /*
2
+ Copyright (c) 2009, Adobe Systems Incorporated
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are
7
+ met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice,
10
+ this list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright
13
+ notice, this list of conditions and the following disclaimer in the
14
+ documentation and/or other materials provided with the distribution.
15
+
16
+ * Neither the name of Adobe Systems Incorporated nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ */
32
+
33
+ package com.adobe.air.filesystem.events
34
+ {
35
+ import flexunit.framework.TestCase;
36
+ import flash.filesystem.File;
37
+
38
+ public class FileMonitorEventTest extends TestCase
39
+ {
40
+ public function FileMonitorEventTest(methodName:String=null)
41
+ {
42
+ super(methodName);
43
+ }
44
+
45
+ public function test_clone():void
46
+ {
47
+ var e1:FileMonitorEvent = new FileMonitorEvent(FileMonitorEvent.ADD_VOLUME);
48
+ e1.file = new File();
49
+
50
+ var e2:FileMonitorEvent = FileMonitorEvent(e1.clone());
51
+
52
+ assertTrue("e1 != e2", e1 != e2);
53
+ assertTrue("e1.cancelable == e2.cancelable", e1.cancelable == e2.cancelable);
54
+ assertTrue("e1.bubbles == e2.bubbles", e1.bubbles == e2.bubbles);
55
+ assertTrue("e1.type == e2.type", e1.type == e2.type);
56
+ assertTrue("e1.file == e2.file", e1.file == e2.file);
57
+ }
58
+ }
59
+ }
@@ -0,0 +1,72 @@
1
+ /*
2
+ Copyright (c) 2009, Adobe Systems Incorporated
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are
7
+ met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice,
10
+ this list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright
13
+ notice, this list of conditions and the following disclaimer in the
14
+ documentation and/or other materials provided with the distribution.
15
+
16
+ * Neither the name of Adobe Systems Incorporated nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ */
32
+
33
+ package com.adobe.air.net.events
34
+ {
35
+ import flash.filesystem.File;
36
+
37
+ import flexunit.framework.TestCase;
38
+
39
+ public class ResourceCacheEventTest extends TestCase
40
+ {
41
+ public function ResourceCacheEventTest(methodName:String=null)
42
+ {
43
+ super(methodName);
44
+ }
45
+
46
+ public function test_clone():void
47
+ {
48
+ var type:String = ResourceCacheEvent.ITEM_CACHED;
49
+ var key:String = "foo";
50
+ var file:File = new File();
51
+
52
+ var original:ResourceCacheEvent = new ResourceCacheEvent(type);
53
+ original.key = key;
54
+ original.file = file;
55
+
56
+ var clone:ResourceCacheEvent = ResourceCacheEvent(original.clone());
57
+
58
+ assertTrue("original != clone", original != clone);
59
+
60
+ assertTrue("clone.bubbles == original.bubbles",
61
+ clone.bubbles == original.bubbles);
62
+ assertTrue("clone.cancelable == original.cancelable",
63
+ clone.cancelable == original.cancelable);
64
+ assertTrue("clone.type == original.type",
65
+ clone.type == original.type);
66
+ assertTrue("clone.key == original.key",
67
+ clone.key == original.key);
68
+ assertTrue("clone.file == original.file",
69
+ clone.file == original.file);
70
+ }
71
+ }
72
+ }
@@ -0,0 +1,134 @@
1
+ /*
2
+ Copyright (c) 2008, Adobe Systems Incorporated
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are
7
+ met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice,
10
+ this list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright
13
+ notice, this list of conditions and the following disclaimer in the
14
+ documentation and/or other materials provided with the distribution.
15
+
16
+ * Neither the name of Adobe Systems Incorporated nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ */
32
+
33
+ package com.adobe.crypto
34
+ {
35
+
36
+ import flash.utils.ByteArray;
37
+ import flexunit.framework.TestCase;
38
+ import flexunit.framework.TestSuite;
39
+
40
+ import com.adobe.crypto.HMAC;
41
+
42
+ public class HMACMD5Test extends TestCase
43
+ {
44
+ private var key:ByteArray;
45
+ private var data:ByteArray;
46
+ private var x:int;
47
+
48
+ public function HMACMD5Test( methodName:String = null) {
49
+ super( methodName );
50
+ }
51
+
52
+ override public function setUp():void
53
+ {
54
+ super.setUp();
55
+ key = new ByteArray();
56
+ data = new ByteArray();
57
+ }
58
+
59
+ public function test1():void {
60
+ for ( x = 0; x < 16; x++ ) {
61
+ key.writeByte(0x0b);
62
+ }
63
+ data.writeUTFBytes("Hi There");
64
+ assertHMAC(key, data, "9294727a3638bb1c13f48ef8158bfc9d");
65
+ }
66
+
67
+ public function test2():void {
68
+ key.writeUTFBytes("Jefe");
69
+ data.writeUTFBytes("what do ya want for nothing?");
70
+ assertHMAC(key, data, "750c783e6ab0b503eaa86e310a5db738");
71
+ }
72
+
73
+ public function test3():void {
74
+ for ( x = 0; x < 16; x++ ) {
75
+ key.writeByte(0xaa);
76
+ }
77
+
78
+ for ( x = 0; x < 50; x++ ) {
79
+ data.writeByte(0xdd);
80
+ }
81
+
82
+ assertHMAC(key, data, "56be34521d144c88dbb8c733f0e8b3f6");
83
+ }
84
+
85
+ public function test4():void {
86
+ for ( x = 0; x < 25; x++ ) {
87
+ key.writeByte( x + 1 );
88
+ }
89
+
90
+ for ( x = 0; x < 50; x++ ) {
91
+ data.writeByte(0xcd);
92
+ }
93
+
94
+ assertHMAC(key, data, "697eaf0aca3a3aea3a75164746ffaa79");
95
+ }
96
+
97
+ public function test5():void {
98
+ for ( x = 0; x < 16; x++ ) {
99
+ key.writeByte(0x0c);
100
+ }
101
+
102
+ data.writeUTFBytes("Test With Truncation");
103
+
104
+ assertHMAC(key, data, "56461ef2342edc00f9bab995690efd4c");
105
+ }
106
+
107
+ public function test6():void {
108
+ for ( x = 0; x < 80; x++ ) {
109
+ key.writeByte( 0xaa );
110
+ }
111
+
112
+ data.writeUTFBytes("Test Using Larger Than Block-Size Key - Hash Key First");
113
+
114
+ assertHMAC(key, data, "6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd");
115
+ }
116
+
117
+ public function test7():void {
118
+ for ( x = 0; x < 80; x++ ) {
119
+ key.writeByte( 0xaa );
120
+ }
121
+
122
+ data.writeUTFBytes("Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data");
123
+
124
+ assertHMAC(key, data, "6f630fad67cda0ee1fb1f562db3aa53e");
125
+ }
126
+
127
+ private function assertHMAC( key:ByteArray, value:ByteArray, expected:String):void {
128
+ assertTrue( "Hash of '" + value.toString() + "' with key '" + key.toString() + "' returned wrong value ('" + HMAC.hashBytes(key,value) + " ')",
129
+ HMAC.hashBytes(key,value) == expected );
130
+ };
131
+
132
+ }
133
+
134
+ }