as3corelib 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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,73 @@
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.utils
34
+ {
35
+
36
+ import flexunit.framework.TestCase;
37
+ import flexunit.framework.TestSuite;
38
+
39
+ import com.adobe.utils.IntUtil;
40
+
41
+ public class IntUtilTest extends TestCase {
42
+
43
+ public function IntUtilTest( methodName:String = null) {
44
+ super( methodName );
45
+ }
46
+
47
+
48
+
49
+ public function testRol():void {
50
+ assertTrue( "IntUtil.rol( 0x00000001, 1 )", IntUtil.rol( 0x00000001, 1 ) == 0x00000002 );
51
+ assertTrue( "IntUtil.rol( 0x00000001, 2 )", IntUtil.rol( 0x00000001, 2 ) == 0x00000004 );
52
+ assertTrue( "IntUtil.rol( 0x00000001, 4 )", IntUtil.rol( 0x00000001, 4 ) == 0x00000010 );
53
+ assertTrue( "IntUtil.rol( 0x00000001, 8 )", IntUtil.rol( 0x00000001, 8 ) == 0x00000100 );
54
+ assertTrue( "IntUtil.rol( 0x00000001, 12 )", IntUtil.rol( 0x00000001, 12 ) == 0x00001000 );
55
+ assertTrue( "IntUtil.rol( 0x00000001, 16 )", IntUtil.rol( 0x00000001, 16 ) == 0x00010000 );
56
+ assertTrue( "IntUtil.rol( 0x00000001, 20 )", IntUtil.rol( 0x00000001, 20 ) == 0x00100000 );
57
+ assertTrue( "IntUtil.rol( 0x00000001, 24 )", IntUtil.rol( 0x00000001, 24 ) == 0x01000000 );
58
+ assertTrue( "IntUtil.rol( 0x00000001, 28 )", IntUtil.rol( 0x00000001, 28 ) == 0x10000000 );
59
+ assertTrue( "IntUtil.rol( 0x00000001, 31 )", uint( IntUtil.rol( 0x00000001, 31 ) ) == 0x80000000 );
60
+ assertTrue( "IntUtil.rol( 0x00000001, 32 )", IntUtil.rol( 0x00000001, 32 ) == 0x00000001 );
61
+
62
+ assertTrue( "IntUtil.rol( 0x80000000, 1 )", IntUtil.rol( int( 0x80000000 ), 1 ) == 0x00000001 );
63
+ }
64
+
65
+ public function testToHex():void {
66
+ assertTrue( "Little Endian", IntUtil.toHex( 0x12345678 ) == "78563412" );
67
+ assertTrue( "Big Endian", IntUtil.toHex( 0x12345678, true ) == "12345678" );
68
+
69
+ assertTrue( "Little Endian Negative", IntUtil.toHex( int( 0x89ABCDEF ) ) == "efcdab89" );
70
+ assertTrue( "Big Endian Negative", IntUtil.toHex( int( 0x89ABCDEF ), true ) == "89abcdef" );
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,70 @@
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.utils
34
+ {
35
+ import flexunit.framework.TestCase;
36
+ import flexunit.framework.TestSuite;
37
+
38
+ import com.adobe.utils.NumberFormatter;
39
+
40
+ public class NumberFormatterTest extends TestCase
41
+ {
42
+ public function NumberFormatterTest(methodName:String = null)
43
+ {
44
+ super(methodName);
45
+ }
46
+
47
+ public function testAddLeadingZero():void
48
+ {
49
+ assertTrue("NumberFormatter.addLeadingZero(7) == \"07\"",
50
+ NumberFormatter.addLeadingZero(7) == "07");
51
+
52
+ assertTrue("NumberFormatter.addLeadingZero(9) == \"09\"",
53
+ NumberFormatter.addLeadingZero(9) == "09");
54
+
55
+ assertTrue("NumberFormatter.addLeadingZero(0) == \"00\"",
56
+ NumberFormatter.addLeadingZero(0) == "00");
57
+
58
+ assertTrue("NumberFormatter.addLeadingZero(-1) == \"-1\"",
59
+ NumberFormatter.addLeadingZero(-1) == "-1");
60
+
61
+ assertTrue("NumberFormatter.addLeadingZero(10) == \"10\"",
62
+ NumberFormatter.addLeadingZero(10) == "10");
63
+
64
+ assertTrue("NumberFormatter.addLeadingZero(10000) == \"10000\"",
65
+ NumberFormatter.addLeadingZero(10000) == "10000");
66
+
67
+ }
68
+
69
+ }
70
+ }
@@ -0,0 +1,304 @@
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.utils
34
+ {
35
+ import flexunit.framework.TestCase;
36
+ import flexunit.framework.TestSuite;
37
+
38
+ import com.adobe.utils.StringUtil;
39
+
40
+ public class StringUtilTest extends TestCase
41
+ {
42
+ public function StringUtilTest(methodName:String = null)
43
+ {
44
+ super(methodName);
45
+ }
46
+
47
+ public function testStringsAreEqual():void
48
+ {
49
+ var s1:String = "a";
50
+ var s2:String = "5";
51
+ var s3:String = new String("a");
52
+ var s4:String = "a";
53
+ var s5:String = "A";
54
+
55
+ assertTrue("StringUtil.stringsAreEqual(s1, s1, true)",
56
+ StringUtil.stringsAreEqual(s1, s1, true));
57
+
58
+ assertTrue("StringUtil.stringsAreEqual(s1, \"a\", true)",
59
+ StringUtil.stringsAreEqual(s1, s1, true));
60
+
61
+ assertTrue("StringUtil.stringsAreEqual(s1, \"A\", true)",
62
+ StringUtil.stringsAreEqual(s1, s1, true));
63
+
64
+ assertTrue("!StringUtil.stringsAreEqual(s1, s2, true)",
65
+ !StringUtil.stringsAreEqual(s1, s2, true));
66
+
67
+ assertTrue("StringUtil.stringsAreEqual(s1, s3, true)",
68
+ StringUtil.stringsAreEqual(s1, s3, true));
69
+
70
+ assertTrue("StringUtil.stringsAreEqual(s1, s5, false)",
71
+ StringUtil.stringsAreEqual(s1, s5, false));
72
+
73
+ assertTrue("!StringUtil.stringsAreEqual(s1, s5, true)",
74
+ !StringUtil.stringsAreEqual(s1, s5, true));
75
+
76
+ assertTrue("StringUtil.stringsAreEqual(s3, s5, false)",
77
+ StringUtil.stringsAreEqual(s1, s5, false));
78
+ }
79
+
80
+ public function testEndsWith():void
81
+ {
82
+ assertTrue(
83
+ "StringUtil.endsWith(\"AAAX\", \"X\") == true",
84
+ StringUtil.endsWith("AAAX", "X") == true
85
+ );
86
+
87
+ assertTrue(
88
+ "StringUtil.endsWith(\"XAAA\", \"O\") == false",
89
+ StringUtil.endsWith("XAAA", "0") == false
90
+ );
91
+
92
+ assertTrue(
93
+ "StringUtil.endsWith(\"AAXX\", \"XX\") == true",
94
+ StringUtil.endsWith("AAXX", "XX") == true
95
+ );
96
+
97
+ assertTrue(
98
+ "StringUtil.endsWith(\"AAXXX\", \"XX\") == true",
99
+ StringUtil.endsWith("AAXXX", "XX") == true
100
+ );
101
+
102
+ assertTrue(
103
+ "StringUtil.endsWith(\"\", \"XX\") == false",
104
+ StringUtil.endsWith("", "XX") == false
105
+ );
106
+
107
+ //TODO : Should this return true or false?
108
+ assertTrue(
109
+ "StringUtil.endsWith(\"XX\", \"\") == true",
110
+ StringUtil.endsWith("XX", "") == true
111
+ );
112
+
113
+ assertTrue(
114
+ "StringUtil.endsWith(\"\", \"\") == true",
115
+ StringUtil.endsWith("", "") == true
116
+ );
117
+ }
118
+
119
+ public function testBeginsWith():void
120
+ {
121
+ assertTrue(
122
+ "StringUtil.beginsWith(\"XAAA\", \"X\") == true",
123
+ StringUtil.beginsWith("XAAA", "X") == true
124
+ );
125
+
126
+ assertTrue(
127
+ "StringUtil.beginsWith(\"XAAA\", \"O\") == false",
128
+ StringUtil.beginsWith("XAAA", "0") == false
129
+ );
130
+
131
+ assertTrue(
132
+ "StringUtil.beginsWith(\"XXAA\", \"XX\") == true",
133
+ StringUtil.beginsWith("XXAA", "XX") == true
134
+ );
135
+
136
+ assertTrue(
137
+ "StringUtil.beginsWith(\"XXXAA\", \"XX\") == true",
138
+ StringUtil.beginsWith("XXXAA", "XX") == true
139
+ );
140
+
141
+ assertTrue(
142
+ "StringUtil.beginsWith(\"\", \"XX\") == false",
143
+ StringUtil.beginsWith("", "XX") == false
144
+ );
145
+
146
+ //TODO : Should this return true or false?
147
+ assertTrue(
148
+ "StringUtil.beginsWith(\"XX\", \"\") == true",
149
+ StringUtil.beginsWith("XX", "") == true
150
+ );
151
+
152
+ assertTrue(
153
+ "StringUtil.beginsWith(\"\", \"\") == true",
154
+ StringUtil.beginsWith("", "") == true
155
+ );
156
+ }
157
+
158
+ public function testRemove():void
159
+ {
160
+ assertTrue(
161
+ "StringUtil.remove(\"AXXA\", \"X\") == \"AA\"",
162
+ StringUtil.remove("AXXA", "X") == "AA"
163
+ );
164
+
165
+ assertTrue(
166
+ "StringUtil.remove(\"AXXAXAXXA\", \"X\") == \"AAAA\"",
167
+ StringUtil.remove("AXXAXAXXA", "X") == "AAAA"
168
+ );
169
+
170
+ assertTrue(
171
+ "StringUtil.remove(\"AXXXXA\", \"XX\") == \"AA\"",
172
+ StringUtil.remove("AXXXXA", "XX") == "AA"
173
+ );
174
+
175
+ assertTrue(
176
+ "StringUtil.remove(\"AXXXA\", \"XX\") == \"AXA\"",
177
+ StringUtil.remove("AXXXA", "XX") == "AXA"
178
+ );
179
+
180
+ assertTrue(
181
+ "StringUtil.remove(\"AXXXA\", \"-\") == \"AXXXA\"",
182
+ StringUtil.remove("AXXXA", "-") == "AXXXA"
183
+ );
184
+
185
+ assertTrue(
186
+ "StringUtil.remove(\"X\", \"\") == \"X\"",
187
+ StringUtil.remove("X", "") == "X"
188
+ );
189
+
190
+ assertTrue(
191
+ "StringUtil.remove(\"\", \"\") == \"\"",
192
+ StringUtil.remove("", "") == ""
193
+ );
194
+ }
195
+
196
+ public function testReplace():void
197
+ {
198
+ assertTrue(
199
+ "StringUtil.replace(\"AXXA\", \"X\", \"-\") == \"A--A\"",
200
+ StringUtil.replace("AXXA", "X", "-") == "A--A"
201
+ );
202
+
203
+ assertTrue(
204
+ "StringUtil.replace(\"AXXA\", \"B\", \"-\") == \"AXXA\"",
205
+ StringUtil.replace("AXXA", "B", "-") == "AXXA"
206
+ );
207
+
208
+ assertTrue(
209
+ "StringUtil.replace(\"AXXA\", \"XX\", \"-\") == \"A-A\"",
210
+ StringUtil.replace("AXXA", "XX", "-") == "A-A"
211
+ );
212
+
213
+ assertTrue(
214
+ "StringUtil.replace(\"AXXA\", \"XX\", \"----\") == \"A----A\"",
215
+ StringUtil.replace("AXXA", "XX", "----") == "A----A"
216
+ );
217
+
218
+ assertTrue(
219
+ "StringUtil.replace(\"X\", \"X\", \"-\") == \"-\"",
220
+ StringUtil.replace("X", "X", "-") == "-"
221
+ );
222
+
223
+ assertTrue(
224
+ "StringUtil.replace(\"AXXA\", \"X\", \"X\") == \"AXXA\"",
225
+ StringUtil.replace("AXXA", "X", "X") == "AXXA"
226
+ );
227
+
228
+ assertTrue(
229
+ "StringUtil.replace(\"AXXXXA\", \"XXXX\", \"-\") == \"A-A\"",
230
+ StringUtil.replace("AXXXXA", "XXXX", "-") == "A-A"
231
+ );
232
+
233
+ }
234
+
235
+ public function testTrim():void
236
+ {
237
+ assertTrue("StringUtil.trim(\" XXX \") == \"XXX\"",
238
+ StringUtil.trim(" XXX ") == "XXX");
239
+
240
+ assertTrue("StringUtil.trim(\" \") == \"\"",
241
+ StringUtil.trim(" ") == "");
242
+
243
+ assertTrue("StringUtil.trim(\"XX\") == \"XX\"",
244
+ StringUtil.trim("XX") == "XX");
245
+
246
+ assertTrue("StringUtil.trim(\"X\") == \"X\"",
247
+ StringUtil.trim("X") == "X");
248
+
249
+ assertTrue("StringUtil.trim(\" XX\") == \"XX\"",
250
+ StringUtil.trim(" XX") == "XX");
251
+
252
+ assertTrue("StringUtil.trim(\"XX \") == \"XX\"",
253
+ StringUtil.trim("XX ") == "XX");
254
+ }
255
+
256
+ public function testRTrim():void
257
+ {
258
+ assertTrue("StringUtil.rtrim(\" XXX \") == \" XXX\"",
259
+ StringUtil.rtrim(" XXX ") == " XXX");
260
+
261
+ assertTrue("StringUtil.rtrim(\" \") == \"\"",
262
+ StringUtil.rtrim(" ") == "");
263
+
264
+ assertTrue("StringUtil.rtrim(\"XX\") == \"XX\"",
265
+ StringUtil.rtrim("XX") == "XX");
266
+
267
+ assertTrue("StringUtil.rTrim(\"X\") == \"X\"",
268
+ StringUtil.rtrim("X") == "X");
269
+
270
+ assertTrue("StringUtil.rtrim(\"X \") == \"X\"",
271
+ StringUtil.rtrim("X ") == "X");
272
+
273
+ assertTrue("StringUtil.rtrim(\" XX\") == \" XX\"",
274
+ StringUtil.rtrim(" XX") == " XX");
275
+
276
+ assertTrue("StringUtil.rtrim(\"XX \") == \"XX\"",
277
+ StringUtil.rtrim("XX ") == "XX");
278
+ }
279
+
280
+ public function testLTrim():void
281
+ {
282
+ assertTrue("StringUtil.ltrim(\" XXX \") == \"XXX \"",
283
+ StringUtil.ltrim(" XXX ") == "XXX ");
284
+
285
+ assertTrue("StringUtil.ltrim(\" \") == \"\"",
286
+ StringUtil.ltrim(" ") == "");
287
+
288
+ assertTrue("StringUtil.ltrim(\"XX\") == \"XX\"",
289
+ StringUtil.ltrim("XX") == "XX");
290
+
291
+ assertTrue("StringUtil.rTrim(\"X\") == \"X\"",
292
+ StringUtil.ltrim("X") == "X");
293
+
294
+ assertTrue("StringUtil.ltrim(\" X\") == \"X\"",
295
+ StringUtil.ltrim(" X") == "X");
296
+
297
+ assertTrue("StringUtil.ltrim(\"XX \") == \"XX \"",
298
+ StringUtil.ltrim("XX ") == "XX ");
299
+
300
+ assertTrue("StringUtil.ltrim(\" XX\") == \"XX\"",
301
+ StringUtil.ltrim(" XX") == "XX");
302
+ }
303
+ }
304
+ }
@@ -0,0 +1,101 @@
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.utils
34
+ {
35
+ import flexunit.framework.TestCase;
36
+ import flexunit.framework.TestSuite;
37
+
38
+ import com.adobe.utils.XMLUtil;
39
+
40
+ public class XMLUtilTest extends TestCase
41
+ {
42
+
43
+ private var validXML:XML =
44
+ <cross-domain-policy>
45
+ <allow-access-from domain="*" />
46
+ </cross-domain-policy>
47
+
48
+ private var nonvalidXML:String = "<div /><div />";
49
+
50
+ private var simpleString:String = "a";
51
+
52
+ private var element:String = "<div />";
53
+
54
+ public function XMLUtilTest(methodName:String = null)
55
+ {
56
+ super(methodName);
57
+ }
58
+
59
+
60
+
61
+ public function testStringsAreEqual():void
62
+ {
63
+ assertTrue("XMLUtil.isValidXML(String(validXML))",XMLUtil.isValidXML(String(validXML)));
64
+ assertTrue("!XMLUtil.isValidXML(simpleString)", !XMLUtil.isValidXML(simpleString));
65
+ assertTrue("XMLUtil.isValidXML(element)", XMLUtil.isValidXML(element));
66
+ assertTrue("!XMLUtil.isValidXML(element)", !XMLUtil.isValidXML(nonvalidXML));
67
+
68
+ }
69
+
70
+ private var xml:XML =
71
+ <xml>
72
+ <top>
73
+ <a>foo</a>
74
+ <b>bar</b>
75
+ <c>bam</c>
76
+ </top>
77
+ </xml>
78
+
79
+ public function testgetNextSibling():void
80
+ {
81
+
82
+ var s:Number = (new Date()).getTime();
83
+ assertTrue("XMLUtil.getNextSibling(xml.top[0].b[0]) == xml.top[0].c[0]",
84
+ XMLUtil.getNextSibling(xml.top[0].b[0]) == xml.top[0].c[0]);
85
+ assertTrue("XMLUtil.getNextSibling(xml.top[0].c[0]) == null",
86
+ XMLUtil.getNextSibling(xml.top[0].c[0]) == null);
87
+ assertTrue("XMLUtil.getNextSibling(xml.top[0]) == null",
88
+ XMLUtil.getNextSibling(xml.top[0]) == null);
89
+ }
90
+
91
+ public function testgetPreviousSibling():void
92
+ {
93
+ assertTrue("XMLUtil.getPreviousSibling(xml.top[0].b[0]) == xml.top[0].a[0]",
94
+ XMLUtil.getPreviousSibling(xml.top[0].b[0]) == xml.top[0].a[0]);
95
+ assertTrue("XMLUtil.getPreviousSibling(xml.top[0].a[0]) == null",
96
+ XMLUtil.getPreviousSibling(xml.top[0].a[0]) == null);
97
+ assertTrue("XMLUtil.getPreviousSibling(xml.top[0]) == null",
98
+ XMLUtil.getPreviousSibling(xml.top[0]) == null);
99
+ }
100
+ }
101
+ }
@@ -0,0 +1,66 @@
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.webapis.events
34
+ {
35
+ import flexunit.framework.TestCase;
36
+
37
+ public class ServiceEventTest extends TestCase
38
+ {
39
+ public function ServiceEventTest(methodName:String=null)
40
+ {
41
+ super(methodName);
42
+ }
43
+
44
+ public function test_clone():void
45
+ {
46
+ var type:String = "foo";
47
+ var o:Object = {foo:"bar"};
48
+
49
+ var original:ServiceEvent = new ServiceEvent(type);
50
+
51
+ var clone:ServiceEvent = ServiceEvent(original.clone());
52
+
53
+ assertTrue("original != clone", original != clone);
54
+
55
+ assertTrue("clone.bubbles == original.bubbles",
56
+ clone.bubbles == original.bubbles);
57
+ assertTrue("clone.cancelable == original.cancelable",
58
+ clone.cancelable == original.cancelable);
59
+ assertTrue("clone.type == original.type",
60
+ clone.type == original.type);
61
+ assertTrue("clone.data == original.data",
62
+ clone.data == original.data);
63
+ }
64
+
65
+ }
66
+ }